diff --git a/configuration.nix b/configuration.nix index c3e5722..98b9999 100644 --- a/configuration.nix +++ b/configuration.nix @@ -51,6 +51,7 @@ isMaximal: { css.enable = isMaximal; sql.enable = isMaximal; java.enable = isMaximal; + kotlin.enable = isMaximal; ts.enable = isMaximal; svelte.enable = isMaximal; go.enable = isMaximal; @@ -64,32 +65,29 @@ isMaximal: { r.enable = isMaximal; tailwind.enable = isMaximal; typst.enable = isMaximal; - clang = { - enable = isMaximal; - lsp.server = "clangd"; - }; - + clang.enable = isMaximal; + scala.enable = isMaximal; rust = { enable = isMaximal; crates.enable = isMaximal; }; + csharp.enable = isMaximal; + julia.enable = isMaximal; + vala.enable = isMaximal; }; visuals = { - enable = true; - nvimWebDevicons.enable = true; - scrollBar.enable = isMaximal; - smoothScroll.enable = true; - cellularAutomaton.enable = false; + nvim-scrollbar.enable = isMaximal; + nvim-web-devicons.enable = true; + nvim-cursorline.enable = true; + cinnamon-nvim.enable = true; fidget-nvim.enable = true; + highlight-undo.enable = true; + indent-blankline.enable = true; - indentBlankline.enable = true; - - cursorline = { - enable = true; - lineTimeout = 0; - }; + # Fun + cellular-automaton.enable = false; }; statusline = { @@ -106,12 +104,10 @@ isMaximal: { transparent = false; }; - autopairs.enable = true; + autopairs.nvim-autopairs.enable = true; - autocomplete = { - enable = true; - type = "nvim-cmp"; - }; + autocomplete.nvim-cmp.enable = true; + snippets.luasnip.enable = true; filetree = { nvimTree = { @@ -175,6 +171,7 @@ isMaximal: { notes = { obsidian.enable = false; # FIXME: neovim fails to build if obsidian is enabled + neorg.enable = false; orgmode.enable = false; mind-nvim.enable = isMaximal; todo-comments.enable = true; diff --git a/docs/manual/configuring/custom-plugins.md b/docs/manual/configuring/custom-plugins.md index c58c497..76b32ea 100644 --- a/docs/manual/configuring/custom-plugins.md +++ b/docs/manual/configuring/custom-plugins.md @@ -20,6 +20,7 @@ custom plugins that you might have added to your configuration. ```{=include=} sections custom-plugins/configuring.md -custom-plugins/new-method.md -custom-plugins/old-method.md +custom-plugins/lazy-method.md +custom-plugins/non-lazy-method.md +custom-plugins/legacy-method.md ``` diff --git a/docs/manual/configuring/custom-plugins/configuring.md b/docs/manual/configuring/custom-plugins/configuring.md index 5e837ce..71ce9b8 100644 --- a/docs/manual/configuring/custom-plugins/configuring.md +++ b/docs/manual/configuring/custom-plugins/configuring.md @@ -1,12 +1,32 @@ # 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.extraPlugins` (which has the `setup` field) or -`config.vim.luaConfigRC`. The first option 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 +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`. + +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. + +```nix +{ + config.vim.lazy.plugins = { + aerial-nvim = { + # ^^^^^^^^^ this name should match the package.pname or package.name + package = aerial-nvim; + + setupModule = "aerial"; + setupOpts = {option_name = false;}; + + after = "print('aerial loaded')"; + }; + }; +} +``` + +The second option 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 respectively. For example: ```nix @@ -24,7 +44,7 @@ config.vim.extraPlugins = with pkgs.vimPlugins; { } ``` -The second option also uses an attribute set, but this one is resolved as a DAG +The third option 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: diff --git a/docs/manual/configuring/custom-plugins/lazy-method.md b/docs/manual/configuring/custom-plugins/lazy-method.md new file mode 100644 index 0000000..77b77d5 --- /dev/null +++ b/docs/manual/configuring/custom-plugins/lazy-method.md @@ -0,0 +1,40 @@ +# 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`. + +```nix +{ + config.vim.lazy.plugins = { + aerial = { + package = pkgs.vimPlugins.aerial-nvim; + setupModule = aerial; + setupOpts = { + option_name = true; + }; + after = '' + -- custom lua code to run after plugin is loaded + print('aerial loaded') + ''; + + # Explicitly mark plugin as lazy. You don't need this if you define one of + # the trigger "events" below + lazy = true; + + # load on command + cmd = ["AerialOpen"]; + + # load on event + event = ["BufEnter"]; + + # load on keymap + keys = [ + { + key = "a"; + action = ":AerialToggle"; + } + ]; + }; + }; +} +``` diff --git a/docs/manual/configuring/custom-plugins/old-method.md b/docs/manual/configuring/custom-plugins/legacy-method.md similarity index 96% rename from docs/manual/configuring/custom-plugins/old-method.md rename to docs/manual/configuring/custom-plugins/legacy-method.md index 3b9d090..0a6b377 100644 --- a/docs/manual/configuring/custom-plugins/old-method.md +++ b/docs/manual/configuring/custom-plugins/legacy-method.md @@ -1,4 +1,4 @@ -# Old Method {#sec-old-method} +# Legacy Method {#sec-legacy-method} Prior to version 0.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 diff --git a/docs/manual/configuring/custom-plugins/new-method.md b/docs/manual/configuring/custom-plugins/non-lazy-method.md similarity index 93% rename from docs/manual/configuring/custom-plugins/new-method.md rename to docs/manual/configuring/custom-plugins/non-lazy-method.md index 200ba5e..351af2e 100644 --- a/docs/manual/configuring/custom-plugins/new-method.md +++ b/docs/manual/configuring/custom-plugins/non-lazy-method.md @@ -1,4 +1,4 @@ -# New Method {#sec-new-method} +# 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 diff --git a/docs/manual/configuring/dag-entries.md b/docs/manual/configuring/dag-entries.md index 402cde6..ff5d5c7 100644 --- a/docs/manual/configuring/dag-entries.md +++ b/docs/manual/configuring/dag-entries.md @@ -12,12 +12,14 @@ entries in nvf: 2. `globalsScript` - used to set globals defined in `vim.globals` 3. `basic` - used to set basic configuration options 4. `optionsScript` - used to set options defined in `vim.o` -5. `theme` (this is simply placed before `pluginConfigs`, meaning that - surrounding entries don't depend on it) - used to set up the theme, which has - to be done before other plugins -6. `pluginConfigs` - the result of the nested `vim.pluginRC` (internal option, +5. `theme` (this is simply placed before `pluginConfigs` and `lazyConfigs`, meaning that + surrounding entries don't depend on it) - used to set up the theme, which has to be done before + other plugins +6. `lazyConfigs` - `lz.n` and `lzn-auto-require` configs. If `vim.lazy.enable` + is false, this will contain each plugin's config instead. +7. `pluginConfigs` - the result of the nested `vim.pluginRC` (internal option, see the [Custom Plugins](/index.xhtml#ch-custom-plugins) page for adding your own plugins) DAG, used to set up internal plugins -7. `extraPluginConfigs` - the result of `vim.extraPlugins`, which is not a +8. `extraPluginConfigs` - the result of `vim.extraPlugins`, which is not a direct DAG, but is converted to, and resolved as one internally -8. `mappings` - the result of `vim.maps` +9. `mappings` - the result of `vim.maps` diff --git a/docs/manual/hacking/additional-plugins.md b/docs/manual/hacking/additional-plugins.md index 7c80215..8531aa9 100644 --- a/docs/manual/hacking/additional-plugins.md +++ b/docs/manual/hacking/additional-plugins.md @@ -124,3 +124,61 @@ vim.your-plugin.setupOpts = { ''; } ``` + +## Lazy plugins {#sec-lazy-plugins} + +If the plugin can be lazy-loaded, `vim.lazy.plugins` should be used to add it. Lazy +plugins are managed by `lz.n`. + +```nix +# in modules/.../your-plugin/config.nix +{lib, config, ...}: +let + cfg = config.vim.your-plugin; +in { + vim.lazy.plugins.your-plugin = { + # instead of vim.startPlugins, use this: + package = "your-plugin"; + + # if your plugin uses the `require('your-plugin').setup{...}` pattern + setupModule = "your-plugin"; + inherit (cfg) setupOpts; + + # events that trigger this plugin to be loaded + event = ["DirChanged"]; + cmd = ["YourPluginCommand"]; + + # keymaps + keys = [ + # we'll cover this in detail in the keymaps section + { + key = "d"; + mode = "n"; + action = ":YourPluginCommand"; + } + ]; + }; +; +} +``` + +This results in the following lua code: +```lua +require('lz.n').load({ + { + "name-of-your-plugin", + after = function() + require('your-plugin').setup({--[[ your setupOpts ]]}) + end, + + event = {"DirChanged"}, + cmd = {"YourPluginCommand"}, + keys = { + {"d", ":YourPluginCommand", mode = {"n"}}, + }, + } +}) +``` + +A full list of options can be found +[here](https://notashelf.github.io/nvf/options.html#opt-vim.lazy.plugins diff --git a/docs/manual/hacking/keybinds.md b/docs/manual/hacking/keybinds.md index f4a5149..63a05d6 100644 --- a/docs/manual/hacking/keybinds.md +++ b/docs/manual/hacking/keybinds.md @@ -7,37 +7,26 @@ section contains a general overview to how you may utilize said functions. ## Custom Key Mappings Support for a Plugin {#sec-custom-key-mappings} -To set a mapping, you should define it in `vim.maps.<>`. -The available modes are: - -- normal -- insert -- select -- visual -- terminal -- normalVisualOp -- visualOnly -- operator -- insertCommand -- lang -- command +To set a mapping, you should define it in `vim.keymaps`. An example, simple keybinding, can look like this: ```nix { - vim.maps.normal = { - "wq" = { + vim.keymaps = [ + { + key = "wq"; + mode = ["n"]; action = ":wq"; silent = true; desc = "Save file and quit"; - }; - }; + } + ]; } ``` There are many settings available in the options. Please refer to the -[documentation](https://notashelf.github.io/nvf/options.html#opt-vim.maps.command._name_.action) +[documentation](https://notashelf.github.io/nvf/options.html#opt-vim.keymaps) to see a list of them. **nvf** provides a list of helper commands, so that you don't have to write the diff --git a/docs/release-notes/rl-0.7.md b/docs/release-notes/rl-0.7.md index a8c2a01..f9eba71 100644 --- a/docs/release-notes/rl-0.7.md +++ b/docs/release-notes/rl-0.7.md @@ -26,6 +26,32 @@ making good use of its extensive Lua API. Additionally, Vimscript is slow and brings unnecessary performance overhead while working with different configuration formats. +### `vim.maps` rewrite {#sec-vim-maps-rewrite} + +Instead of specifying map modes using submodules (eg.: `vim.maps.normal`), a new +`vim.keymaps` submodule with support for a `mode` option has been introduced. It +can be either a string, or a list of strings, where a string represents the +short-name of the map mode(s), that the mapping should be set for. See +`:help map-modes` for more information. + +For example: + +```nix +vim.maps.normal."m" = { ... }; +``` + +has to be replaced by + +```nix +vim.keymaps = [ + { + key = "m"; + mode = "n"; + } + ... +]; +``` + ### `vim.lsp.nvimCodeActionMenu` removed in favor of `vim.ui.fastaction` {#sec-nvim-code-action-menu-deprecation} The nvim-code-action-menu plugin has been archived and broken for a long time, @@ -37,6 +63,24 @@ Note that we are looking to add more alternatives in the future like dressing.nvim and actions-preview.nvim, in case fastaction doesn't work for everyone. +### `type` based modules removed {#sec-type-based-modules-removed} + +As part of the autocompletion rewrite, modules that used to use a `type` option +have been replaced by per-plugin modules instead. Since both modules only had +one type, you can simply change + +- `vim.autocomplete.*` -> `vim.autocomplete.nvim-cmp.*` +- `vim.autopairs.enable` -> `vim.autopairs.nvim-autopairs.enable` + +### `nixpkgs-fmt` removed in favor of `nixfmt` {#sec-nixpkgs-fmt-deprecation} + +`nixpkgs-fmt` has been archived for a while, and it's finally being removed in +favor of nixfmt (more information can be found +[here](https://github.com/nix-community/nixpkgs-fmt?tab=readme-ov-file#nixpkgs-fmt---nix-code-formatter-for-nixpkgs). + +To migrate to `nixfmt`, simply change `vim.languages.nix.format.type` to +`nixfmt`. + ## Changelog {#sec-release-0.7-changelog} [ItsSorae](https://github.com/ItsSorae): @@ -67,6 +111,9 @@ everyone. - Add dap-go for better dap configurations - Make noice.nvim customizable - Standardize border style options and add custom borders +- Remove `vim.disableDefaultRuntimePaths` in wrapper options. + - As nvf uses `$NVIM_APP_NAME` as of recent changes, we can safely assume any + configuration in `$XDG_CONFIG_HOME/nvf` is intentional. [rust-tools.nvim]: https://github.com/simrat39/rust-tools.nvim [rustaceanvim]: https://github.com/mrcjkb/rustaceanvim @@ -76,6 +123,10 @@ everyone. recommended to go through rustacean.nvim's README to take a closer look at its features and usage +- Add [lz.n] support and lazy-load some builtin plugins. + +[lz.n]: https://github.com/mrcjkb/lz.n + [jacekpoz](https://jacekpoz.pl): [ocaml-lsp]: https://github.com/ocaml/ocaml-lsp @@ -124,10 +175,37 @@ everyone. - Replace `vim.lsp.nvimCodeActionMenu` with `vim.ui.fastaction`, see the breaking changes section above for more details +- Add a `setupOpts` option to nvim-surround, which allows modifying options that + aren't defined in nvf. Move the alternate nvim-surround keybinds to use + `setupOpts`. + +- Remove `autopairs.type`, and rename `autopairs.enable` to + `autopairs.nvim-autopairs.enable`. The new + [](#opt-vim.autopairs.nvim-autopairs.enable) supports `setupOpts` format by + default. + +- Refactor of `nvim-cmp` and completion related modules + + - Remove `autocomplete.type` in favor of per-plugin enable options such as + [](#opt-vim.autocomplete.nvim-cmp.enable). + - Deprecate legacy Vimsnip in favor of Luasnip, and integrate + friendly-snippets for bundled snippets. [](#opt-vim.snippets.luasnip.enable) + can be used to toggle Luasnip. + - Add sorting function options for completion sources under + [](#opt-vim.autocomplete.nvim-cmp.setupOpts.sorting.comparators) + +- Add C# support under `vim.languages.csharp`, with support for both + omnisharp-roslyn and csharp-language-server. + +- Add Julia support under `vim.languages.julia`. Note that the entirety of Julia + is bundled with nvf, if you enable the module, since there is no way to + provide only the LSP server. + [Neovim documentation on `vim.cmd`]: https://neovim.io/doc/user/lua.html#vim.cmd() - Make Neovim's configuration file entirely Lua based. This comes with a few breaking changes: + - `vim.configRC` has been removed. You will need to migrate your entries to Neovim-compliant Lua code, and add them to `vim.luaConfigRC` instead. Existing vimscript configurations may be preserved in `vim.cmd` functions. @@ -136,6 +214,8 @@ everyone. has been introduced for setting up internal plugins. See the "DAG entries in nvf" manual page for more information. +- Rewrite `vim.maps`, see the breaking changes section above. + [NotAShelf](https://github.com/notashelf): [ts-error-translator.nvim]: https://github.com/dmmulroy/ts-error-translator.nvim @@ -198,9 +278,16 @@ everyone. configuration for [dashboard.nvim](https://github.com/nvimdev/dashboard-nvim) - Update `lualine.nvim` input and add missing themes: + - Adds `ayu`, `gruvbox_dark`, `iceberg`, `moonfly`, `onedark`, `powerline_dark` and `solarized_light` themes. +- Add [](#opt-vim.spellcheck.extraSpellWords) to allow adding arbitrary + spellfiles to Neovim's runtime with ease. + +- Add combined nvf configuration (`config.vim`) into the final package's + passthru as `passthru.neovimConfiguration` for easier debugging. + [ppenguin](https://github.com/ppenguin): - Telescope: @@ -212,11 +299,35 @@ everyone. - Add LSP and Treesitter support for R under `vim.languages.R`. - Add Otter support under `vim.lsp.otter` and an assert to prevent conflict with ccc +- Fixed typo in Otter's setupOpts +- Add Neorg support under `vim.notes.neorg` +- Add LSP, diagnostics, formatter and Treesitter support for Kotlin under + `vim.languages.kotlin` +- changed default keybinds for leap.nvim to avoid altering expected behavior +- Add LSP, formatter and Treesitter support for Vala under `vim.languages.vala` +- Add [Tinymist](https://github.com/Myriad-Dreamin/tinymist] as a formatter for + the Typst language module. -[Bloxx12](https://github.com/Bloxx12): +[Bloxx12](https://github.com/Bloxx12) +- Add support for [base16 theming](https://github.com/RRethy/base16-nvim) under + `vim.theme` - Fix internal breakage in `elixir-tools` setup. +[ksonj](https://github.com/ksonj): + +- Add LSP support for Scala via + [nvim-metals](https://github.com/scalameta/nvim-metals) + +[nezia1](https://github.com/nezia1): + +- Add [biome](https://github.com/biomejs/biome) support for Typescript, CSS and + Svelte. Enable them via [](#opt-vim.languages.ts.format.type), + [](#opt-vim.languages.css.format.type) and + [](#opt-vim.languages.svelte.format.type) respectively. +- Replace [nixpkgs-fmt](https://github.com/nix-community/nixpkgs-fmt) with + [nixfmt](https://github.com/NixOS/nixfmt) (nixfmt-rfc-style). + [Nowaaru](https://github.com/Nowaaru): - Add `precognition-nvim`. diff --git a/flake.lock b/flake.lock index 0881cae..414478d 100644 --- a/flake.lock +++ b/flake.lock @@ -98,11 +98,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1726871744, - "narHash": "sha256-V5LpfdHyQkUF7RfOaDPrZDP+oqz88lTJrMT1+stXNwo=", + "lastModified": 1730958623, + "narHash": "sha256-JwQZIGSYnRNOgDDoIgqKITrPVil+RMWHsZH1eE1VGN0=", "owner": "nixos", "repo": "nixpkgs", - "rev": "a1d92660c6b3b7c26fb883500a80ea9d33321be2", + "rev": "85f7e662eda4fa3a995556527c87b2524b691933", "type": "github" }, "original": { @@ -172,6 +172,22 @@ "type": "github" } }, + "plugin-base16": { + "flake": false, + "locked": { + "lastModified": 1716483968, + "narHash": "sha256-GRF/6AobXHamw8TZ3FjL7SI6ulcpwpcohsIuZeCSh2A=", + "owner": "rrethy", + "repo": "base16-nvim", + "rev": "6ac181b5733518040a33017dde654059cd771b7c", + "type": "github" + }, + "original": { + "owner": "rrethy", + "repo": "base16-nvim", + "type": "github" + } + }, "plugin-bufdelete-nvim": { "flake": false, "locked": { @@ -191,11 +207,11 @@ "plugin-catppuccin": { "flake": false, "locked": { - "lastModified": 1716704960, - "narHash": "sha256-UDPS+1o8FQGkfqiG4GX4DNUI2pU5hIvagmfnWTKDb44=", + "lastModified": 1728131011, + "narHash": "sha256-j6F078taxuGzr3jngrc+Pc5I1kDdxTLMETgq6Xn4w/4=", "owner": "catppuccin", "repo": "nvim", - "rev": "5215ea59df6d0a7e27da9a5cd1165e06d1b04cbe", + "rev": "7be452ee067978cdc8b2c5f3411f0c71ffa612b9", "type": "github" }, "original": { @@ -300,6 +316,22 @@ "type": "github" } }, + "plugin-cmp-luasnip": { + "flake": false, + "locked": { + "lastModified": 1696878902, + "narHash": "sha256-nUJJl2zyK/oSwz5RzI9j3gf9zpDfCImCYbPbVsyXgz8=", + "owner": "saadparwaiz1", + "repo": "cmp_luasnip", + "rev": "05a9ab28b53f71d1aece421ef32fee2cb857a843", + "type": "github" + }, + "original": { + "owner": "saadparwaiz1", + "repo": "cmp_luasnip", + "type": "github" + } + }, "plugin-cmp-nvim-lsp": { "flake": false, "locked": { @@ -348,22 +380,6 @@ "type": "github" } }, - "plugin-cmp-vsnip": { - "flake": false, - "locked": { - "lastModified": 1669100283, - "narHash": "sha256-2mkN03noOr5vBvRbSb35xZKorSH+8savQNZtgM9+QcM=", - "owner": "hrsh7th", - "repo": "cmp-vsnip", - "rev": "989a8a73c44e926199bfd05fa7a516d51f2d2752", - "type": "github" - }, - "original": { - "owner": "hrsh7th", - "repo": "cmp-vsnip", - "type": "github" - } - }, "plugin-codewindow-nvim": { "flake": false, "locked": { @@ -444,6 +460,22 @@ "type": "github" } }, + "plugin-csharpls-extended": { + "flake": false, + "locked": { + "lastModified": 1728438370, + "narHash": "sha256-sOLPV5IhOvQ0+u7CDAfG3X0ZbRCicz18QyYXQ0dxpwQ=", + "owner": "Decodetalkers", + "repo": "csharpls-extended-lsp.nvim", + "rev": "b647e1bd1f9c0410f5ef4a1517a331cbac322d9a", + "type": "github" + }, + "original": { + "owner": "Decodetalkers", + "repo": "csharpls-extended-lsp.nvim", + "type": "github" + } + }, "plugin-dashboard-nvim": { "flake": false, "locked": { @@ -572,6 +604,22 @@ "type": "github" } }, + "plugin-friendly-snippets": { + "flake": false, + "locked": { + "lastModified": 1727061933, + "narHash": "sha256-yTsuV5unoujY0mhLINssYYBWCeefe+nJaxQHJKm7hlk=", + "owner": "rafamadriz", + "repo": "friendly-snippets", + "rev": "00ba9dd3df89509f95437b8d595553707c46d5ea", + "type": "github" + }, + "original": { + "owner": "rafamadriz", + "repo": "friendly-snippets", + "type": "github" + } + }, "plugin-gesture-nvim": { "flake": false, "locked": { @@ -796,6 +844,22 @@ "type": "github" } }, + "plugin-lua-utils-nvim": { + "flake": false, + "locked": { + "lastModified": 1708177208, + "narHash": "sha256-9ildzQEMkXKZ3LHq+khGFgRQFxlIXQclQ7QU3fcU1C4=", + "owner": "nvim-neorg", + "repo": "lua-utils.nvim", + "rev": "e565749421f4bbb5d2e85e37c3cef9d56553d8bd", + "type": "github" + }, + "original": { + "owner": "nvim-neorg", + "repo": "lua-utils.nvim", + "type": "github" + } + }, "plugin-lualine": { "flake": false, "locked": { @@ -812,6 +876,55 @@ "type": "github" } }, + "plugin-luasnip": { + "flake": false, + "locked": { + "lastModified": 1726165831, + "narHash": "sha256-nkaa1NGOI28Et2QitQB+Spv+J42QVdHE1oywteLcJJw=", + "owner": "L3MON4D3", + "repo": "LuaSnip", + "rev": "e808bee352d1a6fcf902ca1a71cee76e60e24071", + "type": "github" + }, + "original": { + "owner": "L3MON4D3", + "repo": "LuaSnip", + "type": "github" + } + }, + "plugin-lz-n": { + "flake": false, + "locked": { + "lastModified": 1729525284, + "narHash": "sha256-fk+ejqcqqOQz3q4D3VB2Q+U/6wCpCDk1tiDMp2YrPNE=", + "owner": "nvim-neorocks", + "repo": "lz.n", + "rev": "ffd9991400ba7137f4fa8560ff50bccd7f8fb3ee", + "type": "github" + }, + "original": { + "owner": "nvim-neorocks", + "repo": "lz.n", + "type": "github" + } + }, + "plugin-lzn-auto-require": { + "flake": false, + "locked": { + "lastModified": 1727636949, + "narHash": "sha256-BAOzN+XOrFAJwHmsF8JtZ2EyjP9283FD/I2TbFqGSEw=", + "owner": "horriblename", + "repo": "lzn-auto-require", + "rev": "55ecd60831dac8c01d6f3dcb63a30a63a1690eb8", + "type": "github" + }, + "original": { + "owner": "horriblename", + "ref": "require-rewrite", + "repo": "lzn-auto-require", + "type": "github" + } + }, "plugin-mind-nvim": { "flake": false, "locked": { @@ -908,6 +1021,38 @@ "type": "github" } }, + "plugin-neorg": { + "flake": false, + "locked": { + "lastModified": 1727821831, + "narHash": "sha256-yfWQ6yKytu1jkWUtRZTVICslUWej6jVYv7frmSB7/6Q=", + "owner": "nvim-neorg", + "repo": "neorg", + "rev": "afc9a37bf021acb0853e95714c4c6436e1588286", + "type": "github" + }, + "original": { + "owner": "nvim-neorg", + "repo": "neorg", + "type": "github" + } + }, + "plugin-neorg-telescope": { + "flake": false, + "locked": { + "lastModified": 1722358034, + "narHash": "sha256-ei4uUqpIQjGKzu5ryu0Hlmis9TS9FJsYnjt4J4QdWlw=", + "owner": "nvim-neorg", + "repo": "neorg-telescope", + "rev": "ddb2556644cae922699a239bbb0fe16e25b084b7", + "type": "github" + }, + "original": { + "owner": "nvim-neorg", + "repo": "neorg-telescope", + "type": "github" + } + }, "plugin-new-file-template-nvim": { "flake": false, "locked": { @@ -1149,6 +1294,22 @@ "type": "github" } }, + "plugin-nvim-metals": { + "flake": false, + "locked": { + "lastModified": 1728295172, + "narHash": "sha256-ja/+MNxZ3H9io9jDwm5rhE6iKNi86a22eCOY75g19O8=", + "owner": "scalameta", + "repo": "nvim-metals", + "rev": "f861db9fda55939797ac1b05238c49b0dcdc3bdb", + "type": "github" + }, + "original": { + "owner": "scalameta", + "repo": "nvim-metals", + "type": "github" + } + }, "plugin-nvim-navbuddy": { "flake": false, "locked": { @@ -1229,6 +1390,22 @@ "type": "github" } }, + "plugin-nvim-scrollbar": { + "flake": false, + "locked": { + "lastModified": 1729162132, + "narHash": "sha256-/nB7eP2Rz/A9zMXrNEH4FReo6eZS0C/SEGvKhxV7AUA=", + "owner": "petertriho", + "repo": "nvim-scrollbar", + "rev": "6994eb9f73d5fdc36ee2c8717940e8c853e51a49", + "type": "github" + }, + "original": { + "owner": "petertriho", + "repo": "nvim-scrollbar", + "type": "github" + } + }, "plugin-nvim-session-manager": { "flake": false, "locked": { @@ -1341,6 +1518,22 @@ "type": "github" } }, + "plugin-omnisharp-extended": { + "flake": false, + "locked": { + "lastModified": 1719701797, + "narHash": "sha256-P1ZCaW8w+e3H3oBhbEjDc7vuR+XuxJmb/7IbPL3KWi4=", + "owner": "Hoffs", + "repo": "omnisharp-extended-lsp.nvim", + "rev": "aad7bf06b4ca0de816b919d475a75b30f5f62b61", + "type": "github" + }, + "original": { + "owner": "Hoffs", + "repo": "omnisharp-extended-lsp.nvim", + "type": "github" + } + }, "plugin-onedark": { "flake": false, "locked": { @@ -1405,6 +1598,22 @@ "type": "github" } }, + "plugin-pathlib-nvim": { + "flake": false, + "locked": { + "lastModified": 1724943804, + "narHash": "sha256-YhCJeNKlcjgg3q51UWFhuIEPzNueC8YTpeuPPJDndvw=", + "owner": "pysan3", + "repo": "pathlib.nvim", + "rev": "57e5598af6fe253761c1b48e0b59b7cd6699e2c1", + "type": "github" + }, + "original": { + "owner": "pysan3", + "repo": "pathlib.nvim", + "type": "github" + } + }, "plugin-plenary-nvim": { "flake": false, "locked": { @@ -1485,6 +1694,22 @@ "type": "github" } }, + "plugin-rtp-nvim": { + "flake": false, + "locked": { + "lastModified": 1724409589, + "narHash": "sha256-lmJbiD7I7MTEEpukESs67uAmLyn+p66hrUKLbEHp0Kw=", + "owner": "nvim-neorocks", + "repo": "rtp.nvim", + "rev": "494ddfc888bb466555d90ace731856de1320fe45", + "type": "github" + }, + "original": { + "owner": "nvim-neorocks", + "repo": "rtp.nvim", + "type": "github" + } + }, "plugin-rustaceanvim": { "flake": false, "locked": { @@ -1501,22 +1726,6 @@ "type": "github" } }, - "plugin-scrollbar-nvim": { - "flake": false, - "locked": { - "lastModified": 1684886154, - "narHash": "sha256-zLBexSxQCn9HPY04a9w/UCJP1F5ShI2X12I9xE9H0cM=", - "owner": "petertriho", - "repo": "nvim-scrollbar", - "rev": "35f99d559041c7c0eff3a41f9093581ceea534e8", - "type": "github" - }, - "original": { - "owner": "petertriho", - "repo": "nvim-scrollbar", - "type": "github" - } - }, "plugin-smartcolumn": { "flake": false, "locked": { @@ -1757,22 +1966,6 @@ "type": "github" } }, - "plugin-vim-vsnip": { - "flake": false, - "locked": { - "lastModified": 1704937299, - "narHash": "sha256-gvm6z4pgSULBVPukewRyjwxZ0vZgreQWbG/0kOB1QBo=", - "owner": "hrsh7th", - "repo": "vim-vsnip", - "rev": "02a8e79295c9733434aab4e0e2b8c4b7cea9f3a9", - "type": "github" - }, - "original": { - "owner": "hrsh7th", - "repo": "vim-vsnip", - "type": "github" - } - }, "plugin-which-key": { "flake": false, "locked": { @@ -1818,6 +2011,7 @@ "nixpkgs": "nixpkgs", "nmd": "nmd", "plugin-alpha-nvim": "plugin-alpha-nvim", + "plugin-base16": "plugin-base16", "plugin-bufdelete-nvim": "plugin-bufdelete-nvim", "plugin-catppuccin": "plugin-catppuccin", "plugin-ccc": "plugin-ccc", @@ -1826,15 +2020,16 @@ "plugin-cheatsheet-nvim": "plugin-cheatsheet-nvim", "plugin-cinnamon-nvim": "plugin-cinnamon-nvim", "plugin-cmp-buffer": "plugin-cmp-buffer", + "plugin-cmp-luasnip": "plugin-cmp-luasnip", "plugin-cmp-nvim-lsp": "plugin-cmp-nvim-lsp", "plugin-cmp-path": "plugin-cmp-path", "plugin-cmp-treesitter": "plugin-cmp-treesitter", - "plugin-cmp-vsnip": "plugin-cmp-vsnip", "plugin-codewindow-nvim": "plugin-codewindow-nvim", "plugin-comment-nvim": "plugin-comment-nvim", "plugin-copilot-cmp": "plugin-copilot-cmp", "plugin-copilot-lua": "plugin-copilot-lua", "plugin-crates-nvim": "plugin-crates-nvim", + "plugin-csharpls-extended": "plugin-csharpls-extended", "plugin-dashboard-nvim": "plugin-dashboard-nvim", "plugin-diffview-nvim": "plugin-diffview-nvim", "plugin-dracula": "plugin-dracula", @@ -1843,6 +2038,7 @@ "plugin-fastaction-nvim": "plugin-fastaction-nvim", "plugin-fidget-nvim": "plugin-fidget-nvim", "plugin-flutter-tools": "plugin-flutter-tools", + "plugin-friendly-snippets": "plugin-friendly-snippets", "plugin-gesture-nvim": "plugin-gesture-nvim", "plugin-gitsigns-nvim": "plugin-gitsigns-nvim", "plugin-glow-nvim": "plugin-glow-nvim", @@ -1857,13 +2053,19 @@ "plugin-lsp-signature": "plugin-lsp-signature", "plugin-lspkind": "plugin-lspkind", "plugin-lspsaga": "plugin-lspsaga", + "plugin-lua-utils-nvim": "plugin-lua-utils-nvim", "plugin-lualine": "plugin-lualine", + "plugin-luasnip": "plugin-luasnip", + "plugin-lz-n": "plugin-lz-n", + "plugin-lzn-auto-require": "plugin-lzn-auto-require", "plugin-mind-nvim": "plugin-mind-nvim", "plugin-minimap-vim": "plugin-minimap-vim", "plugin-modes-nvim": "plugin-modes-nvim", "plugin-neo-tree-nvim": "plugin-neo-tree-nvim", "plugin-neocord": "plugin-neocord", "plugin-neodev-nvim": "plugin-neodev-nvim", + "plugin-neorg": "plugin-neorg", + "plugin-neorg-telescope": "plugin-neorg-telescope", "plugin-new-file-template-nvim": "plugin-new-file-template-nvim", "plugin-noice-nvim": "plugin-noice-nvim", "plugin-none-ls": "plugin-none-ls", @@ -1879,11 +2081,13 @@ "plugin-nvim-docs-view": "plugin-nvim-docs-view", "plugin-nvim-lightbulb": "plugin-nvim-lightbulb", "plugin-nvim-lspconfig": "plugin-nvim-lspconfig", + "plugin-nvim-metals": "plugin-nvim-metals", "plugin-nvim-navbuddy": "plugin-nvim-navbuddy", "plugin-nvim-navic": "plugin-nvim-navic", "plugin-nvim-neoclip": "plugin-nvim-neoclip", "plugin-nvim-nio": "plugin-nvim-nio", "plugin-nvim-notify": "plugin-nvim-notify", + "plugin-nvim-scrollbar": "plugin-nvim-scrollbar", "plugin-nvim-session-manager": "plugin-nvim-session-manager", "plugin-nvim-surround": "plugin-nvim-surround", "plugin-nvim-tree-lua": "plugin-nvim-tree-lua", @@ -1891,17 +2095,19 @@ "plugin-nvim-ts-autotag": "plugin-nvim-ts-autotag", "plugin-nvim-web-devicons": "plugin-nvim-web-devicons", "plugin-obsidian-nvim": "plugin-obsidian-nvim", + "plugin-omnisharp-extended": "plugin-omnisharp-extended", "plugin-onedark": "plugin-onedark", "plugin-orgmode-nvim": "plugin-orgmode-nvim", "plugin-otter-nvim": "plugin-otter-nvim", "plugin-oxocarbon": "plugin-oxocarbon", + "plugin-pathlib-nvim": "plugin-pathlib-nvim", "plugin-plenary-nvim": "plugin-plenary-nvim", "plugin-precognition-nvim": "plugin-precognition-nvim", "plugin-project-nvim": "plugin-project-nvim", "plugin-registers": "plugin-registers", "plugin-rose-pine": "plugin-rose-pine", + "plugin-rtp-nvim": "plugin-rtp-nvim", "plugin-rustaceanvim": "plugin-rustaceanvim", - "plugin-scrollbar-nvim": "plugin-scrollbar-nvim", "plugin-smartcolumn": "plugin-smartcolumn", "plugin-sqls-nvim": "plugin-sqls-nvim", "plugin-tabular": "plugin-tabular", @@ -1917,7 +2123,6 @@ "plugin-vim-markdown": "plugin-vim-markdown", "plugin-vim-repeat": "plugin-vim-repeat", "plugin-vim-startify": "plugin-vim-startify", - "plugin-vim-vsnip": "plugin-vim-vsnip", "plugin-which-key": "plugin-which-key", "rnix-lsp": "rnix-lsp", "systems": "systems_2" diff --git a/flake.nix b/flake.nix index ed90093..144e136 100644 --- a/flake.nix +++ b/flake.nix @@ -113,6 +113,22 @@ }; ## Plugins + # Lazy loading + plugin-lz-n = { + url = "github:nvim-neorocks/lz.n"; + flake = false; + }; + + plugin-lzn-auto-require = { + url = "github:horriblename/lzn-auto-require/require-rewrite"; + flake = false; + }; + + plugin-rtp-nvim = { + url = "github:nvim-neorocks/rtp.nvim"; + flake = false; + }; + # LSP plugins plugin-nvim-lspconfig = { url = "github:neovim/nvim-lspconfig"; @@ -206,6 +222,21 @@ flake = false; }; + plugin-nvim-metals = { + url = "github:scalameta/nvim-metals"; + flake = false; + }; + + plugin-omnisharp-extended = { + url = "github:Hoffs/omnisharp-extended-lsp.nvim"; + flake = false; + }; + + plugin-csharpls-extended = { + url = "github:Decodetalkers/csharpls-extended-lsp.nvim"; + flake = false; + }; + # Copying/Registers plugin-registers = { url = "github:tversteeg/registers.nvim"; @@ -277,11 +308,6 @@ flake = false; }; - plugin-cmp-vsnip = { - url = "github:hrsh7th/cmp-vsnip"; - flake = false; - }; - plugin-cmp-path = { url = "github:hrsh7th/cmp-path"; flake = false; @@ -292,9 +318,19 @@ flake = false; }; + plugin-cmp-luasnip = { + url = "github:saadparwaiz1/cmp_luasnip"; + flake = false; + }; + # snippets - plugin-vim-vsnip = { - url = "github:hrsh7th/vim-vsnip"; + plugin-luasnip = { + url = "github:L3MON4D3/LuaSnip"; + flake = false; + }; + + plugin-friendly-snippets = { + url = "github:rafamadriz/friendly-snippets"; flake = false; }; @@ -349,6 +385,11 @@ }; # Themes + plugin-base16 = { + url = "github:rrethy/base16-nvim"; + flake = false; + }; + plugin-tokyonight = { url = "github:folke/tokyonight.nvim"; flake = false; @@ -402,7 +443,7 @@ flake = false; }; - plugin-scrollbar-nvim = { + plugin-nvim-scrollbar = { url = "github:petertriho/nvim-scrollbar"; flake = false; }; @@ -636,6 +677,26 @@ flake = false; }; + plugin-lua-utils-nvim = { + url = "github:nvim-neorg/lua-utils.nvim"; + flake = false; + }; + + plugin-pathlib-nvim = { + url = "github:pysan3/pathlib.nvim"; + flake = false; + }; + + plugin-neorg = { + url = "github:nvim-neorg/neorg"; + flake = false; + }; + + plugin-neorg-telescope = { + url = "github:nvim-neorg/neorg-telescope"; + flake = false; + }; + plugin-nui-nvim = { # (required by noice.nvim) url = "github:MunifTanjim/nui.nvim"; diff --git a/flake/packages.nix b/flake/packages.nix index 84514a2..1f38292 100644 --- a/flake/packages.nix +++ b/flake/packages.nix @@ -19,7 +19,7 @@ docs-html-wrapped = pkgs.writeScriptBin "docs-html-wrapped" '' #!${pkgs.stdenv.shell} # use xdg-open to open the docs in the browser - ${pkgs.xdg_utils}/bin/xdg-open ${docs.manual.html} + ${pkgs.xdg-utils}/bin/xdg-open ${docs.manual.html} ''; # Exposed neovim configurations @@ -29,10 +29,10 @@ # Published docker images docker-nix = let - inherit (pkgs) bash gitFull buildEnv dockerTools; + inherit (pkgs) bash gitFull buildEnv; inherit (config.legacyPackages) neovim-nix; in - dockerTools.buildImage { + pkgs.dockerTools.buildImage { name = "nvf"; tag = "latest"; diff --git a/lib/attrsets.nix b/lib/attrsets.nix new file mode 100644 index 0000000..59275af --- /dev/null +++ b/lib/attrsets.nix @@ -0,0 +1,5 @@ +{lib}: let + inherit (builtins) listToAttrs; +in { + mapListToAttrs = f: list: listToAttrs (map f list); +} diff --git a/lib/binds.nix b/lib/binds.nix index 8c9e9a6..298cd30 100644 --- a/lib/binds.nix +++ b/lib/binds.nix @@ -67,6 +67,30 @@ mkLuaBinding binding.value action binding.description; pushDownDefault = attr: mapAttrs (_: mkDefault) attr; + + mkLznBinding = mode: key: action: desc: { + inherit mode desc key action; + }; + + mkLznExprBinding = mode: key: action: desc: { + inherit mode desc key action; + lua = true; + silent = true; + expr = true; + }; + + mkSetLznBinding = binding: action: { + inherit action; + key = binding.value; + desc = binding.description; + }; + + mkSetLuaLznBinding = binding: action: { + inherit action; + key = binding.value; + lua = true; + desc = binding.description; + }; }; in binds diff --git a/lib/default.nix b/lib/default.nix index a418cff..e6ccd2a 100644 --- a/lib/default.nix +++ b/lib/default.nix @@ -10,6 +10,7 @@ dag = import ./dag.nix {inherit lib;}; languages = import ./languages.nix {inherit lib;}; lists = import ./lists.nix {inherit lib;}; + attrsets = import ./attrsets.nix {inherit lib;}; lua = import ./lua.nix {inherit lib;}; neovimConfiguration = import ../modules {inherit inputs lib;}; } diff --git a/lib/languages.nix b/lib/languages.nix index e47202e..52f1b5b 100644 --- a/lib/languages.nix +++ b/lib/languages.nix @@ -2,8 +2,8 @@ {lib}: let inherit (builtins) isString getAttr; inherit (lib.options) mkOption; - inherit (lib.attrsets) listToAttrs; inherit (lib.types) bool; + inherit (lib.nvim.attrsets) mapListToAttrs; in { # Converts a boolean to a yes/no string. This is used in lots of # configuration formats. @@ -12,21 +12,21 @@ in { config, diagnosticsProviders, }: - listToAttrs - (map (v: let - type = - if isString v - then v - else getAttr v.type; - package = - if isString v - then diagnosticsProviders.${type}.package - else v.package; - in { - name = "${lang}-diagnostics-${type}"; - value = diagnosticsProviders.${type}.nullConfig package; - }) - config); + mapListToAttrs + (v: let + type = + if isString v + then v + else getAttr v.type; + package = + if isString v + then diagnosticsProviders.${type}.package + else v.package; + in { + name = "${lang}-diagnostics-${type}"; + value = diagnosticsProviders.${type}.nullConfig package; + }) + config; mkEnable = desc: mkOption { diff --git a/lib/types/custom.nix b/lib/types/custom.nix index a94735c..3d4a2bc 100644 --- a/lib/types/custom.nix +++ b/lib/types/custom.nix @@ -1,8 +1,9 @@ {lib}: let - inherit (lib) isStringLike showOption showFiles getFiles mergeOneOption mergeEqualOption mkOptionType; - inherit (lib.types) anything attrsOf; + inherit (lib.options) showOption showFiles getFiles mergeOneOption mergeEqualOption; + inherit (lib.strings) isString isStringLike; + inherit (lib.types) anything attrsOf listOf mkOptionType; inherit (lib.nvim.types) anythingConcatLists; - inherit (builtins) typeOf isAttrs any head concatLists stringLength; + inherit (builtins) typeOf isAttrs any head concatLists stringLength match; in { # HACK: Does this break anything in our case? # A modified version of the nixpkgs anything type that concatenates lists @@ -51,6 +52,16 @@ in { (mergeFunctions.${commonType} or mergeEqualOption) loc defs; }; + mergelessListOf = elemType: let + super = listOf elemType; + in + super + // { + name = "mergelessListOf"; + description = "mergeless ${super.description}"; + merge = mergeEqualOption; + }; + char = mkOptionType { name = "char"; description = "character"; @@ -58,4 +69,11 @@ in { check = value: stringLength value < 2; merge = mergeEqualOption; }; + + hexColor = mkOptionType { + name = "hex-color"; + descriptionClass = "noun"; + description = "RGB color in hex format"; + check = v: isString v && (match "#?[0-9a-fA-F]{6}" v) != null; + }; } diff --git a/lib/types/default.nix b/lib/types/default.nix index 6751229..73b3595 100644 --- a/lib/types/default.nix +++ b/lib/types/default.nix @@ -6,10 +6,10 @@ typesDag = import ./dag.nix {inherit lib;}; typesPlugin = import ./plugins.nix {inherit inputs lib;}; typesLanguage = import ./languages.nix {inherit lib;}; - typesCustom = import ./custom.nix {inherit lib;}; + customTypes = import ./custom.nix {inherit lib;}; in { inherit (typesDag) dagOf; inherit (typesPlugin) pluginsOpt extraPluginType mkPluginSetupOption luaInline pluginType borderType; inherit (typesLanguage) diagnostics mkGrammarOption; - inherit (typesCustom) anythingConcatLists char; + inherit (customTypes) anythingConcatLists char hexColor mergelessListOf; } diff --git a/modules/default.nix b/modules/default.nix index 6a95080..ee7febd 100644 --- a/modules/default.nix +++ b/modules/default.nix @@ -84,10 +84,7 @@ # built (or "normalized") plugins that are modified builtStartPlugins = buildConfigPlugins vimOptions.startPlugins; - builtOptPlugins = map (package: { - plugin = package; - optional = true; - }) (buildConfigPlugins vimOptions.optPlugins); + builtOptPlugins = map (package: package // {optional = true;}) (buildConfigPlugins vimOptions.optPlugins); # additional Lua and Python3 packages, mapped to their respective functions # to conform to the format mnw expects. end user should @@ -126,6 +123,11 @@ in { paths = [neovim-wrapped printConfig printConfigPath]; postBuild = "echo Helpers added"; + # Allow evaluating vimOptions, i.e., config.vim from the packages' passthru + # attribute. For example, packages.x86_64-linux.neovim.passthru.neovimConfig + # will return the configuration in full. + passthru.neovimConfig = vimOptions; + meta = { description = "Wrapped version of Neovim with additional helper scripts"; mainProgram = "nvim"; diff --git a/modules/extra/deprecations.nix b/modules/extra/deprecations.nix index 388913a..5a30ef5 100644 --- a/modules/extra/deprecations.nix +++ b/modules/extra/deprecations.nix @@ -1,5 +1,5 @@ {lib, ...}: let - inherit (lib.modules) mkRemovedOptionModule; + inherit (lib.modules) mkRemovedOptionModule mkRenamedOptionModule; in { imports = [ # 2024-06-06 @@ -14,5 +14,45 @@ in { available under `vim.ui.fastaction` as a replacement. Simply remove everything under `vim.lsp.nvimCodeActionMenu`, and set `vim.ui.fastaction.enable` to `true`. '') + + (mkRemovedOptionModule ["vim" "autopairs" "enable"] '' + vim.autopairs.enable has been removed in favor of per-plugin modules. + You can enable nvim-autopairs with vim.autopairs.nvim-autopairs.enable instead. + '') + (mkRemovedOptionModule ["vim" "autopairs" "type"] '' + vim.autopairs.type has been removed in favor of per-plugin modules. + You can enable nvim-autopairs with vim.autopairs.nvim-autopairs.enable instead. + '') + (mkRemovedOptionModule ["vim" "autocomplete" "enable"] '' + vim.autocomplete.enable has been removed in favor of per-plugin modules. + You can enable nvim-cmp with vim.autocomplete.nvim-cmp.enable instead. + '') + (mkRemovedOptionModule ["vim" "autocomplete" "type"] '' + vim.autocomplete.type has been removed in favor of per-plugin modules. + You can enable nvim-cmp with vim.autocomplete.nvim-cmp.enable instead. + '') + (mkRemovedOptionModule ["vim" "autocomplete" "sources"] '' + vim.autocomplete.sources has been removed in favor of per-plugin modules. + You can add nvim-cmp sources with vim.autocomplete.nvim-cmp.sources + instead. + '') + (mkRemovedOptionModule ["vim" "snippets" "vsnip" "enable"] '' + vim.snippets.vsnip.enable has been removed in favor of the more modern luasnip. + '') + (mkRenamedOptionModule ["vim" "lsp" "lspkind" "mode"] ["vim" "lsp" "lspkind" "setupOpts" "mode"]) + + # 2024-10-14 + (mkRemovedOptionModule ["vim" "configRC"] '' + Please migrate your configRC sections to Neovim's Lua format, and + add them to `vim.luaConfigRC`. + + See the v0.7 release notes for more information on why and how to + migrate your existing configurations to the new format. + '') + + (mkRemovedOptionModule ["vim" "disableDefaultRuntimePaths"] '' + Nvf now uses $NVIM_APP_NAME so there is no longer the problem of + (accidental) leaking of user configuration. + '') ]; } diff --git a/modules/modules.nix b/modules/modules.nix index 1204e43..784c413 100644 --- a/modules/modules.nix +++ b/modules/modules.nix @@ -50,6 +50,7 @@ "build" "rc" "warnings" + "lazy" ]; # Extra modules, such as deprecation warnings diff --git a/modules/neovim/init/spellcheck.nix b/modules/neovim/init/spellcheck.nix index d8957ef..5d6f5be 100644 --- a/modules/neovim/init/spellcheck.nix +++ b/modules/neovim/init/spellcheck.nix @@ -1,11 +1,14 @@ { config, + pkgs, lib, ... }: let inherit (lib.modules) mkIf mkRenamedOptionModule; inherit (lib.options) mkOption mkEnableOption literalExpression; - inherit (lib.types) listOf str; + inherit (lib.strings) concatLines; + inherit (lib.attrsets) mapAttrsToList; + inherit (lib.types) listOf str attrsOf; inherit (lib.nvim.lua) listToLuaTable; inherit (lib.nvim.dag) entryAfter; @@ -24,10 +27,48 @@ in { description = '' A list of languages that should be used for spellchecking. - To add your own language files, you may place your `spell` - directory in either `~/.config/nvim` or the - [additionalRuntimePaths](#opt-vim.additionalRuntimePaths) - directory provided by **nvf**. + To add your own language files, you may place your `spell` directory in either + {file}`$XDG_CONFIG_HOME/nvf` or in a path that is included in the + [additionalRuntimePaths](#opt-vim.additionalRuntimePaths) list provided by nvf. + ''; + }; + + extraSpellWords = mkOption { + type = attrsOf (listOf str); + default = {}; + example = literalExpression ''{"en.utf-8" = ["nvf" "word_you_want_to_add"];}''; + description = '' + Additional words to be used for spellchecking. The names of each key will be + used as the language code for the spell file. For example + + ```nix + "en.utf-8" = [ ... ]; + ``` + + will result in `en.utf-8.add.spl` being added to Neovim's runtime in the + {file}`spell` directory. + + ::: {.warning} + The attribute keys must be in `"."` format for Neovim to + compile your spellfiles without mangling the resulting file names. Please + make sure that you enter the correct value, as nvf does not do any kind of + internal checking. Please see {command}`:help mkspell` for more details. + + Example: + + ```nix + # "en" is the name, and "utf-8" is the encoding. For most use cases, utf-8 + # will be enough, however, you may change it to any encoding format Neovim + # accepts, e.g., utf-16. + "en.utf-8" = ["nvf" "word_you_want_to_add"]; + => $out/spell/en-utf-8.add.spl + ``` + ::: + + Note that while adding a new language, you will still need to add the name of + the language (e.g. "en") to the {option}`vim.spellcheck.languages` list by name + in order to enable spellchecking for the language. By default only `"en"` is in + the list. ''; }; @@ -38,38 +79,75 @@ in { description = '' A list of filetypes for which spellchecking will be disabled. - You may use `echo &filetype` in Neovim to find out the + ::: {.tip} + You may use {command}`:echo &filetype` in Neovim to find out the filetype for a specific buffer. + ::: ''; }; - /* - # FIXME: This needs to be revisited. It tries to install - # the spellfile to an user directory, but it cannot do so - # as we sanitize runtime paths. programmingWordlist.enable = mkEnableOption '' vim-dirtytalk, a wordlist for programmers containing common programming terms. - Setting this value as `true` has the same effect - as setting {option}`vim.spellCheck.enable` + ::: {.note} + Enabling this option will unconditionally set + {option}`vim.spellcheck.enable` to true as vim-dirtytalk + depends on spellchecking having been set up. + ::: ''; - */ }; config = mkIf cfg.enable { - vim.luaConfigRC.spellcheck = entryAfter ["basic"] '' - vim.opt.spell = true - vim.opt.spelllang = ${listToLuaTable cfg.languages} + vim = { + additionalRuntimePaths = let + compileJoinedSpellfiles = + pkgs.runCommandLocal "nvf-compile-spellfiles" { + # Use the same version of Neovim as the user's configuration + nativeBuildInputs = [config.vim.package]; - -- Disable spellchecking for certain filetypes - -- as configured by `vim.spellcheck.ignoredFiletypes` - vim.api.nvim_create_autocmd({ "FileType" }, { - pattern = ${listToLuaTable cfg.ignoredFiletypes}, - callback = function() - vim.opt_local.spell = false - end, - }) - ''; + spellfilesJoined = pkgs.symlinkJoin { + name = "nvf-spellfiles-joined"; + paths = mapAttrsToList (name: value: pkgs.writeTextDir "spell/${name}.add" (concatLines value)) cfg.extraSpellWords; + postBuild = "echo Spellfiles joined"; + }; + } '' + # Fail on unset variables and non-zero exit codes + # this might be the only way to trace when `nvim --headless` + # fails in batch mode + set -eu + + mkdir -p "$out/spell" + for spellfile in "$spellfilesJoined"/spell/*.add; do + name="$(basename "$spellfile" ".add")" + echo "Compiling spellfile: $spellfile" + nvim --headless --clean \ + --cmd "mkspell $out/spell/$name.add.spl $spellfile" -Es -n + done + + ''; + in + mkIf (cfg.extraSpellWords != {}) [ + # If .outPath is missing, additionalRuntimePaths receives the *function* + # instead of a path, causing errors. + compileJoinedSpellfiles.outPath + ]; + + luaConfigRC.spellcheck = entryAfter ["basic"] '' + vim.opt.spell = true + vim.opt.spelllang = ${listToLuaTable cfg.languages} + + -- Disable spellchecking for certain filetypes + -- as configured by `vim.spellcheck.ignoredFiletypes` + vim.api.nvim_create_augroup("nvf_autocmds", {clear = false}) + vim.api.nvim_create_autocmd({ "FileType" }, { + group = "nvf_autocmds", + pattern = ${listToLuaTable cfg.ignoredFiletypes}, + callback = function() + vim.opt_local.spell = false + end, + }) + ''; + }; }; } diff --git a/modules/neovim/mappings/config.nix b/modules/neovim/mappings/config.nix index 28ebf08..4d7f241 100644 --- a/modules/neovim/mappings/config.nix +++ b/modules/neovim/mappings/config.nix @@ -3,51 +3,75 @@ lib, ... }: let - inherit (lib.modules) mkIf; + inherit (lib.modules) mkIf mkMerge; + inherit (lib.trivial) pipe; + inherit (lib.attrsets) mapAttrsToList; + inherit (lib.lists) flatten; + + legacyMapModes = { + normal = ["n"]; + insert = ["i"]; + select = ["s"]; + visual = ["v"]; + terminal = ["t"]; + normalVisualOp = ["n" "v" "o"]; + visualOnly = ["n" "x"]; + operator = ["o"]; + insertCommand = ["i" "c"]; + lang = ["l"]; + command = ["c"]; + }; cfg = config.vim; in { config = { - vim.maps = { - normal = mkIf cfg.disableArrows { - "" = { - action = ""; - - noremap = false; - }; - "" = { - action = ""; - - noremap = false; - }; - "" = { - action = ""; - noremap = false; - }; - "" = { - action = ""; - noremap = false; - }; - }; - - insert = mkIf cfg.disableArrows { - "" = { - action = ""; - noremap = false; - }; - "" = { - action = ""; - noremap = false; - }; - "" = { - action = ""; - noremap = false; - }; - "" = { - action = ""; - noremap = false; - }; - }; - }; + vim.keymaps = mkMerge [ + ( + mkIf cfg.disableArrows [ + { + key = ""; + mode = ["n" "i"]; + action = ""; + noremap = false; + } + { + key = ""; + mode = ["n" "i"]; + action = ""; + noremap = false; + } + { + key = ""; + mode = ["n" "i"]; + action = ""; + noremap = false; + } + { + key = ""; + mode = ["n" "i"]; + action = ""; + noremap = false; + } + ] + ) + ( + pipe cfg.maps + [ + (mapAttrsToList ( + oldMode: keybinds: + mapAttrsToList ( + key: bind: + bind + // { + inherit key; + mode = legacyMapModes.${oldMode}; + } + ) + keybinds + )) + flatten + ] + ) + ]; }; } diff --git a/modules/neovim/mappings/options.nix b/modules/neovim/mappings/options.nix index 3b1f263..8f0e8eb 100644 --- a/modules/neovim/mappings/options.nix +++ b/modules/neovim/mappings/options.nix @@ -1,101 +1,97 @@ {lib, ...}: let - inherit (lib.options) mkOption; - inherit (lib.types) bool str attrsOf nullOr submodule; + inherit (lib.options) mkOption literalMD; + inherit (lib.types) either str listOf attrsOf nullOr submodule; inherit (lib.nvim.config) mkBool; - # Most of the keybindings code is highly inspired by pta2002/nixvim. - # Thank you! + mapConfigOptions = { - silent = - mkBool false - "Whether this mapping should be silent. Equivalent to adding to a map."; - - nowait = - mkBool false - "Whether to wait for extra input on ambiguous mappings. Equivalent to adding to a map."; - - script = - mkBool false - "Equivalent to adding