diff --git a/configuration.nix b/configuration.nix index 78dad9c7..011d6fae 100644 --- a/configuration.nix +++ b/configuration.nix @@ -25,7 +25,6 @@ isMaximal: { trouble.enable = true; lspSignature.enable = true; otter-nvim.enable = isMaximal; - lsplines.enable = isMaximal; nvim-docs-view.enable = isMaximal; }; diff --git a/docs/release-notes/rl-0.8.md b/docs/release-notes/rl-0.8.md index 8d5562c4..a245b006 100644 --- a/docs/release-notes/rl-0.8.md +++ b/docs/release-notes/rl-0.8.md @@ -87,6 +87,10 @@ - Add [oil.nvim] as an alternative file explorer. It will be available under `vim.utility.oil-nvim`. +- Add `vim.diagnostics` to interact with Neovim's diagnostics module. Available + options for `vim.diagnostic.config()` can now be customized through the + [](#opt-vim.diagnostics.config) in nvf. + [amadaluzia](https://github.com/amadaluzia): [haskell-tools.nvim]: https://github.com/MrcJkb/haskell-tools.nvim @@ -253,8 +257,8 @@ [friendly-snippets](https://github.com/rafamadriz/friendly-snippets) so blink.cmp can source snippets from it. - Fix [blink.cmp] breaking when built-in sources were modified. -- Fix [conform.nvim] not allowing disabling formatting on and after save. - Use `null` value to disable them if conform is enabled. +- Fix [conform.nvim] not allowing disabling formatting on and after save. Use + `null` value to disable them if conform is enabled. [TheColorman](https://github.com/TheColorman): diff --git a/modules/extra/deprecations.nix b/modules/extra/deprecations.nix index 5efe2ae2..86497130 100644 --- a/modules/extra/deprecations.nix +++ b/modules/extra/deprecations.nix @@ -104,6 +104,13 @@ in { their behaviour was abstract, and confusing. Please use 'vim.options' or 'vim.luaConfigRC' to replicate previous behaviour. '') + + # 2025-04-04 + (mkRemovedOptionModule ["vim" "lsp" "lsplines"] '' + lsplines module has been removed from nvf, as its functionality is now built into Neovim + under the diagnostics module. Please consider using one of 'vim.diagnostics.config' or + 'vim.luaConfigRC' to configure LSP lines for Neovim through its own diagnostics API. + '') ] # Migrated via batchRenameOptions. Further batch renames must be below this line. diff --git a/modules/neovim/init/default.nix b/modules/neovim/init/default.nix index ac9d29e5..0e7a4c6b 100644 --- a/modules/neovim/init/default.nix +++ b/modules/neovim/init/default.nix @@ -3,6 +3,7 @@ ./autocmds.nix ./basic.nix ./debug.nix + ./diagnostics.nix ./highlight.nix ./spellcheck.nix ]; diff --git a/modules/neovim/init/diagnostics.nix b/modules/neovim/init/diagnostics.nix new file mode 100644 index 00000000..26ca6e84 --- /dev/null +++ b/modules/neovim/init/diagnostics.nix @@ -0,0 +1,102 @@ +{ + config, + lib, + ... +}: let + inherit (lib.modules) mkIf; + inherit (lib.options) mkOption mkEnableOption literalExpression; + inherit (lib.types) attrsOf anything oneOf bool submodule; + inherit (lib.nvim.dag) entryAfter; + inherit (lib.nvim.types) luaInline; + inherit (lib.nvim.lua) toLuaObject; + + cfg = config.vim.diagnostics; + + diagnosticType = oneOf [(attrsOf anything) bool luaInline]; + diagnosticsSubmodule = submodule { + freeformType = attrsOf diagnosticType; + underline = mkOption { + type = diagnosticType; + default = true; + description = "Use underline for diagnostics."; + }; + + virtual_text = mkOption { + type = diagnosticType; + default = false; + example = literalExpression '' + { + format = lib.generators.mkLuaInline ''' + function(diagnostic) + return string.format("%s (%s)", diagnostic.message, diagnostic.source) + end + '''; + } + ''; + + description = '' + Use virtual text for diagnostics. If multiple diagnostics are set for a namespace, + one prefix per diagnostic + the last diagnostic message are shown. + ''; + }; + + virtual_lines = mkOption { + type = diagnosticType; + default = false; + description = '' + Use virtual lines for diagnostics. + ''; + }; + + signs = mkOption { + type = diagnosticType; + default = false; + example = { + signs.text = { + "vim.diagnostic.severity.ERROR" = "󰅚 "; + "vim.diagnostic.severity.WARN" = "󰀪 "; + }; + }; + description = '' + Use signs for diagnostics. See {command}`:help diagnostic-signs`. + ''; + }; + + update_in_insert = mkOption { + type = bool; + default = false; + description = '' + Update diagnostics in Insert mode. If `false`, diagnostics will + be updated on InsertLeave ({command}`:help InsertLeave`). + ''; + }; + }; +in { + options.vim = { + diagnostics = { + enable = mkEnableOption "diagostics module for Neovim"; + config = mkOption { + type = diagnosticsSubmodule; + default = {}; + description = '' + Values that will be passed to `vim.diagnostic.config` after being converted + to a Lua table. Possible values for each key can be found in the help text + for `vim.diagnostics.Opts`. You may find more about the diagnostics API of + Neovim in {command}`:help diagnostic-api`. + + :::{.note} + This option is freeform. You may set values that are not present in nvf + documentation, but those values will not be fully type checked. Please + refer to the help text for `vim.diagnostic.Opts` for appropriate values. + ::: + ''; + }; + }; + }; + + config.vim = mkIf cfg.enable { + luaConfigRC.diagnostics = entryAfter ["basic"] '' + vim.diagnostic.config(${toLuaObject cfg.config}) + ''; + }; +} diff --git a/modules/plugins/lsp/default.nix b/modules/plugins/lsp/default.nix index 421f5fda..eb694583 100644 --- a/modules/plugins/lsp/default.nix +++ b/modules/plugins/lsp/default.nix @@ -15,7 +15,6 @@ ./lightbulb ./otter ./lspkind - ./lsplines ./nvim-docs-view ]; } diff --git a/modules/plugins/lsp/lsplines/config.nix b/modules/plugins/lsp/lsplines/config.nix deleted file mode 100644 index bb07edc9..00000000 --- a/modules/plugins/lsp/lsplines/config.nix +++ /dev/null @@ -1,21 +0,0 @@ -{ - config, - lib, - ... -}: let - inherit (lib.modules) mkIf; - inherit (lib.nvim.dag) entryAfter; - - cfg = config.vim.lsp; -in { - config = mkIf (cfg.enable && cfg.lsplines.enable) { - vim.startPlugins = ["lsp-lines"]; - vim.pluginRC.lsplines = entryAfter ["lspconfig"] '' - require("lsp_lines").setup() - - vim.diagnostic.config({ - virtual_text = false, - }) - ''; - }; -} diff --git a/modules/plugins/lsp/lsplines/default.nix b/modules/plugins/lsp/lsplines/default.nix deleted file mode 100644 index 359cec4f..00000000 --- a/modules/plugins/lsp/lsplines/default.nix +++ /dev/null @@ -1,6 +0,0 @@ -{ - imports = [ - ./config.nix - ./lsplines.nix - ]; -} diff --git a/modules/plugins/lsp/lsplines/lsplines.nix b/modules/plugins/lsp/lsplines/lsplines.nix deleted file mode 100644 index aac4cbbc..00000000 --- a/modules/plugins/lsp/lsplines/lsplines.nix +++ /dev/null @@ -1,11 +0,0 @@ -{lib, ...}: let - inherit (lib.options) mkEnableOption; -in { - options.vim.lsp = { - lsplines = { - enable = mkEnableOption '' - diagnostics using virtual lines on top of the real line of code. [lsp_lines] - ''; - }; - }; -} diff --git a/npins/sources.json b/npins/sources.json index 86fa0f6b..140b3b24 100644 --- a/npins/sources.json +++ b/npins/sources.json @@ -747,18 +747,6 @@ "url": "https://github.com/kawre/leetcode.nvim/archive/db7e1cd6b9191b34b4c1f2f96e4e3949cde9f951.tar.gz", "hash": "1d3lb7625b2qdzqm74mzrac66rxqc0qgjd3mb37l4v8wqyiyv6pp" }, - "lsp-lines": { - "type": "Git", - "repository": { - "type": "Git", - "url": "https://git.sr.ht/~whynothugo/lsp_lines.nvim" - }, - "branch": "main", - "submodules": false, - "revision": "a92c755f182b89ea91bd8a6a2227208026f27b4d", - "url": null, - "hash": "14ym4d8vgvw2vhsaxik8612wyvszd895q69n9h100yd7x5jqhy4c" - }, "lsp-signature-nvim": { "type": "Git", "repository": {