mirror of
https://github.com/NotAShelf/nvf.git
synced 2024-11-22 21:30:51 +00:00
feat(project-nvim): custom setup
This commit is contained in:
parent
3f4ef987dd
commit
4db6950558
2 changed files with 69 additions and 83 deletions
|
@ -3,10 +3,7 @@
|
||||||
lib,
|
lib,
|
||||||
...
|
...
|
||||||
}: let
|
}: let
|
||||||
inherit (lib.modules) mkIf;
|
inherit (lib) mkIf nvim;
|
||||||
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 {
|
||||||
|
@ -15,40 +12,8 @@ in {
|
||||||
"project-nvim"
|
"project-nvim"
|
||||||
];
|
];
|
||||||
|
|
||||||
vim.luaConfigRC.project-nvim = entryAnywhere ''
|
vim.luaConfigRC.project-nvim = nvim.dag.entryAnywhere ''
|
||||||
require('project_nvim').setup({
|
require('project_nvim').setup(${nvim.lua.toLuaObject cfg.setupOpts})
|
||||||
manual_mode = ${boolToString cfg.manualMode},
|
|
||||||
detection_methods = { ${concatStringsSep ", " (map (x: "\"" + x + "\"") cfg.detectionMethods)} },
|
|
||||||
|
|
||||||
-- All the patterns used to detect root dir, when **"pattern"** is in
|
|
||||||
-- detection_methods
|
|
||||||
patterns = { ${concatStringsSep ", " (map (x: "\"" + x + "\"") cfg.patterns)} },
|
|
||||||
|
|
||||||
-- Table of lsp clients to ignore by name
|
|
||||||
-- eg: { "efm", ... }
|
|
||||||
ignore_lsp = { ${concatStringsSep ", " (map (x: "\"" + x + "\"") cfg.lspIgnored)} },
|
|
||||||
|
|
||||||
-- Don't calculate root dir on specific directories
|
|
||||||
-- Ex: { "~/.cargo/*", ... }
|
|
||||||
exclude_dirs = { ${concatStringsSep ", " (map (x: "\"" + x + "\"") cfg.excludeDirs)} },
|
|
||||||
|
|
||||||
-- Show hidden files in telescope
|
|
||||||
show_hidden = ${boolToString cfg.showHidden},
|
|
||||||
|
|
||||||
-- When set to false, you will get a message when project.nvim changes your
|
|
||||||
-- directory.
|
|
||||||
silent_chdir = ${boolToString cfg.silentChdir},
|
|
||||||
|
|
||||||
-- What scope to change the directory, valid options are
|
|
||||||
-- * global (default)
|
|
||||||
-- * tab
|
|
||||||
-- * win
|
|
||||||
scope_chdir = '${toString cfg.scopeChdir}',
|
|
||||||
|
|
||||||
-- Path where project.nvim will store the project history for use in
|
|
||||||
-- telescope
|
|
||||||
datapath = vim.fn.stdpath("data"),
|
|
||||||
})
|
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,59 +1,80 @@
|
||||||
{lib, ...}: let
|
{
|
||||||
inherit (lib.options) mkEnableOption mkOption;
|
config,
|
||||||
inherit (lib.types) enum bool listOf str;
|
lib,
|
||||||
|
...
|
||||||
|
}: let
|
||||||
|
inherit (lib) mkEnableOption mkOption types mkRenamedOptionModule;
|
||||||
in {
|
in {
|
||||||
|
imports = let
|
||||||
|
renamedSetupOption = oldPath: newPath:
|
||||||
|
mkRenamedOptionModule
|
||||||
|
(["vim" "projects" "project-nvim"] ++ oldPath)
|
||||||
|
(["vim" "projects" "project-nvim" "setupOpts"] ++ newPath);
|
||||||
|
in [
|
||||||
|
(renamedSetupOption ["manualMode"] ["manual_mode"])
|
||||||
|
(renamedSetupOption ["detectionMethods"] ["detection_methods"])
|
||||||
|
(renamedSetupOption ["patterns"] ["patterns"])
|
||||||
|
(renamedSetupOption ["lspIgnored"] ["lsp_ignored"])
|
||||||
|
(renamedSetupOption ["excludeDirs"] ["exclude_dirs"])
|
||||||
|
(renamedSetupOption ["showHidden"] ["show_hidden"])
|
||||||
|
(renamedSetupOption ["silentChdir"] ["silent_chdir"])
|
||||||
|
(renamedSetupOption ["scopeChdir"] ["scope_chdir"])
|
||||||
|
];
|
||||||
|
|
||||||
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 {
|
setupOpts = lib.nvim.types.mkPluginSetupOption "Project.nvim" {
|
||||||
type = bool;
|
manual_mode = mkOption {
|
||||||
default = true;
|
type = types.bool;
|
||||||
description = "don't automatically change the root directory so the user has the option to manually do so using `:ProjectRoot` command";
|
default = true;
|
||||||
};
|
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 {
|
detection_methods = mkOption {
|
||||||
type = listOf str;
|
type = types.listOf types.str;
|
||||||
default = ["lsp" "pattern"];
|
default = ["lsp" "pattern"];
|
||||||
description = "Detection methods to use";
|
description = "Detection methods to use";
|
||||||
};
|
};
|
||||||
|
|
||||||
# patterns
|
# patterns
|
||||||
patterns = mkOption {
|
patterns = mkOption {
|
||||||
type = listOf str;
|
type = types.listOf types.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 {
|
lsp_ignored = mkOption {
|
||||||
type = listOf str;
|
type = types.listOf types.str;
|
||||||
default = [];
|
default = [];
|
||||||
description = "LSP servers no ignore by name";
|
description = "LSP servers no ignore by name";
|
||||||
};
|
};
|
||||||
|
|
||||||
excludeDirs = mkOption {
|
exclude_dirs = mkOption {
|
||||||
type = listOf str;
|
type = types.listOf types.str;
|
||||||
default = [];
|
default = [];
|
||||||
description = "Directories to exclude from project root search";
|
description = "Directories to exclude from project root search";
|
||||||
};
|
};
|
||||||
|
|
||||||
showHidden = mkOption {
|
show_hidden = mkOption {
|
||||||
type = bool;
|
type = types.bool;
|
||||||
default = false;
|
default = false;
|
||||||
description = "Show hidden files in telescope picker";
|
description = "Show hidden files in telescope picker";
|
||||||
};
|
};
|
||||||
|
|
||||||
silentChdir = mkOption {
|
silent_chdir = mkOption {
|
||||||
type = bool;
|
type = types.bool;
|
||||||
default = true;
|
default = true;
|
||||||
description = "Silently change directory when changing project";
|
description = "Silently change directory when changing project";
|
||||||
};
|
};
|
||||||
|
|
||||||
scopeChdir = mkOption {
|
scope_chdir = mkOption {
|
||||||
type = enum ["global" "tab" "win"];
|
type = types.enum ["global" "tab" "win"];
|
||||||
default = "global";
|
default = "global";
|
||||||
description = "What scope to change the directory";
|
description = "What scope to change the directory";
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue