From 8071bfdb72086c362ab9330394f05bfe219142d7 Mon Sep 17 00:00:00 2001 From: Ching Pei Yang <59727193+horriblename@users.noreply.github.com> Date: Wed, 10 Jul 2024 01:37:07 +0200 Subject: [PATCH 1/6] Fix typos (#326) * fix: typo * docs: wrong link --- modules/default.nix | 2 +- modules/wrapper/build/options.nix | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/default.nix b/modules/default.nix index 0404bec5..5c23e536 100644 --- a/modules/default.nix +++ b/modules/default.nix @@ -78,7 +78,7 @@ inputs: { builtStartPlugins = buildConfigPlugins vimOptions.startPlugins; builtOptPlugins = map (package: { plugin = package; - optional = false; + optional = true; }) (buildConfigPlugins vimOptions.optPlugins); # combine built start and optional plugins diff --git a/modules/wrapper/build/options.nix b/modules/wrapper/build/options.nix index 39b425db..6a8d085f 100644 --- a/modules/wrapper/build/options.nix +++ b/modules/wrapper/build/options.nix @@ -47,7 +47,7 @@ in { internally to add plugins to Neovim's runtime. To add additional plugins to your configuration, consider - using the [{option}`vim.extraPlugins`](#opt-vim.optPlugins) + using the [{option}`vim.extraPlugins`](#opt-vim.extraPlugins) option. ''; }; From d33fdda4634bfbb223defdfee983b17d6e177fbe Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Wed, 10 Jul 2024 12:44:03 +0300 Subject: [PATCH 2/6] flake: update nixpkgs input --- flake.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/flake.lock b/flake.lock index abafbd68..2c46aec6 100644 --- a/flake.lock +++ b/flake.lock @@ -114,11 +114,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1719082008, - "narHash": "sha256-jHJSUH619zBQ6WdC21fFAlDxHErKVDJ5fpN0Hgx4sjs=", + "lastModified": 1720571246, + "narHash": "sha256-nkUXwunTck+hNMt2wZuYRN+jf2ySRjKTzI0fo5TDH78=", "owner": "nixos", "repo": "nixpkgs", - "rev": "9693852a2070b398ee123a329e68f0dab5526681", + "rev": "16e401f01842c5bb2499e78c1fe227f939c0c474", "type": "github" }, "original": { From 0dca62eaa28ede380efb4e092c2cb90c34ab13ed Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Wed, 10 Jul 2024 12:44:54 +0300 Subject: [PATCH 3/6] languages/ts: use typescript-language-server from top-level --- modules/plugins/languages/ts.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/plugins/languages/ts.nix b/modules/plugins/languages/ts.nix index c9942ec6..3478d4fe 100644 --- a/modules/plugins/languages/ts.nix +++ b/modules/plugins/languages/ts.nix @@ -20,7 +20,7 @@ defaultServer = "tsserver"; servers = { tsserver = { - package = pkgs.nodePackages.typescript-language-server; + package = pkgs.typescript-language-server; lspConfig = '' lspconfig.tsserver.setup { capabilities = capabilities; From 82d67cbc66b733e0af3d03319769011de25ef97a Mon Sep 17 00:00:00 2001 From: diniamo <55629891+diniamo@users.noreply.github.com> Date: Wed, 10 Jul 2024 21:58:37 +0200 Subject: [PATCH 4/6] lib/types: expose pluginType (#322) --- docs/release-notes/rl-0.7.md | 2 ++ lib/types/default.nix | 2 +- lib/types/plugins.nix | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/docs/release-notes/rl-0.7.md b/docs/release-notes/rl-0.7.md index ff9acc94..d3676aa9 100644 --- a/docs/release-notes/rl-0.7.md +++ b/docs/release-notes/rl-0.7.md @@ -49,6 +49,8 @@ Release notes for release 0.7 - Use `clangd` as the default language server for C languages +- Expose `lib.nvim.types.pluginType`, which for example allows the user to create abstractions for adding plugins + [NotAShelf](https://github.com/notashelf): - Add `deno fmt` as the default Markdown formatter. This will be enabled diff --git a/lib/types/default.nix b/lib/types/default.nix index d00be95e..8f020737 100644 --- a/lib/types/default.nix +++ b/lib/types/default.nix @@ -8,6 +8,6 @@ typesLanguage = import ./languages.nix {inherit lib;}; in { inherit (typesDag) dagOf; - inherit (typesPlugin) pluginsOpt extraPluginType mkPluginSetupOption luaInline; + inherit (typesPlugin) pluginsOpt extraPluginType mkPluginSetupOption luaInline pluginType; inherit (typesLanguage) diagnostics mkGrammarOption; } diff --git a/lib/types/plugins.nix b/lib/types/plugins.nix index e10547fb..c0e89d66 100644 --- a/lib/types/plugins.nix +++ b/lib/types/plugins.nix @@ -52,7 +52,7 @@ }; }; in { - inherit extraPluginType fromInputs; + inherit extraPluginType fromInputs pluginType; pluginsOpt = { description, From 9b48c30e206b2c0e2c73cf85243299f50ee092be Mon Sep 17 00:00:00 2001 From: Ching Pei Yang <59727193+horriblename@users.noreply.github.com> Date: Wed, 10 Jul 2024 23:02:48 +0200 Subject: [PATCH 5/6] Feat noice setup opts (#297) * noice: add setupOpts * noice: add filter * noice: use setupOpts * docs: update release notes * noice: allow null option * noice: add descriptions for some options --- docs/release-notes/rl-0.7.md | 1 + modules/plugins/ui/noice/config.nix | 66 +------------ modules/plugins/ui/noice/noice.nix | 139 +++++++++++++++++++++++++++- 3 files changed, 140 insertions(+), 66 deletions(-) diff --git a/docs/release-notes/rl-0.7.md b/docs/release-notes/rl-0.7.md index d3676aa9..e283ab3c 100644 --- a/docs/release-notes/rl-0.7.md +++ b/docs/release-notes/rl-0.7.md @@ -30,6 +30,7 @@ Release notes for release 0.7 - Deprecate use of `__empty` to define empty tables in lua. Empty attrset are no longer filtered and thus should be used instead. - Add dap-go for better dap configurations +- Make noice.nvim customizable [jacekpoz](https://github.com/jacekpoz): diff --git a/modules/plugins/ui/noice/config.nix b/modules/plugins/ui/noice/config.nix index 8d845846..d3ebe01c 100644 --- a/modules/plugins/ui/noice/config.nix +++ b/modules/plugins/ui/noice/config.nix @@ -6,13 +6,11 @@ }: let inherit (lib.modules) mkIf; inherit (lib.lists) optionals; - inherit (lib.strings) optionalString; - inherit (lib.trivial) boolToString; + inherit (lib.nvim.lua) toLuaObject; 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 { @@ -26,67 +24,7 @@ in { treesitter.grammars = optionals tscfg.addDefaultGrammars defaultGrammars; 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 - }, - }, - - 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 }, - }, - }, - }) + require("noice").setup(${toLuaObject cfg.setupOpts}) ''; }; }; diff --git a/modules/plugins/ui/noice/noice.nix b/modules/plugins/ui/noice/noice.nix index b361d452..bf16e3f1 100644 --- a/modules/plugins/ui/noice/noice.nix +++ b/modules/plugins/ui/noice/noice.nix @@ -1,7 +1,142 @@ -{lib, ...}: let - inherit (lib.options) mkEnableOption; +{ + lib, + config, + ... +}: let + inherit (lib.options) mkEnableOption mkOption; + inherit (lib.types) anything nullOr listOf submodule str; + inherit (lib.nvim.types) mkPluginSetupOption; + inherit (lib.nvim.config) mkBool; in { options.vim.ui.noice = { enable = mkEnableOption "noice.nvim UI modification library"; + + setupOpts = mkPluginSetupOption "noice.nvim" { + lsp = { + override = { + "vim.lsp.util.convert_input_to_markdown_lines" = + mkBool true "override the default lsp markdown formatter with Noice"; + + "vim.lsp.util.stylize_markdown" = + mkBool true "override the lsp markdown formatter with Noice"; + + "cmp.entry.get_documentation" = + mkBool (config.vim.autocomplete.type == "nvim-cmp") "override cmp documentation with Noice"; + }; + + signature = { + enabled = mkEnableOption "signature help"; + }; + }; + + presets = { + bottom_search = mkBool true "use a classic bottom cmdline for search"; + command_palette = mkBool true "position the cmdline and popupmenu together"; + long_message_to_split = mkBool true "long messages will be sent to a split"; + inc_rename = mkBool false "enables an input dialog for inc-rename.nvim"; + lsp_doc_border = + mkBool config.vim.ui.borders.enable "add a border to hover docs and signature help"; + }; + + # TODO: is it possible to write a submodule for this? + format = { + cmdline = mkOption { + description = "formatting options for the cmdline"; + type = nullOr anything; + default = { + pattern = "^:"; + icon = ""; + lang = "vim"; + }; + }; + + search_down = mkOption { + description = "formatting options for search_down"; + type = nullOr anything; + default = { + kind = "search"; + pattern = "^/"; + icon = " "; + lang = "regex"; + }; + }; + + search_up = mkOption { + description = "formatting options for search_up"; + type = nullOr anything; + default = { + kind = "search"; + pattern = "^%?"; + icon = " "; + lang = "regex"; + }; + }; + + filter = mkOption { + description = "formatting options for filter"; + type = nullOr anything; + default = { + pattern = "^:%s*!"; + icon = ""; + lang = "bash"; + }; + }; + + lua = mkOption { + description = "formatting options for lua"; + type = nullOr anything; + default = { + pattern = "^:%s*lua%s+"; + icon = ""; + lang = "lua"; + }; + }; + + help = mkOption { + description = "formatting options for help"; + type = nullOr anything; + default = { + pattern = "^:%s*he?l?p?%s+"; + icon = "󰋖"; + }; + }; + }; + + routes = mkOption { + description = "How to route messages"; + type = listOf (submodule { + options = { + view = mkOption { + description = "how this route is viewed"; + type = nullOr str; + default = null; + }; + + filter = mkOption { + description = "a filter for messages matching this route"; + type = anything; + }; + + opts = mkOption { + description = "options for the view and the route"; + type = nullOr anything; + default = null; + }; + }; + }); + + default = [ + { + filter = { + event = "msg_show"; + kind = ""; + find = "written"; + }; + opts = {skip = true;}; + } + ]; + defaultText = "Hide written messages"; + }; + }; }; } From 0c444830f694541ecd9db89cb3ee95e2c4fc3871 Mon Sep 17 00:00:00 2001 From: Ching Pei Yang <59727193+horriblename@users.noreply.github.com> Date: Wed, 10 Jul 2024 23:07:04 +0200 Subject: [PATCH 6/6] lualine: use mkDefault on backwards compat configs (#318) Co-authored-by: Pei Yang Ching --- modules/plugins/statusline/lualine/config.nix | 46 +++++++++---------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/modules/plugins/statusline/lualine/config.nix b/modules/plugins/statusline/lualine/config.nix index 08b1e08c..6c613678 100644 --- a/modules/plugins/statusline/lualine/config.nix +++ b/modules/plugins/statusline/lualine/config.nix @@ -4,7 +4,7 @@ ... }: let inherit (builtins) map; - inherit (lib.modules) mkIf mkMerge; + inherit (lib.modules) mkIf mkMerge mkDefault; inherit (lib.trivial) boolToString; inherit (lib.nvim.dag) entryAnywhere; inherit (lib.nvim.lua) toLuaObject; @@ -23,7 +23,7 @@ in { (mkIf (breadcrumbsCfg.enable && breadcrumbsCfg.source == "nvim-navic") { vim.statusline.lualine.setupOpts = { # TODO: rewrite in new syntax - winbar.lualine_c = [ + winbar.lualine_c = mkDefault [ [ "navic" (mkLuaInline "draw_empty = ${boolToString config.vim.ui.breadcrumbs.alwaysRender}") @@ -41,36 +41,36 @@ in { ''; # this is for backwards-compatibility + # NOTE: since lualine relies heavily on mixed list + key-value table syntax in lua e.g. {1, 2, three = 3} + # and we don't have a good syntax for that we're keeping the old options for now statusline.lualine.setupOpts = { options = { - icons_enabled = cfg.icons.enable; - inherit (cfg) theme; - component_separators = [cfg.componentSeparator.left cfg.componentSeparator.right]; - section_separators = [cfg.sectionSeparator.left cfg.sectionSeparator.right]; - globalstatus = cfg.globalStatus; - inherit (cfg) refresh; + icons_enabled = mkDefault cfg.icons.enable; + theme = mkDefault cfg.theme; + component_separators = mkDefault [cfg.componentSeparator.left cfg.componentSeparator.right]; + section_separators = mkDefault [cfg.sectionSeparator.left cfg.sectionSeparator.right]; + globalstatus = mkDefault cfg.globalStatus; + refresh = mkDefault cfg.refresh; + always_divide_middle = mkDefault cfg.alwaysDivideMiddle; }; sections = { - lualine_a = map mkLuaInline (cfg.activeSection.a ++ cfg.extraActiveSection.a); - lualine_b = map mkLuaInline (cfg.activeSection.b ++ cfg.extraActiveSection.b); - lualine_c = map mkLuaInline (cfg.activeSection.c ++ cfg.extraActiveSection.c); - lualine_x = map mkLuaInline (cfg.activeSection.x ++ cfg.extraActiveSection.x); - lualine_y = map mkLuaInline (cfg.activeSection.y ++ cfg.extraActiveSection.y); - lualine_z = map mkLuaInline (cfg.activeSection.z ++ cfg.extraActiveSection.z); + lualine_a = mkDefault (map mkLuaInline (cfg.activeSection.a ++ cfg.extraActiveSection.a)); + lualine_b = mkDefault (map mkLuaInline (cfg.activeSection.b ++ cfg.extraActiveSection.b)); + lualine_c = mkDefault (map mkLuaInline (cfg.activeSection.c ++ cfg.extraActiveSection.c)); + lualine_x = mkDefault (map mkLuaInline (cfg.activeSection.x ++ cfg.extraActiveSection.x)); + lualine_y = mkDefault (map mkLuaInline (cfg.activeSection.y ++ cfg.extraActiveSection.y)); + lualine_z = mkDefault (map mkLuaInline (cfg.activeSection.z ++ cfg.extraActiveSection.z)); }; inactive_sections = { - lualine_a = map mkLuaInline (cfg.inactiveSection.a ++ cfg.extraInactiveSection.a); - lualine_b = map mkLuaInline (cfg.inactiveSection.b ++ cfg.extraInactiveSection.b); - lualine_c = map mkLuaInline (cfg.inactiveSection.c ++ cfg.extraInactiveSection.c); - lualine_x = map mkLuaInline (cfg.inactiveSection.x ++ cfg.extraInactiveSection.x); - lualine_y = map mkLuaInline (cfg.inactiveSection.y ++ cfg.extraInactiveSection.y); - lualine_z = map mkLuaInline (cfg.inactiveSection.z ++ cfg.extraInactiveSection.z); + lualine_a = mkDefault (map mkLuaInline (cfg.inactiveSection.a ++ cfg.extraInactiveSection.a)); + lualine_b = mkDefault (map mkLuaInline (cfg.inactiveSection.b ++ cfg.extraInactiveSection.b)); + lualine_c = mkDefault (map mkLuaInline (cfg.inactiveSection.c ++ cfg.extraInactiveSection.c)); + lualine_x = mkDefault (map mkLuaInline (cfg.inactiveSection.x ++ cfg.extraInactiveSection.x)); + lualine_y = mkDefault (map mkLuaInline (cfg.inactiveSection.y ++ cfg.extraInactiveSection.y)); + lualine_z = mkDefault (map mkLuaInline (cfg.inactiveSection.z ++ cfg.extraInactiveSection.z)); }; - - # probably don't need this? - tabline = []; }; }; })