diff --git a/plugins/bufferlines/barbar.nix b/plugins/bufferlines/barbar.nix index 964c60be..7d7e7e48 100644 --- a/plugins/bufferlines/barbar.nix +++ b/plugins/bufferlines/barbar.nix @@ -5,7 +5,7 @@ let in { options.plugins.barbar = { - enable = mkEnableOption "Enable barbar.nvim"; + enable = mkEnableOption "barbar.nvim"; package = mkOption { type = types.package; @@ -32,13 +32,13 @@ in }; icons = mkOption { - type = with types; nullOr (oneOf [bool (enum ["numbers both"])]); + type = with types; nullOr (oneOf [ bool (enum [ "numbers both" ]) ]); default = null; description = "Enable/disable icons"; }; iconCustomColors = mkOption { - type = with types; nullOr (oneOf [bool str]); + type = with types; nullOr (oneOf [ bool str ]); default = null; description = "Sets the icon highlight group"; }; @@ -56,7 +56,8 @@ in config = mkIf cfg.enable { extraPlugins = with pkgs.vimPlugins; [ - cfg.package nvim-web-devicons + cfg.package + nvim-web-devicons ]; # maps = genMaps cfg.keys; diff --git a/plugins/bufferlines/bufferline.nix b/plugins/bufferlines/bufferline.nix index c7a7f645..1d5f0596 100644 --- a/plugins/bufferlines/bufferline.nix +++ b/plugins/bufferlines/bufferline.nix @@ -25,7 +25,7 @@ in { options = { plugins.bufferline = { - enable = mkEnableOption "Enable bufferline"; + enable = mkEnableOption "bufferline"; package = mkOption { type = types.package; description = "Plugin to use for bufferline"; diff --git a/plugins/colorschemes/base16.nix b/plugins/colorschemes/base16.nix index 27786072..d7866c11 100644 --- a/plugins/colorschemes/base16.nix +++ b/plugins/colorschemes/base16.nix @@ -7,7 +7,7 @@ in { options = { colorschemes.base16 = { - enable = mkEnableOption "Enable base16"; + enable = mkEnableOption "base16"; package = mkOption { type = types.package; diff --git a/plugins/colorschemes/gruvbox.nix b/plugins/colorschemes/gruvbox.nix index ac6a65fe..cc591b12 100644 --- a/plugins/colorschemes/gruvbox.nix +++ b/plugins/colorschemes/gruvbox.nix @@ -7,7 +7,7 @@ in { options = { colorschemes.gruvbox = { - enable = mkEnableOption "Enable gruvbox"; + enable = mkEnableOption "gruvbox"; package = mkOption { type = types.package; @@ -15,10 +15,10 @@ in description = "Plugin to use for gruvbox"; }; - italics = mkEnableOption "Enable italics"; - bold = mkEnableOption "Enable bold"; - underline = mkEnableOption "Enable underlined text"; - undercurl = mkEnableOption "Enable undercurled text"; + italics = mkEnableOption "italics"; + bold = mkEnableOption "bold"; + underline = mkEnableOption "underlined text"; + undercurl = mkEnableOption "undercurled text"; contrastDark = mkOption { type = types.nullOr (types.enum [ "soft" "medium" "hard" ]); @@ -110,9 +110,9 @@ in description = "Improved warnings"; }; - transparentBg = mkEnableOption "Transparent background"; + transparentBg = mkEnableOption "transparent background"; - trueColor = mkEnableOption "Enable true color support"; + trueColor = mkEnableOption "true color support"; }; }; diff --git a/plugins/colorschemes/nord.nix b/plugins/colorschemes/nord.nix index d6cc1ff5..68926bbd 100644 --- a/plugins/colorschemes/nord.nix +++ b/plugins/colorschemes/nord.nix @@ -6,7 +6,7 @@ in { options = { colorschemes.nord = { - enable = mkEnableOption "Enable nord"; + enable = mkEnableOption "nord"; package = mkOption { type = types.package; diff --git a/plugins/colorschemes/one.nix b/plugins/colorschemes/one.nix index f5e7660f..7ef50559 100644 --- a/plugins/colorschemes/one.nix +++ b/plugins/colorschemes/one.nix @@ -6,7 +6,7 @@ in { options = { colorschemes.one = { - enable = mkEnableOption "Enable vim-one"; + enable = mkEnableOption "vim-one"; package = mkOption { type = types.package; diff --git a/plugins/colorschemes/onedark.nix b/plugins/colorschemes/onedark.nix index b488ea63..e12ed110 100644 --- a/plugins/colorschemes/onedark.nix +++ b/plugins/colorschemes/onedark.nix @@ -6,7 +6,7 @@ in { options = { colorschemes.onedark = { - enable = mkEnableOption "Enable onedark"; + enable = mkEnableOption "onedark"; package = mkOption { type = types.package; diff --git a/plugins/colorschemes/tokyonight.nix b/plugins/colorschemes/tokyonight.nix index aec6415e..1cf99d9c 100644 --- a/plugins/colorschemes/tokyonight.nix +++ b/plugins/colorschemes/tokyonight.nix @@ -8,7 +8,7 @@ in { options = { colorschemes.tokyonight = { - enable = mkEnableOption "Enable tokyonight"; + enable = mkEnableOption "tokyonight"; package = mkOption { type = types.package; default = pkgs.vimPlugins.tokyonight-nvim; @@ -24,8 +24,7 @@ in default = true; description = "Configure the colors used when opening a :terminal in Neovim"; }; - transparent = - mkEnableOption "Enable this to disable setting the background color"; + transparent = mkEnableOption "disable setting the background color"; styles = let mkBackgroundStyle = name: mkOption { diff --git a/plugins/completion/copilot.nix b/plugins/completion/copilot.nix index 62002064..8a30cb51 100644 --- a/plugins/completion/copilot.nix +++ b/plugins/completion/copilot.nix @@ -6,7 +6,7 @@ in { options = { plugins.copilot = { - enable = mkEnableOption "Enable copilot"; + enable = mkEnableOption "copilot"; package = mkOption { type = types.package; description = "The copilot plugin package to use"; diff --git a/plugins/completion/coq.nix b/plugins/completion/coq.nix index e278bdc1..82be1f98 100644 --- a/plugins/completion/coq.nix +++ b/plugins/completion/coq.nix @@ -9,7 +9,7 @@ in { options = { plugins.coq-nvim = { - enable = mkEnableOption "Enable coq-nvim"; + enable = mkEnableOption "coq-nvim"; package = mkOption { type = types.package; diff --git a/plugins/completion/nvim-cmp/default.nix b/plugins/completion/nvim-cmp/default.nix index 3a0f061e..39b0dd48 100644 --- a/plugins/completion/nvim-cmp/default.nix +++ b/plugins/completion/nvim-cmp/default.nix @@ -15,7 +15,7 @@ let in { options.plugins.nvim-cmp = { - enable = mkEnableOption "Enable nvim-cmp"; + enable = mkEnableOption "nvim-cmp"; package = mkOption { type = types.package; diff --git a/plugins/git/gitgutter.nix b/plugins/git/gitgutter.nix index 93da29c4..e860230c 100644 --- a/plugins/git/gitgutter.nix +++ b/plugins/git/gitgutter.nix @@ -7,7 +7,7 @@ in { options = { plugins.gitgutter = { - enable = mkEnableOption "Enable gitgutter"; + enable = mkEnableOption "gitgutter"; package = mkOption { type = types.package; diff --git a/plugins/git/gitsigns.nix b/plugins/git/gitsigns.nix index 0a6f1ad0..bb14efe0 100644 --- a/plugins/git/gitsigns.nix +++ b/plugins/git/gitsigns.nix @@ -1,9 +1,8 @@ -{ - config, - lib, - pkgs, - helpers, - ... +{ config +, lib +, pkgs +, helpers +, ... }: with lib; let signOptions = defaults: @@ -28,7 +27,7 @@ with lib; let description = "Specifies the highlight group to use for the line"; default = defaults.linehl; }; - showCount = mkEnableOption "Enable showing count of hunk, e.g. number of deleted lines"; + showCount = mkEnableOption "showing count of hunk, e.g. number of deleted lines"; }; signSetupOptions = values: { inherit (values) hl text numhl linehl; @@ -41,7 +40,8 @@ with lib; let description = "Lua function definition"; }; }; -in { +in +{ options.plugins.gitsigns = { enable = mkEnableOption "Enable gitsigns plugin"; package = mkOption { @@ -87,18 +87,19 @@ in { linehl = "GitSignsAddLn"; }; }; - worktrees = let - worktreeModule = { - options = { - toplevel = mkOption { - type = types.str; - }; - gitdir = mkOption { - type = types.str; + worktrees = + let + worktreeModule = { + options = { + toplevel = mkOption { + type = types.str; + }; + gitdir = mkOption { + type = types.str; + }; }; }; - }; - in + in mkOption { type = types.nullOr (types.listOf (types.submodule worktreeModule)); default = null; @@ -166,58 +167,59 @@ in { ''; }; numhl = mkEnableOption '' - Enable/disable line number highlights. + line number highlights. When enabled the highlights defined in `signs.*.numhl` are used. If the highlight group does not exist, then it is automatically defined and linked to the corresponding highlight group in `signs.*.hl`. ''; linehl = mkEnableOption '' - Enable/disable line highlights. + line highlights. When enabled the highlights defined in `signs.*.linehl` are used. If the highlight group does not exist, then it is automatically defined and linked to the corresponding highlight group in `signs.*.hl`. ''; showDeleted = mkEnableOption '' - Show the old version of hunks inline in the buffer (via virtual lines). + showing the old version of hunks inline in the buffer (via virtual lines). Note: Virtual lines currently use the highlight `GitSignsDeleteVirtLn`. ''; - diffOpts = let - diffOptModule = { - options = { - algorithm = mkOption { - type = types.enum ["myers" "minimal" "patience" "histogram"]; - default = "myers"; - description = "Diff algorithm to use"; - }; - internal = mkOption { - type = types.bool; - default = false; - description = "Use Neovim's built in xdiff library for running diffs"; - }; - indentHeuristic = mkOption { - type = types.bool; - default = false; - description = "Use the indent heuristic for the internal diff library."; - }; - vertical = mkOption { - type = types.bool; - default = true; - description = "Start diff mode with vertical splits"; - }; - linematch = mkOption { - type = types.nullOr types.int; - default = null; - description = '' - Enable second-stage diff on hunks to align lines. - Requires `internal=true`. - ''; + diffOpts = + let + diffOptModule = { + options = { + algorithm = mkOption { + type = types.enum [ "myers" "minimal" "patience" "histogram" ]; + default = "myers"; + description = "Diff algorithm to use"; + }; + internal = mkOption { + type = types.bool; + default = false; + description = "Use Neovim's built in xdiff library for running diffs"; + }; + indentHeuristic = mkOption { + type = types.bool; + default = false; + description = "Use the indent heuristic for the internal diff library."; + }; + vertical = mkOption { + type = types.bool; + default = true; + description = "Start diff mode with vertical splits"; + }; + linematch = mkOption { + type = types.nullOr types.int; + default = null; + description = '' + Enable second-stage diff on hunks to align lines. + Requires `internal=true`. + ''; + }; }; }; - }; - in + in mkOption { type = types.nullOr (types.submodule diffOptModule); default = null; @@ -307,7 +309,7 @@ in { description = "Whether to show a virtual text blame annotation"; }; virtTextPos = mkOption { - type = types.enum ["eol" "overlay" "right_align"]; + type = types.enum [ "eol" "overlay" "right_align" ]; default = "eol"; description = "Blame annotation position"; }; @@ -352,7 +354,7 @@ in { window. ''; }; - yadm.enable = mkEnableOption "Enable YADM support"; + yadm.enable = mkEnableOption "YADM support"; wordDiff = mkEnableOption '' Highlight intra-line word differences in the buffer. Requires `config.diff_opts.internal = true`. @@ -363,76 +365,84 @@ in { ''; }; - config = let - cfg = config.plugins.gitsigns; - in + config = + let + cfg = config.plugins.gitsigns; + in mkIf cfg.enable { extraPlugins = with pkgs.vimPlugins; [ cfg.package ]; - extraConfigLua = let - luaFnOrStrToObj = val: - if builtins.isString val - then val - else {__raw = val.function;}; - setupOptions = { - inherit (cfg) worktrees signcolumn numhl linehl trouble yadm; - signs = mapAttrs (_: signSetupOptions) cfg.signs; - on_attach = - if cfg.onAttach != null - then {__raw = cfg.onAttach.function;} - else null; - watch_gitdir = { - inherit (cfg.watchGitDir) enable interval; - follow_files = cfg.watchGitDir.followFiles; - }; - sign_priority = cfg.signPriority; - show_deleted = cfg.showDeleted; - diff_opts = - if cfg.diffOpts == null - then null - else { - inherit (cfg.diffOpts) algorithm internal vertical linematch; - indent_heuristic = cfg.diffOpts.indentHeuristic; + extraConfigLua = + let + luaFnOrStrToObj = val: + if builtins.isString val + then val + else { __raw = val.function; }; + setupOptions = { + inherit (cfg) worktrees signcolumn numhl linehl trouble yadm; + signs = mapAttrs (_: signSetupOptions) cfg.signs; + on_attach = + if cfg.onAttach != null + then { __raw = cfg.onAttach.function; } + else null; + watch_gitdir = { + inherit (cfg.watchGitDir) enable interval; + follow_files = cfg.watchGitDir.followFiles; }; - count_chars = let - isStrInt = s: (builtins.match "[0-9]+" s) != null; - in { - __raw = - "{" - + (concatStringsSep "," ( - lib.mapAttrsToList ( - name: value: - if isStrInt name - then "[${name}] = ${helpers.toLuaObject value}" - else "[${helpers.toLuaObject name}] = ${helpers.toLuaObject value}" - ) - cfg.countChars - )) - + "}"; + sign_priority = cfg.signPriority; + show_deleted = cfg.showDeleted; + diff_opts = + if cfg.diffOpts == null + then null + else { + inherit (cfg.diffOpts) algorithm internal vertical linematch; + indent_heuristic = cfg.diffOpts.indentHeuristic; + }; + count_chars = + let + isStrInt = s: (builtins.match "[0-9]+" s) != null; + in + { + __raw = + "{" + + (concatStringsSep "," ( + lib.mapAttrsToList + ( + name: value: + if isStrInt name + then "[${name}] = ${helpers.toLuaObject value}" + else "[${helpers.toLuaObject name}] = ${helpers.toLuaObject value}" + ) + cfg.countChars + )) + + "}"; + }; + status_formatter = { __raw = cfg.statusFormatter.function; }; + max_file_length = cfg.maxFileLength; + preview_config = cfg.previewConfig; + attach_to_untracked = cfg.attachToUntracked; + update_debounce = cfg.updateDebounce; + current_line_blame = cfg.currentLineBlame; + current_line_blame_opts = + let + cfgCl = cfg.currentLineBlameOpts; + in + { + inherit (cfgCl) delay; + virt_text = cfgCl.virtText; + virt_text_pos = cfgCl.virtTextPos; + ignore_whitespace = cfgCl.ignoreWhitespace; + virt_text_priority = cfgCl.virtTextPriority; + }; + current_line_blame_formatter = luaFnOrStrToObj cfg.currentLineBlameFormatter.normal; + current_line_blame_formatter_nc = luaFnOrStrToObj cfg.currentLineBlameFormatter.nonCommitted; + word_diff = cfg.wordDiff; + debug_mode = cfg.debugMode; }; - status_formatter = {__raw = cfg.statusFormatter.function;}; - max_file_length = cfg.maxFileLength; - preview_config = cfg.previewConfig; - attach_to_untracked = cfg.attachToUntracked; - update_debounce = cfg.updateDebounce; - current_line_blame = cfg.currentLineBlame; - current_line_blame_opts = let - cfgCl = cfg.currentLineBlameOpts; - in { - inherit (cfgCl) delay; - virt_text = cfgCl.virtText; - virt_text_pos = cfgCl.virtTextPos; - ignore_whitespace = cfgCl.ignoreWhitespace; - virt_text_priority = cfgCl.virtTextPriority; - }; - current_line_blame_formatter = luaFnOrStrToObj cfg.currentLineBlameFormatter.normal; - current_line_blame_formatter_nc = luaFnOrStrToObj cfg.currentLineBlameFormatter.nonCommitted; - word_diff = cfg.wordDiff; - debug_mode = cfg.debugMode; - }; - in '' - require('gitsigns').setup(${helpers.toLuaObject setupOptions}) - ''; + in + '' + require('gitsigns').setup(${helpers.toLuaObject setupOptions}) + ''; }; } diff --git a/plugins/git/neogit.nix b/plugins/git/neogit.nix index 29aec256..af69c42d 100644 --- a/plugins/git/neogit.nix +++ b/plugins/git/neogit.nix @@ -16,7 +16,7 @@ in { options = { plugins.neogit = { - enable = mkEnableOption "Enable neogit"; + enable = mkEnableOption "neogit"; package = mkOption { type = types.package; diff --git a/plugins/languages/plantuml-syntax.nix b/plugins/languages/plantuml-syntax.nix index a4fef1de..8083702d 100644 --- a/plugins/languages/plantuml-syntax.nix +++ b/plugins/languages/plantuml-syntax.nix @@ -1,12 +1,11 @@ -{ - pkgs, - lib, - config, - ... +{ pkgs +, lib +, config +, ... }: with lib; { options.plugins.plantuml-syntax = { - enable = mkEnableOption "Enable plantuml syntax support"; + enable = mkEnableOption "plantuml syntax support"; package = mkOption { type = types.package; @@ -26,9 +25,10 @@ with lib; { }; }; - config = let - cfg = config.plugins.plantuml-syntax; - in + config = + let + cfg = config.plugins.plantuml-syntax; + in mkIf cfg.enable { extraPlugins = [ cfg.package ]; diff --git a/plugins/languages/rust.nix b/plugins/languages/rust.nix index b6a424c1..8229950b 100644 --- a/plugins/languages/rust.nix +++ b/plugins/languages/rust.nix @@ -1,218 +1,229 @@ -{ - pkgs, - config, - lib, - helpers, - ... +{ pkgs +, config +, lib +, helpers +, ... }: with lib; { - options.plugins.rust-tools = let - mkNullableOptionWithDefault = { - type, - description, - default, - }: - mkOption { - type = types.nullOr type; - default = null; - description = '' - ${description} + options.plugins.rust-tools = + let + mkNullableOptionWithDefault = + { type + , description + , default + , + }: + mkOption { + type = types.nullOr type; + default = null; + description = '' + ${description} - default: `${default}` - ''; + 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 = mkOption { + type = types.package; + default = pkgs.vimPlugins.rust-tools-nvim; + description = "Package to use for rust-tools"; }; - mkNullableBoolDefault = default: description: - mkNullableOptionWithDefault { - inherit description; - type = types.bool; - default = toString default; + executor = mkNullableOptionWithDefault { + type = types.enum [ "termopen" "quickfix" ]; + default = ''"termopen"''; + description = "how to execute terminal commands"; }; - 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 "Enable rust tools plugins"; - package = mkOption { - type = types.package; - default = pkgs.vimPlugins.rust-tools-nvim; - description = "Package to use for rust-tools"; - }; - - 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/ - ''; - - output = mkOption { + onIntialized = 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 + 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" ''; }; - }; - 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]; - - 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; - - 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; - }; - }; - 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}) + 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/ + ''; + + 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 + mkIf cfg.enable { + extraPlugins = with pkgs.vimPlugins; [ nvim-lspconfig cfg.package ]; + + 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; + + 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; + }; + }; + 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}) + ''; }; } diff --git a/plugins/languages/treesitter-context.nix b/plugins/languages/treesitter-context.nix index 00edf647..5c1f48e5 100644 --- a/plugins/languages/treesitter-context.nix +++ b/plugins/languages/treesitter-context.nix @@ -5,7 +5,7 @@ }: with lib; { options.plugins.treesitter-context = { - enable = mkEnableOption "Enable nvim-treesitter-context"; + enable = mkEnableOption "nvim-treesitter-context"; package = mkOption { type = types.package; diff --git a/plugins/languages/treesitter-refactor.nix b/plugins/languages/treesitter-refactor.nix index 94bd986e..d0791808 100644 --- a/plugins/languages/treesitter-refactor.nix +++ b/plugins/languages/treesitter-refactor.nix @@ -15,7 +15,7 @@ with lib; { { enable = mkEnableOption - "Enable treesitter-refactor (requires plugins.treesitter.enable to be true)"; + "treesitter-refactor (requires plugins.treesitter.enable to be true)"; package = mkOption { type = types.package; @@ -39,7 +39,7 @@ with lib; { }; highlightCurrentScope = { inherit disable; - enable = mkEnableOption "Highlights the block from the current scope where the cursor is."; + enable = mkEnableOption "highlights the block from the current scope where the cursor is."; }; smartRename = { inherit disable; diff --git a/plugins/languages/treesitter.nix b/plugins/languages/treesitter.nix index 7daa8c52..5771d656 100644 --- a/plugins/languages/treesitter.nix +++ b/plugins/languages/treesitter.nix @@ -7,7 +7,7 @@ in { options = { plugins.treesitter = { - enable = mkEnableOption "Enable tree-sitter syntax highlighting"; + enable = mkEnableOption "tree-sitter syntax highlighting"; package = mkOption { type = types.package; @@ -66,7 +66,7 @@ in }; in { - enable = mkEnableOption "Incremental selection based on the named nodes from the grammar"; + enable = mkEnableOption "incremental selection based on the named nodes from the grammar"; keymaps = { initSelection = keymap "gnn"; nodeIncremental = keymap "grn"; @@ -75,9 +75,9 @@ in }; }; - indent = mkEnableOption "Enable tree-sitter based indentation"; + indent = mkEnableOption "tree-sitter based indentation"; - folding = mkEnableOption "Enable tree-sitter based folding"; + folding = mkEnableOption "tree-sitter based folding"; grammarPackages = mkOption { type = with types; listOf package; diff --git a/plugins/null-ls/default.nix b/plugins/null-ls/default.nix index 0f9f0688..e30e0fac 100644 --- a/plugins/null-ls/default.nix +++ b/plugins/null-ls/default.nix @@ -10,7 +10,7 @@ in ]; options.plugins.null-ls = { - enable = mkEnableOption "Enable null-ls"; + enable = mkEnableOption "null-ls"; package = mkOption { type = types.package; diff --git a/plugins/null-ls/helpers.nix b/plugins/null-ls/helpers.nix index 3dc5d6cd..2f6c4fc7 100644 --- a/plugins/null-ls/helpers.nix +++ b/plugins/null-ls/helpers.nix @@ -3,7 +3,7 @@ mkServer = { name , sourceType - , description ? "Enable ${name} source, for null-ls." + , description ? "${name} source, for null-ls." , package ? null , extraPackages ? [ ] , ... diff --git a/plugins/nvim-lsp/default.nix b/plugins/nvim-lsp/default.nix index 702519e4..8b50570c 100644 --- a/plugins/nvim-lsp/default.nix +++ b/plugins/nvim-lsp/default.nix @@ -11,7 +11,7 @@ in options = { plugins.lsp = { - enable = mkEnableOption "Enable neovim's built-in LSP"; + enable = mkEnableOption "neovim's built-in LSP"; enabledServers = mkOption { type = with types; listOf (oneOf [ diff --git a/plugins/nvim-lsp/lspsaga.nix b/plugins/nvim-lsp/lspsaga.nix index d741dbc2..f5bf6ecf 100644 --- a/plugins/nvim-lsp/lspsaga.nix +++ b/plugins/nvim-lsp/lspsaga.nix @@ -7,7 +7,7 @@ in { options = { plugins.lspsaga = { - enable = mkEnableOption "Enable lspsava.nvim"; + enable = mkEnableOption "lspsaga.nvim"; package = mkOption { type = types.package; @@ -111,27 +111,29 @@ in description = "Maximum finder preview lines"; }; - keys = let - defaultKeyOpt = desc: mkOption { - description = desc; - type = types.nullOr types.str; - default = null; - }; - in { - finderAction = { - open = defaultKeyOpt "Open from finder"; - vsplit = defaultKeyOpt "Vertical split in finder"; - split = defaultKeyOpt "Horizontal split in finder"; - quit = defaultKeyOpt "Quit finder"; - scrollDown = defaultKeyOpt "Scroll down finder"; - scrollUp = defaultKeyOpt "Scroll up finder"; - }; + keys = + let + defaultKeyOpt = desc: mkOption { + description = desc; + type = types.nullOr types.str; + default = null; + }; + in + { + finderAction = { + open = defaultKeyOpt "Open from finder"; + vsplit = defaultKeyOpt "Vertical split in finder"; + split = defaultKeyOpt "Horizontal split in finder"; + quit = defaultKeyOpt "Quit finder"; + scrollDown = defaultKeyOpt "Scroll down finder"; + scrollUp = defaultKeyOpt "Scroll up finder"; + }; - codeAction = { - quit = defaultKeyOpt "Quit code actions menu"; - exec = defaultKeyOpt "Execute code action"; + codeAction = { + quit = defaultKeyOpt "Quit code actions menu"; + exec = defaultKeyOpt "Execute code action"; + }; }; - }; borderStyle = mkOption { type = types.nullOr (types.enum [ "thin" "rounded" "thick" ]); @@ -147,67 +149,76 @@ in }; }; - config = let - notDefault = default: opt: if (opt != default) then opt else null; - notEmpty = opt: if ((filterAttrs (_: v: v != null) opt) != {}) then opt else null; - notNull = opt: opt; - lspsagaConfig = { - use_saga_diagnostic_sign = notDefault true cfg.signs.use; - error_sign = notNull cfg.signs.error; - warn_sign = notNull cfg.signs.warning; - hint_sign = notNull cfg.signs.hint; - infor_sign = notNull cfg.signs.info; + config = + let + notDefault = default: opt: if (opt != default) then opt else null; + notEmpty = opt: if ((filterAttrs (_: v: v != null) opt) != { }) then opt else null; + notNull = opt: opt; + lspsagaConfig = { + use_saga_diagnostic_sign = notDefault true cfg.signs.use; + error_sign = notNull cfg.signs.error; + warn_sign = notNull cfg.signs.warning; + hint_sign = notNull cfg.signs.hint; + infor_sign = notNull cfg.signs.info; - # TODO Fix this! - # error_header = notNull cfg.headers.error; - # warn_header = notNull cfg.headers.warning; - # hint_header = notNull cfg.headers.hint; - # infor_header = notNull cfg.headers.info; + # TODO Fix this! + # error_header = notNull cfg.headers.error; + # warn_header = notNull cfg.headers.warning; + # hint_header = notNull cfg.headers.hint; + # infor_header = notNull cfg.headers.info; - max_diag_msg_width = notNull cfg.maxDialogWidth; + max_diag_msg_width = notNull cfg.maxDialogWidth; - code_action_icon = notNull cfg.icons.codeAction; - finder_definition_icon = notNull cfg.icons.findDefinition; - finder_reference_icon = notNull cfg.icons.findReference; - definition_preview_icon = notNull cfg.icons.definitionPreview; + code_action_icon = notNull cfg.icons.codeAction; + finder_definition_icon = notNull cfg.icons.findDefinition; + finder_reference_icon = notNull cfg.icons.findReference; + definition_preview_icon = notNull cfg.icons.definitionPreview; - max_finder_preview_lines = notNull cfg.maxFinderPreviewLines; + max_finder_preview_lines = notNull cfg.maxFinderPreviewLines; - rename_prompt_prefix = notNull cfg.renamePromptPrefix; + rename_prompt_prefix = notNull cfg.renamePromptPrefix; - border_style = let - borderStyle = if cfg.borderStyle == "thin" then 1 - else if cfg.borderStyle == "rounded" then 2 - else if cfg.borderStyle == "thick" then 3 - else null; - in borderStyle; + border_style = + let + borderStyle = + if cfg.borderStyle == "thin" then 1 + else if cfg.borderStyle == "rounded" then 2 + else if cfg.borderStyle == "thick" then 3 + else null; + in + borderStyle; - finder_action_keys = let - keys = { - open = notNull cfg.keys.finderAction.open; - vsplit = notNull cfg.keys.finderAction.vsplit; - split = notNull cfg.keys.finderAction.split; - quit = notNull cfg.keys.finderAction.quit; - scroll_down = notNull cfg.keys.finderAction.scrollDown; - scroll_up = notNull cfg.keys.finderAction.scrollUp; - }; - in notEmpty keys; + finder_action_keys = + let + keys = { + open = notNull cfg.keys.finderAction.open; + vsplit = notNull cfg.keys.finderAction.vsplit; + split = notNull cfg.keys.finderAction.split; + quit = notNull cfg.keys.finderAction.quit; + scroll_down = notNull cfg.keys.finderAction.scrollDown; + scroll_up = notNull cfg.keys.finderAction.scrollUp; + }; + in + notEmpty keys; - code_action_keys = let - keys = { - quit = notNull cfg.keys.codeAction.quit; - exec = notNull cfg.keys.codeAction.exec; - }; - in notEmpty keys; + code_action_keys = + let + keys = { + quit = notNull cfg.keys.codeAction.quit; + exec = notNull cfg.keys.codeAction.exec; + }; + in + notEmpty keys; + }; + in + mkIf cfg.enable { + + extraPlugins = [ cfg.package ]; + + extraConfigLua = '' + local saga = require 'lspsaga' + + saga.init_lsp_saga(${helpers.toLuaObject lspsagaConfig}) + ''; }; - in mkIf cfg.enable { - - extraPlugins = [ cfg.package ]; - - extraConfigLua = '' - local saga = require 'lspsaga' - - saga.init_lsp_saga(${helpers.toLuaObject lspsagaConfig}) - ''; - }; } diff --git a/plugins/pluginmanagers/packer.nix b/plugins/pluginmanagers/packer.nix index f025b807..e5f96703 100644 --- a/plugins/pluginmanagers/packer.nix +++ b/plugins/pluginmanagers/packer.nix @@ -7,7 +7,7 @@ in { options = { plugins.packer = { - enable = mkEnableOption "Enable packer.nvim"; + enable = mkEnableOption "packer.nvim"; plugins = mkOption { type = types.listOf (types.oneOf [ diff --git a/plugins/statuslines/airline.nix b/plugins/statuslines/airline.nix index d560ed41..56f491d9 100644 --- a/plugins/statuslines/airline.nix +++ b/plugins/statuslines/airline.nix @@ -14,7 +14,7 @@ in { options = { plugins.airline = { - enable = mkEnableOption "Enable airline"; + enable = mkEnableOption "airline"; package = mkOption { type = types.package; diff --git a/plugins/statuslines/lightline.nix b/plugins/statuslines/lightline.nix index 08420fd0..5b53ee1c 100644 --- a/plugins/statuslines/lightline.nix +++ b/plugins/statuslines/lightline.nix @@ -7,7 +7,7 @@ in { options = { plugins.lightline = { - enable = mkEnableOption "Enable lightline"; + enable = mkEnableOption "lightline"; package = mkOption { type = types.package; diff --git a/plugins/statuslines/lualine.nix b/plugins/statuslines/lualine.nix index 578e06a3..67f23b8d 100644 --- a/plugins/statuslines/lualine.nix +++ b/plugins/statuslines/lualine.nix @@ -56,7 +56,7 @@ in { options = { plugins.lualine = { - enable = mkEnableOption "Enable lualine"; + enable = mkEnableOption "lualine"; package = mkOption { type = types.package; diff --git a/plugins/telescope/default.nix b/plugins/telescope/default.nix index c914d499..e774fe3b 100644 --- a/plugins/telescope/default.nix +++ b/plugins/telescope/default.nix @@ -16,7 +16,7 @@ in # TODO:add support for aditional filetypes. This requires autocommands! options.plugins.telescope = { - enable = mkEnableOption "Enable telescope.nvim"; + enable = mkEnableOption "telescope.nvim"; package = mkOption { type = types.package; @@ -68,21 +68,23 @@ in let $BAT_THEME = '${cfg.highlightTheme}' ''; - extraConfigLua = let - options = { - extensions = cfg.extensionConfig; - defaults = cfg.defaults; - } // cfg.extraOptions; - in '' - do - local __telescopeExtensions = ${helpers.toLuaObject cfg.enabledExtensions} + extraConfigLua = + let + options = { + extensions = cfg.extensionConfig; + defaults = cfg.defaults; + } // cfg.extraOptions; + in + '' + do + local __telescopeExtensions = ${helpers.toLuaObject cfg.enabledExtensions} - require('telescope').setup(${helpers.toLuaObject options}) + require('telescope').setup(${helpers.toLuaObject options}) - for i, extension in ipairs(__telescopeExtensions) do - require('telescope').load_extension(extension) + for i, extension in ipairs(__telescopeExtensions) do + require('telescope').load_extension(extension) + end end - end - ''; + ''; }; } diff --git a/plugins/telescope/frecency.nix b/plugins/telescope/frecency.nix index eecbfc06..8d871730 100644 --- a/plugins/telescope/frecency.nix +++ b/plugins/telescope/frecency.nix @@ -5,7 +5,7 @@ let in { options.plugins.telescope.extensions.frecency = { - enable = mkEnableOption "Enable frecency"; + enable = mkEnableOption "frecency"; package = mkOption { type = types.package; @@ -50,24 +50,26 @@ in }; }; - config = let - configuration = { - db_root = cfg.dbRoot; - default_workspace = cfg.defaultWorkspace; - ignore_patterns = cfg.ignorePatterns; - show_scores = cfg.showScores; - workspaces = cfg.workspaces; - show_unindexed = cfg.showUnindexed; - devicons_disabled = cfg.deviconsDisabled; - }; - in mkIf cfg.enable { - extraPackages = [ pkgs.sqlite ]; - extraPlugins = with pkgs.vimPlugins; [ - cfg.package - sqlite-lua - ]; + config = + let + configuration = { + db_root = cfg.dbRoot; + default_workspace = cfg.defaultWorkspace; + ignore_patterns = cfg.ignorePatterns; + show_scores = cfg.showScores; + workspaces = cfg.workspaces; + show_unindexed = cfg.showUnindexed; + devicons_disabled = cfg.deviconsDisabled; + }; + in + mkIf cfg.enable { + extraPackages = [ pkgs.sqlite ]; + extraPlugins = with pkgs.vimPlugins; [ + cfg.package + sqlite-lua + ]; - plugins.telescope.enabledExtensions = [ "frecency" ]; - plugins.telescope.extensionConfig."frecency" = configuration; - }; + plugins.telescope.enabledExtensions = [ "frecency" ]; + plugins.telescope.extensionConfig."frecency" = configuration; + }; } diff --git a/plugins/telescope/project-nvim.nix b/plugins/telescope/project-nvim.nix index 32f0b771..e8d7d834 100644 --- a/plugins/telescope/project-nvim.nix +++ b/plugins/telescope/project-nvim.nix @@ -1,11 +1,11 @@ -{ pkgs, config, lib, ...}: +{ pkgs, config, lib, ... }: with lib; let cfg = config.plugins.telescope.extensions.project-nvim; in { options.plugins.telescope.extensions.project-nvim = { - enable = mkEnableOption "Enable project-nvim telescope extension"; + enable = mkEnableOption "project-nvim telescope extension"; }; diff --git a/plugins/utils/commentary.nix b/plugins/utils/commentary.nix index 406e130c..cfd428c5 100644 --- a/plugins/utils/commentary.nix +++ b/plugins/utils/commentary.nix @@ -8,11 +8,11 @@ in options = { plugins.commentary = { - enable = mkEnableOption "Enable commentary"; + enable = mkEnableOption "commentary"; package = mkOption { type = types.package; - default = pkgs.vimPlugins.vim-commentary; + default = pkgs.vimPlugins.vim-commentary; description = "Plugin to use for vim-commentary"; }; }; diff --git a/plugins/utils/dashboard.nix b/plugins/utils/dashboard.nix index 7fe28966..311d7b93 100644 --- a/plugins/utils/dashboard.nix +++ b/plugins/utils/dashboard.nix @@ -8,7 +8,7 @@ in { options = { plugins.dashboard = { - enable = mkEnableOption "Enable dashboard"; + enable = mkEnableOption "dashboard"; package = mkOption { type = types.package; diff --git a/plugins/utils/floaterm.nix b/plugins/utils/floaterm.nix index 92c7aeec..cc340ce6 100644 --- a/plugins/utils/floaterm.nix +++ b/plugins/utils/floaterm.nix @@ -7,7 +7,7 @@ in { options = { plugins.floaterm = { - enable = mkEnableOption "Enable floaterm"; + enable = mkEnableOption "floaterm"; package = mkOption { type = types.package; diff --git a/plugins/utils/mark-radar.nix b/plugins/utils/mark-radar.nix index 5b3e147f..deb55ccf 100644 --- a/plugins/utils/mark-radar.nix +++ b/plugins/utils/mark-radar.nix @@ -8,7 +8,7 @@ let in { options.plugins.mark-radar = { - enable = mkEnableOption "Enable mark-radar"; + enable = mkEnableOption "mark-radar"; package = mkOption { type = types.package; diff --git a/plugins/utils/notify.nix b/plugins/utils/notify.nix index 1819c90e..9bd1a416 100644 --- a/plugins/utils/notify.nix +++ b/plugins/utils/notify.nix @@ -10,7 +10,7 @@ let in { options.plugins.notify = { - enable = mkEnableOption "Enable notify"; + enable = mkEnableOption "notify"; package = mkOption { type = types.package; diff --git a/plugins/utils/nvim-autopairs.nix b/plugins/utils/nvim-autopairs.nix index e37503e2..ec330ea1 100644 --- a/plugins/utils/nvim-autopairs.nix +++ b/plugins/utils/nvim-autopairs.nix @@ -6,7 +6,7 @@ let in { options.plugins.nvim-autopairs = { - enable = mkEnableOption "Enable nvim-autopairs"; + enable = mkEnableOption "nvim-autopairs"; package = mkOption { type = types.package; diff --git a/plugins/utils/nvim-tree.nix b/plugins/utils/nvim-tree.nix index ecc9616a..d657a406 100644 --- a/plugins/utils/nvim-tree.nix +++ b/plugins/utils/nvim-tree.nix @@ -6,7 +6,7 @@ let in { options.plugins.nvim-tree = { - enable = mkEnableOption "Enable nvim-tree"; + enable = mkEnableOption "nvim-tree"; package = mkOption { type = types.package; diff --git a/plugins/utils/project-nvim.nix b/plugins/utils/project-nvim.nix index 5d372848..14651295 100644 --- a/plugins/utils/project-nvim.nix +++ b/plugins/utils/project-nvim.nix @@ -6,7 +6,7 @@ let in { options.plugins.project-nvim = helpers.extraOptionsOptions // { - enable = mkEnableOption "Enable project.nvim"; + enable = mkEnableOption "project.nvim"; package = mkOption { type = types.package; diff --git a/plugins/utils/specs.nix b/plugins/utils/specs.nix index ab9e01c4..a8808fa9 100644 --- a/plugins/utils/specs.nix +++ b/plugins/utils/specs.nix @@ -6,7 +6,7 @@ let in { options.plugins.specs = { - enable = mkEnableOption "Enable specs-nvim"; + enable = mkEnableOption "specs-nvim"; package = mkOption { type = types.package;