diff --git a/docs/release-notes/rl-0.4.md b/docs/release-notes/rl-0.4.md index f5c2c338..ad3cc4dd 100644 --- a/docs/release-notes/rl-0.4.md +++ b/docs/release-notes/rl-0.4.md @@ -49,7 +49,7 @@ absence. - Made Copilot's Node package configurable. It is recommended to keep as default, but providing a different NodeJS version is now possible. -- Added `vim.cursorlineOpt` for configuring Neovim's `vim.o.cursorlineopt`. +- Added [](#opt-vim.cursorlineOpt) for configuring Neovim's cursorlineOpt. - Added `filetree.nvimTreeLua.view.cursorline`, default false, to enable cursorline in nvimtre. diff --git a/docs/release-notes/rl-0.7.md b/docs/release-notes/rl-0.7.md index 1a23634c..8dcfc5b0 100644 --- a/docs/release-notes/rl-0.7.md +++ b/docs/release-notes/rl-0.7.md @@ -91,30 +91,6 @@ default. This is to avoid conflicts with other modules. You can change `maplocalleader` with `vim.globals.maplocalleader`, but it's recommended to set it to something other than `mapleader` to avoid conflicts. -### `vim.*` changes {#sec-vim-opt-changes} - -Inline with the [leader changes](#sec-leader-changes), we have removed some -options that were under `vim` as convenient shorthands for `vim.o.*` options. - -::: {.warning} - -As v0.7 features the addition of [](#opt-vim.options), those options are now -considered as deprecated. You should migrate to the appropriate options in the -`vim.options` submodule. - -::: - -The changes are, in no particular order: - -- `colourTerm`, `mouseSupport`, `cmdHeight`, `updateTime`, `mapTime`, - `cursorlineOpt`, `splitBelow`, `splitRight`, `autoIndent` and `wordWrap` have - been mapped to their [](#opt-vim.options) equivalents. Please see the module - definition for the updated options. - -- `tabWidth` has been **removed** as it lead to confusing behaviour. You can - replicate the same functionality by setting `shiftwidth`, `tabstop` and - `softtabstop` under `vim.options` as you see fit. - ## Changelog {#sec-release-0.7-changelog} [ItsSorae](https://github.com/ItsSorae): @@ -157,10 +133,10 @@ The changes are, in no particular order: recommended to go through rustacean.nvim's README to take a closer look at its features and usage -[lz.n]: https://github.com/mrcjkb/lz.n - - 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 @@ -324,22 +300,17 @@ The changes are, in no particular order: 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. + passthru as `passthru.neovimConfiguration` for easier debugging. - Add support for [tiny-devicons-auto-colors] under `vim.visuals.tiny-devicons-auto-colors` -- Move options that used to set `vim.o` values (e.g. `vim.wordWrap`) into - `vim.options` as default values. Some are left as they don't have a direct - equivalent, but expect a switch eventually. - [ppenguin](https://github.com/ppenguin): - Telescope: - Fixed `project-nvim` command and keybinding - Added default ikeybind/command for `Telescope resume` (`fr`) -- Add `hcl` lsp/formatter (not the same as `terraform`, which is not useful for - e.g. `nomad` config files). +- Add `hcl` lsp/formatter (not the same as `terraform`, which is not useful for e.g. `nomad` config files). [Soliprem](https://github.com/Soliprem): diff --git a/modules/extra/deprecations.nix b/modules/extra/deprecations.nix index e4cb193f..2b6fa7d7 100644 --- a/modules/extra/deprecations.nix +++ b/modules/extra/deprecations.nix @@ -1,93 +1,65 @@ {lib, ...}: let inherit (lib.modules) mkRemovedOptionModule mkRenamedOptionModule; - inherit (lib.lists) concatLists; - inherit (lib.nvim.config) batchRenameOptions; - - renamedVimOpts = batchRenameOptions ["vim"] ["vim" "options"] { - colourTerm = "termguicolors"; - mouseSupport = "mouse"; - cmdHeight = "cmdheight"; - updateTime = "updatetime"; - mapTimeout = "tm"; - cursorlineOpt = "cursorlineopt"; - splitBelow = "splitbelow"; - splitRight = "splitright"; - autoIndent = "autoindent"; - wordWrap = "wrap"; - }; in { - imports = concatLists [ - [ - # 2024-06-06 - (mkRemovedOptionModule ["vim" "tidal"] '' - Tidalcycles language support has been removed as of 2024-06-06 as it was long unmaintained. If - you depended on this functionality, please open an issue. - '') + imports = [ + # 2024-06-06 + (mkRemovedOptionModule ["vim" "tidal"] '' + Tidalcycles language support has been removed as of 2024-06-06 as it was long unmaintained. If + you depended on this functionality, please open an issue. + '') - # 2024-07-20 - (mkRemovedOptionModule ["vim" "lsp" "nvimCodeActionMenu"] '' - nvimCodeActionMenu has been deprecated and removed upstream. As of 0.7, fastaction will be - available under `vim.ui.fastaction` as a replacement. Simply remove everything under - `vim.lsp.nvimCodeActionMenu`, and set `vim.ui.fastaction.enable` to `true`. - '') + # 2024-07-20 + (mkRemovedOptionModule ["vim" "lsp" "nvimCodeActionMenu"] '' + nvimCodeActionMenu has been deprecated and removed upstream. As of 0.7, fastaction will be + 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"]) + (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`. + # 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. - '') + 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. - '') + (mkRemovedOptionModule ["vim" "disableDefaultRuntimePaths"] '' + Nvf now uses $NVIM_APP_NAME so there is no longer the problem of + (accidental) leaking of user configuration. + '') - (mkRemovedOptionModule ["vim" "lsp" "trouble" "mappings" "toggle"] '' - With Trouble having so many different modes, and breaking changes - upstream, it no longer makes sense, nor works, to toggle only Trouble. - '') - - # 2024-11-30 - (mkRenamedOptionModule ["vim" "leaderKey"] ["vim" "globals" "mapleader"]) - - (mkRemovedOptionModule ["vim" "tabWidth"] '' - Previous behaviour of this option was confusing and undocumented. Please set - `tabstop` and `shiftwidth` manually in `vim.options` or per-filetype in a - `ftplugin` directory added to your runtime path. - '') - ] - - # 2024-12-1 - # Migrated via batchRenameOptions. Further batch renames must be below this line. - renamedVimOpts + (mkRemovedOptionModule ["vim" "lsp" "trouble" "mappings" "toggle"] '' + With Trouble having so many different modes, and breaking changes + upstream, it no longer makes sense, nor works, to toggle only Trouble. + '') + # 2024-11-30 + (mkRenamedOptionModule ["vim" "leaderKey"] ["vim" "globals" "mapleader"]) ]; } diff --git a/modules/neovim/init/basic.nix b/modules/neovim/init/basic.nix index 9370fa8f..c7d98e02 100644 --- a/modules/neovim/init/basic.nix +++ b/modules/neovim/init/basic.nix @@ -3,18 +3,23 @@ lib, ... }: let - inherit (lib.options) mkOption mkEnableOption literalMD; + inherit (lib.options) mkOption mkEnableOption literalExpression literalMD; inherit (lib.strings) optionalString; inherit (lib.types) enum bool str int either; inherit (lib.generators) mkLuaInline; inherit (lib.nvim.dag) entryAfter; - inherit (lib.nvim.binds) pushDownDefault; inherit (lib.nvim.lua) toLuaObject; inherit (lib.nvim.types) luaInline; cfg = config.vim; in { options.vim = { + colourTerm = mkOption { + type = bool; + default = true; + description = "Set terminal up for 256 colours"; + }; + disableArrows = mkOption { type = bool; default = false; @@ -33,6 +38,12 @@ in { description = "Start scrolling this number of lines from the top or bottom of the page."; }; + wordWrap = mkOption { + type = bool; + default = true; + description = "Enable word wrapping."; + }; + syntaxHighlighting = mkOption { type = bool; default = !config.vim.treesitter.highlight.enable; @@ -45,10 +56,24 @@ in { description = "Make use of the clipboard for default yank and paste operations. Don't use * and +"; }; + mouseSupport = mkOption { + type = enum ["a" "n" "v" "i" "c"]; + default = "a"; + description = '' + Set modes for mouse support. + + * a - all + * n - normal + * v - visual + * i - insert + * c - command + ''; + }; + lineNumberMode = mkOption { type = enum ["relative" "number" "relNumber" "none"]; default = "relNumber"; - example = "none"; + example = literalExpression "none"; description = "How line numbers are displayed."; }; @@ -58,6 +83,30 @@ in { description = "Prevent swapfile and backupfile from being created"; }; + tabWidth = mkOption { + type = int; + default = 4; + description = "Set the width of tabs"; + }; + + autoIndent = mkOption { + type = bool; + default = true; + description = "Enable auto indent"; + }; + + cmdHeight = mkOption { + type = int; + default = 1; + description = "Height of the command pane"; + }; + + updateTime = mkOption { + type = int; + default = 300; + description = "The number of milliseconds till Cursor Hold event is fired"; + }; + showSignColumn = mkOption { type = bool; default = true; @@ -70,12 +119,36 @@ in { description = "Set how bells are handled. Options: on, visual or none"; }; + mapTimeout = mkOption { + type = int; + default = 500; + description = "Timeout in ms that neovim will wait for mapped action to complete"; + }; + + splitBelow = mkOption { + type = bool; + default = true; + description = "New splits will open below instead of on top"; + }; + + splitRight = mkOption { + type = bool; + default = true; + description = "New splits will open to the right"; + }; + enableEditorconfig = mkOption { type = bool; default = true; description = "Follow editorconfig rules in current directory"; }; + cursorlineOpt = mkOption { + type = enum ["line" "screenline" "number" "both"]; + default = "line"; + description = "Highlight the text line of the cursor with CursorLine hl-CursorLine"; + }; + searchCase = mkOption { type = enum ["ignore" "smart" "sensitive"]; default = "sensitive"; @@ -102,35 +175,44 @@ in { }; }; - config.vim = { - # Set options that were previously interpolated in 'luaConfigRC.basic' as vim.options (vim.o) - # and 'vim.globals' (vim.g). Future options, if possible, should be added here instead of the - # luaConfigRC section below. - options = pushDownDefault { - encoding = "utf-8"; - hidden = true; - expandtab = true; - }; - - globals = pushDownDefault { - editorconfig = cfg.enableEditorconfig; - }; - - # Options that are more difficult to set through 'vim.options'. Fear not, though - # as the Lua DAG is still as powerful as it could be. - luaConfigRC.basic = entryAfter ["globalsScript"] '' + config = { + vim.luaConfigRC.basic = entryAfter ["globalsScript"] '' -- Settings that are set for everything + vim.o.encoding = "utf-8" + vim.o.hidden = true vim.opt.shortmess:append("c") + vim.o.expandtab = true + vim.o.mouse = ${toLuaObject cfg.mouseSupport} + vim.o.tabstop = ${toLuaObject cfg.tabWidth} + vim.o.shiftwidth = ${toLuaObject cfg.tabWidth} + vim.o.softtabstop = ${toLuaObject cfg.tabWidth} + vim.o.cmdheight = ${toLuaObject cfg.cmdHeight} + vim.o.updatetime = ${toLuaObject cfg.updateTime} + vim.o.tm = ${toLuaObject cfg.mapTimeout} + vim.o.cursorlineopt = ${toLuaObject cfg.cursorlineOpt} + vim.o.scrolloff = ${toLuaObject cfg.scrollOffset} ${optionalString cfg.undoFile.enable '' vim.o.undofile = true vim.o.undodir = ${toLuaObject cfg.undoFile.path} ''} + ${optionalString cfg.splitBelow '' + vim.o.splitbelow = true + ''} + + ${optionalString cfg.splitRight '' + vim.o.splitright = true + ''} + ${optionalString cfg.showSignColumn '' vim.o.signcolumn = "yes" ''} + ${optionalString cfg.autoIndent '' + vim.o.autoindent = true + ''} + ${optionalString cfg.preventJunkFiles '' vim.o.swapfile = false vim.o.backup = false @@ -171,11 +253,23 @@ in { vim.cmd("syntax on") ''} + ${optionalString (!cfg.wordWrap) '' + vim.o.wrap = false + ''} + ${optionalString cfg.hideSearchHighlight '' vim.o.hlsearch = false vim.o.incsearch = true ''} + ${optionalString cfg.colourTerm '' + vim.o.termguicolors = true + ''} + + ${optionalString (!cfg.enableEditorconfig) '' + vim.g.editorconfig = false + ''} + ${optionalString (cfg.searchCase == "ignore") '' vim.o.smartcase = false vim.o.ignorecase = true diff --git a/modules/wrapper/rc/options.nix b/modules/wrapper/rc/options.nix index 4680190a..df232572 100644 --- a/modules/wrapper/rc/options.nix +++ b/modules/wrapper/rc/options.nix @@ -5,7 +5,7 @@ }: let inherit (lib.options) mkOption mkEnableOption literalMD literalExpression; inherit (lib.strings) optionalString; - inherit (lib.types) str bool int enum attrsOf lines listOf either path submodule anything; + inherit (lib.types) str attrs lines listOf either path submodule anything; inherit (lib.nvim.types) dagOf; inherit (lib.nvim.lua) listToLuaTable; @@ -102,22 +102,20 @@ in { globals = mkOption { default = {}; type = submodule { - freeformType = attrsOf anything; + freeformType = anything; options = { mapleader = mkOption { type = str; default = " "; - description = "The key used for `` mappings"; + description = "The key used for mappings"; }; - maplocalleader = mkOption { type = str; default = ","; - description = "The key used for `` mappings"; + description = "The key used for mappings"; }; }; }; - example = {"some_variable" = 42;}; description = '' An attribute set containing global variable values @@ -135,80 +133,8 @@ in { }; options = mkOption { + type = attrs; default = {}; - type = submodule { - freeformType = attrsOf anything; - options = { - termguicolors = mkOption { - type = bool; - default = true; - description = "Set terminal up for 256 colours"; - }; - - mouse = mkOption { - type = enum ["a" "n" "v" "i" "c"]; - default = "a"; - description = '' - Set modes for mouse support. - - * a - all - * n - normal - * v - visual - * i - insert - * c - command - ''; - }; - - cmdheight = mkOption { - type = int; - default = 1; - description = "Height of the command pane"; - }; - - updatetime = mkOption { - type = int; - default = 300; - description = "The number of milliseconds till Cursor Hold event is fired"; - }; - - tm = mkOption { - type = int; - default = 500; - description = "Timeout in ms that Neovim will wait for mapped action to complete"; - }; - - cursorlineopt = mkOption { - type = enum ["line" "screenline" "number" "both"]; - default = "line"; - description = "Highlight the text line of the cursor with CursorLine hl-CursorLine"; - }; - - splitbelow = mkOption { - type = bool; - default = true; - description = "New splits will open below instead of on top"; - }; - - splitright = mkOption { - type = bool; - default = true; - description = "New splits will open to the right"; - }; - - autoindent = mkOption { - type = bool; - default = true; - description = "Enable auto indent"; - }; - - wrap = mkOption { - type = bool; - default = true; - description = "Enable word wrapping."; - }; - }; - }; - example = {visualbell = true;}; description = '' An attribute set containing vim options to be set