plugins/navic: migrate to mkNeovimPlugin

This commit is contained in:
Austin Horstman 2024-09-03 19:31:36 -05:00
parent 0d73ab939c
commit 279258294b
No known key found for this signature in database
2 changed files with 89 additions and 85 deletions

View file

@ -1,21 +1,42 @@
{ {
lib, lib,
helpers,
config,
pkgs, pkgs,
... ...
}: }:
with lib;
let let
cfg = config.plugins.navic; inherit (lib.nixvim) defaultNullOpts;
in in
{ lib.nixvim.neovim-plugin.mkNeovimPlugin {
options.plugins.navic = helpers.neovim-plugin.extraOptionsOptions // { name = "navic";
enable = mkEnableOption "nvim-navic"; originalName = "nvim-navic";
luaName = "nvim-navic";
defaultPackage = pkgs.vimPlugins.nvim-navic;
package = helpers.mkPluginPackageOption "nvim-navic" pkgs.vimPlugins.nvim-navic; maintainers = [ lib.maintainers.khaneliman ];
icons = mapAttrs (name: default: helpers.defaultNullOpts.mkStr default "icon for ${name}.") { # TODO: added 2024-09-03 remove after 24.11
deprecateExtraOptions = true;
optionsRenamedToSettings = [
"icons"
[
"lsp"
"autoAttach"
]
[
"lsp"
"preference"
]
"highlight"
"separator"
"depthLimit"
"depthLimitIndicator"
"safeOutput"
"lazyUpdateContext"
"click"
];
settingsOptions = {
icons = lib.mapAttrs (name: default: defaultNullOpts.mkStr default "icon for ${name}.") {
File = "󰈙 "; File = "󰈙 ";
Module = " "; Module = " ";
Namespace = "󰌗 "; Namespace = "󰌗 ";
@ -45,12 +66,12 @@ in
}; };
lsp = { lsp = {
autoAttach = helpers.defaultNullOpts.mkBool false '' auto_attach = defaultNullOpts.mkBool false ''
Enable to have nvim-navic automatically attach to every LSP for current buffer. Its disabled by default. Enable to have nvim-navic automatically attach to every LSP for current buffer. Its disabled by default.
''; '';
preference = helpers.defaultNullOpts.mkListOf' { preference = defaultNullOpts.mkListOf' {
type = types.str; type = lib.types.str;
pluginDefault = [ ]; pluginDefault = [ ];
example = [ example = [
"clangd" "clangd"
@ -62,61 +83,42 @@ in
}; };
}; };
highlight = helpers.defaultNullOpts.mkBool false '' highlight = defaultNullOpts.mkBool false ''
If set to true, will add colors to icons and text as defined by highlight groups NavicIcons* (NavicIconsFile, NavicIconsModule.. etc.), NavicText and NavicSeparator. If set to true, will add colors to icons and text as defined by highlight groups NavicIcons* (NavicIconsFile, NavicIconsModule.. etc.), NavicText and NavicSeparator.
''; '';
separator = helpers.defaultNullOpts.mkStr " > " '' separator = defaultNullOpts.mkStr " > " ''
Icon to separate items. to use between items. Icon to separate items. to use between items.
''; '';
depthLimit = helpers.defaultNullOpts.mkInt 0 '' depth_limit = defaultNullOpts.mkInt 0 ''
Maximum depth of context to be shown. If the context hits this depth limit, it is truncated. Maximum depth of context to be shown. If the context hits this depth limit, it is truncated.
''; '';
depthLimitIndicator = helpers.defaultNullOpts.mkStr ".." '' depth_limit_indicator = defaultNullOpts.mkStr ".." ''
Icon to indicate that depth_limit was hit and the shown context is truncated. Icon to indicate that depth_limit was hit and the shown context is truncated.
''; '';
safeOutput = helpers.defaultNullOpts.mkBool true '' safe_output = defaultNullOpts.mkBool true ''
Sanitize the output for use in statusline and winbar. Sanitize the output for use in statusline and winbar.
''; '';
lazyUpdateContext = helpers.defaultNullOpts.mkBool false '' lazy_update_context = defaultNullOpts.mkBool false ''
If true, turns off context updates for the "CursorMoved" event. If true, turns off context updates for the "CursorMoved" event.
''; '';
click = helpers.defaultNullOpts.mkBool false '' click = defaultNullOpts.mkBool false ''
Single click to goto element, double click to open nvim-navbuddy on the clicked element. Single click to goto element, double click to open nvim-navbuddy on the clicked element.
''; '';
}; };
config = settingsExample = {
let lsp = {
setupOptions = auto_attach = true;
with cfg; preference = [
{ "clangd"
inherit "tsserver"
icons ];
highlight
separator
click
;
lsp = with lsp; {
auto_attach = autoAttach;
inherit preference;
};
depth_limit = depthLimit;
safe_output = safeOutput;
lazy_update_context = lazyUpdateContext;
}
// cfg.extraOptions;
in
mkIf cfg.enable {
extraPlugins = [ cfg.package ];
extraConfigLua = ''
require('nvim-navic').setup(${helpers.toLuaObject setupOptions})
'';
}; };
};
} }

View file

@ -7,46 +7,48 @@
plugins.navic = { plugins.navic = {
enable = true; enable = true;
icons = { settings = {
File = "󰆧 "; icons = {
Module = " "; File = "󰆧 ";
Namespace = "󰌗 "; Module = " ";
Package = " "; Namespace = "󰌗 ";
Class = "󰌗 "; Package = " ";
Method = "󰆧 "; Class = "󰌗 ";
Property = " "; Method = "󰆧 ";
Field = " "; Property = " ";
Constructor = " "; Field = " ";
Enum = "󰕘"; Constructor = " ";
Interface = "󰕘"; Enum = "󰕘";
Function = "󰊕 "; Interface = "󰕘";
Variable = "󰆧 "; Function = "󰊕 ";
Constant = "󰏿 "; Variable = "󰆧 ";
String = "󰀬 "; Constant = "󰏿 ";
Number = "󰎠 "; String = "󰀬 ";
Boolean = " "; Number = "󰎠 ";
Array = "󰅪 "; Boolean = " ";
Object = "󰅩 "; Array = "󰅪 ";
Key = "󰌋 "; Object = "󰅩 ";
Null = "󰟢 "; Key = "󰌋 ";
EnumMember = " "; Null = "󰟢 ";
Struct = "󰌗 "; EnumMember = " ";
Event = " "; Struct = "󰌗 ";
Operator = "󰆕 "; Event = " ";
TypeParameter = "󰊄 "; Operator = "󰆕 ";
TypeParameter = "󰊄 ";
};
lsp = {
auto_attach = true;
preference = [
"clangd"
"pyright"
];
};
highlight = true;
separator = " | ";
depth_limit = 10;
safe_output = false;
click = true;
}; };
lsp = {
autoAttach = true;
preference = [
"clangd"
"pyright"
];
};
highlight = true;
separator = " | ";
depthLimit = 10;
safeOutput = false;
click = true;
}; };
}; };
} }