From 6bdc52cd772e8708db8e32d3533ce4674943ccef Mon Sep 17 00:00:00 2001 From: Nikita <68944906+BANanaD3V@users.noreply.github.com> Date: Mon, 10 Mar 2025 12:51:19 +0300 Subject: [PATCH 01/35] languages/markdown: Add markview renderer --- docs/release-notes/rl-0.8.md | 1 + modules/plugins/languages/markdown.nix | 19 +++++++++++++++++++ npins/sources.json | 12 ++++++++++++ 3 files changed, 32 insertions(+) diff --git a/docs/release-notes/rl-0.8.md b/docs/release-notes/rl-0.8.md index 1a5b7e4c..78d9fc36 100644 --- a/docs/release-notes/rl-0.8.md +++ b/docs/release-notes/rl-0.8.md @@ -241,3 +241,4 @@ [BANanaD3V](https://github.com/BANanaD3V): - `alpha` is now configured with nix. +- Add `markview-nvim` markdown renderer. diff --git a/modules/plugins/languages/markdown.nix b/modules/plugins/languages/markdown.nix index ac098a1c..648513e7 100644 --- a/modules/plugins/languages/markdown.nix +++ b/modules/plugins/languages/markdown.nix @@ -133,6 +133,18 @@ in { }; }; }; + markview-nvim = { + enable = + mkEnableOption "" + // { + description = '' + [markview.nvim]: https://github.com/OXY2DEV/markview.nvim + + [markview.nvim] - a hackable markdown, Typst, latex, html(inline) & YAML previewer + ''; + }; + setupOpts = mkPluginSetupOption "markview-nvim" {}; + }; }; }; @@ -159,5 +171,12 @@ in { require("render-markdown").setup(${toLuaObject cfg.extensions.render-markdown-nvim.setupOpts}) ''; }) + + (mkIf cfg.extensions.markview-nvim.enable { + vim.startPlugins = ["markview-nvim"]; + vim.pluginRC.markview-nvim = entryAnywhere '' + require("markview").setup(${toLuaObject cfg.extensions.markview-nvim.setupOpts}) + ''; + }) ]); } diff --git a/npins/sources.json b/npins/sources.json index daad4177..093fa820 100644 --- a/npins/sources.json +++ b/npins/sources.json @@ -773,6 +773,18 @@ "url": "https://github.com/horriblename/lzn-auto-require/archive/ef746afb55467984ef3200d9709c8059ee0257d0.tar.gz", "hash": "1mgka1mmvpd2gfya898qdbbwrp5rpqds8manjs1s7g5x63xp6b98" }, + "markview-nvim": { + "type": "Git", + "repository": { + "type": "GitHub", + "owner": "OXY2DEV", + "repo": "markview.nvim" + }, + "branch": "main", + "revision": "6c92a6455e97c954a4a419265a032fedd69846f6", + "url": "https://github.com/OXY2DEV/markview.nvim/archive/6c92a6455e97c954a4a419265a032fedd69846f6.tar.gz", + "hash": "01sw4iscnciyifpba4cwjb6fs95wrkk60xvqq67b8d5j8yb5449a" + }, "mind-nvim": { "type": "Git", "repository": { From c5b72f124fdba697603f39e5c8168eac5780fc93 Mon Sep 17 00:00:00 2001 From: Gerg-L Date: Sat, 3 May 2025 18:32:58 -0400 Subject: [PATCH 02/35] chore: update mnw MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Flake lock file updates: • Updated input 'mnw': 'github:Gerg-L/mnw/2a1678ba8e4807bd855dd0da94ea2bef5bca733d?narHash=sha256-X32sM3RQ3X2y6PzfNnX3rhUAlhuITdDOdfSrwZXjlsQ%3D' (2025-05-03) → 'github:Gerg-L/mnw/7b85a1922b0c5d78c03c4e53c82330715d1bf22b?narHash=sha256-g1XBeVvnM6P0QVxbjCEXyNl0aGd3YSf/hsVagUHB3qw%3D' (2025-05-03) --- flake.lock | 6 +++--- modules/wrapper/build/config.nix | 13 +++++-------- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/flake.lock b/flake.lock index 307d3d7a..65cee2ae 100644 --- a/flake.lock +++ b/flake.lock @@ -38,11 +38,11 @@ }, "mnw": { "locked": { - "lastModified": 1746230955, - "narHash": "sha256-X32sM3RQ3X2y6PzfNnX3rhUAlhuITdDOdfSrwZXjlsQ=", + "lastModified": 1746338991, + "narHash": "sha256-GbyoHjf14LOxZQc+0NFblI4xf/uwGrYo3W8lwE4HcwI=", "owner": "Gerg-L", "repo": "mnw", - "rev": "2a1678ba8e4807bd855dd0da94ea2bef5bca733d", + "rev": "c65407ee9387ef75985dad3e30f58c822c766ec1", "type": "github" }, "original": { diff --git a/modules/wrapper/build/config.nix b/modules/wrapper/build/config.nix index 3b147571..61ba1513 100644 --- a/modules/wrapper/build/config.nix +++ b/modules/wrapper/build/config.nix @@ -62,17 +62,14 @@ filter (f: f != null) plugins ); - # built (or "normalized") plugins that are modified - builtStartPlugins = buildConfigPlugins config.vim.startPlugins; - builtOptPlugins = map (package: package // {optional = true;}) ( - buildConfigPlugins config.vim.optPlugins - ); - # Wrap the user's desired (unwrapped) Neovim package with arguments that'll be used to # generate a wrapped Neovim package. - neovim-wrapped = inputs.mnw.lib.wrap pkgs { + neovim-wrapped = inputs.mnw.lib.wrap {inherit pkgs;} { neovim = config.vim.package; - plugins = builtStartPlugins ++ builtOptPlugins; + plugins = { + start = buildConfigPlugins config.vim.startPlugins; + opt = buildConfigPlugins config.vim.optPlugins; + }; appName = "nvf"; extraBinPath = config.vim.extraPackages; initLua = config.vim.builtLuaConfigRC; From 140cfea20505136b6306ddde31802842501da0d6 Mon Sep 17 00:00:00 2001 From: Noah765 Date: Sun, 4 May 2025 15:00:21 +0200 Subject: [PATCH 03/35] ui/breadcrumbs: add missing navbuddy mappings --- modules/plugins/ui/breadcrumbs/breadcrumbs.nix | 18 ++++++++++++++++++ modules/plugins/ui/breadcrumbs/config.nix | 5 +++++ 2 files changed, 23 insertions(+) diff --git a/modules/plugins/ui/breadcrumbs/breadcrumbs.nix b/modules/plugins/ui/breadcrumbs/breadcrumbs.nix index 2faee6c8..716883aa 100644 --- a/modules/plugins/ui/breadcrumbs/breadcrumbs.nix +++ b/modules/plugins/ui/breadcrumbs/breadcrumbs.nix @@ -215,6 +215,24 @@ in { description = "move focused node up"; }; + togglePreview = mkOption { + type = str; + default = "s"; + description = "show preview of current node"; + }; + + vsplit = mkOption { + type = str; + default = ""; + description = "open selected node in a vertical split"; + }; + + hsplit = mkOption { + type = str; + default = ""; + description = "open selected node in a horizontal split"; + }; + telescope = mkOption { type = str; default = "t"; diff --git a/modules/plugins/ui/breadcrumbs/config.nix b/modules/plugins/ui/breadcrumbs/config.nix index 747a7773..324501a5 100644 --- a/modules/plugins/ui/breadcrumbs/config.nix +++ b/modules/plugins/ui/breadcrumbs/config.nix @@ -64,6 +64,11 @@ in { ${cfg.navbuddy.mappings.moveDown} = mkLuaInline "actions.move_down()"; ${cfg.navbuddy.mappings.moveUp} = mkLuaInline "actions.move_up()"; + ${cfg.navbuddy.mappings.togglePreview} = mkLuaInline "actions.toggle_preview()"; + + ${cfg.navbuddy.mappings.vsplit} = mkLuaInline "actions.vsplit()"; + ${cfg.navbuddy.mappings.hsplit} = mkLuaInline "actions.hsplit()"; + ${cfg.navbuddy.mappings.telescope} = mkLuaInline '' actions.telescope({ layout_strategy = "horizontal", From d783fa0b27886e833dbcdf9eb734bb76b97ec70b Mon Sep 17 00:00:00 2001 From: Noah765 Date: Sun, 4 May 2025 15:29:27 +0200 Subject: [PATCH 04/35] ui/breadcrumbs: remove unused attribute --- modules/plugins/ui/breadcrumbs/breadcrumbs.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/plugins/ui/breadcrumbs/breadcrumbs.nix b/modules/plugins/ui/breadcrumbs/breadcrumbs.nix index 716883aa..0d5a3162 100644 --- a/modules/plugins/ui/breadcrumbs/breadcrumbs.nix +++ b/modules/plugins/ui/breadcrumbs/breadcrumbs.nix @@ -4,7 +4,7 @@ ... }: let inherit (lib.options) mkOption mkEnableOption; - inherit (lib.types) nullOr listOf enum bool str int either; + inherit (lib.types) nullOr listOf enum bool str int; inherit (lib.modules) mkRenamedOptionModule; inherit (lib.nvim.types) mkPluginSetupOption borderType; mkSimpleIconOption = default: From c2380761d1e230278c5f7bb34586e52dc22f263d Mon Sep 17 00:00:00 2001 From: Noah765 Date: Sun, 4 May 2025 15:30:17 +0200 Subject: [PATCH 05/35] ui/breadcrumbs: clean up the option descriptions --- .../plugins/ui/breadcrumbs/breadcrumbs.nix | 82 +++++++++---------- 1 file changed, 41 insertions(+), 41 deletions(-) diff --git a/modules/plugins/ui/breadcrumbs/breadcrumbs.nix b/modules/plugins/ui/breadcrumbs/breadcrumbs.nix index 0d5a3162..72351ecc 100644 --- a/modules/plugins/ui/breadcrumbs/breadcrumbs.nix +++ b/modules/plugins/ui/breadcrumbs/breadcrumbs.nix @@ -74,7 +74,7 @@ in { ::: {.note} This will pass `draw_empty` to the `nvim_navic` winbar component, which causes the component to be drawn even - if it's empty + if it's empty. ::: ''; }; @@ -86,163 +86,163 @@ in { close = mkOption { type = str; default = ""; - description = "keybinding to close Navbuddy UI"; + description = "Close and return the cursor to its original location."; }; nextSibling = mkOption { type = str; default = "j"; - description = "keybinding to navigate to the next sibling node"; + description = "Navigate to the next sibling node."; }; previousSibling = mkOption { type = str; default = "k"; - description = "keybinding to navigate to the previous sibling node"; + description = "Navigate to the previous sibling node."; }; parent = mkOption { type = str; default = "h"; - description = "keybinding to navigate to the parent node"; + description = "Navigate to the parent node."; }; children = mkOption { type = str; default = "l"; - description = "keybinding to navigate to the child node"; + description = "Navigate to the child node."; }; root = mkOption { type = str; default = "0"; - description = "keybinding to navigate to the root node"; + description = "Navigate to the root node."; }; visualName = mkOption { type = str; default = "v"; - description = "visual selection of name"; + description = "Select the name visually."; }; visualScope = mkOption { type = str; default = "V"; - description = "visual selection of scope"; + description = "Select the scope visually."; }; yankName = mkOption { type = str; default = "y"; - description = "yank the name to system clipboard"; + description = "Yank the name to system clipboard."; }; yankScope = mkOption { type = str; default = "Y"; - description = "yank the scope to system clipboard"; + description = "Yank the scope to system clipboard."; }; insertName = mkOption { type = str; default = "i"; - description = "insert at start of name"; + description = "Insert at the start of name."; }; insertScope = mkOption { type = str; default = "I"; - description = "insert at start of scope"; + description = "Insert at the start of scope."; }; appendName = mkOption { type = str; default = "a"; - description = "insert at end of name"; + description = "Insert at the end of name."; }; appendScope = mkOption { type = str; default = "A"; - description = "insert at end of scope"; + description = "Insert at the end of scope."; }; rename = mkOption { type = str; default = "r"; - description = "rename the node"; + description = "Rename the node."; }; delete = mkOption { type = str; default = "d"; - description = "delete the node"; + description = "Delete the node."; }; foldCreate = mkOption { type = str; default = "f"; - description = "create a new fold"; + description = "Create a new fold of the node."; }; foldDelete = mkOption { type = str; default = "F"; - description = "delete the current fold"; + description = "Delete the current fold of the node."; }; comment = mkOption { type = str; default = "c"; - description = "comment the node"; + description = "Comment the node."; }; select = mkOption { type = str; default = ""; - description = "goto selected symbol"; + description = "Goto the node."; }; moveDown = mkOption { type = str; default = "J"; - description = "move focused node down"; + description = "Move the node down."; }; moveUp = mkOption { type = str; default = "K"; - description = "move focused node up"; + description = "Move the node up."; }; togglePreview = mkOption { type = str; default = "s"; - description = "show preview of current node"; + description = "Toggle the preview."; }; vsplit = mkOption { type = str; default = ""; - description = "open selected node in a vertical split"; + description = "Open the node in a vertical split."; }; hsplit = mkOption { type = str; default = ""; - description = "open selected node in a horizontal split"; + description = "Open the node in a horizontal split."; }; telescope = mkOption { type = str; default = "t"; - description = "fuzzy finder at current level"; + description = "Start fuzzy finder at the current level."; }; help = mkOption { type = str; default = "g?"; - description = "open mapping help window"; + description = "Open the mappings help window."; }; }; @@ -250,7 +250,7 @@ in { useDefaultMappings = mkOption { type = bool; default = true; - description = "use default Navbuddy keybindings (disables user-specified keybinds)"; + description = "Add the default Navbuddy keybindings in addition to the keybinding added by this module."; }; window = { @@ -260,13 +260,13 @@ in { border = mkOption { type = borderType; default = config.vim.ui.borders.globalStyle; - description = "border style to use"; + description = "The border style to use."; }; scrolloff = mkOption { type = nullOr int; default = null; - description = "Scrolloff value within navbuddy window"; + description = "The scrolloff value within a navbuddy window."; }; sections = { @@ -283,7 +283,7 @@ in { border = mkOption { type = borderType; default = config.vim.ui.borders.globalStyle; - description = "border style to use for the left section of Navbuddy UI"; + description = "The border style to use for the left section of the Navbuddy UI."; }; }; @@ -300,7 +300,7 @@ in { border = mkOption { type = borderType; default = config.vim.ui.borders.globalStyle; - description = "border style to use for the middle section of Navbuddy UI"; + description = "The border style to use for the middle section of the Navbuddy UI."; }; }; @@ -310,13 +310,13 @@ in { border = mkOption { type = borderType; default = config.vim.ui.borders.globalStyle; - description = "border style to use for the right section of Navbuddy UI"; + description = "The border style to use for the right section of the Navbuddy UI."; }; preview = mkOption { type = enum ["leaf" "always" "never"]; default = "leaf"; - description = "display mode of the preview on the right section"; + description = "The display mode of the preview on the right section."; }; }; }; @@ -335,13 +335,13 @@ in { auto_attach = mkOption { type = bool; default = true; - description = "Whether to attach to LSP server manually"; + description = "Whether to attach to LSP server manually."; }; preference = mkOption { type = nullOr (listOf str); default = null; - description = "list of lsp server names in order of preference"; + description = "The preference list ranking LSP servers."; }; }; @@ -349,25 +349,25 @@ in { followNode = mkOption { type = bool; default = true; - description = "keep the current node in focus on the source buffer"; + description = "Whether to keep the current node in focus in the source buffer."; }; highlight = mkOption { type = bool; default = true; - description = "highlight the currently focused node"; + description = "Whether to highlight the currently focused node in the source buffer."; }; reorient = mkOption { type = enum ["smart" "top" "mid" "none"]; default = "smart"; - description = "reorient buffer after changing nodes"; + description = "The mode for reorienting the source buffer after moving nodes."; }; scrolloff = mkOption { type = nullOr int; default = null; - description = "scrolloff value when navbuddy is open"; + description = "The scrolloff value in the source buffer when Navbuddy is open."; }; }; From 1ed6fd9f58f4df669edc55284becd1a90e1b3a47 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Sun, 4 May 2025 17:58:22 +0300 Subject: [PATCH 06/35] languages: deprecate `vim.languages.enableLSP` This change is done in favor of our intentions to use the new API Neovim has exposed, and the one we are exposing to match theirs. --- configuration.nix | 7 ++- flake/templates/standalone/flake.nix | 12 ++++- modules/neovim/init/lsp.nix | 65 +++++++++++++++---------- modules/plugins/languages/asm.nix | 2 +- modules/plugins/languages/astro.nix | 2 +- modules/plugins/languages/bash.nix | 2 +- modules/plugins/languages/clang.nix | 2 +- modules/plugins/languages/csharp.nix | 2 +- modules/plugins/languages/css.nix | 2 +- modules/plugins/languages/cue.nix | 2 +- modules/plugins/languages/dart.nix | 2 +- modules/plugins/languages/default.nix | 14 ++---- modules/plugins/languages/elixir.nix | 2 +- modules/plugins/languages/fsharp.nix | 2 +- modules/plugins/languages/gleam.nix | 2 +- modules/plugins/languages/go.nix | 2 +- modules/plugins/languages/haskell.nix | 2 +- modules/plugins/languages/hcl.nix | 2 +- modules/plugins/languages/helm.nix | 2 +- modules/plugins/languages/java.nix | 2 +- modules/plugins/languages/julia.nix | 2 +- modules/plugins/languages/kotlin.nix | 2 +- modules/plugins/languages/lua.nix | 2 +- modules/plugins/languages/markdown.nix | 2 +- modules/plugins/languages/nim.nix | 2 +- modules/plugins/languages/nix.nix | 2 +- modules/plugins/languages/nu.nix | 2 +- modules/plugins/languages/ocaml.nix | 2 +- modules/plugins/languages/odin.nix | 2 +- modules/plugins/languages/php.nix | 2 +- modules/plugins/languages/python.nix | 2 +- modules/plugins/languages/r.nix | 2 +- modules/plugins/languages/ruby.nix | 2 +- modules/plugins/languages/rust.nix | 2 +- modules/plugins/languages/scala.nix | 2 +- modules/plugins/languages/sql.nix | 2 +- modules/plugins/languages/svelte.nix | 2 +- modules/plugins/languages/tailwind.nix | 2 +- modules/plugins/languages/terraform.nix | 2 +- modules/plugins/languages/ts.nix | 2 +- modules/plugins/languages/typst.nix | 2 +- modules/plugins/languages/vala.nix | 2 +- modules/plugins/languages/wgsl.nix | 2 +- modules/plugins/languages/yaml.nix | 2 +- modules/plugins/languages/zig.nix | 2 +- modules/plugins/lsp/module.nix | 3 +- 46 files changed, 102 insertions(+), 81 deletions(-) diff --git a/configuration.nix b/configuration.nix index 6629810d..6e3175ef 100644 --- a/configuration.nix +++ b/configuration.nix @@ -18,6 +18,10 @@ isMaximal: { }; lsp = { + # This must be enabled for the language modules to hook into + # the LSP API. + enable = true; + formatOnSave = true; lspkind.enable = false; lightbulb.enable = true; @@ -38,8 +42,7 @@ isMaximal: { # This section does not include a comprehensive list of available language modules. # To list all available language module options, please visit the nvf manual. languages = { - enableLSP = true; - enableFormat = true; + enableFormat = true; # enableTreesitter = true; enableExtraDiagnostics = true; diff --git a/flake/templates/standalone/flake.nix b/flake/templates/standalone/flake.nix index 79617260..1057a6d5 100644 --- a/flake/templates/standalone/flake.nix +++ b/flake/templates/standalone/flake.nix @@ -26,12 +26,22 @@ config.vim = { theme.enable = true; + lsp = { + # Enable LSP functionality globally. This is required for modules found + # in `vim.languages` to enable relevant LSPs. + enable = true; + + # You may define your own LSP configurations using `vim.lsp.servers` in + # nvf without ever needing lspconfig to do it. This will use the native + # API provided by Neovim > 0.11 + servers = {}; + }; + # Language support and automatic configuration of companion plugins. # Note that enabling, e.g., languages..diagnostics will automatically # enable top-level options such as enableLSP or enableExtraDiagnostics as # they are needed. languages = { - enableLSP = true; enableFormat = true; enableTreesitter = true; enableExtraDiagnostics = true; diff --git a/modules/neovim/init/lsp.nix b/modules/neovim/init/lsp.nix index faef0f93..b89c3fde 100644 --- a/modules/neovim/init/lsp.nix +++ b/modules/neovim/init/lsp.nix @@ -5,7 +5,7 @@ }: let inherit (builtins) filter; inherit (lib.modules) mkIf mkMerge mkDefault; - inherit (lib.options) mkOption; + inherit (lib.options) mkOption mkEnableOption; inherit (lib.types) attrsOf; inherit (lib.strings) concatLines; inherit (lib.attrsets) mapAttrsToList attrNames filterAttrs; @@ -27,37 +27,48 @@ enabledServers = filterAttrs (_: u: u.enable) cfg.servers; in { options = { - vim.lsp.servers = mkOption { - type = attrsOf lspOptions; - default = {}; - example = '' - { - "*" = { - root_markers = [".git"]; - capabilities = { - textDocument = { - semanticTokens = { - multilineTokenSupport = true; + vim.lsp = { + enable = mkEnableOption '' + global LSP functionality for Neovim. + + This option controls whether to enable LSP functionality within modules under + {option}`vim.languages`. You do not need to set this to `true` for language + servers defined in {option}`vim.lsp.servers` to take effect, since they are + enabled automatically. + ''; + + servers = mkOption { + type = attrsOf lspOptions; + default = {}; + example = '' + { + "*" = { + root_markers = [".git"]; + capabilities = { + textDocument = { + semanticTokens = { + multilineTokenSupport = true; + }; }; }; }; - }; - "clangd" = { - filetypes = ["c"]; - }; - } - ''; - description = '' - LSP configurations that will be managed using `vim.lsp.config()` and - related utilities added in Neovim 0.11. LSPs defined here will be - added to the resulting {file}`init.lua` using `vim.lsp.config` and - enabled through `vim.lsp.enable` below the configuration table. + "clangd" = { + filetypes = ["c"]; + }; + } + ''; + description = '' + LSP configurations that will be managed using `vim.lsp.config()` and related + utilities added in Neovim 0.11. LSPs defined here will be added to the + resulting {file}`init.lua` using `vim.lsp.config` and enabled through + `vim.lsp.enable()` API from Neovim below the configuration table. - You may review the generated configuration by running {command}`nvf-print-config` - in a shell. Please see {command}`:help lsp-config` for more details - on the underlying API. - ''; + You may review the generated configuration by running {command}`nvf-print-config` + in a shell. Please see {command}`:help lsp-config` for more details + on the underlying API. + ''; + }; }; }; diff --git a/modules/plugins/languages/asm.nix b/modules/plugins/languages/asm.nix index a0e96cef..9fe58a76 100644 --- a/modules/plugins/languages/asm.nix +++ b/modules/plugins/languages/asm.nix @@ -20,7 +20,7 @@ in { }; lsp = { - enable = mkEnableOption "Assembly LSP support (asm-lsp)" // {default = config.vim.languages.enableLSP;}; + enable = mkEnableOption "Assembly LSP support (asm-lsp)" // {default = config.vim.lsp.enable;}; package = mkOption { type = package; diff --git a/modules/plugins/languages/astro.nix b/modules/plugins/languages/astro.nix index 2ecbbe47..b7a69bda 100644 --- a/modules/plugins/languages/astro.nix +++ b/modules/plugins/languages/astro.nix @@ -81,7 +81,7 @@ in { }; lsp = { - enable = mkEnableOption "Astro LSP support" // {default = config.vim.languages.enableLSP;}; + enable = mkEnableOption "Astro LSP support" // {default = config.vim.lsp.enable;}; server = mkOption { type = enum (attrNames servers); diff --git a/modules/plugins/languages/bash.nix b/modules/plugins/languages/bash.nix index bfe01032..e02596cf 100644 --- a/modules/plugins/languages/bash.nix +++ b/modules/plugins/languages/bash.nix @@ -56,7 +56,7 @@ in { }; lsp = { - enable = mkEnableOption "Enable Bash LSP support" // {default = config.vim.languages.enableLSP;}; + enable = mkEnableOption "Enable Bash LSP support" // {default = config.vim.lsp.enable;}; server = mkOption { description = "Bash LSP server to use"; diff --git a/modules/plugins/languages/clang.nix b/modules/plugins/languages/clang.nix index bb30cc95..2db178e9 100644 --- a/modules/plugins/languages/clang.nix +++ b/modules/plugins/languages/clang.nix @@ -98,7 +98,7 @@ in { }; lsp = { - enable = mkEnableOption "clang LSP support" // {default = config.vim.languages.enableLSP;}; + enable = mkEnableOption "clang LSP support" // {default = config.vim.lsp.enable;}; server = mkOption { description = "The clang LSP server to use"; diff --git a/modules/plugins/languages/csharp.nix b/modules/plugins/languages/csharp.nix index af7f36e0..49ae4985 100644 --- a/modules/plugins/languages/csharp.nix +++ b/modules/plugins/languages/csharp.nix @@ -91,7 +91,7 @@ in { }; lsp = { - enable = mkEnableOption "C# LSP support" // {default = config.vim.languages.enableLSP;}; + enable = mkEnableOption "C# LSP support" // {default = config.vim.lsp.enable;}; server = mkOption { description = "C# LSP server to use"; type = enum (attrNames servers); diff --git a/modules/plugins/languages/css.nix b/modules/plugins/languages/css.nix index d103f241..0147fba3 100644 --- a/modules/plugins/languages/css.nix +++ b/modules/plugins/languages/css.nix @@ -80,7 +80,7 @@ in { }; lsp = { - enable = mkEnableOption "CSS LSP support" // {default = config.vim.languages.enableLSP;}; + enable = mkEnableOption "CSS LSP support" // {default = config.vim.lsp.enable;}; server = mkOption { description = "CSS LSP server to use"; diff --git a/modules/plugins/languages/cue.nix b/modules/plugins/languages/cue.nix index 313e3233..bd446cbf 100644 --- a/modules/plugins/languages/cue.nix +++ b/modules/plugins/languages/cue.nix @@ -21,7 +21,7 @@ in { }; lsp = { - enable = mkEnableOption "CUE LSP support" // {default = config.vim.languages.enableLSP;}; + enable = mkEnableOption "CUE LSP support" // {default = config.vim.lsp.enable;}; package = mkOption { type = package; diff --git a/modules/plugins/languages/dart.nix b/modules/plugins/languages/dart.nix index 7b9584b9..9cbd0783 100644 --- a/modules/plugins/languages/dart.nix +++ b/modules/plugins/languages/dart.nix @@ -77,7 +77,7 @@ in { flutter-tools = { enable = mkOption { type = bool; - default = config.vim.languages.enableLSP; + default = config.vim.lsp.enable; description = "Enable flutter-tools for flutter support"; }; diff --git a/modules/plugins/languages/default.nix b/modules/plugins/languages/default.nix index b889e60a..25b99080 100644 --- a/modules/plugins/languages/default.nix +++ b/modules/plugins/languages/default.nix @@ -1,8 +1,5 @@ -{ - config, - lib, - ... -}: let +{lib, ...}: let + inherit (lib.modules) mkRenamedOptionModule; inherit (lib.nvim.languages) mkEnable; in { imports = [ @@ -48,13 +45,12 @@ in { ./wgsl.nix ./yaml.nix ./ruby.nix + + # This is now a hard deprecation. + (mkRenamedOptionModule ["vim" "languages" "enableLSP"] ["vim" "lsp" "enable"]) ]; options.vim.languages = { - # LSPs are now built into Neovim, and we should enable them by default - # if `vim.lsp.enable` is true. - enableLSP = mkEnable "LSP" // {default = config.vim.lsp.enable;}; - # Those are still managed by plugins, and should be enabled here. enableDAP = mkEnable "Debug Adapter"; enableTreesitter = mkEnable "Treesitter"; diff --git a/modules/plugins/languages/elixir.nix b/modules/plugins/languages/elixir.nix index 7b3a0256..241efd8e 100644 --- a/modules/plugins/languages/elixir.nix +++ b/modules/plugins/languages/elixir.nix @@ -53,7 +53,7 @@ in { }; lsp = { - enable = mkEnableOption "Elixir LSP support" // {default = config.vim.languages.enableLSP;}; + enable = mkEnableOption "Elixir LSP support" // {default = config.vim.lsp.enable;}; server = mkOption { description = "Elixir LSP server to use"; diff --git a/modules/plugins/languages/fsharp.nix b/modules/plugins/languages/fsharp.nix index 966b0349..6ed0ccab 100644 --- a/modules/plugins/languages/fsharp.nix +++ b/modules/plugins/languages/fsharp.nix @@ -51,7 +51,7 @@ in { }; lsp = { - enable = mkEnableOption "F# LSP support" // {default = config.vim.languages.enableLSP;}; + enable = mkEnableOption "F# LSP support" // {default = config.vim.lsp.enable;}; server = mkOption { type = enum (attrNames servers); default = defaultServer; diff --git a/modules/plugins/languages/gleam.nix b/modules/plugins/languages/gleam.nix index 284d3443..272ef51e 100644 --- a/modules/plugins/languages/gleam.nix +++ b/modules/plugins/languages/gleam.nix @@ -41,7 +41,7 @@ in { }; lsp = { - enable = mkEnableOption "Gleam LSP support" // {default = config.vim.languages.enableLSP;}; + enable = mkEnableOption "Gleam LSP support" // {default = config.vim.lsp.enable;}; server = mkOption { type = enum (attrNames servers); diff --git a/modules/plugins/languages/go.nix b/modules/plugins/languages/go.nix index 3f232669..bab0ff4a 100644 --- a/modules/plugins/languages/go.nix +++ b/modules/plugins/languages/go.nix @@ -67,7 +67,7 @@ in { }; lsp = { - enable = mkEnableOption "Go LSP support" // {default = config.vim.languages.enableLSP;}; + enable = mkEnableOption "Go LSP support" // {default = config.vim.lsp.enable;}; server = mkOption { description = "Go LSP server to use"; diff --git a/modules/plugins/languages/haskell.nix b/modules/plugins/languages/haskell.nix index ff6c7d78..f50c9f09 100644 --- a/modules/plugins/languages/haskell.nix +++ b/modules/plugins/languages/haskell.nix @@ -25,7 +25,7 @@ in { }; lsp = { - enable = mkEnableOption "LSP support for Haskell" // {default = config.vim.languages.enableLSP;}; + enable = mkEnableOption "LSP support for Haskell" // {default = config.vim.lsp.enable;}; package = mkOption { description = "Haskell LSP package or command to run the Haskell LSP"; example = ''[ (lib.getExe pkgs.haskellPackages.haskell-language-server) "--debug" ]''; diff --git a/modules/plugins/languages/hcl.nix b/modules/plugins/languages/hcl.nix index 3a3db782..e702170c 100644 --- a/modules/plugins/languages/hcl.nix +++ b/modules/plugins/languages/hcl.nix @@ -43,7 +43,7 @@ in { }; lsp = { - enable = mkEnableOption "HCL LSP support (terraform-ls)" // {default = config.vim.languages.enableLSP;}; + enable = mkEnableOption "HCL LSP support (terraform-ls)" // {default = config.vim.lsp.enable;}; # TODO: (maybe, is it better?) it would be cooler to use vscode-extensions.hashicorp.hcl probably, shouldn't be too hard package = mkOption { type = package; diff --git a/modules/plugins/languages/helm.nix b/modules/plugins/languages/helm.nix index d3fd636e..ffe115c9 100644 --- a/modules/plugins/languages/helm.nix +++ b/modules/plugins/languages/helm.nix @@ -54,7 +54,7 @@ in { }; lsp = { - enable = mkEnableOption "Helm LSP support" // {default = config.vim.languages.enableLSP;}; + enable = mkEnableOption "Helm LSP support" // {default = config.vim.lsp.enable;}; server = mkOption { description = "Helm LSP server to use"; diff --git a/modules/plugins/languages/java.nix b/modules/plugins/languages/java.nix index dc46fcfe..2e26feea 100644 --- a/modules/plugins/languages/java.nix +++ b/modules/plugins/languages/java.nix @@ -23,7 +23,7 @@ in { }; lsp = { - enable = mkEnableOption "Java LSP support (java-language-server)" // {default = config.vim.languages.enableLSP;}; + enable = mkEnableOption "Java LSP support (java-language-server)" // {default = config.vim.lsp.enable;}; package = mkOption { description = "java language server package, or the command to run as a list of strings"; example = ''[lib.getExe pkgs.jdt-language-server "-data" "~/.cache/jdtls/workspace"]''; diff --git a/modules/plugins/languages/julia.nix b/modules/plugins/languages/julia.nix index aa537df9..8c48b070 100644 --- a/modules/plugins/languages/julia.nix +++ b/modules/plugins/languages/julia.nix @@ -78,7 +78,7 @@ in { lsp = { enable = mkOption { type = bool; - default = config.vim.languages.enableLSP; + default = config.vim.lsp.enable; description = '' Whether to enable Julia LSP support. diff --git a/modules/plugins/languages/kotlin.nix b/modules/plugins/languages/kotlin.nix index 2ddc63e9..1118afdf 100644 --- a/modules/plugins/languages/kotlin.nix +++ b/modules/plugins/languages/kotlin.nix @@ -30,7 +30,7 @@ in { }; lsp = { - enable = mkEnableOption "Kotlin LSP support" // {default = config.vim.languages.enableLSP;}; + enable = mkEnableOption "Kotlin LSP support" // {default = config.vim.lsp.enable;}; package = mkOption { description = "kotlin_language_server package with Kotlin runtime"; diff --git a/modules/plugins/languages/lua.nix b/modules/plugins/languages/lua.nix index d5be4905..9f56cbea 100644 --- a/modules/plugins/languages/lua.nix +++ b/modules/plugins/languages/lua.nix @@ -43,7 +43,7 @@ in { }; lsp = { - enable = mkEnableOption "Lua LSP support via LuaLS" // {default = config.vim.languages.enableLSP;}; + enable = mkEnableOption "Lua LSP support via LuaLS" // {default = config.vim.lsp.enable;}; package = mkOption { description = "LuaLS package, or the command to run as a list of strings"; diff --git a/modules/plugins/languages/markdown.nix b/modules/plugins/languages/markdown.nix index 4563bc44..eeb80e8d 100644 --- a/modules/plugins/languages/markdown.nix +++ b/modules/plugins/languages/markdown.nix @@ -67,7 +67,7 @@ in { }; lsp = { - enable = mkEnableOption "Enable Markdown LSP support" // {default = config.vim.languages.enableLSP;}; + enable = mkEnableOption "Enable Markdown LSP support" // {default = config.vim.lsp.enable;}; server = mkOption { type = enum (attrNames servers); diff --git a/modules/plugins/languages/nim.nix b/modules/plugins/languages/nim.nix index 69288223..d9a29e37 100644 --- a/modules/plugins/languages/nim.nix +++ b/modules/plugins/languages/nim.nix @@ -54,7 +54,7 @@ in { }; lsp = { - enable = mkEnableOption "Nim LSP support" // {default = config.vim.languages.enableLSP;}; + enable = mkEnableOption "Nim LSP support" // {default = config.vim.lsp.enable;}; server = mkOption { description = "Nim LSP server to use"; type = str; diff --git a/modules/plugins/languages/nix.nix b/modules/plugins/languages/nix.nix index ad16a34e..83022adf 100644 --- a/modules/plugins/languages/nix.nix +++ b/modules/plugins/languages/nix.nix @@ -143,7 +143,7 @@ in { }; lsp = { - enable = mkEnableOption "Nix LSP support" // {default = config.vim.languages.enableLSP;}; + enable = mkEnableOption "Nix LSP support" // {default = config.vim.lsp.enable;}; server = mkOption { description = "Nix LSP server to use"; type = enum (attrNames servers); diff --git a/modules/plugins/languages/nu.nix b/modules/plugins/languages/nu.nix index eab0385c..bd007fc8 100644 --- a/modules/plugins/languages/nu.nix +++ b/modules/plugins/languages/nu.nix @@ -40,7 +40,7 @@ in { }; lsp = { - enable = mkEnableOption "Nu LSP support" // {default = config.vim.languages.enableLSP;}; + enable = mkEnableOption "Nu LSP support" // {default = config.vim.lsp.enable;}; server = mkOption { type = str; default = defaultServer; diff --git a/modules/plugins/languages/ocaml.nix b/modules/plugins/languages/ocaml.nix index 568b846e..995ca04d 100644 --- a/modules/plugins/languages/ocaml.nix +++ b/modules/plugins/languages/ocaml.nix @@ -49,7 +49,7 @@ in { }; lsp = { - enable = mkEnableOption "OCaml LSP support (ocaml-lsp)" // {default = config.vim.languages.enableLSP;}; + enable = mkEnableOption "OCaml LSP support (ocaml-lsp)" // {default = config.vim.lsp.enable;}; server = mkOption { description = "OCaml LSP server to user"; type = enum (attrNames servers); diff --git a/modules/plugins/languages/odin.nix b/modules/plugins/languages/odin.nix index 7a32db93..6d20351c 100644 --- a/modules/plugins/languages/odin.nix +++ b/modules/plugins/languages/odin.nix @@ -41,7 +41,7 @@ in { }; lsp = { - enable = mkEnableOption "Odin LSP support" // {default = config.vim.languages.enableLSP;}; + enable = mkEnableOption "Odin LSP support" // {default = config.vim.lsp.enable;}; server = mkOption { type = enum (attrNames servers); diff --git a/modules/plugins/languages/php.nix b/modules/plugins/languages/php.nix index 4dccc8cd..61ff0425 100644 --- a/modules/plugins/languages/php.nix +++ b/modules/plugins/languages/php.nix @@ -95,7 +95,7 @@ in { }; lsp = { - enable = mkEnableOption "PHP LSP support" // {default = config.vim.languages.enableLSP;}; + enable = mkEnableOption "PHP LSP support" // {default = config.vim.lsp.enable;}; server = mkOption { description = "PHP LSP server to use"; diff --git a/modules/plugins/languages/python.nix b/modules/plugins/languages/python.nix index 9905716e..bec7ec8b 100644 --- a/modules/plugins/languages/python.nix +++ b/modules/plugins/languages/python.nix @@ -169,7 +169,7 @@ in { }; lsp = { - enable = mkEnableOption "Python LSP support" // {default = config.vim.languages.enableLSP;}; + enable = mkEnableOption "Python LSP support" // {default = config.vim.lsp.enable;}; server = mkOption { description = "Python LSP server to use"; diff --git a/modules/plugins/languages/r.nix b/modules/plugins/languages/r.nix index fcadcc37..894c63f6 100644 --- a/modules/plugins/languages/r.nix +++ b/modules/plugins/languages/r.nix @@ -79,7 +79,7 @@ in { }; lsp = { - enable = mkEnableOption "R LSP support" // {default = config.vim.languages.enableLSP;}; + enable = mkEnableOption "R LSP support" // {default = config.vim.lsp.enable;}; server = mkOption { description = "R LSP server to use"; diff --git a/modules/plugins/languages/ruby.nix b/modules/plugins/languages/ruby.nix index 2f42aa4f..ab0e0905 100644 --- a/modules/plugins/languages/ruby.nix +++ b/modules/plugins/languages/ruby.nix @@ -57,7 +57,7 @@ in { }; lsp = { - enable = mkEnableOption "Ruby LSP support" // {default = config.vim.languages.enableLSP;}; + enable = mkEnableOption "Ruby LSP support" // {default = config.vim.lsp.enable;}; server = mkOption { type = enum (attrNames servers); diff --git a/modules/plugins/languages/rust.nix b/modules/plugins/languages/rust.nix index 2181623a..677f7d3b 100644 --- a/modules/plugins/languages/rust.nix +++ b/modules/plugins/languages/rust.nix @@ -43,7 +43,7 @@ in { }; lsp = { - enable = mkEnableOption "Rust LSP support (rust-analyzer with extra tools)" // {default = config.vim.languages.enableLSP;}; + enable = mkEnableOption "Rust LSP support (rust-analyzer with extra tools)" // {default = config.vim.lsp.enable;}; package = mkOption { description = "rust-analyzer package, or the command to run as a list of strings"; example = ''[lib.getExe pkgs.jdt-language-server "-data" "~/.cache/jdtls/workspace"]''; diff --git a/modules/plugins/languages/scala.nix b/modules/plugins/languages/scala.nix index f769d092..b5382415 100644 --- a/modules/plugins/languages/scala.nix +++ b/modules/plugins/languages/scala.nix @@ -33,7 +33,7 @@ in { }; lsp = { - enable = mkEnableOption "Scala LSP support (metals)" // {default = config.vim.languages.enableLSP;}; + enable = mkEnableOption "Scala LSP support (metals)" // {default = config.vim.lsp.enable;}; package = mkPackageOption pkgs "metals" { default = ["metals"]; }; diff --git a/modules/plugins/languages/sql.nix b/modules/plugins/languages/sql.nix index 277dbeef..add46c15 100644 --- a/modules/plugins/languages/sql.nix +++ b/modules/plugins/languages/sql.nix @@ -79,7 +79,7 @@ in { }; lsp = { - enable = mkEnableOption "SQL LSP support" // {default = config.vim.languages.enableLSP;}; + enable = mkEnableOption "SQL LSP support" // {default = config.vim.lsp.enable;}; server = mkOption { description = "SQL LSP server to use"; diff --git a/modules/plugins/languages/svelte.nix b/modules/plugins/languages/svelte.nix index 536ff2c1..08a807c7 100644 --- a/modules/plugins/languages/svelte.nix +++ b/modules/plugins/languages/svelte.nix @@ -77,7 +77,7 @@ in { }; lsp = { - enable = mkEnableOption "Svelte LSP support" // {default = config.vim.languages.enableLSP;}; + enable = mkEnableOption "Svelte LSP support" // {default = config.vim.lsp.enable;}; server = mkOption { description = "Svelte LSP server to use"; diff --git a/modules/plugins/languages/tailwind.nix b/modules/plugins/languages/tailwind.nix index 594f6d9d..fbe707ba 100644 --- a/modules/plugins/languages/tailwind.nix +++ b/modules/plugins/languages/tailwind.nix @@ -35,7 +35,7 @@ in { enable = mkEnableOption "Tailwindcss language support"; lsp = { - enable = mkEnableOption "Tailwindcss LSP support" // {default = config.vim.languages.enableLSP;}; + enable = mkEnableOption "Tailwindcss LSP support" // {default = config.vim.lsp.enable;}; server = mkOption { description = "Tailwindcss LSP server to use"; diff --git a/modules/plugins/languages/terraform.nix b/modules/plugins/languages/terraform.nix index 33bb9357..095da072 100644 --- a/modules/plugins/languages/terraform.nix +++ b/modules/plugins/languages/terraform.nix @@ -20,7 +20,7 @@ in { }; lsp = { - enable = mkEnableOption "Terraform LSP support (terraform-ls)" // {default = config.vim.languages.enableLSP;}; + enable = mkEnableOption "Terraform LSP support (terraform-ls)" // {default = config.vim.lsp.enable;}; package = mkOption { description = "terraform-ls package"; diff --git a/modules/plugins/languages/ts.nix b/modules/plugins/languages/ts.nix index df1353ab..5a1e5889 100644 --- a/modules/plugins/languages/ts.nix +++ b/modules/plugins/languages/ts.nix @@ -120,7 +120,7 @@ in { }; lsp = { - enable = mkEnableOption "Typescript/Javascript LSP support" // {default = config.vim.languages.enableLSP;}; + enable = mkEnableOption "Typescript/Javascript LSP support" // {default = config.vim.lsp.enable;}; server = mkOption { description = "Typescript/Javascript LSP server to use"; diff --git a/modules/plugins/languages/typst.nix b/modules/plugins/languages/typst.nix index 8c65ae2c..08a2252b 100644 --- a/modules/plugins/languages/typst.nix +++ b/modules/plugins/languages/typst.nix @@ -76,7 +76,7 @@ in { }; lsp = { - enable = mkEnableOption "Typst LSP support (typst-lsp)" // {default = config.vim.languages.enableLSP;}; + enable = mkEnableOption "Typst LSP support (typst-lsp)" // {default = config.vim.lsp.enable;}; server = mkOption { description = "Typst LSP server to use"; diff --git a/modules/plugins/languages/vala.nix b/modules/plugins/languages/vala.nix index da65a372..220926d0 100644 --- a/modules/plugins/languages/vala.nix +++ b/modules/plugins/languages/vala.nix @@ -50,7 +50,7 @@ in { }; lsp = { - enable = mkEnableOption "Vala LSP support" // {default = config.vim.languages.enableLSP;}; + enable = mkEnableOption "Vala LSP support" // {default = config.vim.lsp.enable;}; server = mkOption { description = "Vala LSP server to use"; type = enum (attrNames servers); diff --git a/modules/plugins/languages/wgsl.nix b/modules/plugins/languages/wgsl.nix index 7c8a1016..f374543e 100644 --- a/modules/plugins/languages/wgsl.nix +++ b/modules/plugins/languages/wgsl.nix @@ -42,7 +42,7 @@ in { }; lsp = { - enable = mkEnableOption "WGSL LSP support" // {default = config.vim.languages.enableLSP;}; + enable = mkEnableOption "WGSL LSP support" // {default = config.vim.lsp.enable;}; server = mkOption { type = enum (attrNames servers); diff --git a/modules/plugins/languages/yaml.nix b/modules/plugins/languages/yaml.nix index c84b17cd..7a1a4552 100644 --- a/modules/plugins/languages/yaml.nix +++ b/modules/plugins/languages/yaml.nix @@ -55,7 +55,7 @@ in { }; lsp = { - enable = mkEnableOption "YAML LSP support" // {default = config.vim.languages.enableLSP;}; + enable = mkEnableOption "YAML LSP support" // {default = config.vim.lsp.enable;}; server = mkOption { type = enum (attrNames servers); diff --git a/modules/plugins/languages/zig.nix b/modules/plugins/languages/zig.nix index 2aa0e2b6..89307eab 100644 --- a/modules/plugins/languages/zig.nix +++ b/modules/plugins/languages/zig.nix @@ -72,7 +72,7 @@ in { }; lsp = { - enable = mkEnableOption "Zig LSP support" // {default = config.vim.languages.enableLSP;}; + enable = mkEnableOption "Zig LSP support" // {default = config.vim.lsp.enable;}; server = mkOption { type = enum (attrNames servers); diff --git a/modules/plugins/lsp/module.nix b/modules/plugins/lsp/module.nix index f408d873..6b63d725 100644 --- a/modules/plugins/lsp/module.nix +++ b/modules/plugins/lsp/module.nix @@ -3,11 +3,12 @@ inherit (lib.nvim.binds) mkMappingOption; in { options.vim.lsp = { - enable = mkEnableOption "LSP, also enabled automatically through null-ls and lspconfig options"; formatOnSave = mkEnableOption "format on save"; + inlayHints = { enable = mkEnableOption "inlay hints"; }; + mappings = { goToDefinition = mkMappingOption "Go to definition" From 4678f734111f341dc29b5f16adb8e084b97ded7e Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Mon, 28 Apr 2025 22:51:04 +0300 Subject: [PATCH 07/35] neovim/clipboard: init module --- docs/release-notes/rl-0.8.md | 6 ++- modules/neovim/init/clipboard.nix | 80 +++++++++++++++++++++++++++++++ modules/neovim/init/default.nix | 1 + 3 files changed, 86 insertions(+), 1 deletion(-) create mode 100644 modules/neovim/init/clipboard.nix diff --git a/docs/release-notes/rl-0.8.md b/docs/release-notes/rl-0.8.md index 80a0300c..f0f58e7c 100644 --- a/docs/release-notes/rl-0.8.md +++ b/docs/release-notes/rl-0.8.md @@ -91,6 +91,9 @@ options for `vim.diagnostic.config()` can now be customized through the [](#opt-vim.diagnostics.config) in nvf. +- Add `vim.clipboard` module for easily managing Neovim clipboard providers and + relevant packages in a simple UI. + [amadaluzia](https://github.com/amadaluzia): [haskell-tools.nvim]: https://github.com/MrcJkb/haskell-tools.nvim @@ -361,4 +364,5 @@ [Hardtime.nvim]: https://github.com/m4xshen/hardtime.nvim -- Add Plugin [Hardtime.nvim] under `vim.binds.hardtime-nvim` with `enable` and `setupOpts` options +- Add Plugin [Hardtime.nvim] under `vim.binds.hardtime-nvim` with `enable` and + `setupOpts` options diff --git a/modules/neovim/init/clipboard.nix b/modules/neovim/init/clipboard.nix new file mode 100644 index 00000000..011effaf --- /dev/null +++ b/modules/neovim/init/clipboard.nix @@ -0,0 +1,80 @@ +{ + config, + pkgs, + lib, + ... +}: let + inherit (lib.modules) mkIf; + inherit (lib.options) mkOption mkEnableOption mkPackageOption; + inherit (lib.types) nullOr either str listOf submodule; + inherit (lib.attrsets) mapAttrs mapAttrsToList filterAttrs; + cfg = config.vim.clipboard; +in { + options = { + vim = { + clipboard = { + enable = mkEnableOption '' + clipboard management for Neovim. Users may still choose to manage their + clipboard through [](#opt-vim.options) should they wish to avoid using + this module. + ''; + + registers = mkOption { + type = either str (listOf str); + default = ""; + example = "unnamedplus"; + description = '' + The register to be used by the Neovim clipboard. Recognized types are: + + * unnamed: Vim will use the clipboard register `"*"` for all yank, delete, + change and put operations which would normally go to the unnamed register. + + * unnamedplus: A variant of the "unnamed" flag which uses the clipboard register + `"+"` ({command}`:h quoteplus`) instead of register `"*"` for all yank, delete, + change and put operations which would normally go to the unnamed register. + + When `unnamed` and `unnamedplus` is included simultaneously yank and delete + operations (but not put) will additionally copy the text into register `"*"`. + + Please see {command}`:h clipboard` for more details. + + ''; + }; + + providers = mkOption { + type = submodule { + options = let + clipboards = { + # name = "package name"; + wl-copy = "wl-clipboard"; + xclip = "xclip"; + xsel = "xsel"; + }; + in + mapAttrs (name: pname: { + enable = mkEnableOption name; + package = mkPackageOption pkgs pname {nullable = true;}; + }) + clipboards; + }; + default = {}; + description = '' + Clipboard providers for which packages will be added to nvf's + {option}`extraPackages`. The `package` field may be set to `null` + if related packages are already found in system packages to + potentially reduce closure sizes. + ''; + }; + }; + }; + }; + + config = mkIf cfg.enable { + vim = { + options.clipboard = cfg.registers; + extraPackages = mapAttrsToList (_: v: v.package) ( + filterAttrs (_: v: v.enable && v.package != null) cfg.providers + ); + }; + }; +} diff --git a/modules/neovim/init/default.nix b/modules/neovim/init/default.nix index 7db6f2ef..30a481a1 100644 --- a/modules/neovim/init/default.nix +++ b/modules/neovim/init/default.nix @@ -2,6 +2,7 @@ imports = [ ./autocmds.nix ./basic.nix + ./clipboard.nix ./debug.nix ./diagnostics.nix ./highlight.nix From 69e75a00ed25a1708fca234a15bbd361e02ead73 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Sun, 4 May 2025 18:22:47 +0300 Subject: [PATCH 08/35] neovim/basic: deprecate `vim.useSystemClipboard` --- docs/release-notes/rl-0.8.md | 7 +++++++ modules/extra/deprecations.nix | 9 +++++++++ modules/neovim/init/basic.nix | 10 ---------- 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/docs/release-notes/rl-0.8.md b/docs/release-notes/rl-0.8.md index f0f58e7c..014a4a23 100644 --- a/docs/release-notes/rl-0.8.md +++ b/docs/release-notes/rl-0.8.md @@ -19,6 +19,11 @@ unavailable as they have been refactored out of the main none-ls repository upstream. +- `vim.useSystemClipboard` has been deprecated as a part of removing most + top-level convenience options, and should instead be configured in the new + module interface. You may set [](#opt-vim.clipboard.registers) appropriately + to configure Neovim to use the system clipboard. + [NotAShelf](https://github.com/notashelf): [typst-preview.nvim]: https://github.com/chomosuke/typst-preview.nvim @@ -93,6 +98,8 @@ - Add `vim.clipboard` module for easily managing Neovim clipboard providers and relevant packages in a simple UI. + - This deprecates `vim.useSystemClipboard` as well, see breaking changes + section above for migration options. [amadaluzia](https://github.com/amadaluzia): diff --git a/modules/extra/deprecations.nix b/modules/extra/deprecations.nix index 86497130..91d8ef28 100644 --- a/modules/extra/deprecations.nix +++ b/modules/extra/deprecations.nix @@ -111,6 +111,15 @@ in { 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. '') + + # 2025-05-04 + (mkRemovedOptionModule ["vim" "useSystemClipboard"] '' + Clipboard behaviour should now be controlled through the new, more fine-grained module + interface found in 'vim.clipboard'. To replicate previous behaviour, you may either + add 'vim.opt.clipboard:append("unnamedplus")' in luaConfigRC, or preferably set it + in 'vim.clipboard.registers'. Please see the documentation for the new module for more + details, or open an issue if you are confused. + '') ] # Migrated via batchRenameOptions. Further batch renames must be below this line. diff --git a/modules/neovim/init/basic.nix b/modules/neovim/init/basic.nix index 47bfe500..195ef5e7 100644 --- a/modules/neovim/init/basic.nix +++ b/modules/neovim/init/basic.nix @@ -34,12 +34,6 @@ in { description = "Enable syntax highlighting"; }; - useSystemClipboard = mkOption { - type = bool; - default = false; - description = "Make use of the clipboard for default yank and paste operations. Don't use * and +"; - }; - lineNumberMode = mkOption { type = enum ["relative" "number" "relNumber" "none"]; default = "relNumber"; @@ -144,10 +138,6 @@ in { # to pre-set Neovim options. Fear not, though as the Lua DAG is still as powerful as it # could be. luaConfigRC.basic = entryAfter ["globalsScript"] '' - ${optionalString cfg.useSystemClipboard '' - vim.opt.clipboard:append("unnamedplus") - ''} - ${optionalString cfg.syntaxHighlighting '' vim.cmd("syntax on") ''} From b61893971636ac268aa72d30a309b1fabfc7d709 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Sun, 4 May 2025 17:58:22 +0300 Subject: [PATCH 09/35] languages: deprecate `vim.languages.enableLSP` This change is done in favor of our intentions to use the new API Neovim has exposed, and the one we are exposing to match theirs. --- modules/plugins/lsp/lspconfig/config.nix | 2 -- 1 file changed, 2 deletions(-) diff --git a/modules/plugins/lsp/lspconfig/config.nix b/modules/plugins/lsp/lspconfig/config.nix index 1c1f0a0a..16cba488 100644 --- a/modules/plugins/lsp/lspconfig/config.nix +++ b/modules/plugins/lsp/lspconfig/config.nix @@ -14,8 +14,6 @@ in { config = mkIf cfg.lspconfig.enable (mkMerge [ { vim = { - lsp.enable = true; - startPlugins = ["nvim-lspconfig"]; pluginRC.lspconfig = entryAfter ["lsp-setup"] '' From f558b7bc00aaef79ba3f60f4075ffde127bbfaf3 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Sun, 4 May 2025 18:25:53 +0300 Subject: [PATCH 10/35] docs: remove broken mentinos in old release notes --- docs/release-notes/rl-0.3.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/docs/release-notes/rl-0.3.md b/docs/release-notes/rl-0.3.md index 87ae5648..089f01f7 100644 --- a/docs/release-notes/rl-0.3.md +++ b/docs/release-notes/rl-0.3.md @@ -50,9 +50,8 @@ soon. - A new section has been added for language support: `vim.languages.`. - - The options [](#opt-vim.languages.enableLSP), - [](#opt-vim.languages.enableTreesitter), etc. will enable the respective - section for all languages that have been enabled. + - The options `enableLSP` [](#opt-vim.languages.enableTreesitter), etc. will + enable the respective section for all languages that have been enabled. - All LSP languages have been moved here - `plantuml` and `markdown` have been moved here - A new section has been added for `html`. The old From e752f59994e8f5c912dc2ca7c23d2ae2a5f193fd Mon Sep 17 00:00:00 2001 From: taylrfnt Date: Sun, 4 May 2025 19:05:09 -0500 Subject: [PATCH 11/35] nvimtree: add missing icon placement options - Address missing `right_align` option in existing icon placement attributes - Add the missing placement options from https://github.com/nvim-tree/nvim-tree.lua/blob/582ae48c9e43d2bcd55dfcc8e2e7a1f29065d924/lua/nvim-tree.lua#L595-L599 - Update the `mkOption` arguments to adhere to the requested style guide: ``` 1. type 2. default 3. (optional) example 4. description ``` --- .../plugins/filetree/nvimtree/nvimtree.nix | 41 +++++++++++++++++-- 1 file changed, 37 insertions(+), 4 deletions(-) diff --git a/modules/plugins/filetree/nvimtree/nvimtree.nix b/modules/plugins/filetree/nvimtree/nvimtree.nix index 9c443a6e..c3beb38f 100644 --- a/modules/plugins/filetree/nvimtree/nvimtree.nix +++ b/modules/plugins/filetree/nvimtree/nvimtree.nix @@ -683,15 +683,48 @@ in { }; git_placement = mkOption { - type = enum ["before" "after" "signcolumn"]; - description = "Place where the git icons will be rendered. `signcolumn` requires `view.signcolumn` to be enabled."; + type = enum ["before" "after" "signcolumn" "right_align"]; default = "before"; + description = '' + Place where the git icons will be rendered. + `signcolumn` requires `view.signcolumn` to be enabled. + ''; }; modified_placement = mkOption { - type = enum ["before" "after" "signcolumn"]; - description = "Place where the modified icons will be rendered. `signcolumn` requires `view.signcolumn` to be enabled."; + type = enum ["before" "after" "signcolumn" "right_align"]; default = "after"; + description = '' + Place where the modified icons will be rendered. + `signcolumn` requires `view.signcolumn` to be enabled. + ''; + }; + + hidden_placement = mkOption { + type = enum ["before" "after" "signcolumn" "right_align"]; + default = "after"; + description = '' + Place where the hidden icons will be rendered. + `signcolumn` requires `view.signcolumn` to be enabled. + ''; + }; + + diagnostics_placement = mkOption { + type = enum ["before" "after" "signcolumn" "right_align"]; + default = "after"; + description = '' + Place where the diagnostics icons will be rendered. + `signcolumn` requires `view.signcolumn` to be enabled. + ''; + }; + + bookmarks_placement = mkOption { + type = enum ["before" "after" "signcolumn" "right_align"]; + default = "after"; + description = '' + Place where the bookmark icons will be rendered. + `signcolumn` requires `view.signcolumn` to be enabled. + ''; }; padding = mkOption { From ee0a7e704824b73015234b4e97eab5a59efae364 Mon Sep 17 00:00:00 2001 From: taylrfnt Date: Sun, 4 May 2025 21:11:30 -0500 Subject: [PATCH 12/35] changelog: update with summary of changes (non-breaking) Add a summary of the (non-breaking) changes to the nvim-tree plugin options per contributing guidelines. --- docs/release-notes/rl-0.8.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/docs/release-notes/rl-0.8.md b/docs/release-notes/rl-0.8.md index 80a0300c..e0c06fc8 100644 --- a/docs/release-notes/rl-0.8.md +++ b/docs/release-notes/rl-0.8.md @@ -362,3 +362,11 @@ [Hardtime.nvim]: https://github.com/m4xshen/hardtime.nvim - Add Plugin [Hardtime.nvim] under `vim.binds.hardtime-nvim` with `enable` and `setupOpts` options + +[taylrfnt](https://github.com/taylrfnt): + +[nvim-tree](https://github.com/nvim-tree/nvim-tree.lua): + +- Add missing `right_align` option for existing `renderer.icons` options. +- Add missing `render.icons` options (`hidden_placement`, + `diagnostics_placement`, and `bookmarks_placement`). From 9feb71594d00e5f40b16d39b06b3fd4bad7630a0 Mon Sep 17 00:00:00 2001 From: Gerg-L Date: Sat, 3 May 2025 17:52:36 -0400 Subject: [PATCH 13/35] refactor: nuke legacyPackages and overlays rework blink-cmp package --- docs/default.nix | 1 + flake.nix | 3 --- flake/blink/default.nix | 31 +++++++++++++++++++++++++ flake/develop.nix | 3 ++- flake/legacyPackages.nix | 35 ---------------------------- flake/legacyPackages/blink-cmp.nix | 37 ------------------------------ flake/overlays.nix | 19 --------------- flake/packages.nix | 15 ++++++++---- lib/default.nix | 2 +- lib/types/default.nix | 7 ++++-- lib/types/plugins.nix | 7 ++++-- modules/plugins/languages/nix.nix | 3 ++- modules/wrapper/build/config.nix | 2 +- npins/sources.json | 16 ------------- 14 files changed, 59 insertions(+), 122 deletions(-) create mode 100644 flake/blink/default.nix delete mode 100644 flake/legacyPackages.nix delete mode 100644 flake/legacyPackages/blink-cmp.nix delete mode 100644 flake/overlays.nix diff --git a/docs/default.nix b/docs/default.nix index 98b29db0..49f90b80 100644 --- a/docs/default.nix +++ b/docs/default.nix @@ -12,6 +12,7 @@ inherit ( (lib.evalModules { + specialArgs = {inherit inputs;}; modules = import ../modules/modules.nix { inherit lib pkgs; diff --git a/flake.nix b/flake.nix index 6e716581..e958f91c 100644 --- a/flake.nix +++ b/flake.nix @@ -18,10 +18,7 @@ systems = import inputs.systems; imports = [ ./flake/templates - ./flake/apps.nix - ./flake/legacyPackages.nix - ./flake/overlays.nix ./flake/packages.nix ./flake/develop.nix ]; diff --git a/flake/blink/default.nix b/flake/blink/default.nix new file mode 100644 index 00000000..08c87073 --- /dev/null +++ b/flake/blink/default.nix @@ -0,0 +1,31 @@ +{ + rustPlatform, + fetchFromGitHub, + writeShellScriptBin, +}: +rustPlatform.buildRustPackage (finalAttrs: { + pname = "blink-cmp"; + version = "1.2.0"; + + src = fetchFromGitHub { + owner = "Saghen"; + repo = "blink.cmp"; + tag = "v${finalAttrs.version}"; + hash = "sha256-bKe8SSg1HPWE7b4iRQJwiOVCrvvgttuHCOIa4U/38AY="; + }; + + postInstall = '' + cp -r {lua,plugin} "$out" + mkdir -p "$out/target" + mv "$out/lib" "$out/target/release" + ''; + + cargoHash = "sha256-IDoDugtNWQovfSstbVMkKHLBXKa06lxRWmywu4zyS3M="; + useFetchCargoVendor = true; + + nativeBuildInputs = [ + (writeShellScriptBin "git" "exit 1") + ]; + + env.RUSTC_BOOTSTRAP = true; +}) diff --git a/flake/develop.nix b/flake/develop.nix index 71c13688..d92b8182 100644 --- a/flake/develop.nix +++ b/flake/develop.nix @@ -3,13 +3,14 @@ pkgs, config, self', + inputs', ... }: { devShells = { default = self'.devShells.lsp; nvim-nix = pkgs.mkShellNoCC {packages = [config.packages.nix];}; lsp = pkgs.mkShellNoCC { - packages = with pkgs; [nil statix deadnix alejandra npins]; + packages = with pkgs; [inputs'.nil.packages.default statix deadnix alejandra npins]; }; }; diff --git a/flake/legacyPackages.nix b/flake/legacyPackages.nix deleted file mode 100644 index 33aee0e3..00000000 --- a/flake/legacyPackages.nix +++ /dev/null @@ -1,35 +0,0 @@ -{ - inputs, - self, - ... -}: { - perSystem = { - system, - inputs', - ... - }: { - legacyPackages = import inputs.nixpkgs { - inherit system; - overlays = [ - inputs.self.overlays.default - - (final: prev: { - # Build nil from source to get most recent - # features as they are added. - nil = inputs'.nil.packages.default; - blink-cmp = let - pin = self.pins.blink-cmp; - in - final.callPackage ./legacyPackages/blink-cmp.nix { - inherit (pin) version; - src = prev.fetchFromGitHub { - inherit (pin.repository) owner repo; - rev = pin.revision; - sha256 = pin.hash; - }; - }; - }) - ]; - }; - }; -} diff --git a/flake/legacyPackages/blink-cmp.nix b/flake/legacyPackages/blink-cmp.nix deleted file mode 100644 index 60dce9de..00000000 --- a/flake/legacyPackages/blink-cmp.nix +++ /dev/null @@ -1,37 +0,0 @@ -{ - stdenv, - rustPlatform, - vimUtils, - gitMinimal, - src, - version, -}: let - blink-fuzzy-lib = rustPlatform.buildRustPackage { - pname = "blink-fuzzy-lib"; - inherit version src; - - # TODO: remove this if plugin stops using nightly rust - env.RUSTC_BOOTSTRAP = true; - - useFetchCargoVendor = true; - cargoHash = "sha256-IDoDugtNWQovfSstbVMkKHLBXKa06lxRWmywu4zyS3M="; - - nativeBuildInputs = [gitMinimal]; - }; -in - vimUtils.buildVimPlugin { - pname = "blink-cmp"; - inherit version src; - - # blink references a repro.lua which is placed outside the lua/ directory - doCheck = false; - preInstall = let - ext = stdenv.hostPlatform.extensions.sharedLibrary; - in '' - mkdir -p target/release - ln -s ${blink-fuzzy-lib}/lib/libblink_cmp_fuzzy${ext} target/release/libblink_cmp_fuzzy${ext} - ''; - - # Module for reproducing issues - nvimSkipModules = ["repro"]; - } diff --git a/flake/overlays.nix b/flake/overlays.nix deleted file mode 100644 index 5d0ff6e8..00000000 --- a/flake/overlays.nix +++ /dev/null @@ -1,19 +0,0 @@ -{ - pkgs, - lib, - ... -}: let - inherit (lib.nvim) neovimConfiguration; - - buildPkg = pkgs: modules: (neovimConfiguration {inherit pkgs modules;}).neovim; - - nixConfig = import ../configuration.nix false; - maximalConfig = import ../configuration.nix true; -in { - flake.overlays.default = final: _prev: { - inherit neovimConfiguration; - neovim-nix = buildPkg final [nixConfig]; - neovim-maximal = buildPkg final [maximalConfig]; - devPkg = buildPkg pkgs [nixConfig {config.vim.languages.html.enable = pkgs.lib.mkForce true;}]; - }; -} diff --git a/flake/packages.nix b/flake/packages.nix index 7abe5ec0..d6afbbf8 100644 --- a/flake/packages.nix +++ b/flake/packages.nix @@ -1,4 +1,4 @@ -{inputs, ...}: { +{inputs, ...} @ args: { perSystem = { config, pkgs, @@ -6,8 +6,15 @@ ... }: let docs = import ../docs {inherit pkgs inputs lib;}; + buildPkg = maximal: + (args.config.flake.lib.nvim.neovimConfiguration { + inherit pkgs; + modules = [(import ../configuration.nix maximal)]; + }).neovim; in { packages = { + blink-cmp = pkgs.callPackage ./blink {}; + inherit (docs.manual) htmlOpenTool; # Documentation docs = docs.manual.html; @@ -61,9 +68,9 @@ ''; # Exposed neovim configurations - nix = config.legacyPackages.neovim-nix; - maximal = config.legacyPackages.neovim-maximal; - default = config.legacyPackages.neovim-nix; + nix = buildPkg false; + maximal = buildPkg true; + default = config.packages.nix; }; }; } diff --git a/lib/default.nix b/lib/default.nix index 952278a8..c4388e82 100644 --- a/lib/default.nix +++ b/lib/default.nix @@ -4,7 +4,7 @@ lib, ... }: { - types = import ./types {inherit lib;}; + types = import ./types {inherit lib self;}; config = import ./config.nix {inherit lib;}; binds = import ./binds.nix {inherit lib;}; dag = import ./dag.nix {inherit lib;}; diff --git a/lib/types/default.nix b/lib/types/default.nix index c6239227..044a8221 100644 --- a/lib/types/default.nix +++ b/lib/types/default.nix @@ -1,6 +1,9 @@ -{lib}: let +{ + lib, + self, +}: let typesDag = import ./dag.nix {inherit lib;}; - typesPlugin = import ./plugins.nix {inherit lib;}; + typesPlugin = import ./plugins.nix {inherit lib self;}; typesLanguage = import ./languages.nix {inherit lib;}; customTypes = import ./custom.nix {inherit lib;}; in { diff --git a/lib/types/plugins.nix b/lib/types/plugins.nix index fc2bd083..4be39289 100644 --- a/lib/types/plugins.nix +++ b/lib/types/plugins.nix @@ -1,4 +1,7 @@ -{lib}: let +{ + lib, + self, +}: let inherit (lib.options) mkOption; inherit (lib.attrsets) attrNames mapAttrs' filterAttrs nameValuePair; inherit (lib.strings) hasPrefix removePrefix; @@ -12,7 +15,7 @@ mapAttrs' (n: v: nameValuePair (removePrefix prefix n) {src = v;}) (filterAttrs (n: _: hasPrefix prefix n) inputs); # Get the names of all npins - pluginInputNames = attrNames (lib.importJSON ../../npins/sources.json).pins; + pluginInputNames = ["blink-cmp"] ++ attrNames self.pins; # You can either use the name of the plugin or a package. pluginType = nullOr ( diff --git a/modules/plugins/languages/nix.nix b/modules/plugins/languages/nix.nix index 83022adf..aceee70d 100644 --- a/modules/plugins/languages/nix.nix +++ b/modules/plugins/languages/nix.nix @@ -2,6 +2,7 @@ config, pkgs, lib, + inputs, ... }: let inherit (builtins) attrNames; @@ -27,7 +28,7 @@ else ''{"${package}/bin/${defaultCmd}"}''; servers = { nil = { - package = pkgs.nil; + package = inputs.nil.packages.${pkgs.stdenv.system}.nil; internalFormatter = true; lspConfig = '' lspconfig.nil_ls.setup{ diff --git a/modules/wrapper/build/config.nix b/modules/wrapper/build/config.nix index 61ba1513..00ad2305 100644 --- a/modules/wrapper/build/config.nix +++ b/modules/wrapper/build/config.nix @@ -51,7 +51,7 @@ doCheck = false; }; - inherit (inputs.self.legacyPackages.${pkgs.stdenv.system}) blink-cmp; + inherit (inputs.self.packages.${pkgs.stdenv.system}) blink-cmp; }; buildConfigPlugins = plugins: diff --git a/npins/sources.json b/npins/sources.json index a2122460..8e82850a 100644 --- a/npins/sources.json +++ b/npins/sources.json @@ -39,22 +39,6 @@ "url": "https://github.com/rrethy/base16-nvim/archive/965160025d0facbe9caa863e5beef2a7a488e9d1.tar.gz", "hash": "02w1mn15gydma9canvqrlwf4l5z76s1vs01zanipwwflvwclsb8f" }, - "blink-cmp": { - "type": "GitRelease", - "repository": { - "type": "GitHub", - "owner": "saghen", - "repo": "blink.cmp" - }, - "pre_releases": false, - "version_upper_bound": null, - "release_prefix": null, - "submodules": false, - "version": "v1.2.0", - "revision": "d72a826e1961e14f91d8867d10a27a89c5cfe748", - "url": "https://api.github.com/repos/saghen/blink.cmp/tarball/v1.2.0", - "hash": "01phyx7y26p2123xpdp0zfp45rc8f014a8myxn2ga71m514vr9vc" - }, "blink-cmp-spell": { "type": "Git", "repository": { From e9e57caa1806f0693d4888c98b077f65ca267913 Mon Sep 17 00:00:00 2001 From: Noah765 Date: Mon, 5 May 2025 09:46:49 +0200 Subject: [PATCH 14/35] languages/dart: fix infinite recursion The default value of the flutter-tools.enable option conflicted with the lsp.enable definition, which was conditionally defined based on flutter-tools.enable. However, the lsp.enable definition isn't required for flutter-tools' LSP functionality, so it can be removed. --- modules/plugins/languages/dart.nix | 2 -- 1 file changed, 2 deletions(-) diff --git a/modules/plugins/languages/dart.nix b/modules/plugins/languages/dart.nix index 9cbd0783..c2a1810d 100644 --- a/modules/plugins/languages/dart.nix +++ b/modules/plugins/languages/dart.nix @@ -143,8 +143,6 @@ in { }) (mkIf ftcfg.enable { - lsp.enable = true; - startPlugins = [ ( if ftcfg.enableNoResolvePatch From 7d191a350df23f2cb3f9110105d3b787559f9479 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Mon, 5 May 2025 10:45:33 +0300 Subject: [PATCH 15/35] ci: backport & labeler config --- .github/labels.yml | 55 ++++++++++++++++++++++++++++++++++ .github/workflows/backport.yml | 33 ++++++++++++++++++++ .github/workflows/labeler.yml | 21 +++++++++++++ 3 files changed, 109 insertions(+) create mode 100644 .github/labels.yml create mode 100644 .github/workflows/backport.yml create mode 100644 .github/workflows/labeler.yml diff --git a/.github/labels.yml b/.github/labels.yml new file mode 100644 index 00000000..e799004f --- /dev/null +++ b/.github/labels.yml @@ -0,0 +1,55 @@ +# This file is used by .github/workflows/labels.yml +"topic: plugins": + - any: + - changed-files: + - any-glob-to-any-file: + - modules/plugins/**/* + +"topic: modules": + - any: + - changed-files: + - any-glob-to-any-file: + - modules/**/* + +"topic: dependencies": + - any: + - changed-files: + - any-glob-to-any-file: + - npins + - flake.lock + +"topic: CI": + - any: + - changed-files: + - any-glob-to-any-file: + - .github/workflows/*.yml + - .github/typos.toml + . .github/dependabot.yml + +"topic: meta": + - any: + - changed-files: + - any-glob-to-any-file: + - .github/CODEOWNERS + - LICENSE + - .github/README.md + - .github/funding.yml + - .github/assets + - .github/*_TEMPLATE + - .gitignore + - .editorconfig + - release.json + +"topic: documentation": + - any: + - changed-files: + - any-glob-to-any-file: + - docs/**/* + - .github/CONTRIBUTING.md + - .github/README.md +"topic: packaging": + - any: + - changed-files: + - any-glob-to-any-file: + - flake.nix + - flake/packages.nix diff --git a/.github/workflows/backport.yml b/.github/workflows/backport.yml new file mode 100644 index 00000000..0a558fb8 --- /dev/null +++ b/.github/workflows/backport.yml @@ -0,0 +1,33 @@ +name: Backport PR on Label + +on: + pull_request_target: + types: + - labeled + +# Permissions needed for the korthout/backport-action to create branches and PRs +permissions: + contents: write + pull-requests: write + +jobs: + backport: + name: Create Backport PR + runs-on: ubuntu-latest + if: | + github.event.pull_request.merged == true && startsWith(github.event.label.name, 'backport-') + steps: + - uses: actions/checkout@v4 + with: + ref: ${{ github.event.pull_request.head.sha }} + token: ${{ steps.app-token.outputs.token }} + + - name: Backport Action + uses: korthout/backport-action@v3 + with: + # Regex pattern for labels that should trigger a backport AND extracts the target branch + # from the name (e.g. v0.x or v0.x.y; we use zerover). This action will ONLY proceed if + # the label that triggered the workflow fully matches this pattern. + # Example matching labels: "backport-v0.1", "backport-v0.10.1" + # Example non-matching labels: "backport-foo", "backport-v1.0" + label_pattern: '^backport-(v0\.\d+(\.\d+)?)$' diff --git a/.github/workflows/labeler.yml b/.github/workflows/labeler.yml new file mode 100644 index 00000000..96d5c7be --- /dev/null +++ b/.github/workflows/labeler.yml @@ -0,0 +1,21 @@ +name: "Label PR" + +on: + pull_request_target: + types: [edited, opened, synchronize, reopened] + +permissions: + contents: read + pull-requests: write + +jobs: + labels: + name: "Label PR" + runs-on: ubuntu-latest + if: "!contains(github.event.pull_request.title, '[skip ci]')" + steps: + - uses: actions/labeler@v5 + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + configuration-path: .github/labeler.yml + sync-labels: true From 5221dc27ddcabaca9eb54f20577b1de955e325ee Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Mon, 5 May 2025 10:58:58 +0300 Subject: [PATCH 16/35] ci: fix labeler config path --- .github/workflows/labeler.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/labeler.yml b/.github/workflows/labeler.yml index 96d5c7be..fc2e0d65 100644 --- a/.github/workflows/labeler.yml +++ b/.github/workflows/labeler.yml @@ -17,5 +17,5 @@ jobs: - uses: actions/labeler@v5 with: repo-token: ${{ secrets.GITHUB_TOKEN }} - configuration-path: .github/labeler.yml + configuration-path: .github/labels.yml sync-labels: true From 3c672f64fc2e7a19aa33000733b5fc84e29f41b8 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Fri, 7 Mar 2025 16:20:46 +0300 Subject: [PATCH 17/35] docs/custom-plugins: avoid using `with` scopes in the manual --- .../configuring/custom-plugins/configuring.md | 20 ++++++++++--------- .../custom-plugins/non-lazy-method.md | 8 ++++---- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/docs/manual/configuring/custom-plugins/configuring.md b/docs/manual/configuring/custom-plugins/configuring.md index 5106d29b..42af11be 100644 --- a/docs/manual/configuring/custom-plugins/configuring.md +++ b/docs/manual/configuring/custom-plugins/configuring.md @@ -32,16 +32,18 @@ that the `extraPlugins` option has its own DAG scope), and the its setup code respectively. For example: ```nix -config.vim.extraPlugins = with pkgs.vimPlugins; { - aerial = { - package = aerial-nvim; - setup = "require('aerial').setup {}"; - }; +{pkgs, ...}: { + config.vim.extraPlugins = { + aerial = { + package = pkgs.vimPlugins.aerial-nvim; + setup = "require('aerial').setup {}"; + }; - harpoon = { - package = harpoon; - setup = "require('harpoon').setup {}"; - after = ["aerial"]; # place harpoon configuration after aerial + harpoon = { + package = pkgs.vimPlugins.harpoon; + setup = "require('harpoon').setup {}"; + after = ["aerial"]; # place harpoon configuration after aerial + }; }; } ``` diff --git a/docs/manual/configuring/custom-plugins/non-lazy-method.md b/docs/manual/configuring/custom-plugins/non-lazy-method.md index 351af2eb..d8477283 100644 --- a/docs/manual/configuring/custom-plugins/non-lazy-method.md +++ b/docs/manual/configuring/custom-plugins/non-lazy-method.md @@ -5,10 +5,10 @@ under `vim.extraPlugins`. Instead of using DAGs exposed by the library, you may use the extra plugin module as follows: ```nix -{ - config.vim.extraPlugins = with pkgs.vimPlugins; { +{pkgs, ...}: { + config.vim.extraPlugins = { aerial = { - package = aerial-nvim; + package = pkgs.vimPlugins.aerial-nvim; setup = '' require('aerial').setup { -- some lua configuration here @@ -17,7 +17,7 @@ use the extra plugin module as follows: }; harpoon = { - package = harpoon; + package = pkgs.vimPlugins.harpoon; setup = "require('harpoon').setup {}"; after = ["aerial"]; }; From 37750d9befcff9ee621c1cc15a8f5fc2d0f5133b Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Wed, 12 Mar 2025 03:53:16 +0300 Subject: [PATCH 18/35] docs/manual: document building plugins from source --- docs/manual/tips.md | 3 +- docs/manual/tips/plugin-sources.md | 131 +++++++++++++++++++++++++++++ 2 files changed, 133 insertions(+), 1 deletion(-) create mode 100644 docs/manual/tips/plugin-sources.md diff --git a/docs/manual/tips.md b/docs/manual/tips.md index 6e6dc9c2..f52cbca2 100644 --- a/docs/manual/tips.md +++ b/docs/manual/tips.md @@ -1,7 +1,8 @@ # Helpful Tips {#ch-helpful-tips} ```{=include=} chapters -tips/pure-lua-config.md tips/debugging-nvf.md tips/offline-docs.md +tips/pure-lua-config.md +tips/plugin-sources.md ``` diff --git a/docs/manual/tips/plugin-sources.md b/docs/manual/tips/plugin-sources.md new file mode 100644 index 00000000..7cf6a470 --- /dev/null +++ b/docs/manual/tips/plugin-sources.md @@ -0,0 +1,131 @@ +# Adding Plugins From Different Sources {#sec-plugin-sources} + +**nvf** attempts to avoid depending on Nixpkgs for Neovim plugins. For the most +part, this is accomplished by defining each plugin's source and building them +from source. + +[npins]: https://github.com/andir/npins + +To define plugin sources, we use [npins] and pin each plugin source using +builtin fetchers. You are not bound by this restriction. In your own +configuration, any kind of fetcher or plugin source is fine. + +## Nixpkgs & Friends {#ch-plugins-from-nixpkgs} + +`vim.startPlugins` and `vim.optPlugins` options take either a **string**, in +which case a plugin from nvf's internal plugins registry will be used, or a +**package**. If your plugin does not require any setup, or ordering for it s +configuration, then it is possible to add it to `vim.startPlugins` to load it on +startup. + +```nix +{pkgs, ...}: { + # Aerial does require some setup. In the case you pass a plugin that *does* + # require manual setup, then you must also call the setup function. + vim.startPlugins = [pkgs.vimPlugins.aerial-nvim]; +} +``` + +[`vim.extraPlugins`]: https://notashelf.github.io/nvf/options.html#opt-vim.extraPlugins + +This will fetch aerial.nvim from nixpkgs, and add it to Neovim's runtime path to +be loaded manually. Although for plugins that require manual setup, you are +encouraged to use [`vim.extraPlugins`]. + +```nix +{ + vim.extraPlugins = { + aerial = { + package = pkgs.vimPlugins.aerial-nvim; + setup = "require('aerial').setup {}"; + }; + }; +} +``` + +[custom plugins section]: https://notashelf.github.io/nvf/index.xhtml#ch-custom-plugins + +More details on the extraPlugins API is documented in the +[custom plugins section]. + +## Building Your Own Plugins {#ch-plugins-from-source} + +In the case a plugin is not available in Nixpkgs, or the Nixpkgs package is +outdated (or, more likely, broken) it is possible to build the plugins from +source using a tool, such as [npins]. You may also use your _flake inputs_ as +sources. + +Example using plugin inputs: + +```nix +{ + # In your flake.nix + inputs = { + aerial-nvim = { + url = "github:stevearc/aerial.nvim" + flake = false; + }; + }; + + # Make sure that 'inputs' is properly propagated into Nvf, for example, through + # specialArgs. + outputs = { ... }; +} +``` + +In the case, you may use the input directly for the plugin's source attribute in +`buildVimPlugin`. + +```nix +# Make sure that 'inputs' is properly propagated! It will be missing otherwise +# and the resulting errors might be too obscure. +{inputs, ...}: let + aerial-from-source = pkgs.vimUtils.buildVimPlugin { + name = "aerial-nvim"; + src = inputs.aerial-nvim; + }; +in { + vim.extraPlugins = { + aerial = { + package = aerial-from-source; + setup = "require('aerial').setup {}"; + }; + }; +} +``` + +Alternatively, if you do not want to keep track of the source using flake inputs +or npins, you may call `fetchFromGitHub` (or other fetchers) directly. An +example would look like this. + +```nix +regexplainer = buildVimPlugin { + name = "nvim-regexplainer"; + src = fetchFromGitHub { + owner = "bennypowers"; + repo = "nvim-regexplainer"; + rev = "4250c8f3c1307876384e70eeedde5149249e154f"; + hash = "sha256-15DLbKtOgUPq4DcF71jFYu31faDn52k3P1x47GL3+b0="; + }; + + # The 'buildVimPlugin' imposes some "require checks" on all plugins build from + # source. Failing tests, if they are not relevant, can be disabled using the + # 'nvimSkipModule' argument to the 'buildVimPlugin' function. + nvimSkipModule = [ + "regexplainer" + "regexplainer.buffers.init" + "regexplainer.buffers.popup" + "regexplainer.buffers.register" + "regexplainer.buffers.shared" + "regexplainer.buffers.split" + "regexplainer.component.descriptions" + "regexplainer.component.init" + "regexplainer.renderers.narrative.init" + "regexplainer.renderers.narrative.narrative" + "regexplainer.renderers.init" + "regexplainer.utils.defer" + "regexplainer.utils.init" + "regexplainer.utils.treesitter" + ]; +} +``` From f1d72cf0764db282a937d756b9a027978ae96e8f Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Mon, 5 May 2025 14:57:32 +0300 Subject: [PATCH 19/35] docs: clarify wording; add examples and remove redundancies --- docs/manual/configuring.md | 11 ++ docs/manual/configuring/autocmds.md | 119 ++++++++++++++++++ docs/manual/configuring/custom-package.md | 4 +- docs/manual/configuring/custom-plugins.md | 35 ++++-- .../configuring/custom-plugins/configuring.md | 46 ++++--- .../configuring/custom-plugins/lazy-method.md | 13 +- .../custom-plugins/legacy-method.md | 29 +++-- .../custom-plugins/non-lazy-method.md | 9 +- docs/manual/configuring/languages/lsp.md | 19 +-- docs/manual/default-configs.md | 10 -- docs/manual/default-configs/maximal.md | 11 -- docs/manual/default-configs/nix.md | 9 -- docs/manual/manual.md | 1 - docs/manual/tips.md | 6 + docs/manual/try-it-out.md | 30 ++++- 15 files changed, 262 insertions(+), 90 deletions(-) create mode 100644 docs/manual/configuring/autocmds.md delete mode 100644 docs/manual/default-configs.md delete mode 100644 docs/manual/default-configs/maximal.md delete mode 100644 docs/manual/default-configs/nix.md diff --git a/docs/manual/configuring.md b/docs/manual/configuring.md index f891c7a6..28c7e66a 100644 --- a/docs/manual/configuring.md +++ b/docs/manual/configuring.md @@ -1,5 +1,15 @@ # Configuring nvf {#ch-configuring} +[helpful tips section]: #ch-helpful-tips + +nvf allows for _very_ extensive configuration in Neovim through the Nix module +interface. The below chapters describe several of the options exposed in nvf for +your convenience. You might also be interested in the [helpful tips section] for +more advanced or unusual configuration options supported by nvf. + +Note that this section does not cover module _options_. For an overview of all +module options provided by nvf, please visit the [appendix](/options.html) + ```{=include=} chapters configuring/custom-package.md configuring/custom-plugins.md @@ -7,4 +17,5 @@ configuring/overriding-plugins.md configuring/languages.md configuring/dags.md configuring/dag-entries.md +configuring/autocmds.md ``` diff --git a/docs/manual/configuring/autocmds.md b/docs/manual/configuring/autocmds.md new file mode 100644 index 00000000..be10e726 --- /dev/null +++ b/docs/manual/configuring/autocmds.md @@ -0,0 +1,119 @@ +# Autocommands and Autogroups {#ch-autocmds-augroups} + +This module allows you to declaratively configure Neovim autocommands and +autogroups within your Nix configuration. + +## Autogroups (`vim.augroups`) {#sec-vim-augroups} + +Autogroups (`augroup`) organize related autocommands. This allows them to be +managed collectively, such as clearing them all at once to prevent duplicates. +Each entry in the list is a submodule with the following options: + +| Option | Type | Default | Description | Example | +| :------- | :----- | :------ | :--------------------------------------------------------------------------------------------------- | :---------------- | +| `enable` | `bool` | `true` | Enables or disables this autogroup definition. | `true` | +| `name` | `str` | _None_ | **Required.** The unique name for the autogroup. | `"MyFormatGroup"` | +| `clear` | `bool` | `true` | Clears any existing autocommands within this group before adding new ones defined in `vim.autocmds`. | `true` | + +**Example:** + +```nix +{ + vim.augroups = [ + { + name = "MyCustomAuGroup"; + clear = true; # Clear previous autocommands in this group on reload + } + { + name = "Formatting"; + # clear defaults to true + } + ]; +} +``` + +## Autocommands (`vim.autocmds`) {#sec-vim-autocmds} + +Autocommands (`autocmd`) trigger actions based on events happening within Neovim +(e.g., saving a file, entering a buffer). Each entry in the list is a submodule +with the following options: + +| Option | Type | Default | Description | Example | +| :--------- | :-------------------- | :------ | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :--------------------------------------------------------------- | +| `enable` | `bool` | `true` | Enables or disables this autocommand definition. | `true` | +| `event` | `nullOr (listOf str)` | `null` | **Required.** List of Neovim events that trigger this autocommand (e.g., `BufWritePre`, `FileType`). | `[ "BufWritePre" ]` | +| `pattern` | `nullOr (listOf str)` | `null` | List of file patterns (globs) to match against (e.g., `*.py`, `*`). If `null`, matches all files for the given event. | `[ "*.lua", "*.nix" ]` | +| `callback` | `nullOr luaInline` | `null` | A Lua function to execute when the event triggers. Use `lib.nvim.types.luaInline` or `lib.options.literalExpression "mkLuaInline '''...'''"`. **Cannot be used with `command`.** | `lib.nvim.types.luaInline "function() print('File saved!') end"` | +| `command` | `nullOr str` | `null` | A Vimscript command to execute when the event triggers. **Cannot be used with `callback`.** | `"echo 'File saved!'"` | +| `group` | `nullOr str` | `null` | The name of an `augroup` (defined in `vim.augroups`) to associate this autocommand with. | `"MyCustomAuGroup"` | +| `desc` | `nullOr str` | `null` | A description for the autocommand (useful for introspection). | `"Format buffer on save"` | +| `once` | `bool` | `false` | If `true`, the autocommand runs only once and then automatically removes itself. | `false` | +| `nested` | `bool` | `false` | If `true`, allows this autocommand to trigger other autocommands. | `false` | + +:::{.warning} + +You cannot define both `callback` (for Lua functions) and `command` (for +Vimscript) for the same autocommand. Choose one. + +::: + +**Examples:** + +```nix +{ lib, ... }: +{ + vim.augroups = [ { name = "UserSetup"; } ]; + + vim.autocmds = [ + # Example 1: Using a Lua callback + { + event = [ "BufWritePost" ]; + pattern = [ "*.lua" ]; + group = "UserSetup"; + desc = "Notify after saving Lua file"; + callback = lib.nvim.types.luaInline '' + function() + vim.notify("Lua file saved!", vim.log.levels.INFO) + end + ''; + } + + # Example 2: Using a Vim command + { + event = [ "FileType" ]; + pattern = [ "markdown" ]; + group = "UserSetup"; + desc = "Set spellcheck for Markdown"; + command = "setlocal spell"; + } + + # Example 3: Autocommand without a specific group + { + event = [ "BufEnter" ]; + pattern = [ "*.log" ]; + desc = "Disable line numbers in log files"; + command = "setlocal nonumber"; + # No 'group' specified + } + + # Example 4: Using Lua for callback + { + event = [ "BufWinEnter" ]; + pattern = [ "*" ]; + desc = "Simple greeting on entering a buffer window"; + callback = lib.generators.mkLuaInline '' + function(args) + print("Entered buffer: " .. args.buf) + end + ''; + + # Run only once per session trigger + once = true; + } + ]; +} +``` + +These definitions are automatically translated into the necessary Lua code to +configure `vim.api.nvim_create_augroup` and `vim.api.nvim_create_autocmd` when +Neovim starts. diff --git a/docs/manual/configuring/custom-package.md b/docs/manual/configuring/custom-package.md index 51d996b6..3e9e324a 100644 --- a/docs/manual/configuring/custom-package.md +++ b/docs/manual/configuring/custom-package.md @@ -1,12 +1,12 @@ # Custom Neovim Package {#ch-custom-package} As of v0.5, you may now specify the Neovim package that will be wrapped with -your configuration. This is done with the `vim.package` option. +your configuration. This is done with the [](#opt-vim.package) option. ```nix {inputs, pkgs, ...}: { # using the neovim-nightly overlay - vim.package = inputs.neovim-overlay.packages.${pkgs.system}.neovim; + vim.package = inputs.neovim-overlay.packages.${pkgs.stdenv.system}.neovim; } ``` diff --git a/docs/manual/configuring/custom-plugins.md b/docs/manual/configuring/custom-plugins.md index c621e03c..bf986a0f 100644 --- a/docs/manual/configuring/custom-plugins.md +++ b/docs/manual/configuring/custom-plugins.md @@ -1,22 +1,33 @@ # Custom Plugins {#ch-custom-plugins} -**nvf**, by default, exposes a wide variety of plugins as module options for -your convenience and bundles necessary dependencies into **nvf**'s runtime. In -case a plugin is not available in **nvf**, you may consider making a pull -request to **nvf** to include it as a module or you may add it to your -configuration locally. +**nvf** exposes a very wide variety of plugins by default, which are consumed by +module options. This is done for your convenience, and to bundle all necessary +dependencies into **nvf**'s runtime with full control of versioning, testing and +dependencies. In the case a plugin you need is _not_ available, you may consider +making a pull request to add the package you're looking for, or you may add it +to your configuration locally. The below section describes how new plugins may +be added to the user's configuration. ## Adding Plugins {#ch-adding-plugins} -There are multiple ways of adding custom plugins to your **nvf** configuration. +Per **nvf**'s design choices, there are several ways of adding custom plugins to +your configuration as you need them. As we aim for extensive configuration, it +is possible to add custom plugins (from nixpkgs, pinning tools, flake inputs, +etc.) to your Neovim configuration before they are even implemented in **nvf** +as a module. -You can use custom plugins, before they are implemented in the flake. To add a -plugin to the runtime, you need to add it to the [](#opt-vim.startPlugins) list -in your configuration. +:::{.info} -Adding a plugin to `startPlugins` will not allow you to configure the plugin -that you have added, but **nvf** provides multiple ways of configuring any custom -plugins that you might have added to your configuration. +To add a plugin to your runtime, you will need to add it to +[](#opt-vim.startPlugins) list in your configuration. This is akin to cloning a +plugin to `~/.config/nvim`, but they are only ever placed in the Nix store and +never exposed to the outside world for purity and full isolation. + +::: + +As you would configure a cloned plugin, you must configure the new plugins that +you've added to `startPlugins.` **nvf** provides multiple ways of configuring +any custom plugins that you might have added to your configuration. ```{=include=} sections custom-plugins/configuring.md diff --git a/docs/manual/configuring/custom-plugins/configuring.md b/docs/manual/configuring/custom-plugins/configuring.md index 42af11be..a4b3ce19 100644 --- a/docs/manual/configuring/custom-plugins/configuring.md +++ b/docs/manual/configuring/custom-plugins/configuring.md @@ -1,13 +1,20 @@ # Configuring {#sec-configuring-plugins} Just making the plugin to your Neovim configuration available might not always -be enough. In that case, you can write custom lua config using either -`config.vim.lazy.plugins.*.setupOpts` `config.vim.extraPlugins.*.setup` or -`config.vim.luaConfigRC`. +be enough., for example, if the plugin requires a setup table. In that case, you +can write custom Lua configuration using one of -The first option uses an extended version of `lz.n`'s PluginSpec. `setupModule` -and `setupOpt` can be used if the plugin uses a `require('module').setup(...)` -pattern. Otherwise, the `before` and `after` hooks should do what you need. +- `config.vim.lazy.plugins.*.setupOpts` +- `config.vim.extraPlugins.*.setup` +- `config.vim.luaConfigRC`. + +## Lazy Plugins {#ch-vim-lazy-plugins} + +`config.vim.lazy.plugins.*.setupOpts` is useful for lazy-loading plugins, and +uses an extended version of `lz.n's` `PluginSpec` to expose a familiar +interface. `setupModule` and `setupOpt` can be used if the plugin uses a +`require('module').setup(...)` pattern. Otherwise, the `before` and `after` +hooks should do what you need. ```nix { @@ -25,7 +32,9 @@ pattern. Otherwise, the `before` and `after` hooks should do what you need. } ``` -The second option uses an attribute set, which maps DAG section names to a +## Standard API {#ch-vim-extra-plugins} + +`vim.extraPlugins` uses an attribute set, which maps DAG section names to a custom type, which has the fields `package`, `after`, `setup`. They allow you to set the package of the plugin, the sections its setup code should be after (note that the `extraPlugins` option has its own DAG scope), and the its setup code @@ -48,29 +57,36 @@ respectively. For example: } ``` -The third option also uses an attribute set, but this one is resolved as a DAG +### Setup using luaConfigRC {#setup-using-luaconfigrc} + +`vim.luaConfigRC` also uses an attribute set, but this one is resolved as a DAG directly. The attribute names denote the section names, and the values lua code. For example: ```nix { - # this will create an "aquarium" section in your init.lua with the contents of your custom config - # which will be *appended* to the rest of your configuration, inside your init.vim + # This will create a section called "aquarium" in the 'init.lua' with the + # contents of your custom configuration. By default 'entryAnywhere' is implied + # in DAGs, so this will be inserted to an arbitrary position. In the case you + # wish to control the position of this section with more precision, please + # look into the DAGs section of the manual. config.vim.luaConfigRC.aquarium = "vim.cmd('colorscheme aquiarum')"; } ``` +[DAG system]: #ch-using-dags +[DAG section]: #ch-dag-entries ::: {.note} -One of the greatest strengths of nvf is the ability to order -snippets of configuration via the DAG system. It will allow specifying positions -of individual sections of configuration as needed. nvf provides helper functions +One of the **greatest strengths** of **nvf** is the ability to order +configuration snippets precisely using the [DAG system]. DAGs +are a very powerful mechanism that allows specifying positions +of individual sections of configuration as needed. We provide helper functions in the extended library, usually under `inputs.nvf.lib.nvim.dag` that you may use. -Please refer to the [DAG section](#ch-dag-entries) in the nvf manual +Please refer to the [DAG section] in the nvf manual to find out more about the DAG system. ::: - diff --git a/docs/manual/configuring/custom-plugins/lazy-method.md b/docs/manual/configuring/custom-plugins/lazy-method.md index ae766535..c16966b8 100644 --- a/docs/manual/configuring/custom-plugins/lazy-method.md +++ b/docs/manual/configuring/custom-plugins/lazy-method.md @@ -1,7 +1,8 @@ # Lazy Method {#sec-lazy-method} -As of version **0.7**, we exposed an API for configuring lazy-loaded plugins via -`lz.n` and `lzn-auto-require`. +As of version **0.7**, an API is exposed to allow configuring lazy-loaded +plugins via `lz.n` and `lzn-auto-require`. Below is a comprehensive example of +how it may be loaded to lazy-load an arbitrary plugin. ```nix { @@ -41,7 +42,8 @@ As of version **0.7**, we exposed an API for configuring lazy-loaded plugins via ## LazyFile event {#sec-lazyfile-event} -You can use the `LazyFile` user event to load a plugin when a file is opened: +**nvf** re-implements `LazyFile` as a familiar user event to load a plugin when +a file is opened: ```nix { @@ -55,5 +57,6 @@ You can use the `LazyFile` user event to load a plugin when a file is opened: } ``` -You can consider `LazyFile` as an alias to -`["BufReadPost" "BufNewFile" "BufWritePre"]` +You can consider the `LazyFile` event as an alias to the combination of +`"BufReadPost"`, `"BufNewFile"` and `"BufWritePre"`, i.e., a list containing all +three of those events: `["BufReadPost" "BufNewFile" "BufWritePre"]` diff --git a/docs/manual/configuring/custom-plugins/legacy-method.md b/docs/manual/configuring/custom-plugins/legacy-method.md index b2bddf43..6c399aaf 100644 --- a/docs/manual/configuring/custom-plugins/legacy-method.md +++ b/docs/manual/configuring/custom-plugins/legacy-method.md @@ -1,26 +1,31 @@ # Legacy Method {#sec-legacy-method} -Prior to version v0.5, the method of adding new plugins was adding the plugin -package to `vim.startPlugins` and add its configuration as a DAG under one of -`vim.configRC` or `vim.luaConfigRC`. Users who have not yet updated to 0.5, or -prefer a more hands-on approach may use the old method where the load order of -the plugins is determined by DAGs. +Prior to version **0.5**, the method of adding new plugins was adding the plugin +package to [](#opt-vim.startPlugins) and adding its configuration as a DAG under +one of `vim.configRC` or [](#opt-vim.luaConfigRC). While `configRC` has been +deprecated, users who have not yet updated to 0.5 or those who prefer a more +hands-on approach may choose to use the old method where the load order of the +plugins is explicitly determined by DAGs without internal abstractions. -## Adding plugins {#sec-adding-plugins} +## Adding New Plugins {#sec-adding-new-plugins} -To add a plugin not available in nvf as a module to your configuration, you may -add it to [](#opt-vim.startPlugins) in order to make it available to Neovim at -runtime. +To add a plugin not available in **nvf** as a module to your configuration using +the legacy method, you must add it to [](#opt-vim.startPlugins) in order to make +it available to Neovim at runtime. ```nix {pkgs, ...}: { # Add a Neovim plugin from Nixpkgs to the runtime. + # This does not need to come explicitly from packages. 'vim.startPlugins' + # takes a list of *string* (to load internal plugins) or *package* to load + # a Neovim package from any source. vim.startPlugins = [pkgs.vimPlugins.aerial-nvim]; } ``` -And to configure the added plugin, you can use the `luaConfigRC` option to -provide configuration as a DAG using the **nvf** extended library. +Once the package is available in Neovim's runtime, you may use the `luaConfigRC` +option to provide configuration as a DAG using the **nvf** extended library in +order to configure the added plugin, ```nix {inputs, ...}: let @@ -29,6 +34,8 @@ provide configuration as a DAG using the **nvf** extended library. # to specialArgs, the 'inputs' prefix may be omitted. inherit (inputs.nvf.lib.nvim.dag) entryAnywhere; in { + # luaConfigRC takes Lua configuration verbatim and inserts it at an arbitrary + # position by default or if 'entryAnywhere' is used. vim.luaConfigRC.aerial-nvim= entryAnywhere '' require('aerial').setup { -- your configuration here diff --git a/docs/manual/configuring/custom-plugins/non-lazy-method.md b/docs/manual/configuring/custom-plugins/non-lazy-method.md index d8477283..24ef7688 100644 --- a/docs/manual/configuring/custom-plugins/non-lazy-method.md +++ b/docs/manual/configuring/custom-plugins/non-lazy-method.md @@ -1,8 +1,9 @@ # Non-lazy Method {#sec-non-lazy-method} -As of version **0.5**, we have a more extensive API for configuring plugins, -under `vim.extraPlugins`. Instead of using DAGs exposed by the library, you may -use the extra plugin module as follows: +As of version **0.5**, we have a more extensive API for configuring plugins that +should be preferred over the legacy method. This API is available as +[](#opt-vim.extraPlugins). Instead of using DAGs exposed by the library +_directly_, you may use the extra plugin module as follows: ```nix {pkgs, ...}: { @@ -24,3 +25,5 @@ use the extra plugin module as follows: }; } ``` + +This provides a level of abstraction over the DAG system for faster iteration. diff --git a/docs/manual/configuring/languages/lsp.md b/docs/manual/configuring/languages/lsp.md index 6d6ed5bc..2ddc08b5 100644 --- a/docs/manual/configuring/languages/lsp.md +++ b/docs/manual/configuring/languages/lsp.md @@ -1,17 +1,22 @@ # LSP Custom Packages/Command {#sec-languages-custom-lsp-packages} -In any of the `opt.languages..lsp.package` options you can provide -your own LSP package, or provide the command to launch the language server, as a -list of strings. You can use this to skip automatic installation of a language -server, and instead use the one found in your `$PATH` during runtime, for -example: +One of the strengths of **nvf** is convenient aliases to quickly configure LSP +servers through the Nix module system. By default the LSP packages for relevant +language modules will be pulled into the closure. If this is not desirable, you +may provide **a custom LSP package** (e.g., a Bash script that calls a command) +or **a list of strings** to be interpreted as the command to launch the language +server. By using a list of strings, you can use this to skip automatic +installation of a language server, and instead use the one found in your `$PATH` +during runtime, for example: ```nix vim.languages.java = { lsp = { enable = true; - # this expects jdt-language-server to be in your PATH - # or in `vim.extraPackages` + + # This expects 'jdt-language-server' to be in your PATH or in + # 'vim.extraPackages.' There are no additional checks performed to see + # if the command provided is valid. package = ["jdt-language-server" "-data" "~/.cache/jdtls/workspace"]; }; } diff --git a/docs/manual/default-configs.md b/docs/manual/default-configs.md deleted file mode 100644 index 96ffa81a..00000000 --- a/docs/manual/default-configs.md +++ /dev/null @@ -1,10 +0,0 @@ -# Default Configs {#ch-default-configs} - -While you can configure **nvf** yourself using the builder, you can also use the -pre-built configs that are available. Here are a few default configurations you -can use. - -```{=include=} chapters -default-configs/maximal.md -default-configs/nix.md -``` diff --git a/docs/manual/default-configs/maximal.md b/docs/manual/default-configs/maximal.md deleted file mode 100644 index e1f5273e..00000000 --- a/docs/manual/default-configs/maximal.md +++ /dev/null @@ -1,11 +0,0 @@ -# Maximal {#sec-default-maximal} - -```bash -$ nix run github:notashelf/nvf#maximal -- test.nix -``` - -It is the same fully configured Neovim as with the [Nix](#sec-default-nix) -configuration, but with every supported language enabled. - -::: {.note} Running the maximal config will download _a lot_ of packages as it -is downloading language servers, formatters, and more. ::: diff --git a/docs/manual/default-configs/nix.md b/docs/manual/default-configs/nix.md deleted file mode 100644 index 5210ef39..00000000 --- a/docs/manual/default-configs/nix.md +++ /dev/null @@ -1,9 +0,0 @@ -# Nix {#sec-default-nix} - -```bash -$ nix run github:notashelf/nvf#nix test.nix -``` - -Enables all the of Neovim plugins, with language support for specifically Nix. -This lets you see what a fully configured neovim setup looks like without -downloading a whole bunch of language servers and associated tools. diff --git a/docs/manual/manual.md b/docs/manual/manual.md index fd225766..18932896 100644 --- a/docs/manual/manual.md +++ b/docs/manual/manual.md @@ -8,7 +8,6 @@ try-it-out.md ``` ```{=include=} parts -default-configs.md installation.md configuring.md tips.md diff --git a/docs/manual/tips.md b/docs/manual/tips.md index f52cbca2..01bddc40 100644 --- a/docs/manual/tips.md +++ b/docs/manual/tips.md @@ -1,5 +1,11 @@ # Helpful Tips {#ch-helpful-tips} +This section provides helpful tips that may be considered "unorthodox" or "too +advanced" for some users. We will cover basic debugging steps, offline +documentation, configuring **nvf** with pure Lua and using custom plugin sources +in **nvf** in this section. For general configuration tips, please see previous +chapters. + ```{=include=} chapters tips/debugging-nvf.md tips/offline-docs.md diff --git a/docs/manual/try-it-out.md b/docs/manual/try-it-out.md index 8244c2b7..8714be80 100644 --- a/docs/manual/try-it-out.md +++ b/docs/manual/try-it-out.md @@ -26,7 +26,12 @@ $ nix run github:notashelf/nvf#nix $ nix run github:notashelf/nvf#maximal ``` -### Available Configs {#sec-available-configs} +### Available Configurations {#sec-available-configs} + +:::{.info} + +The below configurations are provided for demonstration purposes, and are +**not** designed to be installed as is. You may #### Nix {#sec-configs-nix} @@ -34,15 +39,32 @@ $ nix run github:notashelf/nvf#maximal a set of visual and functional plugins. By running `nix run .#`, which is the default package, you will build Neovim with this config. +```bash +$ nix run github:notashelf/nvf#nix test.nix +``` + +This command will start Neovim with some opinionated plugin configurations, and +is designed specifically for Nix. the `nix` configuration lets you see how a +fully configured Neovim setup _might_ look like without downloading too many +packages or shell utilities. + #### Maximal {#sec-configs-maximal} `Maximal` is the ultimate configuration that will enable support for more commonly used language as well as additional complementary plugins. Keep in mind, however, that this will pull a lot of dependencies. -::: {.tip} +```bash +$ nix run github:notashelf/nvf#maximal -- test.nix +``` -You are _strongly_ recommended to use the binary cache if you would like to try -the Maximal configuration. +It uses the same configuration template with the [Nix](#sec-configs-nix) +configuration, but supports many more languages, and enables more utility, +companion or fun plugins. + +::: {.warning} + +Running the maximal config will download _a lot_ of packages as it is +downloading language servers, formatters, and more. ::: From 61be6cf4053537b1d0cf709b3283143e1f1b4b65 Mon Sep 17 00:00:00 2001 From: Ching Pei Yang Date: Mon, 5 May 2025 22:30:27 +0200 Subject: [PATCH 20/35] cmp: use normal priority for default values After this change, user configs should be "appended" to default ones instead of overriding them --- modules/plugins/completion/nvim-cmp/config.nix | 5 +++++ modules/plugins/completion/nvim-cmp/nvim-cmp.nix | 8 ++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/modules/plugins/completion/nvim-cmp/config.nix b/modules/plugins/completion/nvim-cmp/config.nix index 749ebb7c..cf27caaf 100644 --- a/modules/plugins/completion/nvim-cmp/config.nix +++ b/modules/plugins/completion/nvim-cmp/config.nix @@ -60,6 +60,11 @@ in { enableSharedCmpSources = true; nvim-cmp = { + sources = { + nvim-cmp = null; + buffer = "[Buffer]"; + path = "[Path]"; + }; sourcePlugins = ["cmp-buffer" "cmp-path"]; setupOpts = { diff --git a/modules/plugins/completion/nvim-cmp/nvim-cmp.nix b/modules/plugins/completion/nvim-cmp/nvim-cmp.nix index 2c8c77d3..8105ed00 100644 --- a/modules/plugins/completion/nvim-cmp/nvim-cmp.nix +++ b/modules/plugins/completion/nvim-cmp/nvim-cmp.nix @@ -98,11 +98,15 @@ in { sources = mkOption { type = attrsOf (nullOr str); - default = { + defaultText = literalMD '' + These sources are included by default: + + ```nix nvim-cmp = null; buffer = "[Buffer]"; path = "[Path]"; - }; + ``` + ''; example = { nvim-cmp = null; buffer = "[Buffer]"; From 9e9458710229d95bc19512c29cfea2b85c377b75 Mon Sep 17 00:00:00 2001 From: myu Date: Mon, 5 May 2025 20:02:37 -0400 Subject: [PATCH 21/35] tabline/bufferline: fix typo in the word "indicator" --- modules/plugins/tabline/nvim-bufferline/nvim-bufferline.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/plugins/tabline/nvim-bufferline/nvim-bufferline.nix b/modules/plugins/tabline/nvim-bufferline/nvim-bufferline.nix index 14243670..ff255c6c 100644 --- a/modules/plugins/tabline/nvim-bufferline/nvim-bufferline.nix +++ b/modules/plugins/tabline/nvim-bufferline/nvim-bufferline.nix @@ -109,7 +109,7 @@ in { type = nullOr str; default = null; description = '' - The indicatotor icon to use for the current buffer. + The indicator icon to use for the current buffer. ::: {.warning} This **must** be omitted while style is not `icon` From f07468e13a994b04ec3b9cd41777429942cdc8b1 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Tue, 6 May 2025 12:06:33 +0300 Subject: [PATCH 22/35] ci: fix labeler config --- .github/labels.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/labels.yml b/.github/labels.yml index e799004f..34c3bf2c 100644 --- a/.github/labels.yml +++ b/.github/labels.yml @@ -24,7 +24,7 @@ - any-glob-to-any-file: - .github/workflows/*.yml - .github/typos.toml - . .github/dependabot.yml + - .github/dependabot.yml "topic: meta": - any: From 99f1200c8db9295e556255e49175a6d2a5c02fbd Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Tue, 6 May 2025 20:58:31 +0300 Subject: [PATCH 23/35] revert "Merge pull request #884 from horriblename/cmp-sources-normal-prio" Reverts commit d3c7f7125c5302721d711d1dc4e025c63c5e09a4, reversing changes made to f07468e13a994b04ec3b9cd41777429942cdc8b1. --- modules/plugins/completion/nvim-cmp/config.nix | 5 ----- modules/plugins/completion/nvim-cmp/nvim-cmp.nix | 8 ++------ 2 files changed, 2 insertions(+), 11 deletions(-) diff --git a/modules/plugins/completion/nvim-cmp/config.nix b/modules/plugins/completion/nvim-cmp/config.nix index cf27caaf..749ebb7c 100644 --- a/modules/plugins/completion/nvim-cmp/config.nix +++ b/modules/plugins/completion/nvim-cmp/config.nix @@ -60,11 +60,6 @@ in { enableSharedCmpSources = true; nvim-cmp = { - sources = { - nvim-cmp = null; - buffer = "[Buffer]"; - path = "[Path]"; - }; sourcePlugins = ["cmp-buffer" "cmp-path"]; setupOpts = { diff --git a/modules/plugins/completion/nvim-cmp/nvim-cmp.nix b/modules/plugins/completion/nvim-cmp/nvim-cmp.nix index 8105ed00..2c8c77d3 100644 --- a/modules/plugins/completion/nvim-cmp/nvim-cmp.nix +++ b/modules/plugins/completion/nvim-cmp/nvim-cmp.nix @@ -98,15 +98,11 @@ in { sources = mkOption { type = attrsOf (nullOr str); - defaultText = literalMD '' - These sources are included by default: - - ```nix + default = { nvim-cmp = null; buffer = "[Buffer]"; path = "[Path]"; - ``` - ''; + }; example = { nvim-cmp = null; buffer = "[Buffer]"; From edbfc120af31ab01eb92f32df6052c100ba4e218 Mon Sep 17 00:00:00 2001 From: tebro Date: Thu, 8 May 2025 20:59:27 +0300 Subject: [PATCH 24/35] Add .eslintrc.cjs as eslint config file option --- modules/plugins/languages/ts.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/plugins/languages/ts.nix b/modules/plugins/languages/ts.nix index 5a1e5889..b9971488 100644 --- a/modules/plugins/languages/ts.nix +++ b/modules/plugins/languages/ts.nix @@ -101,6 +101,7 @@ "eslint.config.js" "eslint.config.mjs" ".eslintrc" + ".eslintrc.cjs" ".eslintrc.json" ".eslintrc.js" ".eslintrc.yml" From 09f2e1d5245c5e9d35e6b451d47affec0c006157 Mon Sep 17 00:00:00 2001 From: Noah765 <99338019+Noah765@users.noreply.github.com> Date: Fri, 9 May 2025 01:33:01 +0200 Subject: [PATCH 25/35] lsp: fix toggleFormatOnSave (#869) Co-authored-by: Ching Pei Yang <59727193+horriblename@users.noreply.github.com> Co-authored-by: raf --- modules/plugins/lsp/config.nix | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/plugins/lsp/config.nix b/modules/plugins/lsp/config.nix index 3702ac5f..c2320aaf 100644 --- a/modules/plugins/lsp/config.nix +++ b/modules/plugins/lsp/config.nix @@ -84,13 +84,13 @@ in { group = augroup, buffer = bufnr, callback = function() + if vim.b.disableFormatSave then + return + end + ${ if config.vim.lsp.null-ls.enable then '' - if vim.b.disableFormatSave then - return - end - local function is_null_ls_formatting_enabled(bufnr) local file_type = vim.api.nvim_buf_get_option(bufnr, "filetype") local generators = require("null-ls.generators").get_available( From 22f57045275e2e2ca27e070372c8c16664705df7 Mon Sep 17 00:00:00 2001 From: Venkatesan Ravi Date: Mon, 31 Mar 2025 21:06:54 +0000 Subject: [PATCH 26/35] Make conform respect config.vim.lsp.formatOnSave and config.vim.lsp.mappings.toggleFormatOnSave --- .../formatter/conform-nvim/conform-nvim.nix | 67 ++++++++++++------- 1 file changed, 42 insertions(+), 25 deletions(-) diff --git a/modules/plugins/formatter/conform-nvim/conform-nvim.nix b/modules/plugins/formatter/conform-nvim/conform-nvim.nix index 727985a3..cfe89bf3 100644 --- a/modules/plugins/formatter/conform-nvim/conform-nvim.nix +++ b/modules/plugins/formatter/conform-nvim/conform-nvim.nix @@ -1,12 +1,9 @@ -{ - pkgs, - lib, - ... -}: let - inherit (lib.options) mkOption mkEnableOption literalExpression; - inherit (lib.types) attrs enum nullOr; - inherit (lib.nvim.types) mkPluginSetupOption; - inherit (lib.nvim.lua) mkLuaInline; +{lib, ...}: let + inherit (lib.generators) mkLuaInline; + inherit (lib.options) mkOption mkEnableOption literalMD; + inherit (lib.types) attrs either nullOr; + inherit (lib.nvim.lua) toLuaObject; + inherit (lib.nvim.types) luaInline mkPluginSetupOption; in { options.vim.formatter.conform-nvim = { enable = mkEnableOption "lightweight yet powerful formatter plugin for Neovim [conform-nvim]"; @@ -31,26 +28,46 @@ in { }; format_on_save = mkOption { - type = nullOr attrs; - default = { - lsp_format = "fallback"; - timeout_ms = 500; - }; + type = nullOr (either attrs luaInline); + default = mkLuaInline '' + function() + if not vim.g.formatsave or vim.b.disableFormatSave then + return + else + return {lsp_format = "fallback", timeout_ms = 500} + end + end + ''; + defaultText = literalMD '' + enabled by default, and respects {option}`vim.lsp.formatOnSave` and + {option}`vim.lsp.mappings.toggleFormatSave` + ''; description = '' - Table that will be passed to `conform.format()`. If this - is set, Conform will run the formatter on save. + Attribute set or Lua function that will be passed to + `conform.format()`. If this is set, Conform will run the formatter + on save. ''; }; - format_after_save = mkOption { - type = nullOr attrs; - default = {lsp_format = "fallback";}; - description = '' - Table that will be passed to `conform.format()`. If this - is set, Conform will run the formatter asynchronously after - save. - ''; - }; + format_after_save = let + defaultFormatAfterSaveOpts = {lsp_format = "fallback";}; + in + mkOption { + type = nullOr (either attrs luaInline); + default = mkLuaInline '' + function() + if not vim.g.formatsave or vim.b.disableFormatSave then + return + else + return ${toLuaObject defaultFormatAfterSaveOpts} + end + end + ''; + description = '' + Table or function(luainline) that will be passed to `conform.format()`. If this + is set, Conform will run the formatter asynchronously after save. + ''; + }; }; }; } From 4f0cc5725a7bdf2a9e880d5a59f360968419e8ea Mon Sep 17 00:00:00 2001 From: Ching Pei Yang Date: Fri, 9 May 2025 03:56:41 +0200 Subject: [PATCH 27/35] lsp: prefer conform for format on save --- modules/plugins/lsp/config.nix | 120 +++++++++++++++------------------ 1 file changed, 54 insertions(+), 66 deletions(-) diff --git a/modules/plugins/lsp/config.nix b/modules/plugins/lsp/config.nix index c2320aaf..8d4a3c8e 100644 --- a/modules/plugins/lsp/config.nix +++ b/modules/plugins/lsp/config.nix @@ -6,6 +6,7 @@ }: let inherit (lib.generators) mkLuaInline; inherit (lib.modules) mkIf; + inherit (lib.lists) optional; inherit (lib.strings) optionalString; inherit (lib.trivial) boolToString; inherit (lib.nvim.binds) addDescriptionsToMappings; @@ -14,7 +15,10 @@ usingNvimCmp = config.vim.autocomplete.nvim-cmp.enable; usingBlinkCmp = config.vim.autocomplete.blink-cmp.enable; self = import ./module.nix {inherit config lib pkgs;}; + conformCfg = config.vim.formatter.conform-nvim; + conformFormatOnSave = conformCfg.enable && conformCfg.setupOpts.format_on_save != null; + augroup = "nvf_lsp"; mappingDefinitions = self.options.vim.lsp.mappings; mappings = addDescriptionsToMappings cfg.mappings mappingDefinitions; mkBinding = binding: action: @@ -29,24 +33,59 @@ in { sourcePlugins = ["cmp-nvim-lsp"]; }; + augroups = [{name = augroup;}]; autocmds = - if cfg.inlayHints.enable - then [ - { - callback = mkLuaInline '' - function(event) - local bufnr = event.buf - local client = vim.lsp.get_client_by_id(event.data.client_id) - if client and client.supports_method(vim.lsp.protocol.Methods.textDocument_inlayHint) then - vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled({ bufnr = bufnr }), { bufnr = bufnr }) + (optional cfg.inlayHints.enable { + group = augroup; + event = ["LspAttach"]; + desc = "LSP on-attach enable inlay hints autocmd"; + callback = mkLuaInline '' + function(event) + local bufnr = event.buf + local client = vim.lsp.get_client_by_id(event.data.client_id) + if client and client.supports_method(vim.lsp.protocol.Methods.textDocument_inlayHint) then + vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled({ bufnr = bufnr }), { bufnr = bufnr }) + end + end + ''; + }) + ++ (optional (!conformFormatOnSave) { + group = augroup; + event = ["BufWritePre"]; + desc = "LSP on-attach create format on save autocmd"; + callback = mkLuaInline '' + function(ev) + if vim.b.disableFormatSave or not vim.g.formatsave then + return + end + + local bufnr = ev.buf + + ${optionalString cfg.null-ls.enable '' + -- prefer null_ls formatter + do + local clients = vim.lsp.get_clients({ + bufnr = bufnr, + name = "null-ls", + method = "textDocument/formatting", + }) + if clients[1] then + vim.lsp.buf.format({ bufnr = bufnr, id = clients[1].id }) + return end end - ''; - desc = "LSP on-attach enable inlay hints autocmd"; - event = ["LspAttach"]; - } - ] - else []; + ''} + + local clients = vim.lsp.get_clients({ + bufnr = bufnr, + method = "textDocument/formatting", + }) + if clients[1] then + vim.lsp.buf.format({ bufnr = bufnr, id = clients[1].id }) + end + end + ''; + }); pluginRC.lsp-setup = '' vim.g.formatsave = ${boolToString cfg.formatOnSave}; @@ -74,60 +113,9 @@ in { ${mkBinding mappings.toggleFormatOnSave "function() vim.b.disableFormatSave = not vim.b.disableFormatSave end"} end - -- Enable formatting - local augroup = vim.api.nvim_create_augroup("LspFormatting", {}) - - format_callback = function(client, bufnr) - if vim.g.formatsave then - vim.api.nvim_clear_autocmds({ group = augroup, buffer = bufnr }) - vim.api.nvim_create_autocmd("BufWritePre", { - group = augroup, - buffer = bufnr, - callback = function() - if vim.b.disableFormatSave then - return - end - - ${ - if config.vim.lsp.null-ls.enable - then '' - local function is_null_ls_formatting_enabled(bufnr) - local file_type = vim.api.nvim_buf_get_option(bufnr, "filetype") - local generators = require("null-ls.generators").get_available( - file_type, - require("null-ls.methods").internal.FORMATTING - ) - return #generators > 0 - end - - if is_null_ls_formatting_enabled(bufnr) then - vim.lsp.buf.format({ - bufnr = bufnr, - filter = function(client) - return client.name == "null-ls" - end - }) - else - vim.lsp.buf.format({ - bufnr = bufnr, - }) - end - '' - else " - vim.lsp.buf.format({ - bufnr = bufnr, - }) - " - } - end, - }) - end - end - ${optionalString config.vim.ui.breadcrumbs.enable ''local navic = require("nvim-navic")''} default_on_attach = function(client, bufnr) attach_keymaps(client, bufnr) - format_callback(client, bufnr) ${optionalString config.vim.ui.breadcrumbs.enable '' -- let navic attach to buffers if client.server_capabilities.documentSymbolProvider then From 955f2046cf7f6518ae7aab044af2318f7b80cd18 Mon Sep 17 00:00:00 2001 From: Ching Pei Yang Date: Fri, 9 May 2025 04:02:10 +0200 Subject: [PATCH 28/35] lsp: add TODO --- modules/plugins/lsp/config.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/plugins/lsp/config.nix b/modules/plugins/lsp/config.nix index 8d4a3c8e..e7b67c8e 100644 --- a/modules/plugins/lsp/config.nix +++ b/modules/plugins/lsp/config.nix @@ -126,6 +126,7 @@ in { local capabilities = vim.lsp.protocol.make_client_capabilities() ${optionalString usingNvimCmp '' + -- TODO(horriblename): migrate to vim.lsp.config['*'] -- HACK: copied from cmp-nvim-lsp. If we ever lazy load lspconfig we -- should re-evaluate whether we can just use `default_capabilities` capabilities = { From 29f6940868c30a75494bf6586b8314538bd395ad Mon Sep 17 00:00:00 2001 From: Ching Pei Yang Date: Fri, 9 May 2025 04:16:30 +0200 Subject: [PATCH 29/35] docs: update release notes --- docs/release-notes/rl-0.8.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/docs/release-notes/rl-0.8.md b/docs/release-notes/rl-0.8.md index e0c06fc8..6581a277 100644 --- a/docs/release-notes/rl-0.8.md +++ b/docs/release-notes/rl-0.8.md @@ -109,6 +109,7 @@ - Add tsx support in conform and lint - Moved code setting `additionalRuntimePaths` and `enableLuaLoader` out of `luaConfigPre`'s default to prevent being overridden +- Use conform over custom autocmds for LSP format on save [diniamo](https://github.com/diniamo): @@ -312,6 +313,8 @@ - Fix fzf-lua having a hard dependency on fzf. - Enable inlay hints support - `config.vim.lsp.inlayHints`. - Add `neo-tree`, `snacks.picker` extensions to `lualine`. +- Add support for `vim.lsp.formatOnSave` and + `vim.lsp.mappings.toggleFormatOnSave` [tebuevd](https://github.com/tebuevd): @@ -361,7 +364,8 @@ [Hardtime.nvim]: https://github.com/m4xshen/hardtime.nvim -- Add Plugin [Hardtime.nvim] under `vim.binds.hardtime-nvim` with `enable` and `setupOpts` options +- Add Plugin [Hardtime.nvim] under `vim.binds.hardtime-nvim` with `enable` and + `setupOpts` options [taylrfnt](https://github.com/taylrfnt): From fee3bbe536b5bf484aedebafa5130b485068b64f Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Sat, 10 May 2025 07:54:24 +0300 Subject: [PATCH 30/35] languages/markdown: fix formatting --- modules/plugins/languages/markdown.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/plugins/languages/markdown.nix b/modules/plugins/languages/markdown.nix index aadb0c40..23848835 100644 --- a/modules/plugins/languages/markdown.nix +++ b/modules/plugins/languages/markdown.nix @@ -193,7 +193,7 @@ in { require("markview").setup(${toLuaObject cfg.extensions.markview-nvim.setupOpts}) ''; }) - + (mkIf cfg.extraDiagnostics.enable { vim.diagnostics.nvim-lint = { enable = true; From a099cdaf977beb3517afdfcee2057fc70b870ce7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexandra=20=C3=98stermark?= Date: Sat, 10 May 2025 13:42:57 +0200 Subject: [PATCH 31/35] add ruby lsp as ruby server option --- modules/plugins/languages/ruby.nix | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/modules/plugins/languages/ruby.nix b/modules/plugins/languages/ruby.nix index ab0e0905..5d6a151e 100644 --- a/modules/plugins/languages/ruby.nix +++ b/modules/plugins/languages/ruby.nix @@ -9,6 +9,8 @@ inherit (lib.meta) getExe; inherit (lib.modules) mkIf mkMerge; inherit (lib.nvim.types) mkGrammarOption diagnostics; + inherit (lib.nvim.lua) expToLua; + inherit (lib.lists) isList; inherit (lib.types) either listOf package str enum; cfg = config.vim.languages.ruby; @@ -24,10 +26,28 @@ flags = { debounce_text_changes = 150, }, - cmd = { "${pkgs.solargraph}/bin/solargraph", "stdio" } + cmd = ${ + if isList cfg.lsp.package + then expToLua cfg.lsp.package + else ''{ "${cfg.lsp.package}/bin/solargraph", "stdio" }'' + } } ''; }; + rubylsp = { + package = pkgs.ruby-lsp; + lspConfig = '' + lspconfig.ruby_lsp.setup { + capabilities = capabilities, + on_attach = default_on_attach, + cmd = ${ + if isList cfg.lsp.package + then expToLua cfg.lsp.package + else ''{ "${cfg.lsp.package}/bin/ruby-lsp" }'' + } + } + ''; + } }; # testing From 054e4a3b9c8be8609b5134e058becd15b96eb4c2 Mon Sep 17 00:00:00 2001 From: Christoph Koehler Date: Thu, 8 May 2025 18:52:16 -0600 Subject: [PATCH 32/35] feat: add treesitter textobjects --- docs/release-notes/rl-0.8.md | 2 ++ modules/plugins/treesitter/default.nix | 1 + .../treesitter/ts-textobjects/config.nix | 23 +++++++++++++++++++ .../treesitter/ts-textobjects/default.nix | 6 +++++ .../treesitter/ts-textobjects/textobjects.nix | 21 +++++++++++++++++ npins/sources.json | 13 +++++++++++ 6 files changed, 66 insertions(+) create mode 100644 modules/plugins/treesitter/ts-textobjects/config.nix create mode 100644 modules/plugins/treesitter/ts-textobjects/default.nix create mode 100644 modules/plugins/treesitter/ts-textobjects/textobjects.nix diff --git a/docs/release-notes/rl-0.8.md b/docs/release-notes/rl-0.8.md index 0155c759..45e4eb9b 100644 --- a/docs/release-notes/rl-0.8.md +++ b/docs/release-notes/rl-0.8.md @@ -329,11 +329,13 @@ [flash.nvim]: https://github.com/folke/flash.nvim [gitlinker.nvim]: https://github.com/linrongbin16/gitlinker.nvim +[nvim-treesitter-textobjects]: https://github.com/nvim-treesitter/nvim-treesitter-textobjects - Fix oil config referencing snacks - Add [flash.nvim] plugin to `vim.utility.motion.flash-nvim` - Fix default telescope ignore list entry for '.git/' to properly match - Add [gitlinker.nvim] plugin to `vim.git.gitlinker-nvim` +- Add [nvim-treesitter-textobjects] plugin to `vim.treesitter.textobjects` [rrvsh](https://github.com/rrvsh): diff --git a/modules/plugins/treesitter/default.nix b/modules/plugins/treesitter/default.nix index a859f3af..ea8ac9cd 100644 --- a/modules/plugins/treesitter/default.nix +++ b/modules/plugins/treesitter/default.nix @@ -2,6 +2,7 @@ imports = [ # treesitter extras ./ts-context + ./ts-textobjects ./treesitter.nix ./config.nix diff --git a/modules/plugins/treesitter/ts-textobjects/config.nix b/modules/plugins/treesitter/ts-textobjects/config.nix new file mode 100644 index 00000000..7a9239d1 --- /dev/null +++ b/modules/plugins/treesitter/ts-textobjects/config.nix @@ -0,0 +1,23 @@ +{ + config, + lib, + ... +}: let + inherit (lib.modules) mkIf; + inherit (lib.nvim.lua) toLuaObject; + inherit (lib.nvim.dag) entryAfter; + + inherit (config.vim) treesitter; + cfg = treesitter.textobjects; +in { + config = mkIf (treesitter.enable && cfg.enable) { + vim = { + startPlugins = ["nvim-treesitter-textobjects"]; + + # set up treesitter-textobjects after Treesitter, whose config we're adding to. + pluginRC.treesitter-textobjects = entryAfter ["treesitter"] '' + require("nvim-treesitter.configs").setup({textobjects = ${toLuaObject cfg.setupOpts}}) + ''; + }; + }; +} diff --git a/modules/plugins/treesitter/ts-textobjects/default.nix b/modules/plugins/treesitter/ts-textobjects/default.nix new file mode 100644 index 00000000..d0ae48a3 --- /dev/null +++ b/modules/plugins/treesitter/ts-textobjects/default.nix @@ -0,0 +1,6 @@ +{ + imports = [ + ./textobjects.nix + ./config.nix + ]; +} diff --git a/modules/plugins/treesitter/ts-textobjects/textobjects.nix b/modules/plugins/treesitter/ts-textobjects/textobjects.nix new file mode 100644 index 00000000..07e72135 --- /dev/null +++ b/modules/plugins/treesitter/ts-textobjects/textobjects.nix @@ -0,0 +1,21 @@ +{lib, ...}: let + inherit (lib.options) mkEnableOption; + inherit (lib.nvim.types) mkPluginSetupOption; +in { + options.vim.treesitter.textobjects = { + enable = mkEnableOption "Treesitter textobjects"; + setupOpts = + mkPluginSetupOption "treesitter-textobjects" {} + // { + example = { + select = { + enable = true; + lookahead = true; + keymaps = { + af = "@function.outer"; + }; + }; + }; + }; + }; +} diff --git a/npins/sources.json b/npins/sources.json index e74da05b..d4c0aa14 100644 --- a/npins/sources.json +++ b/npins/sources.json @@ -1906,6 +1906,19 @@ "url": "https://github.com/nvim-treesitter/nvim-treesitter-context/archive/6daca3ad780f045550b820f262002f35175a6c04.tar.gz", "hash": "0qprwd44hw9sz0vh14p6lpvs9vxrick462pfkradmal6ak1kfwn3" }, + "nvim-treesitter-textobjects": { + "type": "Git", + "repository": { + "type": "GitHub", + "owner": "nvim-treesitter", + "repo": "nvim-treesitter-textobjects" + }, + "branch": "master", + "submodules": false, + "revision": "0e3be38005e9673d044e994b1e4b123adb040179", + "url": "https://github.com/nvim-treesitter/nvim-treesitter-textobjects/archive/0e3be38005e9673d044e994b1e4b123adb040179.tar.gz", + "hash": "0y93pj3asarw7jhk4cdphhx6awxdyiwajc0n9nr4836gn48qcs85" + }, "nvim-ts-autotag": { "type": "Git", "repository": { From 8efdfd508e7f17ed8ea36e2a84e219fec89d3481 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexandra=20=C3=98stermark?= Date: Mon, 12 May 2025 10:41:58 +0200 Subject: [PATCH 33/35] add release notes --- docs/release-notes/rl-0.8.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/docs/release-notes/rl-0.8.md b/docs/release-notes/rl-0.8.md index 0155c759..de683d5d 100644 --- a/docs/release-notes/rl-0.8.md +++ b/docs/release-notes/rl-0.8.md @@ -375,3 +375,8 @@ - Add missing `right_align` option for existing `renderer.icons` options. - Add missing `render.icons` options (`hidden_placement`, `diagnostics_placement`, and `bookmarks_placement`). + +[cramt](https://github.com/cramt): + +- Add `rubylsp` option in `vim.languages.ruby.lsp.server` to use shopify's + ruby-lsp language server From e72bf9398df3801ea7ee61fe5e4725cec1f9bd8e Mon Sep 17 00:00:00 2001 From: Gerg-L Date: Mon, 12 May 2025 20:04:29 -0400 Subject: [PATCH 34/35] fix: install blink docs --- flake/blink/default.nix | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/flake/blink/default.nix b/flake/blink/default.nix index 08c87073..ef1498d8 100644 --- a/flake/blink/default.nix +++ b/flake/blink/default.nix @@ -14,8 +14,15 @@ rustPlatform.buildRustPackage (finalAttrs: { hash = "sha256-bKe8SSg1HPWE7b4iRQJwiOVCrvvgttuHCOIa4U/38AY="; }; + forceShare = [ + "man" + "info" + ]; + postInstall = '' cp -r {lua,plugin} "$out" + mkdir -p "$out/doc" + cp 'doc/'*'.txt' "$out/doc/" mkdir -p "$out/target" mv "$out/lib" "$out/target/release" ''; From ae49dd7dd3671dd1d7cd6d6c91d5ecca9dc74cc7 Mon Sep 17 00:00:00 2001 From: Soliprem <73885403+Soliprem@users.noreply.github.com> Date: Tue, 13 May 2025 13:51:29 +0200 Subject: [PATCH 35/35] languages/ruby: fix missing semicolon missing semicolon --- modules/plugins/languages/ruby.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/plugins/languages/ruby.nix b/modules/plugins/languages/ruby.nix index 5d6a151e..1f3ce82f 100644 --- a/modules/plugins/languages/ruby.nix +++ b/modules/plugins/languages/ruby.nix @@ -47,7 +47,7 @@ } } ''; - } + }; }; # testing