added formatter + reformat existing codebase (#175)

This commit is contained in:
Gaétan Lepage 2023-02-20 11:42:13 +01:00 committed by GitHub
parent 0bf4313f22
commit 264de8cefb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
96 changed files with 3727 additions and 3341 deletions

View file

@ -17,7 +17,7 @@ in
options.plugins.clangd-extensions = {
enable = mkEnableOption "clangd_extensions, plugin implementing clangd LSP extensions";
package =
package =
helpers.mkPackageOption "clangd_extensions.nvim" pkgs.vimPlugins.clangd_extensions-nvim;
enableOffsetEncodingWorkaround = mkEnableOption ''

View file

@ -1,33 +1,38 @@
{ pkgs, lib, ... }@args:
with lib; with import ../helpers.nix { inherit lib; };
mkPlugin args {
name = "ledger";
description = "Enable ledger language features";
package = pkgs.vimPlugins.vim-ledger;
{
pkgs,
lib,
...
} @ args:
with lib;
with import ../helpers.nix {inherit lib;};
mkPlugin args {
name = "ledger";
description = "Enable ledger language features";
package = pkgs.vimPlugins.vim-ledger;
options = {
maxWidth = mkDefaultOpt {
global = "ledger_maxwidth";
description = "Number of columns to display foldtext";
type = types.int;
};
options = {
maxWidth = mkDefaultOpt {
global = "ledger_maxwidth";
description = "Number of columns to display foldtext";
type = types.int;
};
fillString = mkDefaultOpt {
global = "ledger_fillstring";
description = "String used to fill the space between account name and amount in the foldtext";
type = types.int;
};
fillString = mkDefaultOpt {
global = "ledger_fillstring";
description = "String used to fill the space between account name and amount in the foldtext";
type = types.int;
};
detailedFirst = mkDefaultOpt {
global = "ledger_detailed_first";
description = "Account completion sorted by depth instead of alphabetically";
type = types.bool;
};
detailedFirst = mkDefaultOpt {
global = "ledger_detailed_first";
description = "Account completion sorted by depth instead of alphabetically";
type = types.bool;
};
foldBlanks = mkDefaultOpt {
global = "ledger_fold_blanks";
description = "Hide blank lines following a transaction on a fold";
type = types.bool;
foldBlanks = mkDefaultOpt {
global = "ledger_fold_blanks";
description = "Hide blank lines following a transaction on a fold";
type = types.bool;
};
};
};
}
}

View file

@ -1,10 +1,13 @@
{ config, pkgs, lib, ... }:
with lib;
let
cfg = config.plugins.markdown-preview;
helpers = import ../helpers.nix { inherit lib; };
in
{
config,
pkgs,
lib,
...
}:
with lib; let
cfg = config.plugins.markdown-preview;
helpers = import ../helpers.nix {inherit lib;};
in {
options = {
plugins.markdown-preview = {
enable = mkEnableOption "markdown-preview";
@ -54,7 +57,7 @@ in
uml = helpers.defaultNullOpts.mkNullable (types.listOf types.str) "[]" "markdown-it-plantuml options";
maid = helpers.defaultNullOpts.mkNullable (types.listOf types.str) "[]" "mermaid options";
disable_sync_scroll = helpers.defaultNullOpts.mkBool false "Disable sync scroll";
sync_scroll_type = helpers.defaultNullOpts.mkNullable (types.enum [ "middle" "top" "relative" ]) "middle" ''
sync_scroll_type = helpers.defaultNullOpts.mkNullable (types.enum ["middle" "top" "relative"]) "middle" ''
Scroll type:
- "middle": The cursor position is always shown at the middle of the preview page.
- "top": The vim top viewport is always shown at the top of the preview page.
@ -86,18 +89,17 @@ in
Recognized filetypes. These filetypes will have MarkdownPreview... commands.
'';
theme = helpers.defaultNullOpts.mkNullable (types.enum [ "dark" "light" ]) "dark" ''
theme = helpers.defaultNullOpts.mkNullable (types.enum ["dark" "light"]) "dark" ''
Default theme (dark or light). By default the theme is define according to the preferences of the system.
'';
};
};
config =
let
previewOptions = mapAttrs (name: value: cfg.previewOptions.${name}) cfg.previewOptions;
in
config = let
previewOptions = mapAttrs (name: value: cfg.previewOptions.${name}) cfg.previewOptions;
in
mkIf cfg.enable {
extraPlugins = [ cfg.package ];
extraPlugins = [cfg.package];
globals = {
mkdp_auto_start = mkIf (!isNull cfg.autoStart) cfg.autoStart;
@ -109,7 +111,7 @@ in
mkdp_browser = mkIf (!isNull cfg.browser) cfg.browser;
mkdp_echo_preview_url = mkIf (!isNull cfg.echoPreviewUrl) cfg.echoPreviewUrl;
mkdp_browserfunc = mkIf (!isNull cfg.browserFunc) cfg.browserFunc;
mkdp_preview_options = mkIf (cfg.previewOptions != { }) previewOptions;
mkdp_preview_options = mkIf (cfg.previewOptions != {}) previewOptions;
mkdp_markdown_css = mkIf (!isNull cfg.markdownCss) cfg.markdownCss;
mkdp_highlight_css = mkIf (!isNull cfg.highlightCss) cfg.highlightCss;
mkdp_port = mkIf (!isNull cfg.port) cfg.port;

View file

@ -1,12 +1,17 @@
{ lib, pkgs, ... }@attrs:
let
helpers = import ../helpers.nix { inherit lib; };
in with helpers; with lib;
mkPlugin attrs {
name = "nix";
description = "Enable nix";
package = pkgs.vimPlugins.vim-nix;
{
lib,
pkgs,
...
} @ attrs: let
helpers = import ../helpers.nix {inherit lib;};
in
with helpers;
with lib;
mkPlugin attrs {
name = "nix";
description = "Enable nix";
package = pkgs.vimPlugins.vim-nix;
# Possibly add option to disable Treesitter highlighting if this is installed
options = {};
}
# Possibly add option to disable Treesitter highlighting if this is installed
options = {};
}

View file

@ -1,11 +1,11 @@
{ pkgs
, lib
, config
, ...
{
pkgs,
lib,
config,
...
}:
with lib;
let
helpers = import ../helpers.nix { inherit lib; };
with lib; let
helpers = import ../helpers.nix {inherit lib;};
in {
options.plugins.plantuml-syntax = {
enable = mkEnableOption "plantuml syntax support";
@ -24,12 +24,11 @@ in {
};
};
config =
let
cfg = config.plugins.plantuml-syntax;
in
config = let
cfg = config.plugins.plantuml-syntax;
in
mkIf cfg.enable {
extraPlugins = [ cfg.package ];
extraPlugins = [cfg.package];
globals = {
plantuml_set_makeprg = cfg.setMakeprg;

View file

@ -1,233 +1,221 @@
{ pkgs
, config
, lib
, ...
{
pkgs,
config,
lib,
...
}:
with lib;
let
helpers = import ../helpers.nix { inherit lib; };
with lib; let
helpers = import ../helpers.nix {inherit lib;};
in {
options.plugins.rust-tools =
let
mkNullableOptionWithDefault =
{ type
, description
, default
,
}:
mkOption {
type = types.nullOr type;
default = null;
description = ''
${description}
default: `${default}`
'';
};
mkNullableBoolDefault = default: description:
mkNullableOptionWithDefault {
inherit description;
type = types.bool;
default = toString default;
};
mkNullableStrDefault = default: description:
mkNullableOptionWithDefault {
inherit description;
type = types.str;
default = ''"${default}"'';
};
mkNullableIntDefault = default: description:
mkNullableOptionWithDefault {
inherit description;
type = types.int;
default = toString default;
};
in
{
enable = mkEnableOption "rust tools plugins";
package = helpers.mkPackageOption "rust-tools" pkgs.vimPlugins.rust-tools-nvim;
serverPackage = mkOption {
type = types.package;
default = pkgs.rust-analyzer;
description = "Package to use for rust-analyzer";
};
executor = mkNullableOptionWithDefault {
type = types.enum [ "termopen" "quickfix" ];
default = ''"termopen"'';
description = "how to execute terminal commands";
};
onIntialized = mkOption {
type = types.nullOr types.str;
options.plugins.rust-tools = let
mkNullableOptionWithDefault = {
type,
description,
default,
}:
mkOption {
type = types.nullOr type;
default = null;
description = ''
Callback to execute once rust-analyzer is done initializing the workspace
The callback receives one parameter indicating the `health` of the server:
"ok" | "warning" | "error"
${description}
default: `${default}`
'';
};
reloadWorkspaceFromCargoToml = mkNullableBoolDefault true ''
Automatically call RustReloadWorkspace when writing to a Cargo.toml file.
mkNullableBoolDefault = default: description:
mkNullableOptionWithDefault {
inherit description;
type = types.bool;
default = toString default;
};
mkNullableStrDefault = default: description:
mkNullableOptionWithDefault {
inherit description;
type = types.str;
default = ''"${default}"'';
};
mkNullableIntDefault = default: description:
mkNullableOptionWithDefault {
inherit description;
type = types.int;
default = toString default;
};
in {
enable = mkEnableOption "rust tools plugins";
package = helpers.mkPackageOption "rust-tools" pkgs.vimPlugins.rust-tools-nvim;
serverPackage = mkOption {
type = types.package;
default = pkgs.rust-analyzer;
description = "Package to use for rust-analyzer";
};
executor = mkNullableOptionWithDefault {
type = types.enum ["termopen" "quickfix"];
default = ''"termopen"'';
description = "how to execute terminal commands";
};
onIntialized = mkOption {
type = types.nullOr types.str;
default = null;
description = ''
Callback to execute once rust-analyzer is done initializing the workspace
The callback receives one parameter indicating the `health` of the server:
"ok" | "warning" | "error"
'';
};
reloadWorkspaceFromCargoToml = mkNullableBoolDefault true ''
Automatically call RustReloadWorkspace when writing to a Cargo.toml file.
'';
inlayHints = {
auto = mkNullableBoolDefault true "automatically set inlay hints (type hints)";
onlyCurrentLine = mkNullableBoolDefault false "Only show for current line";
showParameterHints =
mkNullableBoolDefault true
"whether to show parameter hints with the inlay hints or not";
parameterHintsPrefix = mkNullableStrDefault "<- " "prefix for parameter hints";
otherHintsPrefix = mkNullableStrDefault "=> " "prefix for all the other hints (type, chaining)";
maxLenAlign =
mkNullableBoolDefault false
"whether to align to the length of the longest line in the file";
maxLenAlignPadding = mkNullableIntDefault 1 "padding from the left if max_len_align is true";
rightAlign = mkNullableBoolDefault false "whether to align to the extreme right or not";
rightAlignPadding = mkNullableIntDefault 7 "padding from the right if right_align is true";
highlight = mkNullableStrDefault "Comment" "The color of the hints";
};
hoverActions = {
border = mkOption {
type = types.nullOr types.anything;
default = null;
description = ''
the border that is used for the hover window. see vim.api.nvim_open_win()
'';
};
maxWidth = mkOption {
type = types.nullOr types.int;
default = null;
description = "Maximal width of the hover window. Nil means no max.";
};
maxHeight = mkOption {
type = types.nullOr types.int;
default = null;
description = "Maximal height of the hover window. Nil means no max.";
};
autoFocus = mkNullableBoolDefault false "whether the hover action window gets automatically focused";
};
crateGraph = {
backend = mkNullableStrDefault "x11" ''
Backend used for displaying the graph
see: https://graphviz.org/docs/outputs/
'';
inlayHints = {
auto = mkNullableBoolDefault true "automatically set inlay hints (type hints)";
onlyCurrentLine = mkNullableBoolDefault false "Only show for current line";
showParameterHints =
mkNullableBoolDefault true
"whether to show parameter hints with the inlay hints or not";
parameterHintsPrefix = mkNullableStrDefault "<- " "prefix for parameter hints";
otherHintsPrefix = mkNullableStrDefault "=> " "prefix for all the other hints (type, chaining)";
maxLenAlign =
mkNullableBoolDefault false
"whether to align to the length of the longest line in the file";
maxLenAlignPadding = mkNullableIntDefault 1 "padding from the left if max_len_align is true";
rightAlign = mkNullableBoolDefault false "whether to align to the extreme right or not";
rightAlignPadding = mkNullableIntDefault 7 "padding from the right if right_align is true";
highlight = mkNullableStrDefault "Comment" "The color of the hints";
output = mkOption {
type = types.nullOr types.str;
default = null;
description = "where to store the output, nil for no output stored";
};
hoverActions = {
border = mkOption {
type = types.nullOr types.anything;
default = null;
description = ''
the border that is used for the hover window. see vim.api.nvim_open_win()
'';
};
full = mkNullableBoolDefault true ''
true for all crates.io and external crates, false only the local crates
'';
maxWidth = mkOption {
type = types.nullOr types.int;
default = null;
description = "Maximal width of the hover window. Nil means no max.";
};
maxHeight = mkOption {
type = types.nullOr types.int;
default = null;
description = "Maximal height of the hover window. Nil means no max.";
};
autoFocus = mkNullableBoolDefault false "whether the hover action window gets automatically focused";
};
crateGraph = {
backend = mkNullableStrDefault "x11" ''
Backend used for displaying the graph
see: https://graphviz.org/docs/outputs/
enabledGraphvizBackends = mkOption {
type = types.nullOr (types.listOf types.str);
default = null;
description = ''
List of backends found on: https://graphviz.org/docs/outputs/
Is used for input validation and autocompletion
'';
output = mkOption {
type = types.nullOr types.str;
default = null;
description = "where to store the output, nil for no output stored";
};
full = mkNullableBoolDefault true ''
true for all crates.io and external crates, false only the local crates
'';
enabledGraphvizBackends = mkOption {
type = types.nullOr (types.listOf types.str);
default = null;
description = ''
List of backends found on: https://graphviz.org/docs/outputs/
Is used for input validation and autocompletion
'';
};
};
server =
{
standalone = mkNullableBoolDefault true ''
standalone file support
setting it to false may improve startup time
'';
}
// (import ../nvim-lsp/rust-analyzer-config.nix lib);
};
config =
let
cfg = config.plugins.rust-tools;
in
server =
{
standalone = mkNullableBoolDefault true ''
standalone file support
setting it to false may improve startup time
'';
}
// (import ../nvim-lsp/rust-analyzer-config.nix lib);
};
config = let
cfg = config.plugins.rust-tools;
in
mkIf cfg.enable {
extraPlugins = with pkgs.vimPlugins; [ nvim-lspconfig cfg.package ];
extraPackages = [ cfg.serverPackage ];
extraPlugins = with pkgs.vimPlugins; [nvim-lspconfig cfg.package];
extraPackages = [cfg.serverPackage];
plugins.lsp.postConfig =
let
setupOptions = {
tools = {
executor =
if cfg.executor != null
then { __raw = ''require("rust-tools.executors").${cfg.executor}''; }
else null;
plugins.lsp.postConfig = let
setupOptions = {
tools = {
executor =
if cfg.executor != null
then {__raw = ''require("rust-tools.executors").${cfg.executor}'';}
else null;
on_initialized =
if cfg.onIntialized != null
then { __raw = cfg.onIntialized; }
else null;
on_initialized =
if cfg.onIntialized != null
then {__raw = cfg.onIntialized;}
else null;
reload_workspace_from_cargo_toml = cfg.reloadWorkspaceFromCargoToml;
inlay_hints =
let
cfgIH = cfg.inlayHints;
in
{
auto = cfgIH.auto;
only_current_line = cfgIH.onlyCurrentLine;
show_parameter_hints = cfgIH.showParameterHints;
parameter_hints_prefix = cfgIH.parameterHintsPrefix;
other_hints_prefix = cfgIH.otherHintsPrefix;
max_len_align = cfgIH.maxLenAlign;
max_len_align_padding = cfgIH.maxLenAlignPadding;
right_align = cfgIH.rightAlign;
right_align_padding = cfgIH.rightAlignPadding;
highlight = cfgIH.highlight;
};
hover_actions =
let
cfgHA = cfg.hoverActions;
in
{
border = cfgHA.border;
max_width = cfgHA.maxWidth;
max_height = cfgHA.maxHeight;
auto_focus = cfgHA.autoFocus;
};
crate_graph =
let
cfgCG = cfg.crateGraph;
in
{
backend = cfgCG.backend;
output = cfgCG.output;
full = cfgCG.full;
enabled_graphviz_backends = cfgCG.enabledGraphvizBackends;
};
reload_workspace_from_cargo_toml = cfg.reloadWorkspaceFromCargoToml;
inlay_hints = let
cfgIH = cfg.inlayHints;
in {
auto = cfgIH.auto;
only_current_line = cfgIH.onlyCurrentLine;
show_parameter_hints = cfgIH.showParameterHints;
parameter_hints_prefix = cfgIH.parameterHintsPrefix;
other_hints_prefix = cfgIH.otherHintsPrefix;
max_len_align = cfgIH.maxLenAlign;
max_len_align_padding = cfgIH.maxLenAlignPadding;
right_align = cfgIH.rightAlign;
right_align_padding = cfgIH.rightAlignPadding;
highlight = cfgIH.highlight;
};
server = {
standalone = cfg.server.standalone;
settings.rust-analyzer = lib.filterAttrs (n: v: n != "standalone") cfg.server;
on_attach = { __raw = "__lspOnAttach"; };
hover_actions = let
cfgHA = cfg.hoverActions;
in {
border = cfgHA.border;
max_width = cfgHA.maxWidth;
max_height = cfgHA.maxHeight;
auto_focus = cfgHA.autoFocus;
};
crate_graph = let
cfgCG = cfg.crateGraph;
in {
backend = cfgCG.backend;
output = cfgCG.output;
full = cfgCG.full;
enabled_graphviz_backends = cfgCG.enabledGraphvizBackends;
};
};
in
''
require('rust-tools').setup(${helpers.toLuaObject setupOptions})
'';
server = {
standalone = cfg.server.standalone;
settings.rust-analyzer = lib.filterAttrs (n: v: n != "standalone") cfg.server;
on_attach = {__raw = "__lspOnAttach";};
};
};
in ''
require('rust-tools').setup(${helpers.toLuaObject setupOptions})
'';
};
}

View file

@ -1,35 +1,32 @@
{ pkgs
, lib
, config
, ...
}:
let
cfg = config.plugins.tagbar;
helpers = import ../helpers.nix { inherit lib; };
in
with lib;
{
options.plugins.tagbar = {
pkgs,
lib,
config,
...
}: let
cfg = config.plugins.tagbar;
helpers = import ../helpers.nix {inherit lib;};
in
with lib; {
options.plugins.tagbar = {
enable = mkEnableOption "tagbar";
enable = mkEnableOption "tagbar";
package = helpers.mkPackageOption "tagbar" pkgs.vimPlugins.tagbar;
package = helpers.mkPackageOption "tagbar" pkgs.vimPlugins.tagbar;
extraConfig = helpers.mkNullOrOption types.attrs ''
The configuration options for tagbar without the 'tagbar_' prefix.
Example: To set 'tagbar_show_tag_count' to 1, write
extraConfig = {
show_tag_count= true;
};
'';
};
extraConfig = helpers.mkNullOrOption types.attrs ''
The configuration options for tagbar without the 'tagbar_' prefix.
Example: To set 'tagbar_show_tag_count' to 1, write
extraConfig = {
show_tag_count= true;
};
'';
};
config = mkIf cfg.enable {
extraPlugins = [cfg.package];
config = mkIf cfg.enable {
extraPackages = [pkgs.ctags];
extraPlugins = [ cfg.package ];
extraPackages = [ pkgs.ctags ];
globals = mapAttrs' (name: value: nameValuePair ("tagbar_" + name) value) cfg.extraConfig;
};
}
globals = mapAttrs' (name: value: nameValuePair ("tagbar_" + name) value) cfg.extraConfig;
};
}

View file

@ -1,11 +1,11 @@
{ pkgs
, lib
, config
, ...
{
pkgs,
lib,
config,
...
}:
with lib;
let
helpers = import ../helpers.nix { inherit lib; };
with lib; let
helpers = import ../helpers.nix {inherit lib;};
in {
options.plugins.treesitter-context = {
enable = mkEnableOption "nvim-treesitter-context";
@ -19,7 +19,7 @@ in {
};
trimScope = mkOption {
type = types.enum [ "outer" "inner" ];
type = types.enum ["outer" "inner"];
default = "outer";
description = "Which context lines to discard if `max_lines` is exceeded";
};
@ -32,7 +32,7 @@ in {
patterns = mkOption {
type = types.attrsOf (types.listOf types.str);
default = { };
default = {};
description = ''
Patterns to use for context delimitation. The 'default' key matches all filetypes
'';
@ -40,17 +40,16 @@ in {
exactPatterns = mkOption {
type = types.attrsOf types.bool;
default = { };
default = {};
description = "Treat the coresponding entry in patterns as an exact match";
};
};
config =
let
cfg = config.plugins.treesitter-context;
in
config = let
cfg = config.plugins.treesitter-context;
in
mkIf cfg.enable {
extraPlugins = [ cfg.package ];
extraPlugins = [cfg.package];
plugins.treesitter.moduleConfig.context = {
max_lines = cfg.maxLines;

View file

@ -1,114 +1,110 @@
{ pkgs
, config
, lib
, ...
}:
with lib;
let
helpers = import ../helpers.nix { inherit lib; };
in
{
options.plugins.treesitter-refactor =
let
disable = mkOption {
type = types.listOf types.str;
default = [ ];
description = "List of languages to disable the module on";
};
in
{
pkgs,
config,
lib,
...
}:
with lib; let
helpers = import ../helpers.nix {inherit lib;};
in {
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;
highlightDefinitions = {
inherit disable;
enable =
mkEnableOption
"treesitter-refactor (requires plugins.treesitter.enable to be true)";
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.
'';
};
};
highlightCurrentScope = {
inherit disable;
enable = mkEnableOption "highlights 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.
"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.
'';
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 fo `lua require'nvim-treesitter.refactor.navigation(nil, fallback_function)<cr>`.
'';
};
listDefinitons = mkOption {
type = types.nullOr types.str;
default = "gnD";
description = "list all definitions from the current file";
};
listDefinitonsToc = 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";
};
};
};
highlightCurrentScope = {
inherit disable;
enable = mkEnableOption "highlights 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.
'';
config =
let
cfg = config.plugins.treesitter-refactor;
in
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 fo `lua require'nvim-treesitter.refactor.navigation(nil, fallback_function)<cr>`.
'';
};
listDefinitons = mkOption {
type = types.nullOr types.str;
default = "gnD";
description = "list all definitions from the current file";
};
listDefinitonsToc = 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";
};
};
};
};
config = let
cfg = config.plugins.treesitter-refactor;
in
mkIf cfg.enable {
extraPlugins = [ cfg.package ];
extraPlugins = [cfg.package];
plugins.treesitter.moduleConfig.refactor = {
highlight_definitions = {
@ -118,22 +114,20 @@ in
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.listDefinitons;
list_definitions_toc = cfgK.listDefinitonsToc;
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.listDefinitons;
list_definitions_toc = cfgK.listDefinitonsToc;
goto_next_usage = cfgK.gotoNextUsage;
goto_previous_usage = cfgK.gotoPreviousUsage;
};
};
};
};

View file

@ -1,10 +1,13 @@
{ pkgs, lib, config, ... }:
with lib;
let
cfg = config.plugins.treesitter;
helpers = import ../helpers.nix { inherit lib; };
in
{
pkgs,
lib,
config,
...
}:
with lib; let
cfg = config.plugins.treesitter;
helpers = import ../helpers.nix {inherit lib;};
in {
options = {
plugins.treesitter = {
enable = mkEnableOption "tree-sitter syntax highlighting";
@ -22,7 +25,7 @@ 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";
};
@ -32,8 +35,7 @@ in
default =
if cfg.nixGrammars
then null
else "$XDG_DATA_HOME/nvim/treesitter"
;
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!
@ -42,38 +44,37 @@ 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 {
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";
@ -87,24 +88,31 @@ in
moduleConfig = mkOption {
type = types.attrsOf types.anything;
default = { };
default = {};
description = "This is the configuration for extra modules. It should not be used directly";
};
};
};
config =
let
tsOptions = {
config = let
tsOptions =
{
highlight = {
enable = 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 {
if cfg.incrementalSelection.enable
then {
enable = true;
keymaps = {
init_selection = cfg.incrementalSelection.keymaps.initSelection;
@ -112,29 +120,39 @@ in
scope_incremental = cfg.incrementalSelection.keymaps.scopeIncremental;
node_decremental = cfg.incrementalSelection.keymaps.nodeDecremental;
};
} else null;
}
else null;
indent =
if cfg.indent then {
if cfg.indent
then {
enable = true;
} else null;
}
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) ''
vim.opt.runtimepath:append("${cfg.parserInstallDir}")
'') + ''
require('nvim-treesitter.configs').setup(${helpers.toLuaObject tsOptions})
'';
extraConfigLua =
(optionalString (cfg.parserInstallDir != null) ''
vim.opt.runtimepath:append("${cfg.parserInstallDir}")
'')
+ ''
require('nvim-treesitter.configs').setup(${helpers.toLuaObject tsOptions})
'';
extraPlugins = with pkgs; if cfg.nixGrammars then
[ (cfg.package.withPlugins (_: cfg.grammarPackages)) ]
else [ cfg.package ];
extraPackages = [ pkgs.tree-sitter pkgs.nodejs ];
extraPlugins = with pkgs;
if cfg.nixGrammars
then [(cfg.package.withPlugins (_: cfg.grammarPackages))]
else [cfg.package];
extraPackages = [pkgs.tree-sitter pkgs.nodejs];
options = mkIf cfg.folding {
foldmethod = "expr";
@ -142,4 +160,3 @@ in
};
};
}

View file

@ -1,42 +1,40 @@
{ pkgs
, lib
, config
, ...
}:
let
cfg = config.plugins.vimtex;
helpers = import ../helpers.nix { inherit lib; };
in
with lib;
{
options.plugins.vimtex = {
pkgs,
lib,
config,
...
}: let
cfg = config.plugins.vimtex;
helpers = import ../helpers.nix {inherit lib;};
in
with lib; {
options.plugins.vimtex = {
enable = mkEnableOption "vimtex";
enable = mkEnableOption "vimtex";
package = helpers.mkPackageOption "vimtex" pkgs.vimPlugins.vimtex;
package = helpers.mkPackageOption "vimtex" pkgs.vimPlugins.vimtex;
extraConfig = helpers.mkNullOrOption types.attrs ''
The configuration options for vimtex without the 'vimtex_' prefix.
Example: To set 'vimtex_compiler_enabled' to 1, write
extraConfig = {
compiler_enabled = true;
};
'';
};
config =
let
globals = {
enabled = cfg.enable;
} // cfg.extraConfig;
in
mkIf cfg.enable {
extraPlugins = [ cfg.package ];
# Usefull for inverse search
extraPackages = with pkgs; [ pstree xdotool ];
globals = mapAttrs' (name: value: nameValuePair ("vimtex_" + name) value) globals;
extraConfig = helpers.mkNullOrOption types.attrs ''
The configuration options for vimtex without the 'vimtex_' prefix.
Example: To set 'vimtex_compiler_enabled' to 1, write
extraConfig = {
compiler_enabled = true;
};
'';
};
}
config = let
globals =
{
enabled = cfg.enable;
}
// cfg.extraConfig;
in
mkIf cfg.enable {
extraPlugins = [cfg.package];
# Usefull for inverse search
extraPackages = with pkgs; [pstree xdotool];
globals = mapAttrs' (name: value: nameValuePair ("vimtex_" + name) value) globals;
};
}

View file

@ -1,18 +1,23 @@
{ lib, pkgs, ... }@attrs:
let
helpers = import ../helpers.nix { inherit lib; };
in with helpers; with lib;
mkPlugin attrs {
name = "zig";
description = "Enable zig";
package = pkgs.vimPlugins.zig-vim;
{
lib,
pkgs,
...
} @ attrs: let
helpers = import ../helpers.nix {inherit lib;};
in
with helpers;
with lib;
mkPlugin attrs {
name = "zig";
description = "Enable zig";
package = pkgs.vimPlugins.zig-vim;
# Possibly add option to disable Treesitter highlighting if this is installed
options = {
formatOnSave = mkDefaultOpt {
type = types.bool;
global = "zig_fmt_autosave";
description = "Run zig fmt on save";
};
};
}
# Possibly add option to disable Treesitter highlighting if this is installed
options = {
formatOnSave = mkDefaultOpt {
type = types.bool;
global = "zig_fmt_autosave";
description = "Run zig fmt on save";
};
};
}