treewide: Reformat with nixfmt

This commit is contained in:
traxys 2024-05-05 19:39:35 +02:00
parent c6281260dc
commit 62f32bfc71
459 changed files with 28139 additions and 26377 deletions

View file

@ -5,10 +5,12 @@
pkgs,
...
}:
with lib; let
with lib;
let
cfg = config.plugins.hmts;
in {
meta.maintainers = [maintainers.GaetanLepage];
in
{
meta.maintainers = [ maintainers.GaetanLepage ];
options.plugins.hmts = {
enable = mkEnableOption "hmts.nvim";
@ -21,6 +23,6 @@ in {
"Nixvim: treesitter-refactor needs treesitter to function as intended"
];
extraPlugins = [cfg.package];
extraPlugins = [ cfg.package ];
};
}

View file

@ -5,26 +5,24 @@
pkgs,
...
}:
with lib; {
options.plugins.rainbow-delimiters =
helpers.neovim-plugin.extraOptionsOptions
// {
enable = mkEnableOption "rainbow-delimiters.nvim";
with lib;
{
options.plugins.rainbow-delimiters = helpers.neovim-plugin.extraOptionsOptions // {
enable = mkEnableOption "rainbow-delimiters.nvim";
package =
helpers.mkPackageOption
"rainbow-delimiters.nvim"
pkgs.vimPlugins.rainbow-delimiters-nvim;
package = helpers.mkPackageOption "rainbow-delimiters.nvim" pkgs.vimPlugins.rainbow-delimiters-nvim;
strategy =
helpers.defaultNullOpts.mkNullable
strategy =
helpers.defaultNullOpts.mkNullable
(
with types;
attrsOf (
either
helpers.nixvimTypes.rawLua
(enum ["global" "local" "noop"])
)
attrsOf (
either helpers.nixvimTypes.rawLua (enum [
"global"
"local"
"noop"
])
)
)
''
{
@ -61,9 +59,8 @@ with lib; {
```
'';
query =
helpers.defaultNullOpts.mkNullable
(with types; attrsOf str)
query =
helpers.defaultNullOpts.mkNullable (with types; attrsOf str)
''
{
default = "rainbow-delimiters";
@ -75,8 +72,8 @@ with lib; {
See `|rb-delimiters-query|` for more information about queries.
'';
highlight =
helpers.defaultNullOpts.mkNullable (with types; listOf str)
highlight =
helpers.defaultNullOpts.mkNullable (with types; listOf str)
''
[
"RainbowDelimiterRed"
@ -93,20 +90,19 @@ with lib; {
`|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.
'';
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.
'';
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.mkNullable
(with types; either str helpers.nixvimTypes.rawLua)
log = {
file =
helpers.defaultNullOpts.mkNullable (with types; either str helpers.nixvimTypes.rawLua)
''
{
__raw = "vim.fn.stdpath('log') .. '/rainbow-delimiters.log'";
@ -117,22 +113,22 @@ with lib; {
(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.
'';
};
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
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";
warnings = optional (
!config.plugins.treesitter.enable
) "Nixvim: treesitter-rainbow needs treesitter to function as intended";
assertions = [
{
assertion = (cfg.whitelist == null) || (cfg.blacklist == null);
@ -144,53 +140,27 @@ with lib; {
}
];
extraPlugins = [cfg.package];
extraPlugins = [ cfg.package ];
globals.rainbow_delimiters = with cfg;
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
;
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
;
inherit file level;
};
}
// cfg.extraOptions;

View file

@ -6,88 +6,100 @@
...
}:
with lib;
helpers.neovim-plugin.mkNeovimPlugin config {
name = "treesitter-context";
originalName = "nvim-treesitter-context";
defaultPackage = pkgs.vimPlugins.nvim-treesitter-context;
helpers.neovim-plugin.mkNeovimPlugin config {
name = "treesitter-context";
originalName = "nvim-treesitter-context";
defaultPackage = pkgs.vimPlugins.nvim-treesitter-context;
maintainers = [maintainers.GaetanLepage];
maintainers = [ maintainers.GaetanLepage ];
# TODO introduced 2024-04-22: remove 2024-06-22
deprecateExtraOptions = true;
optionsRenamedToSettings = [
"maxLines"
"minWindowHeight"
"lineNumbers"
"multilineThreshold"
"trimScope"
"mode"
"separator"
"zindex"
"onAttach"
# 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"
];
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"
];
};
}
};
}

View file

@ -1,11 +1,14 @@
{lib, ...}:
with lib; {
{ lib, ... }:
with lib;
{
# Deprecation notice added 2023/08/29
# TODO: remove (along with this file) in early November 2023.
imports = [
(
mkRemovedOptionModule
["plugins" "treesitter-playground"]
(mkRemovedOptionModule
[
"plugins"
"treesitter-playground"
]
''
The `treesitter-playground` plugin has been deprecated since the functionality is included in Neovim.
Use:

View file

@ -5,120 +5,144 @@
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)";
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 = helpers.mkPackageOption "treesitter-refactor" pkgs.vimPlugins.nvim-treesitter-refactor;
package = helpers.mkPackageOption "treesitter-refactor" pkgs.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.
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.
'';
};
};
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";
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"])
[
"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"])
[
"plugins"
"treesitter-refactor"
"navigation"
"keymaps"
"listDefinitonsToc"
]
[
"plugins"
"treesitter-refactor"
"navigation"
"keymaps"
"listDefinitionsToc"
]
)
];
config = let
cfg = config.plugins.treesitter-refactor;
in
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];
extraPlugins = [ cfg.package ];
plugins.treesitter.moduleConfig.refactor = {
highlight_definitions = {
@ -128,20 +152,24 @@ with lib; {
highlight_current_scope = cfg.highlightCurrentScope;
smart_rename = {
inherit (cfg.smartRename) enable disable;
keymaps = {smart_rename = cfg.smartRename.keymaps.smartRename;};
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;
};
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;
};
};
};
};

