mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-26 10:48:35 +02:00
plugins/navic: init + tests (#597)
Co-authored-by: Haseeb Majid <haseeb.majid@imaginecurve.com> Co-authored-by: Gaétan Lepage <33058747+GaetanLepage@users.noreply.github.com>
This commit is contained in:
parent
ada99e5763
commit
32a64af231
3 changed files with 171 additions and 0 deletions
121
plugins/bufferlines/navic.nix
Normal file
121
plugins/bufferlines/navic.nix
Normal file
|
@ -0,0 +1,121 @@
|
||||||
|
{
|
||||||
|
lib,
|
||||||
|
pkgs,
|
||||||
|
config,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
with lib; let
|
||||||
|
cfg = config.plugins.navic;
|
||||||
|
helpers = import ../helpers.nix {inherit lib;};
|
||||||
|
mkListStr = helpers.defaultNullOpts.mkNullable (types.listOf types.str);
|
||||||
|
in {
|
||||||
|
options.plugins.navic =
|
||||||
|
helpers.extraOptionsOptions
|
||||||
|
// {
|
||||||
|
enable = mkEnableOption "nvim-navic";
|
||||||
|
|
||||||
|
package = helpers.mkPackageOption "nvim-navic" pkgs.vimPlugins.nvim-navic;
|
||||||
|
|
||||||
|
icons =
|
||||||
|
mapAttrs
|
||||||
|
(
|
||||||
|
name: default:
|
||||||
|
helpers.defaultNullOpts.mkStr default "icon for ${name}."
|
||||||
|
)
|
||||||
|
{
|
||||||
|
File = " ";
|
||||||
|
Module = " ";
|
||||||
|
Namespace = " ";
|
||||||
|
Package = " ";
|
||||||
|
Class = " ";
|
||||||
|
Method = " ";
|
||||||
|
Property = " ";
|
||||||
|
Field = " ";
|
||||||
|
Constructor = " ";
|
||||||
|
Enum = "";
|
||||||
|
Interface = "";
|
||||||
|
Function = " ";
|
||||||
|
Variable = " ";
|
||||||
|
Constant = " ";
|
||||||
|
String = " ";
|
||||||
|
Number = " ";
|
||||||
|
Boolean = "◩ ";
|
||||||
|
Array = " ";
|
||||||
|
Object = " ";
|
||||||
|
Key = " ";
|
||||||
|
Null = " ";
|
||||||
|
EnumMember = " ";
|
||||||
|
Struct = " ";
|
||||||
|
Event = " ";
|
||||||
|
Operator = " ";
|
||||||
|
TypeParameter = " ";
|
||||||
|
};
|
||||||
|
|
||||||
|
lsp = {
|
||||||
|
autoAttach = helpers.defaultNullOpts.mkBool false ''
|
||||||
|
Enable to have nvim-navic automatically attach to every LSP for current buffer. Its disabled by default.
|
||||||
|
'';
|
||||||
|
|
||||||
|
preference = helpers.defaultNullOpts.mkNullable (with types; listOf str) "[]" ''
|
||||||
|
Table ranking lsp_servers. Lower the index, higher the priority of the server. If there are more than one server attached to a buffer. In the example below will prefer clangd over pyright
|
||||||
|
|
||||||
|
Example: `[ "clangd" "pyright" ]`.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
highlight = helpers.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.
|
||||||
|
'';
|
||||||
|
|
||||||
|
separator = helpers.defaultNullOpts.mkStr " > " ''
|
||||||
|
Icon to separate items. to use between items.
|
||||||
|
'';
|
||||||
|
|
||||||
|
depthLimit = helpers.defaultNullOpts.mkInt 0 ''
|
||||||
|
Maximum depth of context to be shown. If the context hits this depth limit, it is truncated.
|
||||||
|
'';
|
||||||
|
|
||||||
|
depthLimitIndicator = helpers.defaultNullOpts.mkStr ".." ''
|
||||||
|
Icon to indicate that depth_limit was hit and the shown context is truncated.
|
||||||
|
'';
|
||||||
|
|
||||||
|
safeOutput = helpers.defaultNullOpts.mkBool true ''
|
||||||
|
Sanitize the output for use in statusline and winbar.
|
||||||
|
'';
|
||||||
|
|
||||||
|
lazyUpdateContext = helpers.defaultNullOpts.mkBool false ''
|
||||||
|
If true, turns off context updates for the "CursorMoved" event.
|
||||||
|
'';
|
||||||
|
|
||||||
|
click = helpers.defaultNullOpts.mkBool false ''
|
||||||
|
Single click to goto element, double click to open nvim-navbuddy on the clicked element.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
config = let
|
||||||
|
setupOptions = with cfg;
|
||||||
|
{
|
||||||
|
inherit
|
||||||
|
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})
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
}
|
|
@ -2,6 +2,7 @@
|
||||||
imports = [
|
imports = [
|
||||||
./bufferlines/barbar.nix
|
./bufferlines/barbar.nix
|
||||||
./bufferlines/bufferline.nix
|
./bufferlines/bufferline.nix
|
||||||
|
./bufferlines/navic.nix
|
||||||
|
|
||||||
./colorschemes/ayu.nix
|
./colorschemes/ayu.nix
|
||||||
./colorschemes/base16.nix
|
./colorschemes/base16.nix
|
||||||
|
|
49
tests/test-sources/plugins/bufferlines/navic.nix
Normal file
49
tests/test-sources/plugins/bufferlines/navic.nix
Normal file
|
@ -0,0 +1,49 @@
|
||||||
|
{
|
||||||
|
empty = {
|
||||||
|
plugins.navic.enable = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
defaults = {
|
||||||
|
plugins.navic = {
|
||||||
|
enable = true;
|
||||||
|
|
||||||
|
icons = {
|
||||||
|
File = " ";
|
||||||
|
Module = " ";
|
||||||
|
Namespace = " ";
|
||||||
|
Package = " ";
|
||||||
|
Class = " ";
|
||||||
|
Method = " ";
|
||||||
|
Property = " ";
|
||||||
|
Field = " ";
|
||||||
|
Constructor = " ";
|
||||||
|
Enum = "";
|
||||||
|
Interface = "";
|
||||||
|
Function = " ";
|
||||||
|
Variable = " ";
|
||||||
|
Constant = " ";
|
||||||
|
String = " ";
|
||||||
|
Number = " ";
|
||||||
|
Boolean = "◩ ";
|
||||||
|
Array = " ";
|
||||||
|
Object = " ";
|
||||||
|
Key = " ";
|
||||||
|
Null = " ";
|
||||||
|
EnumMember = " ";
|
||||||
|
Struct = " ";
|
||||||
|
Event = " ";
|
||||||
|
Operator = " ";
|
||||||
|
TypeParameter = " ";
|
||||||
|
};
|
||||||
|
lsp = {
|
||||||
|
autoAttach = true;
|
||||||
|
preference = ["clangd" "pyright"];
|
||||||
|
};
|
||||||
|
highlight = true;
|
||||||
|
separator = " | ";
|
||||||
|
depthLimit = 10;
|
||||||
|
safeOutput = false;
|
||||||
|
click = true;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue