mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-28 03:20:08 +02:00
plugins/treesitter: move to by-name
This commit is contained in:
parent
8815180c62
commit
4491ce4db2
18 changed files with 0 additions and 8 deletions
|
@ -1,33 +0,0 @@
|
|||
{
|
||||
lib,
|
||||
helpers,
|
||||
config,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
with lib;
|
||||
let
|
||||
cfg = config.plugins.hmts;
|
||||
in
|
||||
{
|
||||
meta.maintainers = [ maintainers.GaetanLepage ];
|
||||
|
||||
options.plugins.hmts = {
|
||||
enable = mkEnableOption "hmts.nvim";
|
||||
|
||||
package = lib.mkPackageOption pkgs "hmts.nvim" {
|
||||
default = [
|
||||
"vimPlugins"
|
||||
"hmts-nvim"
|
||||
];
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
warnings = optional (!config.plugins.treesitter.enable) [
|
||||
"Nixvim: hmts needs treesitter to function as intended"
|
||||
];
|
||||
|
||||
extraPlugins = [ cfg.package ];
|
||||
};
|
||||
}
|
|
@ -1,40 +0,0 @@
|
|||
;; extends
|
||||
|
||||
(binding
|
||||
attrpath: (attrpath
|
||||
(identifier) @_path)
|
||||
expression: [
|
||||
(string_expression
|
||||
((string_fragment) @injection.content
|
||||
(#set! injection.language "lua")))
|
||||
(indented_string_expression
|
||||
((string_fragment) @injection.content
|
||||
(#set! injection.language "lua")))
|
||||
]
|
||||
(#match? @_path "(^(extraConfigLua(Pre|Post)?|__raw))$"))
|
||||
|
||||
(apply_expression
|
||||
function: (_) @_func
|
||||
argument: [
|
||||
(string_expression
|
||||
((string_fragment) @injection.content
|
||||
(#set! injection.language "lua")))
|
||||
(indented_string_expression
|
||||
((string_fragment) @injection.content
|
||||
(#set! injection.language "lua")))
|
||||
]
|
||||
(#match? @_func "(^|\\.)mkRaw$")
|
||||
(#set! injection.combined))
|
||||
|
||||
(binding
|
||||
attrpath: (attrpath
|
||||
(identifier) @_path)
|
||||
expression: [
|
||||
(string_expression
|
||||
((string_fragment) @injection.content
|
||||
(#set! injection.language "vim")))
|
||||
(indented_string_expression
|
||||
((string_fragment) @injection.content
|
||||
(#set! injection.language "vim")))
|
||||
]
|
||||
(#match? @_path "(^extraConfigVim(Pre|Post)?)$"))
|
|
@ -1,157 +0,0 @@
|
|||
{
|
||||
lib,
|
||||
helpers,
|
||||
config,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
with lib;
|
||||
{
|
||||
options.plugins.rainbow-delimiters = helpers.neovim-plugin.extraOptionsOptions // {
|
||||
enable = mkEnableOption "rainbow-delimiters.nvim";
|
||||
|
||||
package = lib.mkPackageOption pkgs "rainbow-delimiters.nvim" {
|
||||
default = [
|
||||
"vimPlugins"
|
||||
"rainbow-delimiters-nvim"
|
||||
];
|
||||
};
|
||||
|
||||
strategy = helpers.defaultNullOpts.mkAttrsOf' {
|
||||
type = types.enum [
|
||||
"global"
|
||||
"local"
|
||||
"noop"
|
||||
];
|
||||
pluginDefault = {
|
||||
default = "global";
|
||||
};
|
||||
description = ''
|
||||
Attrs mapping Tree-sitter language names to strategies.
|
||||
See `|rb-delimiters-strategy|` for more information about strategies.
|
||||
'';
|
||||
example = literalMD ''
|
||||
```nix
|
||||
{
|
||||
# Use global strategy by default
|
||||
default = "global";
|
||||
|
||||
# Use local for HTML
|
||||
html = "local";
|
||||
|
||||
# Pick the strategy for LaTeX dynamically based on the buffer size
|
||||
latex.__raw = '''
|
||||
function()
|
||||
-- Disabled for very large files, global strategy for large files,
|
||||
-- local strategy otherwise
|
||||
if vim.fn.line('$') > 10000 then
|
||||
return nil
|
||||
elseif vim.fn.line('$') > 1000 then
|
||||
return require 'rainbow-delimiters'.strategy['global']
|
||||
end
|
||||
return require 'rainbow-delimiters'.strategy['local']
|
||||
end
|
||||
''';
|
||||
}
|
||||
```
|
||||
'';
|
||||
};
|
||||
|
||||
query =
|
||||
helpers.defaultNullOpts.mkAttrsOf types.str
|
||||
{
|
||||
default = "rainbow-delimiters";
|
||||
lua = "rainbow-blocks";
|
||||
}
|
||||
''
|
||||
Attrs mapping Tree-sitter language names to queries.
|
||||
See `|rb-delimiters-query|` for more information about queries.
|
||||
'';
|
||||
|
||||
highlight =
|
||||
helpers.defaultNullOpts.mkListOf types.str
|
||||
[
|
||||
"RainbowDelimiterRed"
|
||||
"RainbowDelimiterYellow"
|
||||
"RainbowDelimiterBlue"
|
||||
"RainbowDelimiterOrange"
|
||||
"RainbowDelimiterGreen"
|
||||
"RainbowDelimiterViolet"
|
||||
"RainbowDelimiterCyan"
|
||||
]
|
||||
''
|
||||
List of names of the highlight groups to use for highlighting, for more information see
|
||||
`|rb-delimiters-colors|`.
|
||||
'';
|
||||
|
||||
whitelist = helpers.mkNullOrOption (with types; listOf str) ''
|
||||
List of Tree-sitter languages for which to enable rainbow delimiters.
|
||||
Rainbow delimiters will be disabled for all other languages.
|
||||
'';
|
||||
|
||||
blacklist = helpers.mkNullOrOption (with types; listOf str) ''
|
||||
List of Tree-sitter languages for which to disable rainbow delimiters.
|
||||
Rainbow delimiters will be enabled for all other languages.
|
||||
'';
|
||||
|
||||
log = {
|
||||
file =
|
||||
helpers.defaultNullOpts.mkStr { __raw = "vim.fn.stdpath('log') .. '/rainbow-delimiters.log'"; }
|
||||
''
|
||||
Path to the log file, default is `rainbow-delimiters.log` in your standard log path
|
||||
(see `|standard-path|`).
|
||||
'';
|
||||
|
||||
level = helpers.defaultNullOpts.mkLogLevel "warn" ''
|
||||
Only messages equal to or above this value will be logged.
|
||||
The default is to log warnings or above.
|
||||
See `|log_levels|` for possible values.
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
config =
|
||||
let
|
||||
cfg = config.plugins.rainbow-delimiters;
|
||||
in
|
||||
mkIf cfg.enable {
|
||||
warnings = optional (
|
||||
!config.plugins.treesitter.enable
|
||||
) "Nixvim: treesitter-rainbow needs treesitter to function as intended";
|
||||
assertions = [
|
||||
{
|
||||
assertion = (cfg.whitelist == null) || (cfg.blacklist == null);
|
||||
message = ''
|
||||
Both `rainbow-delimiters.whitelist` and `rainbow-delimiters.blacklist` should not be
|
||||
set simultaneously.
|
||||
Please remove one of them.
|
||||
'';
|
||||
}
|
||||
];
|
||||
|
||||
extraPlugins = [ cfg.package ];
|
||||
|
||||
globals.rainbow_delimiters =
|
||||
with cfg;
|
||||
{
|
||||
strategy = helpers.ifNonNull' strategy (
|
||||
mapAttrs' (name: value: {
|
||||
name = if name == "default" then "__emptyString" else name;
|
||||
value =
|
||||
if isString value then helpers.mkRaw "require 'rainbow-delimiters'.strategy['${value}']" else value;
|
||||
}) strategy
|
||||
);
|
||||
query = helpers.ifNonNull' query (
|
||||
mapAttrs' (name: value: {
|
||||
name = if name == "default" then "__emptyString" else name;
|
||||
inherit value;
|
||||
}) query
|
||||
);
|
||||
inherit highlight whitelist blacklist;
|
||||
log = with log; {
|
||||
inherit file level;
|
||||
};
|
||||
}
|
||||
// cfg.extraOptions;
|
||||
};
|
||||
}
|
|
@ -1,104 +0,0 @@
|
|||
{
|
||||
lib,
|
||||
helpers,
|
||||
config,
|
||||
...
|
||||
}:
|
||||
with lib;
|
||||
helpers.neovim-plugin.mkNeovimPlugin {
|
||||
name = "treesitter-context";
|
||||
originalName = "nvim-treesitter-context";
|
||||
package = "nvim-treesitter-context";
|
||||
|
||||
maintainers = [ maintainers.GaetanLepage ];
|
||||
|
||||
# TODO introduced 2024-04-22: remove 2024-06-22
|
||||
deprecateExtraOptions = true;
|
||||
optionsRenamedToSettings = [
|
||||
"maxLines"
|
||||
"minWindowHeight"
|
||||
"lineNumbers"
|
||||
"multilineThreshold"
|
||||
"trimScope"
|
||||
"mode"
|
||||
"separator"
|
||||
"zindex"
|
||||
"onAttach"
|
||||
];
|
||||
|
||||
settingsOptions = {
|
||||
enable = helpers.defaultNullOpts.mkBool true ''
|
||||
Enable this plugin (Can be enabled/disabled later via commands)
|
||||
'';
|
||||
|
||||
max_lines = helpers.defaultNullOpts.mkUnsignedInt 0 ''
|
||||
How many lines the window should span. 0 means no limit.
|
||||
'';
|
||||
|
||||
min_window_height = helpers.defaultNullOpts.mkUnsignedInt 0 ''
|
||||
Minimum editor window height to enable context. 0 means no limit.
|
||||
'';
|
||||
|
||||
line_numbers = helpers.defaultNullOpts.mkBool true ''
|
||||
Whether to show line numbers.
|
||||
'';
|
||||
|
||||
multiline_threshold = helpers.defaultNullOpts.mkUnsignedInt 20 ''
|
||||
Maximum number of lines to collapse for a single context line.
|
||||
'';
|
||||
|
||||
trim_scope =
|
||||
helpers.defaultNullOpts.mkEnumFirstDefault
|
||||
[
|
||||
"outer"
|
||||
"inner"
|
||||
]
|
||||
''
|
||||
Which context lines to discard if `max_lines` is exceeded.
|
||||
'';
|
||||
|
||||
mode =
|
||||
helpers.defaultNullOpts.mkEnumFirstDefault
|
||||
[
|
||||
"cursor"
|
||||
"topline"
|
||||
]
|
||||
''
|
||||
Line used to calculate context.
|
||||
'';
|
||||
|
||||
separator = helpers.mkNullOrOption types.str ''
|
||||
Separator between context and content.
|
||||
Should be a single character string, like "-".
|
||||
When separator is set, the context will only show up when there are at least 2 lines above
|
||||
cursorline.
|
||||
'';
|
||||
|
||||
zindex = helpers.defaultNullOpts.mkUnsignedInt 20 ''
|
||||
The Z-index of the context window.
|
||||
'';
|
||||
|
||||
on_attach = helpers.defaultNullOpts.mkLuaFn "nil" ''
|
||||
The implementation of a lua function which takes an integer `buf` as parameter and returns a
|
||||
boolean.
|
||||
Return `false` to disable attaching.
|
||||
'';
|
||||
};
|
||||
|
||||
settingsExample = {
|
||||
max_lines = 0;
|
||||
min_window_height = 0;
|
||||
line_numbers = true;
|
||||
multiline_threshold = 20;
|
||||
trim_scope = "inner";
|
||||
mode = "topline";
|
||||
separator = "-";
|
||||
zindex = 20;
|
||||
};
|
||||
|
||||
extraConfig = cfg: {
|
||||
warnings = mkIf (!config.plugins.treesitter.enable) [
|
||||
"Nixvim: treesitter-context needs treesitter to function as intended"
|
||||
];
|
||||
};
|
||||
}
|
|
@ -1,181 +0,0 @@
|
|||
{
|
||||
lib,
|
||||
helpers,
|
||||
config,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
with lib;
|
||||
{
|
||||
options.plugins.treesitter-refactor =
|
||||
let
|
||||
disable = mkOption {
|
||||
type = types.listOf types.str;
|
||||
default = [ ];
|
||||
description = "List of languages to disable the module on";
|
||||
};
|
||||
in
|
||||
{
|
||||
enable = mkEnableOption "treesitter-refactor (requires plugins.treesitter.enable to be true)";
|
||||
|
||||
package = lib.mkPackageOption pkgs "treesitter-refactor" {
|
||||
default = [
|
||||
"vimPlugins"
|
||||
"nvim-treesitter-refactor"
|
||||
];
|
||||
};
|
||||
|
||||
highlightDefinitions = {
|
||||
inherit disable;
|
||||
enable = mkEnableOption "Highlights definition and usages of the current symbol under the cursor.";
|
||||
clearOnCursorMove = mkOption {
|
||||
type = types.bool;
|
||||
default = true;
|
||||
description = ''
|
||||
Controls if highlights should be cleared when the cursor is moved. If your 'updatetime'
|
||||
is around `100` you can set this to false to have a less laggy experience.
|
||||
'';
|
||||
};
|
||||
};
|
||||
highlightCurrentScope = {
|
||||
inherit disable;
|
||||
enable = mkEnableOption "highlighting the block from the current scope where the cursor is";
|
||||
};
|
||||
smartRename = {
|
||||
inherit disable;
|
||||
enable = mkEnableOption "Renames the symbol under the cursor within the current scope (and current file).";
|
||||
keymaps = {
|
||||
smartRename = mkOption {
|
||||
type = types.nullOr types.str;
|
||||
default = "grr";
|
||||
description = "rename symbol under the cursor";
|
||||
};
|
||||
};
|
||||
};
|
||||
navigation = {
|
||||
inherit disable;
|
||||
enable = mkEnableOption ''
|
||||
Provides "go to definition" for the symbol under the cursor,
|
||||
and lists the definitions from the current file.
|
||||
'';
|
||||
|
||||
keymaps = {
|
||||
gotoDefinition = mkOption {
|
||||
type = types.nullOr types.str;
|
||||
default = "gnd";
|
||||
description = "go to the definition of the symbol under the cursor";
|
||||
};
|
||||
gotoDefinitionLspFallback = mkOption {
|
||||
type = types.nullOr types.str;
|
||||
default = null;
|
||||
description = ''
|
||||
go to the definition of the symbol under the cursor or use vim.lsp.buf.definition if
|
||||
the symbol can not be resolved. You can use your own fallback function if create a
|
||||
mapping for `lua require'nvim-treesitter.refactor.navigation(nil, fallback_function)<cr>`.
|
||||
'';
|
||||
};
|
||||
listDefinitions = mkOption {
|
||||
type = types.nullOr types.str;
|
||||
default = "gnD";
|
||||
description = "list all definitions from the current file";
|
||||
};
|
||||
listDefinitionsToc = mkOption {
|
||||
type = types.nullOr types.str;
|
||||
default = "gO";
|
||||
description = ''
|
||||
list all definitions from the current file like a table of contents (similar to the one
|
||||
you see when pressing |gO| in help files).
|
||||
'';
|
||||
};
|
||||
gotoNextUsage = mkOption {
|
||||
type = types.nullOr types.str;
|
||||
default = "<a-*>";
|
||||
description = "go to next usage of identifier under the cursor";
|
||||
};
|
||||
gotoPreviousUsage = mkOption {
|
||||
type = types.nullOr types.str;
|
||||
default = "<a-#>";
|
||||
description = "go to previous usage of identifier";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
imports = [
|
||||
# Added 2024-02-07
|
||||
(mkRenamedOptionModule
|
||||
[
|
||||
"plugins"
|
||||
"treesitter-refactor"
|
||||
"navigation"
|
||||
"keymaps"
|
||||
"listDefinitons"
|
||||
]
|
||||
[
|
||||
"plugins"
|
||||
"treesitter-refactor"
|
||||
"navigation"
|
||||
"keymaps"
|
||||
"listDefinitions"
|
||||
]
|
||||
)
|
||||
# Added 2024-02-07
|
||||
(mkRenamedOptionModule
|
||||
[
|
||||
"plugins"
|
||||
"treesitter-refactor"
|
||||
"navigation"
|
||||
"keymaps"
|
||||
"listDefinitonsToc"
|
||||
]
|
||||
[
|
||||
"plugins"
|
||||
"treesitter-refactor"
|
||||
"navigation"
|
||||
"keymaps"
|
||||
"listDefinitionsToc"
|
||||
]
|
||||
)
|
||||
];
|
||||
|
||||
config =
|
||||
let
|
||||
cfg = config.plugins.treesitter-refactor;
|
||||
in
|
||||
mkIf cfg.enable {
|
||||
warnings = mkIf (!config.plugins.treesitter.enable) [
|
||||
"Nixvim: treesitter-refactor needs treesitter to function as intended"
|
||||
];
|
||||
|
||||
extraPlugins = [ cfg.package ];
|
||||
|
||||
plugins.treesitter.settings.refactor = {
|
||||
highlight_definitions = {
|
||||
inherit (cfg.highlightDefinitions) enable disable;
|
||||
clear_on_cursor_move = cfg.highlightDefinitions.clearOnCursorMove;
|
||||
};
|
||||
highlight_current_scope = cfg.highlightCurrentScope;
|
||||
smart_rename = {
|
||||
inherit (cfg.smartRename) enable disable;
|
||||
keymaps = {
|
||||
smart_rename = cfg.smartRename.keymaps.smartRename;
|
||||
};
|
||||
};
|
||||
navigation = {
|
||||
inherit (cfg.navigation) enable disable;
|
||||
keymaps =
|
||||
let
|
||||
cfgK = cfg.navigation.keymaps;
|
||||
in
|
||||
{
|
||||
goto_definition = cfgK.gotoDefinition;
|
||||
goto_definition_lsp_fallback = cfgK.gotoDefinitionLspFallback;
|
||||
list_definitions = cfgK.listDefinitions;
|
||||
list_definitions_toc = cfgK.listDefinitionsToc;
|
||||
goto_next_usage = cfgK.gotoNextUsage;
|
||||
goto_previous_usage = cfgK.gotoPreviousUsage;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
|
@ -1,250 +0,0 @@
|
|||
{
|
||||
lib,
|
||||
helpers,
|
||||
config,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
with lib;
|
||||
{
|
||||
options.plugins.treesitter-textobjects =
|
||||
let
|
||||
disable = helpers.defaultNullOpts.mkListOf types.str [ ] ''
|
||||
List of languages to disable this module for.
|
||||
'';
|
||||
|
||||
mkKeymapsOption =
|
||||
desc:
|
||||
helpers.defaultNullOpts.mkAttrsOf (
|
||||
with types;
|
||||
either str (submodule {
|
||||
options = {
|
||||
query = mkOption {
|
||||
type = str;
|
||||
description = "";
|
||||
example = "@class.inner";
|
||||
};
|
||||
|
||||
queryGroup = helpers.mkNullOrOption str ''
|
||||
You can also use captures from other query groups like `locals.scm`
|
||||
'';
|
||||
|
||||
desc = helpers.mkNullOrOption str ''
|
||||
You can optionally set descriptions to the mappings (used in the `desc`
|
||||
parameter of `nvim_buf_set_keymap`) which plugins like _which-key_ display.
|
||||
'';
|
||||
};
|
||||
})
|
||||
) { } desc;
|
||||
in
|
||||
helpers.neovim-plugin.extraOptionsOptions
|
||||
// {
|
||||
enable = mkEnableOption "treesitter-textobjects (requires plugins.treesitter.enable to be true)";
|
||||
|
||||
package = lib.mkPackageOption pkgs "treesitter-textobjects" {
|
||||
default = [
|
||||
"vimPlugins"
|
||||
"nvim-treesitter-textobjects"
|
||||
];
|
||||
};
|
||||
|
||||
select = {
|
||||
enable = helpers.defaultNullOpts.mkBool false ''
|
||||
Text object selection:
|
||||
|
||||
Define your own text objects mappings similar to `ip` (inner paragraph) and `ap`
|
||||
(a paragraph).
|
||||
'';
|
||||
|
||||
inherit disable;
|
||||
|
||||
lookahead = helpers.defaultNullOpts.mkBool false ''
|
||||
Whether or not to look ahead for the textobject.
|
||||
'';
|
||||
|
||||
keymaps = mkKeymapsOption ''
|
||||
Map of keymaps to a tree-sitter query (`(function_definition) @function`) or capture
|
||||
group (`@function.inner`).
|
||||
'';
|
||||
|
||||
selectionModes =
|
||||
helpers.defaultNullOpts.mkAttrsOf
|
||||
(
|
||||
with types;
|
||||
enum [
|
||||
"v"
|
||||
"V"
|
||||
"<c-v>"
|
||||
]
|
||||
)
|
||||
{ }
|
||||
''
|
||||
Map of capture group to `v`(charwise), `V`(linewise), or `<c-v>`(blockwise), choose a
|
||||
selection mode per capture, default is `v`(charwise).
|
||||
'';
|
||||
|
||||
includeSurroundingWhitespace = helpers.defaultNullOpts.mkStrLuaFnOr types.bool false ''
|
||||
`true` or `false`, when `true` textobjects are extended to include preceding or
|
||||
succeeding whitespace.
|
||||
|
||||
Can also be a function which gets passed a table with the keys `query_string`
|
||||
(`@function.inner`) and `selection_mode` (`v`) and returns `true` of `false`.
|
||||
|
||||
If you set this to `true` (default is `false`) then any textobject is extended to
|
||||
include preceding or succeeding whitespace.
|
||||
Succeeding whitespace has priority in order to act similarly to eg the built-in `ap`.
|
||||
'';
|
||||
};
|
||||
|
||||
swap = {
|
||||
enable = helpers.defaultNullOpts.mkBool false ''
|
||||
Swap text objects:
|
||||
|
||||
Define your own mappings to swap the node under the cursor with the next or previous one,
|
||||
like function parameters or arguments.
|
||||
'';
|
||||
|
||||
inherit disable;
|
||||
|
||||
swapNext = mkKeymapsOption ''
|
||||
Map of keymaps to a list of tree-sitter capture groups (`{@parameter.inner}`).
|
||||
Capture groups that come earlier in the list are preferred.
|
||||
'';
|
||||
|
||||
swapPrevious = mkKeymapsOption ''
|
||||
Same as `swapNext`, but it will swap with the previous text object.
|
||||
'';
|
||||
};
|
||||
|
||||
move = {
|
||||
enable = helpers.defaultNullOpts.mkBool false ''
|
||||
Go to next/previous text object~
|
||||
|
||||
Define your own mappings to jump to the next or previous text object.
|
||||
This is similar to `|]m|`, `|[m|`, `|]M|`, `|[M|` Neovim's mappings to jump to the next or
|
||||
previous function.
|
||||
'';
|
||||
|
||||
inherit disable;
|
||||
|
||||
setJumps = helpers.defaultNullOpts.mkBool true "Whether to set jumps in the jumplist.";
|
||||
|
||||
gotoNextStart = mkKeymapsOption ''
|
||||
Map of keymaps to a list of tree-sitter capture groups (`{@function.outer,
|
||||
@class.outer}`).
|
||||
The one that starts closest to the cursor will be chosen, preferring row-proximity to
|
||||
column-proximity.
|
||||
'';
|
||||
|
||||
gotoNextEnd = mkKeymapsOption ''
|
||||
Same as `gotoNextStart`, but it jumps to the start of the text object.
|
||||
'';
|
||||
|
||||
gotoPreviousStart = mkKeymapsOption ''
|
||||
Same as `gotoNextStart`, but it jumps to the previous text object.
|
||||
'';
|
||||
|
||||
gotoPreviousEnd = mkKeymapsOption ''
|
||||
Same as `gotoNextEnd`, but it jumps to the previous text object.
|
||||
'';
|
||||
|
||||
gotoNext = mkKeymapsOption ''
|
||||
Will go to either the start or the end, whichever is closer.
|
||||
Use if you want more granular movements.
|
||||
Make it even more gradual by adding multiple queries and regex.
|
||||
'';
|
||||
|
||||
gotoPrevious = mkKeymapsOption ''
|
||||
Will go to either the start or the end, whichever is closer.
|
||||
Use if you want more granular movements.
|
||||
Make it even more gradual by adding multiple queries and regex.
|
||||
'';
|
||||
};
|
||||
|
||||
lspInterop = {
|
||||
enable = helpers.defaultNullOpts.mkBool false "LSP interop.";
|
||||
|
||||
border = helpers.defaultNullOpts.mkEnumFirstDefault [
|
||||
"none"
|
||||
"single"
|
||||
"double"
|
||||
"rounded"
|
||||
"solid"
|
||||
"shadow"
|
||||
] "Define the style of the floating window border.";
|
||||
|
||||
peekDefinitionCode = mkKeymapsOption ''
|
||||
Show textobject surrounding definition as determined using Neovim's built-in LSP in a
|
||||
floating window.
|
||||
Press the shortcut twice to enter the floating window
|
||||
(when https://github.com/neovim/neovim/pull/12720 or its successor is merged).
|
||||
'';
|
||||
|
||||
floatingPreviewOpts = helpers.defaultNullOpts.mkAttrsOf types.anything { } ''
|
||||
Options to pass to `vim.lsp.util.open_floating_preview`.
|
||||
For example, `maximum_height`.
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
config =
|
||||
let
|
||||
cfg = config.plugins.treesitter-textobjects;
|
||||
in
|
||||
mkIf cfg.enable {
|
||||
warnings = mkIf (!config.plugins.treesitter.enable) [
|
||||
"Nixvim: treesitter-textobjects needs treesitter to function as intended"
|
||||
];
|
||||
|
||||
extraPlugins = [ cfg.package ];
|
||||
|
||||
plugins.treesitter.settings.textobjects =
|
||||
with cfg;
|
||||
let
|
||||
processKeymapsOpt =
|
||||
keymapsOptionValue:
|
||||
helpers.ifNonNull' keymapsOptionValue (
|
||||
mapAttrs (
|
||||
key: mapping:
|
||||
if isString mapping then
|
||||
mapping
|
||||
else
|
||||
{
|
||||
inherit (mapping) query;
|
||||
query_group = mapping.queryGroup;
|
||||
inherit (mapping) desc;
|
||||
}
|
||||
) keymapsOptionValue
|
||||
);
|
||||
in
|
||||
{
|
||||
select = with select; {
|
||||
inherit enable disable lookahead;
|
||||
keymaps = processKeymapsOpt keymaps;
|
||||
selection_modes = selectionModes;
|
||||
include_surrounding_whitespace = includeSurroundingWhitespace;
|
||||
};
|
||||
swap = with swap; {
|
||||
inherit enable disable;
|
||||
swap_next = processKeymapsOpt swapNext;
|
||||
swap_previous = processKeymapsOpt swapPrevious;
|
||||
};
|
||||
move = with move; {
|
||||
inherit enable disable;
|
||||
set_jumps = setJumps;
|
||||
goto_next_start = processKeymapsOpt gotoNextStart;
|
||||
goto_next_end = processKeymapsOpt gotoNextEnd;
|
||||
goto_previous_start = processKeymapsOpt gotoPreviousStart;
|
||||
goto_previous_end = processKeymapsOpt gotoPreviousEnd;
|
||||
goto_next = processKeymapsOpt gotoNext;
|
||||
goto_previous = processKeymapsOpt gotoPrevious;
|
||||
};
|
||||
lsp_interop = with lspInterop; {
|
||||
inherit enable border;
|
||||
peek_definition_code = processKeymapsOpt peekDefinitionCode;
|
||||
floating_preview_opts = floatingPreviewOpts;
|
||||
};
|
||||
}
|
||||
// cfg.extraOptions;
|
||||
};
|
||||
}
|
|
@ -1,420 +0,0 @@
|
|||
{
|
||||
lib,
|
||||
helpers,
|
||||
config,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
with lib;
|
||||
helpers.neovim-plugin.mkNeovimPlugin {
|
||||
name = "treesitter";
|
||||
originalName = "nvim-treesitter";
|
||||
luaName = "nvim-treesitter.configs";
|
||||
package = "nvim-treesitter";
|
||||
|
||||
description = ''
|
||||
Provides an interface to [tree-sitter]
|
||||
|
||||
### Installing Your Own Grammars with Nixvim
|
||||
|
||||
The grammars you want will usually be included in `nixGrammars` by default.
|
||||
But, in the rare case it isn't, you can build your own and use it with Nixvim like so:
|
||||
|
||||
```nix
|
||||
{ pkgs, ... }:
|
||||
let
|
||||
# Example of building your own grammar
|
||||
treesitter-nu-grammar = pkgs.tree-sitter.buildGrammar {
|
||||
language = "nu";
|
||||
version = "0.0.0+rev=0bb9a60";
|
||||
src = pkgs.fetchFromGitHub {
|
||||
owner = "nushell";
|
||||
repo = "tree-sitter-nu";
|
||||
rev = "0bb9a602d9bc94b66fab96ce51d46a5a227ab76c";
|
||||
hash = "sha256-A5GiOpITOv3H0wytCv6t43buQ8IzxEXrk3gTlOrO0K0=";
|
||||
};
|
||||
meta.homepage = "https://github.com/nushell/tree-sitter-nu";
|
||||
};
|
||||
|
||||
# or you can yoink any grammars in tree-sitter.grammars.''${grammar-name}
|
||||
# treesitter-nu-grammar = pkgs.tree-sitter-grammars.tree-sitter-nu;
|
||||
in
|
||||
{
|
||||
|
||||
programs.nixvim.plugins = {
|
||||
treesitter = {
|
||||
enable = true;
|
||||
settings.indent.enable = true;
|
||||
grammarPackages = pkgs.vimPlugins.nvim-treesitter.passthru.allGrammars ++ [
|
||||
treesitter-nu-grammar
|
||||
];
|
||||
};
|
||||
|
||||
extraConfigLua =
|
||||
'''
|
||||
do
|
||||
local parser_config = require("nvim-treesitter.parsers").get_parser_configs()
|
||||
-- change the following as needed
|
||||
parser_config.nu = {
|
||||
install_info = {
|
||||
url = "''${treesitter-nu-grammar}", -- local path or git repo
|
||||
files = {"src/parser.c"}, -- note that some parsers also require src/scanner.c or src/scanner.cc
|
||||
-- optional entries:
|
||||
-- branch = "main", -- default branch in case of git repo if different from master
|
||||
-- generate_requires_npm = false, -- if stand-alone parser without npm dependencies
|
||||
-- requires_generate_from_grammar = false, -- if folder contains pre-generated src/parser.c
|
||||
},
|
||||
filetype = "nu", -- if filetype does not match the parser name
|
||||
}
|
||||
end
|
||||
''';
|
||||
|
||||
# Add as extra plugins so that their `queries/{language}/*.scm` get
|
||||
# installed and can be picked up by `tree-sitter`
|
||||
extraPlugins = [
|
||||
treesitter-nu-grammar
|
||||
];
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
The queries for the grammar should be added to one of the runtime directories under `queries/{language}` but sometimes plugins do not conform to this structure.
|
||||
|
||||
In such cases, you can override the source derivation (or the grammar derivation) to move the queries to the appropriate folder:
|
||||
|
||||
```nix
|
||||
(
|
||||
(pkgs.fetchFromGitLab {
|
||||
owner = "joncoole";
|
||||
repo = "tree-sitter-nginx";
|
||||
rev = "b4b61db443602b69410ab469c122c01b1e685aa0";
|
||||
hash = "sha256-Sa7audtwH8EgrHJ5XIUKTdveZU2pDPoUq70InQ6qcKA=";
|
||||
}).overrideAttrs
|
||||
(drv: {
|
||||
fixupPhase = '''
|
||||
mkdir -p $out/queries/nginx
|
||||
mv $out/queries/*.scm $out/queries/nginx/
|
||||
''';
|
||||
})
|
||||
)
|
||||
```
|
||||
|
||||
Verify if the queries were picked up by running `:TSModuleInfo`.
|
||||
|
||||
[tree-sitter]: https://github.com/tree-sitter/tree-sitter
|
||||
'';
|
||||
|
||||
maintainers = [ lib.maintainers.khaneliman ];
|
||||
|
||||
# TODO introduced 2024-07-06: remove after 24.11
|
||||
optionsRenamedToSettings = [
|
||||
"ensureInstalled"
|
||||
"ignoreInstall"
|
||||
"parserInstallDir"
|
||||
[
|
||||
"incrementalSelection"
|
||||
"enable"
|
||||
]
|
||||
[
|
||||
"incrementalSelection"
|
||||
"keymaps"
|
||||
"initSelection"
|
||||
"nodeDecremental"
|
||||
]
|
||||
[
|
||||
"incrementalSelection"
|
||||
"keymaps"
|
||||
"initSelection"
|
||||
"nodeIncremental"
|
||||
]
|
||||
[
|
||||
"incrementalSelection"
|
||||
"keymaps"
|
||||
"initSelection"
|
||||
"scopeIncremental"
|
||||
]
|
||||
];
|
||||
|
||||
imports =
|
||||
let
|
||||
basePluginPath = [
|
||||
"plugins"
|
||||
"treesitter"
|
||||
];
|
||||
settingsPath = basePluginPath ++ [ "settings" ];
|
||||
in
|
||||
[
|
||||
(lib.mkRenamedOptionModule (basePluginPath ++ [ "moduleConfig" ]) settingsPath)
|
||||
(lib.mkRenamedOptionModule (basePluginPath ++ [ "customCaptures" ]) (
|
||||
settingsPath
|
||||
++ [
|
||||
"highlight"
|
||||
"custom_captures"
|
||||
]
|
||||
))
|
||||
(lib.mkRenamedOptionModule (basePluginPath ++ [ "disabledLanguages" ]) (
|
||||
settingsPath
|
||||
++ [
|
||||
"highlight"
|
||||
"disable"
|
||||
]
|
||||
))
|
||||
(lib.mkRenamedOptionModule (basePluginPath ++ [ "indent" ]) (
|
||||
settingsPath
|
||||
++ [
|
||||
"indent"
|
||||
"enable"
|
||||
]
|
||||
))
|
||||
];
|
||||
|
||||
settingsOptions = {
|
||||
auto_install = helpers.defaultNullOpts.mkBool false ''
|
||||
Whether to automatically install missing parsers when entering a buffer.
|
||||
'';
|
||||
|
||||
highlight = {
|
||||
additional_vim_regex_highlighting =
|
||||
helpers.defaultNullOpts.mkNullableWithRaw
|
||||
(with helpers.nixvimTypes; either bool (listOf (maybeRaw str)))
|
||||
false
|
||||
''
|
||||
Setting this to true will run `syntax` and tree-sitter at the same time. \
|
||||
Set this to `true` if you depend on 'syntax' being enabled (e.g. for indentation). \
|
||||
See `:h syntax`.
|
||||
|
||||
Using this option may slow down your editor, and you may see some duplicate highlights. \
|
||||
Instead of true, it can also be a list of languages.
|
||||
'';
|
||||
|
||||
enable = helpers.defaultNullOpts.mkBool false ''
|
||||
Whether to enable treesitter highlighting.
|
||||
'';
|
||||
|
||||
disable =
|
||||
helpers.defaultNullOpts.mkStrLuaFnOr (with helpers.nixvimTypes; listOf (maybeRaw str)) null
|
||||
''
|
||||
Can either be a list of the names of parsers you wish to disable or
|
||||
a lua function that returns a boolean indicating the parser should be disabled.
|
||||
'';
|
||||
|
||||
custom_captures = helpers.defaultNullOpts.mkAttrsOf types.str { } ''
|
||||
Custom capture group highlighting.
|
||||
'';
|
||||
};
|
||||
|
||||
incremental_selection = {
|
||||
enable = helpers.defaultNullOpts.mkBool false ''
|
||||
Incremental selection based on the named nodes from the grammar.
|
||||
'';
|
||||
|
||||
keymaps =
|
||||
let
|
||||
mkKeymap =
|
||||
default:
|
||||
helpers.defaultNullOpts.mkNullableWithRaw (
|
||||
with types; either str bool
|
||||
) default "Key shortcut or false to unset.";
|
||||
in
|
||||
{
|
||||
init_selection = mkKeymap "gnn";
|
||||
node_incremental = mkKeymap "grn";
|
||||
scope_incremental = mkKeymap "grc";
|
||||
node_decremental = mkKeymap "grm";
|
||||
};
|
||||
};
|
||||
|
||||
indent = {
|
||||
enable = helpers.defaultNullOpts.mkBool false ''
|
||||
Whether to enable treesitter indentation.
|
||||
'';
|
||||
};
|
||||
|
||||
ensure_installed = helpers.defaultNullOpts.mkNullable' {
|
||||
type =
|
||||
with helpers.nixvimTypes;
|
||||
oneOf [
|
||||
(enum [ "all" ])
|
||||
(listOf (maybeRaw str))
|
||||
rawLua
|
||||
];
|
||||
pluginDefault = [ ];
|
||||
description = ''
|
||||
Either `"all"` or a list of languages to ensure installing.
|
||||
'';
|
||||
};
|
||||
|
||||
ignore_install = helpers.defaultNullOpts.mkListOf types.str [ ] ''
|
||||
List of parsers to ignore installing. Used when `ensure_installed` is set to `"all"`.
|
||||
'';
|
||||
|
||||
parser_install_dir = helpers.mkNullOrOption' {
|
||||
type = with helpers.nixvimTypes; maybeRaw str;
|
||||
# Backport the default from nvim-treesitter 1.0
|
||||
# The current default doesn't work on nix, as it is readonly
|
||||
default.__raw = "vim.fs.joinpath(vim.fn.stdpath('data'), 'site')";
|
||||
pluginDefault = lib.literalMD "the plugin's package directory";
|
||||
description = ''
|
||||
Location of the parsers to be installed by the plugin (only needed when `nixGrammars` is disabled).
|
||||
|
||||
By default, parsers are installed to the "site" dir.
|
||||
If set to `null` the _plugin default_ is used, which will not work on nix.
|
||||
'';
|
||||
};
|
||||
|
||||
sync_install = helpers.defaultNullOpts.mkBool false ''
|
||||
Install parsers synchronously (only applied to `ensure_installed`).
|
||||
'';
|
||||
};
|
||||
|
||||
settingsExample = {
|
||||
auto_install = false;
|
||||
ensure_installed = "all";
|
||||
ignore_install = [ "rust" ];
|
||||
parser_install_dir.__raw = "vim.fs.joinpath(vim.fn.stdpath('data'), 'treesitter')";
|
||||
sync_install = false;
|
||||
|
||||
highlight = {
|
||||
enable = true;
|
||||
|
||||
additional_vim_regex_highlighting = true;
|
||||
disable = [ "rust" ];
|
||||
custom_captures = { };
|
||||
};
|
||||
|
||||
incremental_selection = {
|
||||
enable = true;
|
||||
|
||||
keymaps = {
|
||||
init_selection = false;
|
||||
node_decremental = "grm";
|
||||
node_incremental = "grn";
|
||||
scope_incremental = "grc";
|
||||
};
|
||||
};
|
||||
|
||||
indent = {
|
||||
enable = true;
|
||||
};
|
||||
};
|
||||
|
||||
extraOptions = {
|
||||
folding = mkEnableOption "tree-sitter based folding";
|
||||
|
||||
gccPackage = lib.mkPackageOption pkgs "gcc" {
|
||||
nullable = true;
|
||||
example = "pkgs.gcc14";
|
||||
extraDescription = ''
|
||||
This is required to build grammars if you are not using `nixGrammars`.
|
||||
'';
|
||||
};
|
||||
|
||||
grammarPackages = mkOption {
|
||||
type = with types; listOf package;
|
||||
default = config.plugins.treesitter.package.passthru.allGrammars;
|
||||
example = literalExpression "pkgs.vimPlugins.nvim-treesitter.passthru.allGrammars";
|
||||
defaultText = literalExpression "config.plugins.treesitter.package.passthru.allGrammars";
|
||||
description = "Grammar packages to install";
|
||||
};
|
||||
|
||||
# TODO: Implement rawLua support to be passed into extraConfigLua.
|
||||
languageRegister = mkOption {
|
||||
type = with types; attrsOf (coercedTo str toList (listOf str));
|
||||
default = { };
|
||||
example = {
|
||||
cpp = "onelab";
|
||||
python = [
|
||||
"foo"
|
||||
"bar"
|
||||
];
|
||||
};
|
||||
description = ''
|
||||
This is a wrapping of the `vim.treesitter.language.register` function.
|
||||
|
||||
Register specific parsers to one or several filetypes.
|
||||
|
||||
The keys are the parser names and the values are either one or several filetypes.
|
||||
'';
|
||||
};
|
||||
|
||||
nixGrammars = mkOption {
|
||||
type = types.bool;
|
||||
default = true;
|
||||
example = false;
|
||||
description = "Whether to install grammars defined in `grammarPackages`.";
|
||||
};
|
||||
|
||||
nixvimInjections = mkOption {
|
||||
type = types.bool;
|
||||
default = true;
|
||||
example = false;
|
||||
description = "Whether to enable Nixvim injections, e.g. highlighting `extraConfigLua` as lua.";
|
||||
};
|
||||
|
||||
nodejsPackage = lib.mkPackageOption pkgs "nodejs" {
|
||||
nullable = true;
|
||||
example = "pkgs.nodejs_22";
|
||||
extraDescription = ''
|
||||
This is required to build grammars if you are not using `nixGrammars`.
|
||||
'';
|
||||
};
|
||||
|
||||
treesitterPackage = lib.mkPackageOption pkgs "tree-sitter" {
|
||||
nullable = true;
|
||||
extraDescription = ''
|
||||
This is required to build grammars if you are not using `nixGrammars`.
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
# NOTE: We call setup manually below.
|
||||
callSetup = false;
|
||||
# NOTE: We install cfg.package manually so we can install grammars using it.
|
||||
installPackage = false;
|
||||
|
||||
extraConfig = cfg: {
|
||||
extraConfigLua =
|
||||
# NOTE: Upstream state that the parser MUST be at the beginning of runtimepath.
|
||||
# Otherwise the parsers from Neovim takes precedent, which may be incompatible with some queries.
|
||||
(optionalString (cfg.settings.parser_install_dir != null) ''
|
||||
vim.opt.runtimepath:prepend(${helpers.toLuaObject cfg.settings.parser_install_dir})
|
||||
'')
|
||||
+ ''
|
||||
require('nvim-treesitter.configs').setup(${helpers.toLuaObject cfg.settings})
|
||||
''
|
||||
+ (optionalString (cfg.languageRegister != { }) ''
|
||||
do
|
||||
local __parserFiletypeMappings = ${helpers.toLuaObject cfg.languageRegister}
|
||||
|
||||
for parser_name, ft in pairs(__parserFiletypeMappings) do
|
||||
require('vim.treesitter.language').register(parser_name, ft)
|
||||
end
|
||||
end
|
||||
'');
|
||||
|
||||
extraFiles = mkIf cfg.nixvimInjections { "queries/nix/injections.scm".source = ./injections.scm; };
|
||||
|
||||
extraPlugins = mkIf (cfg.package != null) [
|
||||
(mkIf cfg.nixGrammars (cfg.package.withPlugins (_: cfg.grammarPackages)))
|
||||
(mkIf (!cfg.nixGrammars) cfg.package)
|
||||
];
|
||||
|
||||
extraPackages = [
|
||||
cfg.gccPackage
|
||||
cfg.nodejsPackage
|
||||
cfg.treesitterPackage
|
||||
];
|
||||
|
||||
opts = mkIf cfg.folding {
|
||||
foldmethod = mkDefault "expr";
|
||||
foldexpr = mkDefault "nvim_treesitter#foldexpr()";
|
||||
};
|
||||
|
||||
# Since https://github.com/NixOS/nixpkgs/pull/321550 upstream queries are added
|
||||
# to grammar plugins. Exclude nvim-treesitter itself from combining to avoid
|
||||
# collisions with grammar's queries
|
||||
performance.combinePlugins.standalonePlugins = [ cfg.package ];
|
||||
};
|
||||
}
|
|
@ -1,102 +0,0 @@
|
|||
{
|
||||
lib,
|
||||
helpers,
|
||||
config,
|
||||
...
|
||||
}:
|
||||
with lib;
|
||||
helpers.neovim-plugin.mkNeovimPlugin {
|
||||
name = "ts-autotag";
|
||||
originalName = "nvim-ts-autotag";
|
||||
luaName = "nvim-ts-autotag";
|
||||
package = "nvim-ts-autotag";
|
||||
|
||||
maintainers = [ maintainers.GaetanLepage ];
|
||||
|
||||
# TODO introduced 2024-06-17: remove 2024-08-17
|
||||
deprecateExtraOptions = true;
|
||||
imports =
|
||||
map
|
||||
(
|
||||
optionName:
|
||||
mkRemovedOptionModule
|
||||
[
|
||||
"plugins"
|
||||
"ts-autotag"
|
||||
optionName
|
||||
]
|
||||
''
|
||||
The `ts-autotag` plugin is no longer configured using `nvim-treesitter.configs`.
|
||||
Please, refer to upstream documentation:
|
||||
https://github.com/windwp/nvim-ts-autotag#setup
|
||||
''
|
||||
)
|
||||
[
|
||||
"filetypes"
|
||||
"skipTags"
|
||||
];
|
||||
|
||||
extraConfig = cfg: {
|
||||
warnings = mkIf (!config.plugins.treesitter.enable) [
|
||||
"Nixvim: ts-autotag needs treesitter to function as intended"
|
||||
];
|
||||
};
|
||||
|
||||
settingsOptions =
|
||||
let
|
||||
opts = {
|
||||
enable_close = helpers.defaultNullOpts.mkBool true ''
|
||||
Whether or not to auto close tags.
|
||||
'';
|
||||
|
||||
enable_rename = helpers.defaultNullOpts.mkBool true ''
|
||||
Whether or not to auto rename paired tags.
|
||||
'';
|
||||
|
||||
enable_close_on_slash = helpers.defaultNullOpts.mkBool true ''
|
||||
Whether or not to auto close tags when a `/` is inserted.
|
||||
'';
|
||||
};
|
||||
in
|
||||
{
|
||||
inherit opts;
|
||||
|
||||
aliases = helpers.defaultNullOpts.mkAttrsOf types.str {
|
||||
"astro" = "html";
|
||||
"eruby" = "html";
|
||||
"vue" = "html";
|
||||
"htmldjango" = "html";
|
||||
"markdown" = "html";
|
||||
"php" = "html";
|
||||
"twig" = "html";
|
||||
"blade" = "html";
|
||||
"javascriptreact" = "typescriptreact";
|
||||
"javascript.jsx" = "typescriptreact";
|
||||
"typescript.tsx" = "typescriptreact";
|
||||
"javascript" = "typescriptreact";
|
||||
"typescript" = "typescriptreact";
|
||||
"rescript" = "typescriptreact";
|
||||
"handlebars" = "glimmer";
|
||||
"hbs" = "glimmer";
|
||||
"rust" = "rust";
|
||||
} "Filetype aliases.";
|
||||
|
||||
per_filetype = helpers.defaultNullOpts.mkAttrsOf (types.submodule {
|
||||
freeformType = with types; attrsOf anything;
|
||||
options = opts;
|
||||
}) { } "Per filetype config overrides.";
|
||||
};
|
||||
|
||||
settingsExample = {
|
||||
opts = {
|
||||
enable_close = true;
|
||||
enable_rename = true;
|
||||
enable_close_on_slash = false;
|
||||
};
|
||||
per_filetype = {
|
||||
html = {
|
||||
enable_close = false;
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
|
@ -1,64 +0,0 @@
|
|||
{
|
||||
lib,
|
||||
helpers,
|
||||
config,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
with lib;
|
||||
{
|
||||
options.plugins.ts-context-commentstring = helpers.neovim-plugin.extraOptionsOptions // {
|
||||
enable = mkEnableOption "nvim-ts-context-commentstring";
|
||||
|
||||
package = lib.mkPackageOption pkgs "ts-context-commentstring" {
|
||||
default = [
|
||||
"vimPlugins"
|
||||
"nvim-ts-context-commentstring"
|
||||
];
|
||||
};
|
||||
|
||||
skipTsContextCommentStringModule = mkOption {
|
||||
type = types.bool;
|
||||
default = true;
|
||||
description = ''
|
||||
Whether to skip backwards compatibility routines and speed up loading.
|
||||
'';
|
||||
example = false;
|
||||
};
|
||||
|
||||
disableAutoInitialization = helpers.defaultNullOpts.mkBool false ''
|
||||
Whether to disable auto-initialization.
|
||||
'';
|
||||
|
||||
languages = helpers.mkNullOrOption (with types; attrsOf (either str (attrsOf str))) ''
|
||||
Allows you to add support for more languages.
|
||||
|
||||
See `:h ts-context-commentstring-commentstring-configuration` for more information.
|
||||
'';
|
||||
};
|
||||
|
||||
config =
|
||||
let
|
||||
cfg = config.plugins.ts-context-commentstring;
|
||||
in
|
||||
mkIf cfg.enable {
|
||||
warnings = mkIf (!config.plugins.treesitter.enable) [
|
||||
"Nixvim: ts-context-commentstring needs treesitter to function as intended"
|
||||
];
|
||||
|
||||
extraPlugins = [ cfg.package ];
|
||||
|
||||
globals = with cfg; {
|
||||
skip_ts_context_commentstring_module = skipTsContextCommentStringModule;
|
||||
loaded_ts_context_commentstring = disableAutoInitialization;
|
||||
};
|
||||
|
||||
extraConfigLua =
|
||||
let
|
||||
setupOptions = with cfg; { inherit languages; } // cfg.extraOptions;
|
||||
in
|
||||
''
|
||||
require('ts_context_commentstring').setup(${helpers.toLuaObject setupOptions})
|
||||
'';
|
||||
};
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue