modules/projects: switch to explicit lib calls

This commit is contained in:
raf 2024-03-12 03:48:38 +03:00
parent 03025f76e1
commit b54032f3f3
No known key found for this signature in database
GPG key ID: 02D1DD3FA08B6B29
4 changed files with 18 additions and 18 deletions

View file

@ -1,4 +1,4 @@
_: { {
imports = [ imports = [
./project-nvim ./project-nvim
]; ];

View file

@ -3,7 +3,10 @@
lib, lib,
... ...
}: let }: let
inherit (lib) mkIf nvim boolToString concatStringsSep; inherit (lib.modules) mkIf;
inherit (lib.trivial) boolToString;
inherit (lib.strings) concatStringsSep;
inherit (lib.nvim.dag) entryAnywhere;
cfg = config.vim.projects.project-nvim; cfg = config.vim.projects.project-nvim;
in { in {
@ -12,7 +15,7 @@ in {
"project-nvim" "project-nvim"
]; ];
vim.luaConfigRC.project-nvim = nvim.dag.entryAnywhere '' vim.luaConfigRC.project-nvim = entryAnywhere ''
require('project_nvim').setup({ require('project_nvim').setup({
manual_mode = ${boolToString cfg.manualMode}, manual_mode = ${boolToString cfg.manualMode},
detection_methods = { ${concatStringsSep ", " (map (x: "\"" + x + "\"") cfg.detectionMethods)} }, detection_methods = { ${concatStringsSep ", " (map (x: "\"" + x + "\"") cfg.detectionMethods)} },

View file

@ -1,4 +1,4 @@
_: { {
imports = [ imports = [
./config.nix ./config.nix
./project-nvim.nix ./project-nvim.nix

View file

@ -1,60 +1,57 @@
{ {lib, ...}: let
config, inherit (lib.options) mkEnableOption mkOption;
lib, inherit (lib.types) enum bool listOf str;
...
}: let
inherit (lib) mkEnableOption mkOption types;
in { in {
options.vim.projects.project-nvim = { options.vim.projects.project-nvim = {
enable = mkEnableOption "project-nvim for project management"; enable = mkEnableOption "project-nvim for project management";
manualMode = mkOption { manualMode = mkOption {
type = types.bool; type = bool;
default = true; default = true;
description = "don't automatically change the root directory so the user has the option to manually do so using `:ProjectRoot` command"; description = "don't automatically change the root directory so the user has the option to manually do so using `:ProjectRoot` command";
}; };
# detection methods should accept one or more strings from a list # detection methods should accept one or more strings from a list
detectionMethods = mkOption { detectionMethods = mkOption {
type = types.listOf types.str; type = listOf str;
default = ["lsp" "pattern"]; default = ["lsp" "pattern"];
description = "Detection methods to use"; description = "Detection methods to use";
}; };
# patterns # patterns
patterns = mkOption { patterns = mkOption {
type = types.listOf types.str; type = listOf str;
default = [".git" "_darcs" ".hg" ".bzr" ".svn" "Makefile" "package.json" "flake.nix" "cargo.toml"]; default = [".git" "_darcs" ".hg" ".bzr" ".svn" "Makefile" "package.json" "flake.nix" "cargo.toml"];
description = "Patterns to use for pattern detection method"; description = "Patterns to use for pattern detection method";
}; };
# table of lsp servers to ignore by name # table of lsp servers to ignore by name
lspIgnored = mkOption { lspIgnored = mkOption {
type = types.listOf types.str; type = listOf str;
default = []; default = [];
description = "LSP servers no ignore by name"; description = "LSP servers no ignore by name";
}; };
excludeDirs = mkOption { excludeDirs = mkOption {
type = types.listOf types.str; type = listOf str;
default = []; default = [];
description = "Directories to exclude from project root search"; description = "Directories to exclude from project root search";
}; };
showHidden = mkOption { showHidden = mkOption {
type = types.bool; type = bool;
default = false; default = false;
description = "Show hidden files in telescope picker"; description = "Show hidden files in telescope picker";
}; };
silentChdir = mkOption { silentChdir = mkOption {
type = types.bool; type = bool;
default = true; default = true;
description = "Silently change directory when changing project"; description = "Silently change directory when changing project";
}; };
scopeChdir = mkOption { scopeChdir = mkOption {
type = types.enum ["global" "tab" "win"]; type = enum ["global" "tab" "win"];
default = "global"; default = "global";
description = "What scope to change the directory"; description = "What scope to change the directory";
}; };