nix-community.nixvim/plugins/utils/project-nvim.nix

123 lines
3.5 KiB
Nix
Raw Normal View History

2022-10-25 01:15:09 +02:00
{
lib,
helpers,
config,
pkgs,
...
}:
2024-05-05 19:39:35 +02:00
with lib;
let
cfg = config.plugins.project-nvim;
2024-05-05 19:39:35 +02:00
in
{
imports = [
(lib.mkRenamedOptionModule
2024-05-05 19:39:35 +02:00
[
"plugins"
"telescope"
"extensions"
"project-nvim"
"enable"
]
[
"plugins"
"project-nvim"
"enableTelescope"
]
)
];
2024-05-05 19:39:35 +02:00
options.plugins.project-nvim = helpers.neovim-plugin.extraOptionsOptions // {
enable = mkEnableOption "project.nvim";
2022-10-25 01:15:09 +02:00
2024-05-05 19:39:35 +02:00
package = helpers.mkPackageOption "project-nvim" pkgs.vimPlugins.project-nvim;
general: add package options (#127) * barbar: package option * Base16: package option * gruvbox: package option * nord: package option * one: package option * onedark: package option * tokyonight: package option * nvim-cmp: package option * coq: package option * lspkind: package option * helpers: added package option to mkPlugin * fugitive: package option * gitgutter: package option * gitsigns: package option * neogit: package option * ledger: package option * nix: package option * plantuml-syntax: package option * treesitter-context: package option + formatting * treesitter-refactor: package option + formatting * treesitter: package option * zig: package option * null-ls: package option * null-ls/servers: package option * lsp-lines: package option * lspsaga: package option * trouble: package option * luasnip: added description for package option * airline: package option * lightline: package option * lualine: package option * telescope: package option * telescope/frecency: package option * telescope/fzf-native: package option * telescope/media-files: package option * comment-nvim: package option * vim-commentary: package option * dashboard: package option * easyescape: package option * emmet: package option * endwise: package option * floaterm: package option * goyo: package option * intellitab: package option * mark-radar: package option * notify: package option * nvim-autopairs: package option * nvim-tree: package option * project-nvim: package option * specs: package option * startify: package option * surround: package option * undotree: package option
2023-01-19 10:45:15 +00:00
2024-05-05 19:39:35 +02: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
2024-05-05 19:39:35 +02: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
2024-05-05 19:39:35 +02: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
2024-05-05 19:39:35 +02: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
2024-05-05 19:39:35 +02: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
2024-05-05 19:39:35 +02:00
showHidden = helpers.defaultNullOpts.mkBool false "Show hidden files in telescope.";
2022-10-25 01:15:09 +02:00
2024-05-05 19:39:35 +02: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
2024-05-05 19:39:35 +02:00
scopeChdir =
helpers.defaultNullOpts.mkEnumFirstDefault
[
"global"
"tab"
"win"
]
''
What scope to change the directory.
'';
2022-10-25 01:15:09 +02:00
2024-05-05 19:39:35 +02:00
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.";
2024-05-05 19:39:35 +02:00
enableTelescope = mkEnableOption ''
When set to true, enabled project-nvim telescope integration.
'';
};
config = mkIf cfg.enable {
2024-05-05 19:39:35 +02:00
warnings = optional (cfg.enableTelescope && (!config.plugins.telescope.enable)) ''
Telescope support for project-nvim is enabled but the telescope plugin is not.
'';
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
''
2024-05-05 19:39:35 +02:00
require('project_nvim').setup(${helpers.toLuaObject setupOptions})
'';
2024-05-05 19:39:35 +02:00
plugins.telescope.enabledExtensions = mkIf cfg.enableTelescope [ "projects" ];
};
2022-10-25 01:15:09 +02:00
}