modules/{neovim,wrapper}: move Vim options to vim.options defaults

This commit is contained in:
NotAShelf 2024-12-01 10:09:13 +03:00
parent 864ee05f57
commit a6a06f4e72
No known key found for this signature in database
GPG key ID: AF26552424E53993
3 changed files with 157 additions and 145 deletions

View file

@ -1,65 +1,95 @@
{lib, ...}: let {lib, ...}: let
inherit (lib.modules) mkRemovedOptionModule mkRenamedOptionModule; inherit (lib.modules) mkRemovedOptionModule mkRenamedOptionModule;
inherit (lib.lists) concatLists;
inherit (lib.nvim.config) batchRenameOptions;
migrationTable = {
colourTerm = "termguicolors";
mouseSupport = "mouse";
cmdHeight = "cmdheight";
updateTime = "updatetime";
mapTimeout = "tm";
cursorlineOpt = "cursorlineopt";
splitBelow = "splitbelow";
splitRight = "splitright";
autoIndent = "autoindent";
wordWrap = "wrap";
};
renamedVimOpts = batchRenameOptions ["vim"] ["vim" "options"] migrationTable;
in { in {
imports = [ imports = concatLists [
# 2024-06-06 [
(mkRemovedOptionModule ["vim" "tidal"] '' # 2024-06-06
Tidalcycles language support has been removed as of 2024-06-06 as it was long unmaintained. If (mkRemovedOptionModule ["vim" "tidal"] ''
you depended on this functionality, please open an issue. 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 # 2024-07-20
(mkRemovedOptionModule ["vim" "lsp" "nvimCodeActionMenu"] '' (mkRemovedOptionModule ["vim" "lsp" "nvimCodeActionMenu"] ''
nvimCodeActionMenu has been deprecated and removed upstream. As of 0.7, fastaction will be 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 available under `vim.ui.fastaction` as a replacement. Simply remove everything under
`vim.lsp.nvimCodeActionMenu`, and set `vim.ui.fastaction.enable` to `true`. `vim.lsp.nvimCodeActionMenu`, and set `vim.ui.fastaction.enable` to `true`.
'') '')
(mkRemovedOptionModule ["vim" "autopairs" "enable"] '' (mkRemovedOptionModule ["vim" "autopairs" "enable"] ''
vim.autopairs.enable has been removed in favor of per-plugin modules. vim.autopairs.enable has been removed in favor of per-plugin modules.
You can enable nvim-autopairs with vim.autopairs.nvim-autopairs.enable instead. You can enable nvim-autopairs with vim.autopairs.nvim-autopairs.enable instead.
'') '')
(mkRemovedOptionModule ["vim" "autopairs" "type"] '' (mkRemovedOptionModule ["vim" "autopairs" "type"] ''
vim.autopairs.type has been removed in favor of per-plugin modules. vim.autopairs.type has been removed in favor of per-plugin modules.
You can enable nvim-autopairs with vim.autopairs.nvim-autopairs.enable instead. You can enable nvim-autopairs with vim.autopairs.nvim-autopairs.enable instead.
'') '')
(mkRemovedOptionModule ["vim" "autocomplete" "enable"] '' (mkRemovedOptionModule ["vim" "autocomplete" "enable"] ''
vim.autocomplete.enable has been removed in favor of per-plugin modules. vim.autocomplete.enable has been removed in favor of per-plugin modules.
You can enable nvim-cmp with vim.autocomplete.nvim-cmp.enable instead. You can enable nvim-cmp with vim.autocomplete.nvim-cmp.enable instead.
'') '')
(mkRemovedOptionModule ["vim" "autocomplete" "type"] '' (mkRemovedOptionModule ["vim" "autocomplete" "type"] ''
vim.autocomplete.type has been removed in favor of per-plugin modules. vim.autocomplete.type has been removed in favor of per-plugin modules.
You can enable nvim-cmp with vim.autocomplete.nvim-cmp.enable instead. You can enable nvim-cmp with vim.autocomplete.nvim-cmp.enable instead.
'') '')
(mkRemovedOptionModule ["vim" "autocomplete" "sources"] '' (mkRemovedOptionModule ["vim" "autocomplete" "sources"] ''
vim.autocomplete.sources has been removed in favor of per-plugin modules. vim.autocomplete.sources has been removed in favor of per-plugin modules.
You can add nvim-cmp sources with vim.autocomplete.nvim-cmp.sources You can add nvim-cmp sources with vim.autocomplete.nvim-cmp.sources
instead. instead.
'') '')
(mkRemovedOptionModule ["vim" "snippets" "vsnip" "enable"] '' (mkRemovedOptionModule ["vim" "snippets" "vsnip" "enable"] ''
vim.snippets.vsnip.enable has been removed in favor of the more modern luasnip. vim.snippets.vsnip.enable has been removed in favor of the more modern luasnip.
'') '')
(mkRenamedOptionModule ["vim" "lsp" "lspkind" "mode"] ["vim" "lsp" "lspkind" "setupOpts" "mode"]) (mkRenamedOptionModule ["vim" "lsp" "lspkind" "mode"] ["vim" "lsp" "lspkind" "setupOpts" "mode"])
# 2024-10-14 # 2024-10-14
(mkRemovedOptionModule ["vim" "configRC"] '' (mkRemovedOptionModule ["vim" "configRC"] ''
Please migrate your configRC sections to Neovim's Lua format, and Please migrate your configRC sections to Neovim's Lua format, and
add them to `vim.luaConfigRC`. add them to `vim.luaConfigRC`.
See the v0.7 release notes for more information on why and how to See the v0.7 release notes for more information on why and how to
migrate your existing configurations to the new format. migrate your existing configurations to the new format.
'') '')
(mkRemovedOptionModule ["vim" "disableDefaultRuntimePaths"] '' (mkRemovedOptionModule ["vim" "disableDefaultRuntimePaths"] ''
Nvf now uses $NVIM_APP_NAME so there is no longer the problem of Nvf now uses $NVIM_APP_NAME so there is no longer the problem of
(accidental) leaking of user configuration. (accidental) leaking of user configuration.
'') '')
(mkRemovedOptionModule ["vim" "lsp" "trouble" "mappings" "toggle"] '' (mkRemovedOptionModule ["vim" "lsp" "trouble" "mappings" "toggle"] ''
With Trouble having so many different modes, and breaking changes With Trouble having so many different modes, and breaking changes
upstream, it no longer makes sense, nor works, to toggle only Trouble. upstream, it no longer makes sense, nor works, to toggle only Trouble.
'') '')
# 2024-11-30
(mkRenamedOptionModule ["vim" "leaderKey"] ["vim" "globals" "mapleader"]) # 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
]; ];
} }

View file

@ -15,12 +15,6 @@
cfg = config.vim; cfg = config.vim;
in { in {
options.vim = { options.vim = {
colourTerm = mkOption {
type = bool;
default = true;
description = "Set terminal up for 256 colours";
};
disableArrows = mkOption { disableArrows = mkOption {
type = bool; type = bool;
default = false; default = false;
@ -39,12 +33,6 @@ in {
description = "Start scrolling this number of lines from the top or bottom of the page."; 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 { syntaxHighlighting = mkOption {
type = bool; type = bool;
default = !config.vim.treesitter.highlight.enable; default = !config.vim.treesitter.highlight.enable;
@ -57,20 +45,6 @@ in {
description = "Make use of the clipboard for default yank and paste operations. Don't use * and +"; 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 { lineNumberMode = mkOption {
type = enum ["relative" "number" "relNumber" "none"]; type = enum ["relative" "number" "relNumber" "none"];
default = "relNumber"; default = "relNumber";
@ -84,30 +58,6 @@ in {
description = "Prevent swapfile and backupfile from being created"; 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 { showSignColumn = mkOption {
type = bool; type = bool;
default = true; default = true;
@ -120,36 +70,12 @@ in {
description = "Set how bells are handled. Options: on, visual or none"; 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 { enableEditorconfig = mkOption {
type = bool; type = bool;
default = true; default = true;
description = "Follow editorconfig rules in current directory"; 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 { searchCase = mkOption {
type = enum ["ignore" "smart" "sensitive"]; type = enum ["ignore" "smart" "sensitive"];
default = "sensitive"; default = "sensitive";
@ -184,19 +110,6 @@ in {
encoding = "utf-8"; encoding = "utf-8";
hidden = true; hidden = true;
expandtab = true; expandtab = true;
mouse = cfg.mouseSupport;
tabstop = cfg.tabWidth;
shiftwidth = cfg.tabWidth;
softtabstop = cfg.tabWidth;
cmdheight = cfg.cmdHeight;
updatetime = cfg.updateTime;
tm = cfg.mapTimeout;
cursorlineopt = cfg.cursorlineOpt;
splitbelow = cfg.splitBelow;
splitright = cfg.splitRight;
autoindent = cfg.autoIndent;
termguicolors = cfg.colourTerm;
wrap = cfg.wordWrap;
}; };
globals = pushDownDefault { globals = pushDownDefault {

View file

@ -5,7 +5,7 @@
}: let }: let
inherit (lib.options) mkOption mkEnableOption literalMD literalExpression; inherit (lib.options) mkOption mkEnableOption literalMD literalExpression;
inherit (lib.strings) optionalString; inherit (lib.strings) optionalString;
inherit (lib.types) str attrsOf lines listOf either path submodule anything; inherit (lib.types) str bool int enum attrsOf lines listOf either path submodule anything;
inherit (lib.nvim.types) dagOf; inherit (lib.nvim.types) dagOf;
inherit (lib.nvim.lua) listToLuaTable; inherit (lib.nvim.lua) listToLuaTable;
@ -107,12 +107,13 @@ in {
mapleader = mkOption { mapleader = mkOption {
type = str; type = str;
default = " "; default = " ";
description = "The key used for <leader> mappings"; description = "The key used for `<leader>` mappings";
}; };
maplocalleader = mkOption { maplocalleader = mkOption {
type = str; type = str;
default = ","; default = ",";
description = "The key used for <localleader> mappings"; description = "The key used for `<localleader>` mappings";
}; };
}; };
}; };
@ -137,7 +138,75 @@ in {
default = {}; default = {};
type = submodule { type = submodule {
freeformType = attrsOf anything; freeformType = attrsOf anything;
options = {}; 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;}; example = {visualbell = true;};