View file

@ -5,20 +5,20 @@
pkgs,
...
}:
with lib; {
options.plugins.treesitter-textobjects = let
disable = helpers.defaultNullOpts.mkNullable (with types; listOf str) "[]" ''
List of languages to disable this module for.
'';
with lib;
{
options.plugins.treesitter-textobjects =
let
disable = helpers.defaultNullOpts.mkNullable (with types; listOf str) "[]" ''
List of languages to disable this module for.
'';
mkKeymapsOption = desc:
helpers.defaultNullOpts.mkNullable
(
with types;
mkKeymapsOption =
desc:
helpers.defaultNullOpts.mkNullable (
with types;
attrsOf (
either
str
(submodule {
either str (submodule {
options = {
query = mkOption {
type = str;
@ -37,15 +37,11 @@ with lib; {
};
})
)
)
"{}"
desc;
in
) "{}" desc;
in
helpers.neovim-plugin.extraOptionsOptions
// {
enable =
mkEnableOption
"treesitter-textobjects (requires plugins.treesitter.enable to be true)";
enable = mkEnableOption "treesitter-textobjects (requires plugins.treesitter.enable to be true)";
package = helpers.mkPackageOption "treesitter-textobjects" pkgs.vimPlugins.nvim-treesitter-textobjects;
@ -70,19 +66,19 @@ with lib; {
selectionModes =
helpers.defaultNullOpts.mkNullable
(
with types;
attrsOf
(
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).
'';
(
with types;
attrsOf (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
@ -165,10 +161,14 @@ with lib; {
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.";
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
@ -177,67 +177,57 @@ with lib; {
(when https://github.com/neovim/neovim/pull/12720 or its successor is merged).
'';
floatingPreviewOpts =
helpers.defaultNullOpts.mkNullable
(with types; attrsOf anything)
"{}"
''
Options to pass to `vim.lsp.util.open_floating_preview`.
For example, `maximum_height`.
'';
floatingPreviewOpts = helpers.defaultNullOpts.mkNullable (with types; attrsOf anything) "{}" ''
Options to pass to `vim.lsp.util.open_floating_preview`.
For example, `maximum_height`.
'';
};
};
config = let
cfg = config.plugins.treesitter-textobjects;
in
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];
extraPlugins = [ cfg.package ];
plugins.treesitter.moduleConfig.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
plugins.treesitter.moduleConfig.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
;
inherit enable disable lookahead;
keymaps = processKeymapsOpt keymaps;
selection_modes = selectionModes;
include_surrounding_whitespace = includeSurroundingWhitespace;
};
swap = with swap; {
inherit
enable
disable
;
inherit enable disable;
swap_next = processKeymapsOpt swapNext;
swap_previous = processKeymapsOpt swapPrevious;
};
move = with move; {
inherit
enable
disable
;
inherit enable disable;
set_jumps = setJumps;
goto_next_start = processKeymapsOpt gotoNextStart;
goto_next_end = processKeymapsOpt gotoNextEnd;
@ -247,10 +237,7 @@ with lib; {
goto_previous = processKeymapsOpt gotoPrevious;
};
lsp_interop = with lspInterop; {
inherit
enable
border
;
inherit enable border;
peek_definition_code = processKeymapsOpt peekDefinitionCode;
floating_preview_opts = floatingPreviewOpts;
};

View file

@ -5,9 +5,11 @@
pkgs,
...
}:
with lib; let
with lib;
let
cfg = config.plugins.treesitter;
in {
in
{
options = {
plugins.treesitter = {
enable = mkEnableOption "tree-sitter syntax highlighting";
@ -25,17 +27,19 @@ in {
};
ensureInstalled = mkOption {
type = with types; oneOf [(enum ["all"]) (listOf str)];
type =
with types;
oneOf [
(enum [ "all" ])
(listOf str)
];
default = "all";
description = "Either \"all\" or a list of languages";
};
gccPackage = mkOption {
type = with types; nullOr package;
default =
if cfg.nixGrammars
then null
else pkgs.gcc;
default = if cfg.nixGrammars then null else pkgs.gcc;
example = null;
description = ''
Which package (if any) to be added as the GCC compiler.
@ -46,10 +50,7 @@ in {
parserInstallDir = mkOption {
type = types.nullOr types.str;
default =
if cfg.nixGrammars
then null
else "$XDG_DATA_HOME/nvim/treesitter";
default = if cfg.nixGrammars then null else "$XDG_DATA_HOME/nvim/treesitter";
description = ''
Location of the parsers to be installed by the plugin (only needed when nixGrammars is disabled).
This default might not work on your own install, please make sure that $XDG_DATA_HOME is set if you want to use the default. Otherwise, change it to something that will work for you!
@ -58,37 +59,40 @@ in {
ignoreInstall = mkOption {
type = types.listOf types.str;
default = [];
default = [ ];
description = "List of parsers to ignore installing (for \"all\")";
};
disabledLanguages = mkOption {
type = types.listOf types.str;
default = [];
default = [ ];
description = "A list of languages to disable";
};
customCaptures = mkOption {
type = types.attrsOf types.str;
default = {};
default = { };
description = "Custom capture group highlighting";
};
incrementalSelection = let
keymap = default:
mkOption {
type = types.str;
inherit default;
incrementalSelection =
let
keymap =
default:
mkOption {
type = types.str;
inherit default;
};
in
{
enable = mkEnableOption "incremental selection based on the named nodes from the grammar";
keymaps = {
initSelection = keymap "gnn";
nodeIncremental = keymap "grn";
scopeIncremental = keymap "grc";
nodeDecremental = keymap "grm";
};
in {
enable = mkEnableOption "incremental selection based on the named nodes from the grammar";
keymaps = {
initSelection = keymap "gnn";
nodeIncremental = keymap "grn";
scopeIncremental = keymap "grc";
nodeDecremental = keymap "grm";
};
};
indent = mkEnableOption "tree-sitter based indentation";
@ -101,10 +105,13 @@ in {
Register specific parsers to one or several filetypes.
The keys are the parser names and the values are either one or several filetypes.
'';
default = {};
default = { };
example = {
cpp = "onelab";
python = ["myFiletype" "anotherFiletype"];
python = [
"myFiletype"
"anotherFiletype"
];
};
};
@ -116,61 +123,45 @@ in {
moduleConfig = mkOption {
type = types.attrsOf types.anything;
default = {};
default = { };
description = "This is the configuration for extra modules. It should not be used directly";
};
nixvimInjections =
mkEnableOption
"nixvim specific injections, like lua highlighting in extraConfigLua";
nixvimInjections = mkEnableOption "nixvim specific injections, like lua highlighting in extraConfigLua";
};
};
config = let
tsOptions =
{
config =
let
tsOptions = {
highlight = {
inherit (cfg) enable;
disable =
if (cfg.disabledLanguages != [])
then cfg.disabledLanguages
else null;
disable = if (cfg.disabledLanguages != [ ]) then cfg.disabledLanguages else null;
custom_captures =
if (cfg.customCaptures != {})
then cfg.customCaptures
else null;
custom_captures = if (cfg.customCaptures != { }) then cfg.customCaptures else null;
};
incremental_selection =
if cfg.incrementalSelection.enable
then {
enable = true;
keymaps = {
init_selection = cfg.incrementalSelection.keymaps.initSelection;
node_incremental = cfg.incrementalSelection.keymaps.nodeIncremental;
scope_incremental = cfg.incrementalSelection.keymaps.scopeIncremental;
node_decremental = cfg.incrementalSelection.keymaps.nodeDecremental;
};
}
else null;
if cfg.incrementalSelection.enable then
{
enable = true;
keymaps = {
init_selection = cfg.incrementalSelection.keymaps.initSelection;
node_incremental = cfg.incrementalSelection.keymaps.nodeIncremental;
scope_incremental = cfg.incrementalSelection.keymaps.scopeIncremental;
node_decremental = cfg.incrementalSelection.keymaps.nodeDecremental;
};
}
else
null;
indent =
if cfg.indent
then {
enable = true;
}
else null;
indent = if cfg.indent then { enable = true; } else null;
ensure_installed =
if cfg.nixGrammars
then []
else cfg.ensureInstalled;
ensure_installed = if cfg.nixGrammars then [ ] else cfg.ensureInstalled;
ignore_install = cfg.ignoreInstall;
parser_install_dir = cfg.parserInstallDir;
}
// cfg.moduleConfig;
in
} // cfg.moduleConfig;
in
mkIf cfg.enable {
extraConfigLua =
(optionalString (cfg.parserInstallDir != null) ''
@ -179,7 +170,7 @@ in {
+ ''
require('nvim-treesitter.configs').setup(${helpers.toLuaObject tsOptions})
''
+ (optionalString (cfg.languageRegister != {}) ''
+ (optionalString (cfg.languageRegister != { }) ''
__parserFiletypeMappings = ${helpers.toLuaObject cfg.languageRegister}
for parser_name, ft in pairs(__parserFiletypeMappings) do
@ -210,9 +201,7 @@ in {
};
extraPlugins =
if cfg.nixGrammars
then [(cfg.package.withPlugins (_: cfg.grammarPackages))]
else [cfg.package];
if cfg.nixGrammars then [ (cfg.package.withPlugins (_: cfg.grammarPackages)) ] else [ cfg.package ];
extraPackages = with pkgs; [
tree-sitter
nodejs

View file

@ -5,84 +5,74 @@
config,
...
}:
with lib; {
options.plugins.ts-autotag =
helpers.neovim-plugin.extraOptionsOptions
// {
enable = mkEnableOption "nvim-ts-autotag";
with lib;
{
options.plugins.ts-autotag = helpers.neovim-plugin.extraOptionsOptions // {
enable = mkEnableOption "nvim-ts-autotag";
package = helpers.mkPackageOption "ts-autotag" pkgs.vimPlugins.nvim-ts-autotag;
package = helpers.mkPackageOption "ts-autotag" pkgs.vimPlugins.nvim-ts-autotag;
filetypes =
helpers.defaultNullOpts.mkNullable
(with types; listOf str)
''
[
"html"
"javascript"
"typescript"
"javascriptreact"
"typescriptreact"
"svelte"
"vue"
"tsx"
"jsx"
"rescript"
"xml"
"php"
"markdown"
"astro"
"glimmer"
"handlebars"
"hbs"
]
''
"Filetypes for which ts-autotag should be enabled.";
filetypes = helpers.defaultNullOpts.mkNullable (with types; listOf str) ''
[
"html"
"javascript"
"typescript"
"javascriptreact"
"typescriptreact"
"svelte"
"vue"
"tsx"
"jsx"
"rescript"
"xml"
"php"
"markdown"
"astro"
"glimmer"
"handlebars"
"hbs"
]
'' "Filetypes for which ts-autotag should be enabled.";
skipTags =
helpers.defaultNullOpts.mkNullable
(with types; listOf str)
''
[
"area"
"base"
"br"
"col"
"command"
"embed"
"hr"
"img"
"slot"
"input"
"keygen"
"link"
"meta"
"param"
"source"
"track"
"wbr"
"menuitem"
]
''
"Which tags to skip.";
};
skipTags = helpers.defaultNullOpts.mkNullable (with types; listOf str) ''
[
"area"
"base"
"br"
"col"
"command"
"embed"
"hr"
"img"
"slot"
"input"
"keygen"
"link"
"meta"
"param"
"source"
"track"
"wbr"
"menuitem"
]
'' "Which tags to skip.";
};
config = let
cfg = config.plugins.ts-autotag;
in
config =
let
cfg = config.plugins.ts-autotag;
in
mkIf cfg.enable {
warnings = mkIf (!config.plugins.treesitter.enable) [
"Nixvim: ts-autotag needs treesitter to function as intended"
];
extraPlugins = [cfg.package];
extraPlugins = [ cfg.package ];
plugins.treesitter.moduleConfig.autotag =
{
enable = true;
inherit (cfg) filetypes;
skip_tags = cfg.skipTags;
}
// cfg.extraOptions;
plugins.treesitter.moduleConfig.autotag = {
enable = true;
inherit (cfg) filetypes;
skip_tags = cfg.skipTags;
} // cfg.extraOptions;
};
}

View file

@ -5,71 +5,55 @@
pkgs,
...
}:
with lib; {
options.plugins.ts-context-commentstring =
helpers.neovim-plugin.extraOptionsOptions
// {
enable = mkEnableOption "nvim-ts-context-commentstring";
with lib;
{
options.plugins.ts-context-commentstring = helpers.neovim-plugin.extraOptionsOptions // {
enable = mkEnableOption "nvim-ts-context-commentstring";
package =
helpers.mkPackageOption
"ts-context-commentstring"
pkgs.vimPlugins.nvim-ts-context-commentstring;
package = helpers.mkPackageOption "ts-context-commentstring" pkgs.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.
skipTsContextCommentStringModule = mkOption {
type = types.bool;
default = true;
description = ''
Whether to skip backwards compatibility routines and speed up loading.
'';
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.
'';
example = false;
};
config = let
cfg = config.plugins.ts-context-commentstring;
in
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];
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})
'';
extraConfigLua =
let
setupOptions = with cfg; { inherit languages; } // cfg.extraOptions;
in
''
require('ts_context_commentstring').setup(${helpers.toLuaObject setupOptions})
'';
};
}