mirror of
https://github.com/nix-community/nixvim.git
synced 2025-07-09 08:44:32 +02:00
plugins/project-nvim: migrate to mkNeovimPlugin
This commit is contained in:
parent
d928d6deb1
commit
0d73ab939c
2 changed files with 74 additions and 73 deletions
|
@ -1,16 +1,35 @@
|
||||||
{
|
{
|
||||||
lib,
|
lib,
|
||||||
helpers,
|
|
||||||
config,
|
config,
|
||||||
pkgs,
|
pkgs,
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
with lib;
|
|
||||||
let
|
let
|
||||||
cfg = config.plugins.project-nvim;
|
inherit (lib.nixvim) defaultNullOpts;
|
||||||
in
|
in
|
||||||
{
|
lib.nixvim.neovim-plugin.mkNeovimPlugin {
|
||||||
|
name = "project-nvim";
|
||||||
|
originalName = "project.nvim";
|
||||||
|
luaName = "project_nvim";
|
||||||
|
defaultPackage = pkgs.vimPlugins.project-nvim;
|
||||||
|
|
||||||
|
maintainers = [ lib.maintainers.khaneliman ];
|
||||||
|
|
||||||
|
# TODO: added 2024-09-03 remove after 24.11
|
||||||
|
deprecateExtraOptions = true;
|
||||||
|
optionsRenamedToSettings = [
|
||||||
|
"manualMode"
|
||||||
|
"detectionMethods"
|
||||||
|
"patterns"
|
||||||
|
"ignoreLsp"
|
||||||
|
"excludeDirs"
|
||||||
|
"showHidden"
|
||||||
|
"silentChdir"
|
||||||
|
"scopeChdir"
|
||||||
|
"dataPath"
|
||||||
|
];
|
||||||
imports = [
|
imports = [
|
||||||
|
# TODO: added 2024-03-13 remove after 24.11
|
||||||
(lib.mkRenamedOptionModule
|
(lib.mkRenamedOptionModule
|
||||||
[
|
[
|
||||||
"plugins"
|
"plugins"
|
||||||
|
@ -27,18 +46,14 @@ in
|
||||||
)
|
)
|
||||||
];
|
];
|
||||||
|
|
||||||
options.plugins.project-nvim = helpers.neovim-plugin.extraOptionsOptions // {
|
settingsOptions = {
|
||||||
enable = mkEnableOption "project.nvim";
|
manual_mode = defaultNullOpts.mkBool false ''
|
||||||
|
|
||||||
package = helpers.mkPluginPackageOption "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
|
Manual mode doesn't automatically change your root directory, so you have the option to
|
||||||
manually do so using `:ProjectRoot` command.
|
manually do so using `:ProjectRoot` command.
|
||||||
'';
|
'';
|
||||||
|
|
||||||
detectionMethods =
|
detection_methods =
|
||||||
helpers.defaultNullOpts.mkListOf types.str
|
defaultNullOpts.mkListOf lib.types.str
|
||||||
[
|
[
|
||||||
"lsp"
|
"lsp"
|
||||||
"pattern"
|
"pattern"
|
||||||
|
@ -52,7 +67,7 @@ in
|
||||||
'';
|
'';
|
||||||
|
|
||||||
patterns =
|
patterns =
|
||||||
helpers.defaultNullOpts.mkListOf types.str
|
defaultNullOpts.mkListOf lib.types.str
|
||||||
[
|
[
|
||||||
".git"
|
".git"
|
||||||
"_darcs"
|
"_darcs"
|
||||||
|
@ -66,22 +81,20 @@ in
|
||||||
All the patterns used to detect root dir, when **"pattern"** is in `detectionMethods`.
|
All the patterns used to detect root dir, when **"pattern"** is in `detectionMethods`.
|
||||||
'';
|
'';
|
||||||
|
|
||||||
ignoreLsp =
|
ignore_lsp = defaultNullOpts.mkListOf lib.types.str [ ] "Table of lsp clients to ignore by name.";
|
||||||
helpers.defaultNullOpts.mkListOf types.str [ ]
|
|
||||||
"Table of lsp clients to ignore by name.";
|
|
||||||
|
|
||||||
excludeDirs =
|
exclude_dirs =
|
||||||
helpers.defaultNullOpts.mkListOf types.str [ ]
|
defaultNullOpts.mkListOf lib.types.str [ ]
|
||||||
"Don't calculate root dir on specific directories.";
|
"Don't calculate root dir on specific directories.";
|
||||||
|
|
||||||
showHidden = helpers.defaultNullOpts.mkBool false "Show hidden files in telescope.";
|
show_hidden = defaultNullOpts.mkBool false "Show hidden files in telescope.";
|
||||||
|
|
||||||
silentChdir = helpers.defaultNullOpts.mkBool true ''
|
silent_chdir = defaultNullOpts.mkBool true ''
|
||||||
When set to false, you will get a message when `project.nvim` changes your directory.
|
When set to false, you will get a message when `project.nvim` changes your directory.
|
||||||
'';
|
'';
|
||||||
|
|
||||||
scopeChdir =
|
scope_chdir =
|
||||||
helpers.defaultNullOpts.mkEnumFirstDefault
|
defaultNullOpts.mkEnumFirstDefault
|
||||||
[
|
[
|
||||||
"global"
|
"global"
|
||||||
"tab"
|
"tab"
|
||||||
|
@ -91,41 +104,29 @@ in
|
||||||
What scope to change the directory.
|
What scope to change the directory.
|
||||||
'';
|
'';
|
||||||
|
|
||||||
dataPath = helpers.defaultNullOpts.mkStr {
|
data_path = defaultNullOpts.mkStr {
|
||||||
__raw = "vim.fn.stdpath('data')";
|
__raw = "vim.fn.stdpath('data')";
|
||||||
} "Path where project.nvim will store the project history for use in telescope.";
|
} "Path where project.nvim will store the project history for use in telescope.";
|
||||||
|
|
||||||
enableTelescope = mkEnableOption "project-nvim telescope integration";
|
|
||||||
};
|
};
|
||||||
|
|
||||||
config = mkIf cfg.enable {
|
settingsExample = {
|
||||||
warnings = optional (cfg.enableTelescope && (!config.plugins.telescope.enable)) ''
|
detection_methods = [ "lsp" ];
|
||||||
|
patterns = [ ".git" ];
|
||||||
|
ignore_lsp = [ "tsserver" ];
|
||||||
|
excludeDirs = [ "/home/user/secret-directory" ];
|
||||||
|
showHidden = true;
|
||||||
|
silent_chdir = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
extraOptions = {
|
||||||
|
enableTelescope = lib.mkEnableOption "project-nvim telescope integration";
|
||||||
|
};
|
||||||
|
|
||||||
|
extraConfig = cfg: {
|
||||||
|
warnings = lib.optional (cfg.enableTelescope && (!config.plugins.telescope.enable)) ''
|
||||||
Telescope support for project-nvim is enabled but the telescope plugin is not.
|
Telescope support for project-nvim is enabled but the telescope plugin is not.
|
||||||
'';
|
'';
|
||||||
|
|
||||||
extraPlugins = [ cfg.package ];
|
plugins.telescope.enabledExtensions = lib.mkIf cfg.enableTelescope [ "projects" ];
|
||||||
|
|
||||||
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})
|
|
||||||
'';
|
|
||||||
|
|
||||||
plugins.telescope.enabledExtensions = mkIf cfg.enableTelescope [ "projects" ];
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,6 @@
|
||||||
plugins.telescope = {
|
plugins.telescope = {
|
||||||
enable = true;
|
enable = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
plugins.project-nvim = {
|
plugins.project-nvim = {
|
||||||
enable = true;
|
enable = true;
|
||||||
enableTelescope = true;
|
enableTelescope = true;
|
||||||
|
@ -17,27 +16,28 @@
|
||||||
defaults = {
|
defaults = {
|
||||||
plugins.project-nvim = {
|
plugins.project-nvim = {
|
||||||
enable = true;
|
enable = true;
|
||||||
|
settings = {
|
||||||
manualMode = false;
|
manual_mode = false;
|
||||||
detectionMethods = [
|
detection_methods = [
|
||||||
"lsp"
|
"lsp"
|
||||||
"pattern"
|
"pattern"
|
||||||
];
|
];
|
||||||
patterns = [
|
patterns = [
|
||||||
".git"
|
".git"
|
||||||
"_darcs"
|
"_darcs"
|
||||||
".hg"
|
".hg"
|
||||||
".bzr"
|
".bzr"
|
||||||
".svn"
|
".svn"
|
||||||
"Makefile"
|
"Makefile"
|
||||||
"package.json"
|
"package.json"
|
||||||
];
|
];
|
||||||
ignoreLsp = [ ];
|
ignore_lsp = [ ];
|
||||||
excludeDirs = [ ];
|
exclude_dirs = [ ];
|
||||||
showHidden = false;
|
show_hidden = false;
|
||||||
silentChdir = true;
|
silent_chdir = true;
|
||||||
scopeChdir = "global";
|
scope_chdir = "global";
|
||||||
dataPath.__raw = "vim.fn.stdpath('data')";
|
data_path.__raw = "vim.fn.stdpath('data')";
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue