nix-community.nixvim/plugins/utils/project-nvim.nix
traxys af41ea2d80
helpers: move rawType to helpers.nixvimTypes (#871)
This is done in preparation of adding new (lua) types to help the
documentation.
2024-01-01 23:33:53 +01:00

93 lines
2.8 KiB
Nix

{
lib,
helpers,
config,
pkgs,
...
}:
with lib; let
cfg = config.plugins.project-nvim;
in {
options.plugins.project-nvim =
helpers.extraOptionsOptions
// {
enable = mkEnableOption "project.nvim";
package = helpers.mkPackageOption "project-nvim" pkgs.vimPlugins.project-nvim;
manualMode = helpers.defaultNullOpts.mkBool false ''
Manual mode doesn't automatically change your root directory, so you have the option to
manually do so using `:ProjectRoot` command.
'';
detectionMethods =
helpers.defaultNullOpts.mkNullable
(with types; listOf str)
''["lsp" "pattern"]''
''
Methods of detecting the root directory.
**"lsp"** uses the native neovim lsp, while **"pattern"** uses vim-rooter like glob pattern
matching.
Here order matters: if one is not detected, the other is used as fallback.
You can also delete or rearangne the detection methods.
'';
patterns =
helpers.defaultNullOpts.mkNullable
(with types; listOf str)
''[".git" "_darcs" ".hg" ".bzr" ".svn" "Makefile" "package.json"]''
''
All the patterns used to detect root dir, when **"pattern"** is in `detectionMethods`.
'';
ignoreLsp =
helpers.defaultNullOpts.mkNullable
(with types; listOf str)
"[]"
"Table of lsp clients to ignore by name.";
excludeDirs =
helpers.defaultNullOpts.mkNullable
(with types; listOf str)
"[]"
"Don't calculate root dir on specific directories.";
showHidden = helpers.defaultNullOpts.mkBool false "Show hidden files in telescope.";
silentChdir = helpers.defaultNullOpts.mkBool true ''
When set to false, you will get a message when `project.nvim` changes your directory.
'';
scopeChdir = helpers.defaultNullOpts.mkEnumFirstDefault ["global" "tab" "win"] ''
What scope to change the directory.
'';
dataPath =
helpers.defaultNullOpts.mkNullable
(with types; either str helpers.nixvimTypes.rawLua)
''{__raw = "vim.fn.stdpath('data')";}''
"Path where project.nvim will store the project history for use in telescope.";
};
config = mkIf cfg.enable {
extraPlugins = [cfg.package];
extraConfigLua = let
setupOptions = with cfg;
{
manual_mode = manualMode;
detection_methods = detectionMethods;
inherit patterns;
ignore_lsp = ignoreLsp;
exclude_dirs = excludeDirs;
show_hidden = showHidden;
silent_chdir = silentChdir;
scope_schdir = scopeChdir;
data_path = dataPath;
}
// cfg.extraOptions;
in ''
require('project_nvim').setup(${helpers.toLuaObject setupOptions})
'';
};
}