2022-10-25 01:15:09 +02:00
|
|
|
{
|
2023-02-20 11:42:13 +01:00
|
|
|
lib,
|
2023-11-06 15:04:08 +01:00
|
|
|
helpers,
|
|
|
|
config,
|
|
|
|
pkgs,
|
2023-02-20 11:42:13 +01:00
|
|
|
...
|
|
|
|
}:
|
|
|
|
with lib; let
|
|
|
|
cfg = config.plugins.project-nvim;
|
|
|
|
in {
|
2024-03-13 08:43:39 -05:00
|
|
|
imports = [
|
|
|
|
(lib.mkRenamedOptionModule
|
|
|
|
["plugins" "telescope" "extensions" "project-nvim" "enable"]
|
|
|
|
["plugins" "project-nvim" "enableTelescope"])
|
|
|
|
];
|
|
|
|
|
2023-02-20 11:42:13 +01:00
|
|
|
options.plugins.project-nvim =
|
2024-01-25 16:15:55 +01:00
|
|
|
helpers.neovim-plugin.extraOptionsOptions
|
2023-02-20 11:42:13 +01:00
|
|
|
// {
|
|
|
|
enable = mkEnableOption "project.nvim";
|
2022-10-25 01:15:09 +02:00
|
|
|
|
2023-02-20 11:42:13 +01:00
|
|
|
package = helpers.mkPackageOption "project-nvim" pkgs.vimPlugins.project-nvim;
|
2023-01-19 10:45:15 +00:00
|
|
|
|
2023-11-28 00:01:49 +01:00
|
|
|
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.
|
|
|
|
'';
|
2022-10-25 01:15:09 +02:00
|
|
|
|
2023-11-28 00:01:49 +01:00
|
|
|
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.
|
|
|
|
'';
|
2022-10-25 01:15:09 +02:00
|
|
|
|
2023-11-28 00:01:49 +01:00
|
|
|
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`.
|
|
|
|
'';
|
2022-10-25 01:15:09 +02:00
|
|
|
|
2023-11-28 00:01:49 +01:00
|
|
|
ignoreLsp =
|
|
|
|
helpers.defaultNullOpts.mkNullable
|
|
|
|
(with types; listOf str)
|
|
|
|
"[]"
|
|
|
|
"Table of lsp clients to ignore by name.";
|
2022-10-25 01:15:09 +02:00
|
|
|
|
2023-11-28 00:01:49 +01:00
|
|
|
excludeDirs =
|
|
|
|
helpers.defaultNullOpts.mkNullable
|
|
|
|
(with types; listOf str)
|
|
|
|
"[]"
|
|
|
|
"Don't calculate root dir on specific directories.";
|
2022-10-25 01:15:09 +02:00
|
|
|
|
2023-11-28 00:01:49 +01:00
|
|
|
showHidden = helpers.defaultNullOpts.mkBool false "Show hidden files in telescope.";
|
2022-10-25 01:15:09 +02:00
|
|
|
|
2023-11-28 00:01:49 +01:00
|
|
|
silentChdir = helpers.defaultNullOpts.mkBool true ''
|
|
|
|
When set to false, you will get a message when `project.nvim` changes your directory.
|
|
|
|
'';
|
2022-10-25 01:15:09 +02:00
|
|
|
|
2023-11-28 00:01:49 +01:00
|
|
|
scopeChdir = helpers.defaultNullOpts.mkEnumFirstDefault ["global" "tab" "win"] ''
|
|
|
|
What scope to change the directory.
|
|
|
|
'';
|
2022-10-25 01:15:09 +02:00
|
|
|
|
2023-11-28 00:01:49 +01:00
|
|
|
dataPath =
|
|
|
|
helpers.defaultNullOpts.mkNullable
|
2024-01-01 23:33:53 +01:00
|
|
|
(with types; either str helpers.nixvimTypes.rawLua)
|
2023-11-28 00:01:49 +01:00
|
|
|
''{__raw = "vim.fn.stdpath('data')";}''
|
|
|
|
"Path where project.nvim will store the project history for use in telescope.";
|
2024-03-13 08:43:39 -05:00
|
|
|
|
|
|
|
enableTelescope = mkEnableOption ''
|
|
|
|
When set to true, enabled project-nvim telescope integration.
|
|
|
|
'';
|
2022-10-25 01:15:09 +02:00
|
|
|
};
|
2022-12-01 20:57:06 +01:00
|
|
|
|
2023-11-28 00:01:49 +01:00
|
|
|
config = mkIf cfg.enable {
|
2024-03-13 08:43:39 -05:00
|
|
|
warnings =
|
|
|
|
optional
|
|
|
|
(cfg.enableTelescope && (!config.plugins.telescope.enable))
|
|
|
|
''
|
|
|
|
Telescope support for project-nvim is enabled but the telescope plugin is not.
|
|
|
|
'';
|
|
|
|
|
2023-11-28 00:01:49 +01:00
|
|
|
extraPlugins = [cfg.package];
|
2022-10-25 01:15:09 +02:00
|
|
|
|
2023-11-28 00:01:49 +01:00
|
|
|
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})
|
|
|
|
'';
|
2024-03-13 08:43:39 -05:00
|
|
|
|
|
|
|
plugins.telescope.enabledExtensions = mkIf cfg.enableTelescope ["projects"];
|
2023-11-28 00:01:49 +01:00
|
|
|
};
|
2022-10-25 01:15:09 +02:00
|
|
|
}
|