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

This commit is contained in:
raf 2024-12-01 10:09:13 +03:00
parent 864ee05f57
commit a6a06f4e72
Signed by: NotAShelf
GPG key ID: AF26552424E53993
3 changed files with 157 additions and 145 deletions

View file

@ -1,7 +1,25 @@
{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 # 2024-06-06
(mkRemovedOptionModule ["vim" "tidal"] '' (mkRemovedOptionModule ["vim" "tidal"] ''
Tidalcycles language support has been removed as of 2024-06-06 as it was long unmaintained. If Tidalcycles language support has been removed as of 2024-06-06 as it was long unmaintained. If
@ -59,7 +77,19 @@ in {
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 # 2024-11-30
(mkRenamedOptionModule ["vim" "leaderKey"] ["vim" "globals" "mapleader"]) (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;};