plugins/neo-tree: add documentSymbols options

This commit is contained in:
Gaetan Lepage 2023-05-12 14:13:41 +02:00 committed by Gaétan Lepage
parent cc21669583
commit b77e3e9ccb
2 changed files with 76 additions and 0 deletions

View file

@ -926,6 +926,52 @@ in {
} }
''; '';
}; };
documentSymbols = {
followCursor =
helpers.defaultNullOpts.mkBool false
"If set to `true`, will automatically focus on the symbol under the cursor.";
kinds =
helpers.mkNullOrOption
(
with types;
attrsOf (submodule {
options = {
icon = mkOption {
description = "Icon for this LSP kind.";
type = types.str;
example = "";
};
hl = mkOption {
description = "Highlight group for this LSP kind.";
type = types.str;
example = "Include";
};
};
})
)
''
An attrs specifying how LSP kinds should be rendered.
Each entry should map the LSP kind name to an icon and a highlight group, for example
`Class = { icon = ""; hl = "Include"; }`
'';
customKinds = mkOption {
type = with types; attrsOf str;
default = {};
example = {
"252" = "TypeAlias";
};
description = ''
A table mapping the LSP kind id (an integer) to the LSP kind name that is used for
`kinds`.
For the list of kinds (id and name), please refer to
https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#textDocument_documentSymbol
'';
};
};
}; };
config = let config = let
@ -1154,6 +1200,19 @@ in {
custom = processRendererComponentList renderers.custom; custom = processRendererComponentList renderers.custom;
}; };
}; };
document_symbols = {
follow_cursor = cfg.documentSymbols.followCursor;
inherit (cfg.documentSymbols) kinds;
custom_kinds.__raw =
"{"
+ (concatStringsSep ","
(
mapAttrsToList
(id: name: ''[${id}] = "${name}"'')
cfg.documentSymbols.customKinds
))
+ "}";
};
} }
// cfg.extraOptions; // cfg.extraOptions;
in in

View file

@ -409,6 +409,23 @@
}; };
}; };
}; };
documentSymbols = {
followCursor = false;
kinds = {
File = {
icon = "󰈙";
hl = "Tag";
};
Namespace = {
icon = "󰌗";
hl = "Include";
};
};
customKinds = {
"12" = "foo";
"15" = "bar";
};
};
}; };
}; };
} }