diff --git a/configuration.nix b/configuration.nix index f56061b..a3ab7bf 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,15 +65,15 @@ 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 = { @@ -106,12 +107,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 = { @@ -174,6 +173,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/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 7023371..87df91e 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 @@ -124,10 +171,36 @@ 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 +209,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 @@ -212,7 +287,29 @@ 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` -[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). diff --git a/flake.lock b/flake.lock index 7775fb1..4e5ec65 100644 --- a/flake.lock +++ b/flake.lock @@ -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,22 @@ "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-mind-nvim": { "flake": false, "locked": { @@ -908,6 +988,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 +1261,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": { @@ -1341,6 +1469,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 +1549,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": { @@ -1741,22 +1901,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": { @@ -1802,6 +1946,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", @@ -1810,15 +1955,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", @@ -1827,6 +1973,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", @@ -1841,13 +1988,17 @@ "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-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", @@ -1863,6 +2014,7 @@ "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", @@ -1875,10 +2027,12 @@ "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-project-nvim": "plugin-project-nvim", "plugin-registers": "plugin-registers", @@ -1900,7 +2054,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 987e3e5..00b56c5 100644 --- a/flake.nix +++ b/flake.nix @@ -206,6 +206,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 +292,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 +302,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 +369,11 @@ }; # Themes + plugin-base16 = { + url = "github:rrethy/base16-nvim"; + flake = false; + }; + plugin-tokyonight = { url = "github:folke/tokyonight.nvim"; flake = false; @@ -631,6 +656,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/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/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/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/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