mirror of
https://github.com/NotAShelf/nvf.git
synced 2024-11-26 15:06:45 +00:00
feat: add project-nvim
This commit is contained in:
parent
e00ad1f653
commit
3065032ad2
4 changed files with 125 additions and 0 deletions
|
@ -0,0 +1,5 @@
|
|||
_: {
|
||||
imports = [
|
||||
./project-nvim
|
||||
];
|
||||
}
|
63
modules/projects/project-nvim/config.nix
Normal file
63
modules/projects/project-nvim/config.nix
Normal file
|
@ -0,0 +1,63 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
with lib;
|
||||
with builtins; {
|
||||
options.vim.projects.project-nvim = {
|
||||
enable = mkEnableOption "Enable project-nvim for project management";
|
||||
|
||||
manualMode = mkOption {
|
||||
type = types.bool;
|
||||
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
|
||||
detectionMethods = mkOption {
|
||||
type = types.listOf types.str;
|
||||
default = ["lsp" "pattern"];
|
||||
description = "Detection methods to use";
|
||||
};
|
||||
|
||||
# patterns
|
||||
patterns = mkOption {
|
||||
type = types.listOf types.str;
|
||||
default = [".git" "_darcs" ".hg" ".bzr" ".svn" "Makefile" "package.json" "flake.nix" "cargo.toml"];
|
||||
description = "Patterns to use for pattern detection method";
|
||||
};
|
||||
|
||||
# table of lsp servers to ignore by name
|
||||
lspIgnored = mkOption {
|
||||
type = types.listOf types.str;
|
||||
default = [];
|
||||
description = "LSP servers no ignore by name";
|
||||
};
|
||||
|
||||
excludeDirs = mkOption {
|
||||
type = types.listOf types.str;
|
||||
default = [];
|
||||
description = "Directories to exclude from project root search";
|
||||
};
|
||||
|
||||
showHidden = mkOption {
|
||||
type = types.bool;
|
||||
default = false;
|
||||
description = "Show hidden files in telescope picker";
|
||||
};
|
||||
|
||||
silentChdir = mkOption {
|
||||
type = types.bool;
|
||||
default = true;
|
||||
description = "Silently change directory when changing project";
|
||||
};
|
||||
|
||||
scopeChdir = mkOption {
|
||||
type = types.enum ["global" "tab" "win"];
|
||||
default = "global";
|
||||
description = "What scope to change the directory";
|
||||
};
|
||||
};
|
||||
}
|
||||
|
6
modules/projects/project-nvim/default.nix
Normal file
6
modules/projects/project-nvim/default.nix
Normal file
|
@ -0,0 +1,6 @@
|
|||
_: {
|
||||
imports = [
|
||||
./config.nix
|
||||
./project-nvim.nix
|
||||
];
|
||||
}
|
51
modules/projects/project-nvim/project-nvim.nix
Normal file
51
modules/projects/project-nvim/project-nvim.nix
Normal file
|
@ -0,0 +1,51 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
with lib;
|
||||
with builtins; let
|
||||
cfg = config.vim.projects.project-nvim;
|
||||
in {
|
||||
config = mkIf cfg.enable {
|
||||
vim.startPlugins = [
|
||||
"project-nvim"
|
||||
];
|
||||
|
||||
vim.luaConfigRC.project-nvim = nvim.dag.entryAnywhere ''
|
||||
require('project_nvim').setup({
|
||||
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"),
|
||||
})
|
||||
'';
|
||||
};
|
||||
}
|
Loading…
Reference in a new issue