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
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 {
imports = [
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
@ -59,7 +77,19 @@ in {
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
];
}

View file

@ -15,12 +15,6 @@
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;
@ -39,12 +33,6 @@ 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;
@ -57,20 +45,6 @@ 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";
@ -84,30 +58,6 @@ 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;
@ -120,36 +70,12 @@ 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";
@ -184,19 +110,6 @@ in {
encoding = "utf-8";
hidden = 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 {

View file

@ -5,7 +5,7 @@
}: let
inherit (lib.options) mkOption mkEnableOption literalMD literalExpression;
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.lua) listToLuaTable;
@ -107,12 +107,13 @@ in {
mapleader = mkOption {
type = str;
default = " ";
description = "The key used for <leader> mappings";
description = "The key used for `<leader>` mappings";
};
maplocalleader = mkOption {
type = str;
default = ",";
description = "The key used for <localleader> mappings";
description = "The key used for `<localleader>` mappings";
};
};
};
@ -137,7 +138,75 @@ in {
default = {};
type = submodule {
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;};