From 495e7620d21771c8217e1b65b68d6d3061ac305c Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Tue, 23 Apr 2024 16:08:36 +0300 Subject: [PATCH 1/7] plugins/treesitter: move nvim-treesitter-context to its own dir --- .../plugins/treesitter/ts-context/config.nix | 31 ++++++++++ .../plugins/treesitter/ts-context/context.nix | 60 +++++++++++++++++++ .../plugins/treesitter/ts-context/default.nix | 6 ++ 3 files changed, 97 insertions(+) create mode 100644 modules/plugins/treesitter/ts-context/config.nix create mode 100644 modules/plugins/treesitter/ts-context/context.nix create mode 100644 modules/plugins/treesitter/ts-context/default.nix diff --git a/modules/plugins/treesitter/ts-context/config.nix b/modules/plugins/treesitter/ts-context/config.nix new file mode 100644 index 0000000..89ac74c --- /dev/null +++ b/modules/plugins/treesitter/ts-context/config.nix @@ -0,0 +1,31 @@ +{ + config, + lib, + ... +}: let + inherit (lib.modules) mkIf; + inherit (lib.trivial) boolToString; + inherit (lib.nvim.lua) nullString; + inherit (lib.nvim.dag) entryAfter; + + inherit (config.vim) treesitter; + cfg = treesitter.context; +in { + config = mkIf (treesitter.enable && cfg.enable) { + vim.startPlugins = ["nvim-treesitter-context"]; + + vim.luaConfigRC.treesitter-context = entryAfter ["treesitter"] '' + require'treesitter-context'.setup { + enable = true, + max_lines = ${toString cfg.maxLines}, + min_window_height = ${toString cfg.minWindowHeight}, + line_numbers = ${boolToString cfg.lineNumbers}, + multiline_threshold = ${toString cfg.multilineThreshold}, + trim_scope = '${cfg.trimScope}', + mode = '${cfg.mode}', + separator = ${nullString cfg.separator}, + max_lines = ${toString cfg.zindex}, + } + ''; + }; +} diff --git a/modules/plugins/treesitter/ts-context/context.nix b/modules/plugins/treesitter/ts-context/context.nix new file mode 100644 index 0000000..387aa81 --- /dev/null +++ b/modules/plugins/treesitter/ts-context/context.nix @@ -0,0 +1,60 @@ +{lib, ...}: let + inherit (lib.options) mkOption mkEnableOption; + inherit (lib.types) int bool str nullOr enum; +in { + options.vim.treesitter.context = { + enable = mkEnableOption "context of current buffer contents [nvim-treesitter-context] "; + + maxLines = mkOption { + type = int; + default = 0; + description = "How many lines the window should span. Values <=0 mean no limit."; + }; + + minWindowHeight = mkOption { + type = int; + default = 0; + description = "Minimum editor window height to enable context. Values <= 0 mean no limit."; + }; + + lineNumbers = mkOption { + type = bool; + default = true; + description = ""; + }; + + multilineThreshold = mkOption { + type = int; + default = 20; + description = "Maximum number of lines to collapse for a single context line."; + }; + + trimScope = mkOption { + type = enum ["inner" "outer"]; + default = "outer"; + description = "Which context lines to discard if [](#opt-vim.treesitter.context.maxLines) is exceeded."; + }; + + mode = mkOption { + type = enum ["cursor" "topline"]; + default = "cursor"; + description = "Line used to calculate context."; + }; + + separator = mkOption { + type = nullOr str; + default = null; + description = '' + 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 = mkOption { + type = int; + default = 20; + description = "The Z-index of the context window."; + }; + }; +} diff --git a/modules/plugins/treesitter/ts-context/default.nix b/modules/plugins/treesitter/ts-context/default.nix new file mode 100644 index 0000000..bf53d2b --- /dev/null +++ b/modules/plugins/treesitter/ts-context/default.nix @@ -0,0 +1,6 @@ +{ + imports = [ + ./context.nix + ./config.nix + ]; +} From 7fd653b4d8aa2c0b1777f49918b0321139f2636e Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Tue, 23 Apr 2024 16:08:55 +0300 Subject: [PATCH 2/7] plugins/treesitter: add an internal `defaultGrammars` options --- modules/plugins/treesitter/config.nix | 14 ++-- modules/plugins/treesitter/context.nix | 89 ----------------------- modules/plugins/treesitter/default.nix | 4 +- modules/plugins/treesitter/treesitter.nix | 50 ++++++++++--- 4 files changed, 51 insertions(+), 106 deletions(-) delete mode 100644 modules/plugins/treesitter/context.nix diff --git a/modules/plugins/treesitter/config.nix b/modules/plugins/treesitter/config.nix index 92802a8..e4d6c24 100644 --- a/modules/plugins/treesitter/config.nix +++ b/modules/plugins/treesitter/config.nix @@ -1,5 +1,6 @@ { config, + pkgs, lib, ... }: let @@ -11,7 +12,7 @@ cfg = config.vim.treesitter; usingNvimCmp = config.vim.autocomplete.enable && config.vim.autocomplete.type == "nvim-cmp"; - self = import ./treesitter.nix {inherit lib;}; + self = import ./treesitter.nix {inherit pkgs lib;}; mappingDefinitions = self.options.vim.treesitter.mappings; mappings = addDescriptionsToMappings cfg.mappings mappingDefinitions; in { @@ -32,7 +33,6 @@ in { (mkSetBinding mappings.incrementalSelection.decrementByNode ":lua require('nvim-treesitter.incremental_selection').node_decremental()") ]; }; - # For some reason treesitter highlighting does not work on start if this is set before syntax on configRC.treesitter-fold = mkIf cfg.fold (entryBefore ["basic"] '' set foldmethod=expr @@ -42,14 +42,18 @@ in { luaConfigRC.treesitter = entryAnywhere '' require'nvim-treesitter.configs'.setup { + -- Disable imperative treesitter options that would attempt to fetch + -- grammars into the read-only Nix store. To add additionall grammars here + -- you must use the `config.vim.treesitter.grammars` option. + auto_install = false, + sync_install = false, + ensure_installed = {}, + highlight = { enable = true, disable = {}, }, - auto_install = false, - ensure_installed = {}, - incremental_selection = { enable = true, keymaps = { diff --git a/modules/plugins/treesitter/context.nix b/modules/plugins/treesitter/context.nix deleted file mode 100644 index 8bb65b5..0000000 --- a/modules/plugins/treesitter/context.nix +++ /dev/null @@ -1,89 +0,0 @@ -{ - config, - lib, - ... -}: let - inherit (lib.options) mkOption mkEnableOption; - inherit (lib.types) int bool str nullOr enum; - inherit (lib.modules) mkIf; - inherit (lib.trivial) boolToString; - inherit (lib.nvim.lua) nullString; - inherit (lib.nvim.dag) entryAnywhere; - - inherit (config.vim) treesitter; - cfg = treesitter.context; -in { - options.vim.treesitter.context = { - enable = mkEnableOption "context of current buffer contents [nvim-treesitter-context] "; - - maxLines = mkOption { - description = "How many lines the window should span. Values <=0 mean no limit."; - type = int; - default = 0; - }; - - minWindowHeight = mkOption { - description = "Minimum editor window height to enable context. Values <= 0 mean no limit."; - type = int; - default = 0; - }; - - lineNumbers = mkOption { - description = ""; - type = bool; - default = true; - }; - - multilineThreshold = mkOption { - description = "Maximum number of lines to collapse for a single context line."; - type = int; - default = 20; - }; - - trimScope = mkOption { - description = "Which context lines to discard if [](#opt-vim.treesitter.context.maxLines) is exceeded."; - type = enum ["inner" "outer"]; - default = "outer"; - }; - - mode = mkOption { - description = "Line used to calculate context."; - type = enum ["cursor" "topline"]; - default = "cursor"; - }; - - separator = mkOption { - description = '' - 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. - ''; - type = nullOr str; - default = null; - }; - - zindex = mkOption { - description = "The Z-index of the context window."; - type = int; - default = 20; - }; - }; - - config = mkIf (treesitter.enable && cfg.enable) { - vim.startPlugins = ["nvim-treesitter-context"]; - - vim.luaConfigRC.treesitter-context = entryAnywhere '' - require'treesitter-context'.setup { - enable = true, - max_lines = ${toString cfg.maxLines}, - min_window_height = ${toString cfg.minWindowHeight}, - line_numbers = ${boolToString cfg.lineNumbers}, - multiline_threshold = ${toString cfg.multilineThreshold}, - trim_scope = '${cfg.trimScope}', - mode = '${cfg.mode}', - separator = ${nullString cfg.separator}, - max_lines = ${toString cfg.zindex}, - } - ''; - }; -} diff --git a/modules/plugins/treesitter/default.nix b/modules/plugins/treesitter/default.nix index 5520cfe..a859f3a 100644 --- a/modules/plugins/treesitter/default.nix +++ b/modules/plugins/treesitter/default.nix @@ -1,7 +1,9 @@ { imports = [ + # treesitter extras + ./ts-context + ./treesitter.nix - ./context.nix ./config.nix ]; } diff --git a/modules/plugins/treesitter/treesitter.nix b/modules/plugins/treesitter/treesitter.nix index feae8d7..373f0ee 100644 --- a/modules/plugins/treesitter/treesitter.nix +++ b/modules/plugins/treesitter/treesitter.nix @@ -1,20 +1,16 @@ -{lib, ...}: let +{ + pkgs, + lib, + ... +}: let inherit (lib.options) mkOption mkEnableOption; inherit (lib.nvim.binds) mkMappingOption; inherit (lib.types) listOf package; + + inherit (pkgs.vimPlugins.nvim-treesitter) builtGrammars; in { options.vim.treesitter = { enable = mkEnableOption "treesitter, also enabled automatically through language options"; - fold = mkEnableOption "fold with treesitter"; - autotagHtml = mkEnableOption "autoclose and rename html tag"; - grammars = mkOption { - type = listOf package; - default = []; - description = '' - List of treesitter grammars to install. For supported languages - use the `vim.language..treesitter` option - ''; - }; mappings.incrementalSelection = { init = mkMappingOption "Init selection [treesitter]" "gnn"; @@ -22,5 +18,37 @@ in { incrementByScope = mkMappingOption "Increment selection by scope [treesitter]" "grc"; decrementByNode = mkMappingOption "Decrement selection by node [treesitter]" "grm"; }; + + fold = mkEnableOption "fold with treesitter"; + autotagHtml = mkEnableOption "autoclose and rename html tag"; + grammars = mkOption { + type = listOf package; + default = []; + description = '' + List of treesitter grammars to install. + + For languages already supported by neovim-flake, you may + use the {option}`vim.language..treesitter` options, which + will automatically add the required grammars to this. + ''; + }; + + defaultGrammars = mkOption { + internal = true; + readOnly = true; + type = listOf package; + default = with builtGrammars; [c lua vim vimdoc query]; + description = '' + A list of treesitter grammars that will be installed by default + if treesitter has been enabled. + + ::: {.warning} + Regardless of which language module options you enable, Neovim + depends on those grammars to be enabled while treesitter is enabled. + This list cannot be modified, but its contents will only be appended + if the list of grammars does not contain the required grammars. + ::: + ''; + }; }; } From b614dc6b4139035a9c33554831aec4b439955f39 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Tue, 23 Apr 2024 16:17:09 +0300 Subject: [PATCH 3/7] lib/lists: init; add `listContainsValue` Helps us validate lists that contain a bunch of values and see if it contains a desired list of values --- lib/default.nix | 1 + lib/lists.nix | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+) create mode 100644 lib/lists.nix diff --git a/lib/default.nix b/lib/default.nix index 693aff9..eade2e2 100644 --- a/lib/default.nix +++ b/lib/default.nix @@ -9,6 +9,7 @@ binds = import ./binds.nix {inherit lib;}; dag = import ./dag.nix {inherit lib;}; languages = import ./languages.nix {inherit lib;}; + lists = import ./lists.nix {inherit lib;}; lua = import ./lua.nix {inherit lib;}; vim = import ./vim.nix; } diff --git a/lib/lists.nix b/lib/lists.nix new file mode 100644 index 0000000..25e85ad --- /dev/null +++ b/lib/lists.nix @@ -0,0 +1,34 @@ +{lib}: let + inherit (lib.lists) elem all; +in { + /* + Checks if all values are present in the list. + + Type: + listContainsValues :: { list :: [a], values :: [a] } -> Bool + + Arguments: + list - A list of elements. + values - A list of values to check for presence in the list. + + Returns: + True if all values are present in the list, otherwise False. + + Example: + ```nix + listContainsValues { list = [1 2 3]; values = [2 3]; } + => True + + listContainsValues { list = [1 2 3]; values = [2 4]; } + => False + ``` + */ + listContainsValues = { + list, + values, + }: let + # Check if all values are present in the list + containsValue = value: elem value list; + in + all containsValue values; +} From 49b705b6aa43762240755b4f9c737e291297226e Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Tue, 23 Apr 2024 16:24:00 +0300 Subject: [PATCH 4/7] plugins/treesitter: fix typo in doc comment --- modules/plugins/treesitter/config.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/plugins/treesitter/config.nix b/modules/plugins/treesitter/config.nix index e4d6c24..e91e5cd 100644 --- a/modules/plugins/treesitter/config.nix +++ b/modules/plugins/treesitter/config.nix @@ -43,7 +43,7 @@ in { luaConfigRC.treesitter = entryAnywhere '' require'nvim-treesitter.configs'.setup { -- Disable imperative treesitter options that would attempt to fetch - -- grammars into the read-only Nix store. To add additionall grammars here + -- grammars into the read-only Nix store. To add additional grammars here -- you must use the `config.vim.treesitter.grammars` option. auto_install = false, sync_install = false, From 5e08ed42e74e1aeb5ccec71d0e50de5fb50337f3 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Tue, 23 Apr 2024 16:48:39 +0300 Subject: [PATCH 5/7] plugins/treesitter: allow `highlight` to be fine-grained --- modules/plugins/treesitter/config.nix | 6 ++-- modules/plugins/treesitter/treesitter.nix | 40 +++++++++++++++++++++-- 2 files changed, 42 insertions(+), 4 deletions(-) diff --git a/modules/plugins/treesitter/config.nix b/modules/plugins/treesitter/config.nix index e91e5cd..8fee4dc 100644 --- a/modules/plugins/treesitter/config.nix +++ b/modules/plugins/treesitter/config.nix @@ -6,7 +6,9 @@ }: let inherit (lib.modules) mkIf mkMerge; inherit (lib.lists) optional; + inherit (lib.trivial) boolToString; inherit (lib.nvim.binds) mkSetBinding addDescriptionsToMappings; + inherit (lib.nvim.lua) toLuaObject; inherit (lib.nvim.dag) entryBefore entryAnywhere; cfg = config.vim.treesitter; @@ -50,8 +52,8 @@ in { ensure_installed = {}, highlight = { - enable = true, - disable = {}, + enable = ${boolToString cfg.highlight.enable}, + disable = ${toLuaObject cfg.highlight.disable}, }, incremental_selection = { diff --git a/modules/plugins/treesitter/treesitter.nix b/modules/plugins/treesitter/treesitter.nix index 373f0ee..74c1b62 100644 --- a/modules/plugins/treesitter/treesitter.nix +++ b/modules/plugins/treesitter/treesitter.nix @@ -3,9 +3,10 @@ lib, ... }: let - inherit (lib.options) mkOption mkEnableOption; + inherit (lib.options) mkOption mkEnableOption literalMD; inherit (lib.nvim.binds) mkMappingOption; - inherit (lib.types) listOf package; + inherit (lib.types) listOf package str either; + inherit (lib.nvim.types) luaInline; inherit (pkgs.vimPlugins.nvim-treesitter) builtGrammars; in { @@ -33,6 +34,41 @@ in { ''; }; + highlight = { + enable = mkEnableOption "highlighting with treesitter"; + disable = mkOption { + type = either (luaInline (listOf str)); + default = []; + example = literalMD '' + ```lua + -- Disable slow treesitter highlight for large files + disable = function(lang, buf) + local max_filesize = 1000 * 1024 -- 1MB + local ok, stats = pcall(vim.loop.fs_stat, vim.api.nvim_buf_get_name(buf)) + if ok and stats and stats.size > max_filesize then + return true + end + end + ``` + ''; + + description = '' + List of treesitter grammars to disable highlighting for. + + This option can be either a list, in which case it will be + converted to a Lua table containing grammars to disable + highlighting for, or a string containing a **lua function** + that will be read as is. + + ::: {.warning} + A comma will be added at the end of your function, so you + do not need to add it yourself. Doing so will cause in + syntax errors within your Neovim configuration. + ::: + ''; + }; + }; + defaultGrammars = mkOption { internal = true; readOnly = true; From 5e12c2315a688ce5af764ddef8a1c804de4f7f65 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Tue, 23 Apr 2024 20:20:49 +0300 Subject: [PATCH 6/7] plugins/treesitter: allow user to toggle default grammars --- modules/plugins/treesitter/config.nix | 17 +++++++++++-- modules/plugins/treesitter/treesitter.nix | 31 +++++++++++++++-------- 2 files changed, 36 insertions(+), 12 deletions(-) diff --git a/modules/plugins/treesitter/config.nix b/modules/plugins/treesitter/config.nix index 8fee4dc..cf1d595 100644 --- a/modules/plugins/treesitter/config.nix +++ b/modules/plugins/treesitter/config.nix @@ -5,8 +5,9 @@ ... }: let inherit (lib.modules) mkIf mkMerge; - inherit (lib.lists) optional; + inherit (lib.lists) optional optionals; inherit (lib.trivial) boolToString; + inherit (lib.nvim.lists) listContainsValues; inherit (lib.nvim.binds) mkSetBinding addDescriptionsToMappings; inherit (lib.nvim.lua) toLuaObject; inherit (lib.nvim.dag) entryBefore entryAnywhere; @@ -23,6 +24,7 @@ in { startPlugins = ["nvim-treesitter"] ++ optional usingNvimCmp "cmp-treesitter"; autocomplete.sources = {"treesitter" = "[Treesitter]";}; + treesitter.grammars = optionals cfg.addDefaultGrammars cfg.defaultGrammars; maps = { # HACK: Using mkSetLuaBinding and putting the lua code does not work for some reason: It just selects the whole file. @@ -35,6 +37,7 @@ in { (mkSetBinding mappings.incrementalSelection.decrementByNode ":lua require('nvim-treesitter.incremental_selection').node_decremental()") ]; }; + # For some reason treesitter highlighting does not work on start if this is set before syntax on configRC.treesitter-fold = mkIf cfg.fold (entryBefore ["basic"] '' set foldmethod=expr @@ -43,7 +46,7 @@ in { ''); luaConfigRC.treesitter = entryAnywhere '' - require'nvim-treesitter.configs'.setup { + require('nvim-treesitter.configs').setup { -- Disable imperative treesitter options that would attempt to fetch -- grammars into the read-only Nix store. To add additional grammars here -- you must use the `config.vim.treesitter.grammars` option. @@ -51,13 +54,23 @@ in { sync_install = false, ensure_installed = {}, + -- Indentation module for Treesitter + indent = { + enable = true, + disable = {}, + }, + + -- Highlight module for Treesitter highlight = { enable = ${boolToString cfg.highlight.enable}, disable = ${toLuaObject cfg.highlight.disable}, + additional_vim_regex_highlighting = false, }, + -- Indentation module for Treesitter incremental_selection = { enable = true, + disable = {}, keymaps = { init_selection = false, node_incremental = false, diff --git a/modules/plugins/treesitter/treesitter.nix b/modules/plugins/treesitter/treesitter.nix index 74c1b62..1ff4dfe 100644 --- a/modules/plugins/treesitter/treesitter.nix +++ b/modules/plugins/treesitter/treesitter.nix @@ -4,11 +4,9 @@ ... }: let inherit (lib.options) mkOption mkEnableOption literalMD; + inherit (lib.types) listOf package str either bool; inherit (lib.nvim.binds) mkMappingOption; - inherit (lib.types) listOf package str either; - inherit (lib.nvim.types) luaInline; - - inherit (pkgs.vimPlugins.nvim-treesitter) builtGrammars; + inherit (lib.nvim.types) luaInline mkGrammarOption; in { options.vim.treesitter = { enable = mkEnableOption "treesitter, also enabled automatically through language options"; @@ -37,7 +35,7 @@ in { highlight = { enable = mkEnableOption "highlighting with treesitter"; disable = mkOption { - type = either (luaInline (listOf str)); + type = either (listOf str) luaInline; default = []; example = literalMD '' ```lua @@ -69,20 +67,33 @@ in { }; }; + addDefaultGrammars = mkOption { + type = bool; + default = true; + description = '' + Whether to add the default grammars to the list of grammars + to install. + This option is only relevant if treesitter has been enabled. + ''; + }; + defaultGrammars = mkOption { internal = true; readOnly = true; type = listOf package; - default = with builtGrammars; [c lua vim vimdoc query]; + default = with pkgs.vimPlugins.nvim-treesitter.builtGrammars; [c lua vim vimdoc query]; description = '' A list of treesitter grammars that will be installed by default - if treesitter has been enabled. + if treesitter has been enabled and {option}`vim.treeesitter.addDefaultGrammars` + has been set to true. - ::: {.warning} + ::: {.note} Regardless of which language module options you enable, Neovim depends on those grammars to be enabled while treesitter is enabled. - This list cannot be modified, but its contents will only be appended - if the list of grammars does not contain the required grammars. + + This list cannot be modified, but if you would like to bring your own + parsers instead of those provided here, you can set `addDefaultGrammars` + to false ::: ''; }; From ad9d0c6cdb35bad5cd0cc2a3197262ad51265dd7 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Tue, 23 Apr 2024 20:43:41 +0300 Subject: [PATCH 7/7] ui/noice: add missing treesitter grammars --- modules/plugins/ui/noice/config.nix | 132 ++++++++++++++++------------ 1 file changed, 75 insertions(+), 57 deletions(-) diff --git a/modules/plugins/ui/noice/config.nix b/modules/plugins/ui/noice/config.nix index 63c4f2b..8d84584 100644 --- a/modules/plugins/ui/noice/config.nix +++ b/modules/plugins/ui/noice/config.nix @@ -1,75 +1,93 @@ { config, + pkgs, lib, ... }: let inherit (lib.modules) mkIf; + inherit (lib.lists) optionals; + inherit (lib.strings) optionalString; inherit (lib.trivial) boolToString; inherit (lib.nvim.dag) entryAnywhere; cfg = config.vim.ui.noice; + tscfg = config.vim.treesitter; + cmptype = config.vim.autocomplete.type; + + defaultGrammars = with pkgs.vimPlugins.nvim-treesitter.builtGrammars; [vim regex lua bash markdown]; in { config = mkIf cfg.enable { - vim.startPlugins = [ - "noice-nvim" - "nui-nvim" - ]; + vim = { + startPlugins = [ + "noice-nvim" + "nui-nvim" + ]; - vim.luaConfigRC.noice-nvim = entryAnywhere '' - require("noice").setup({ - lsp = { - override = { - ["vim.lsp.util.convert_input_to_markdown_lines"] = true, - ["vim.lsp.util.stylize_markdown"] = true, - ["cmp.entry.get_documentation"] = true, - }, + treesitter.grammars = optionals tscfg.addDefaultGrammars defaultGrammars; - signature = { - enabled = false, -- FIXME: enabling this file throws an error which I couldn't figure out - }, - }, - - presets = { - bottom_search = true, -- use a classic bottom cmdline for search - command_palette = true, -- position the cmdline and popupmenu together - long_message_to_split = true, -- long messages will be sent to a split - inc_rename = false, -- enables an input dialog for inc-rename.nvim - lsp_doc_border = ${boolToString config.vim.ui.borders.enable}, -- add a border to hover docs and signature help - }, - - format = { - cmdline = { pattern = "^:", icon = "", lang = "vim" }, - search_down = { kind = "search", pattern = "^/", icon = " ", lang = "regex" }, - search_up = { kind = "search", pattern = "^%?", icon = " ", lang = "regex" }, - filter = { pattern = "^:%s*!", icon = "", lang = "bash" }, - lua = { pattern = "^:%s*lua%s+", icon = "", lang = "lua" }, - help = { pattern = "^:%s*he?l?p?%s+", icon = "󰋖" }, - input = {}, - }, - - messages = { - -- NOTE: If you enable messages, then the cmdline is enabled automatically. - -- This is a current Neovim limitation. - enabled = false, -- enables the Noice messages UI - view = "notify", -- default view for messages - view_error = "notify", -- view for errors - view_warn = "notify", -- view for warnings - view_history = "messages", -- view for :messages - view_search = "virtualtext", -- view for search count messages. Set to `false` to disable - }, - - -- Hide written messages - routes = { - { - filter = { - event = "msg_show", - kind = "", - find = "written", + luaConfigRC.noice-nvim = entryAnywhere '' + require("noice").setup({ + lsp = { + override = { + ["vim.lsp.util.convert_input_to_markdown_lines"] = true, + ["vim.lsp.util.stylize_markdown"] = true, + ${optionalString (cmptype == "nvim-cmp") "[\"cmp.entry.get_documentation\"] = true,"} + }, + + signature = { + enabled = false, -- FIXME: enabling this file throws an error which I couldn't figure out }, - opts = { skip = true }, }, - }, - }) - ''; + + hover = { + enabled = true, + silent = false, -- set to true to not show a message if hover is not available + view = nil, -- when nil, use defaults from documentation + opts = {}, -- merged with defaults from documentation + }, + + presets = { + bottom_search = true, -- use a classic bottom cmdline for search + command_palette = true, -- position the cmdline and popupmenu together + long_message_to_split = true, -- long messages will be sent to a split + inc_rename = false, -- enables an input dialog for inc-rename.nvim + lsp_doc_border = ${boolToString config.vim.ui.borders.enable}, -- add a border to hover docs and signature help + }, + + format = { + cmdline = { pattern = "^:", icon = "", lang = "vim" }, + search_down = { kind = "search", pattern = "^/", icon = " ", lang = "regex" }, + search_up = { kind = "search", pattern = "^%?", icon = " ", lang = "regex" }, + filter = { pattern = "^:%s*!", icon = "", lang = "bash" }, + lua = { pattern = "^:%s*lua%s+", icon = "", lang = "lua" }, + help = { pattern = "^:%s*he?l?p?%s+", icon = "󰋖" }, + input = {}, + }, + + messages = { + -- NOTE: If you enable messages, then the cmdline is enabled automatically. + -- This is a current Neovim limitation. + enabled = true, -- enables the Noice messages UI + view = "notify", -- default view for messages + view_error = "notify", -- view for errors + view_warn = "notify", -- view for warnings + view_history = "messages", -- view for :messages + view_search = "virtualtext", -- view for search count messages. Set to `false` to disable + }, + + -- Hide written messages + routes = { + { + filter = { + event = "msg_show", + kind = "", + find = "written", + }, + opts = { skip = true }, + }, + }, + }) + ''; + }; }; }