2023-02-27 15:53:34 +01:00
|
|
|
{
|
2024-04-07 16:16:08 +02:00
|
|
|
config,
|
2023-02-27 15:53:34 +01:00
|
|
|
lib,
|
|
|
|
...
|
2023-11-06 10:33:38 +01:00
|
|
|
}: let
|
2024-11-10 23:38:52 +01:00
|
|
|
inherit (lib.options) mkOption mkEnableOption literalMD;
|
2024-04-07 16:16:08 +02:00
|
|
|
inherit (lib.strings) optionalString;
|
2024-09-19 21:07:25 +02:00
|
|
|
inherit (lib.types) enum bool str int either;
|
|
|
|
inherit (lib.generators) mkLuaInline;
|
2024-04-07 16:16:08 +02:00
|
|
|
inherit (lib.nvim.dag) entryAfter;
|
2024-11-10 23:38:52 +01:00
|
|
|
inherit (lib.nvim.binds) pushDownDefault;
|
2024-07-20 10:30:48 +02:00
|
|
|
inherit (lib.nvim.lua) toLuaObject;
|
2024-09-19 21:07:25 +02:00
|
|
|
inherit (lib.nvim.types) luaInline;
|
2024-04-07 16:16:08 +02:00
|
|
|
|
|
|
|
cfg = config.vim;
|
2023-11-06 10:33:38 +01:00
|
|
|
in {
|
2023-02-27 15:53:34 +01:00
|
|
|
options.vim = {
|
|
|
|
disableArrows = mkOption {
|
2024-03-24 01:14:39 +01:00
|
|
|
type = bool;
|
2023-02-27 15:53:34 +01:00
|
|
|
default = false;
|
|
|
|
description = "Set to prevent arrow keys from moving cursor";
|
|
|
|
};
|
|
|
|
|
|
|
|
hideSearchHighlight = mkOption {
|
2024-03-24 01:14:39 +01:00
|
|
|
type = bool;
|
2023-02-27 15:53:34 +01:00
|
|
|
default = false;
|
|
|
|
description = "Hide search highlight so it doesn't stay highlighted";
|
|
|
|
};
|
|
|
|
|
|
|
|
scrollOffset = mkOption {
|
2024-03-24 01:14:39 +01:00
|
|
|
type = int;
|
2023-02-27 15:53:34 +01:00
|
|
|
default = 8;
|
|
|
|
description = "Start scrolling this number of lines from the top or bottom of the page.";
|
|
|
|
};
|
|
|
|
|
|
|
|
syntaxHighlighting = mkOption {
|
2024-03-24 01:14:39 +01:00
|
|
|
type = bool;
|
2024-04-30 07:08:54 +02:00
|
|
|
default = !config.vim.treesitter.highlight.enable;
|
2023-02-27 15:53:34 +01:00
|
|
|
description = "Enable syntax highlighting";
|
|
|
|
};
|
|
|
|
|
|
|
|
useSystemClipboard = mkOption {
|
2024-03-24 01:14:39 +01:00
|
|
|
type = bool;
|
2023-09-21 12:14:35 +02:00
|
|
|
default = false;
|
2023-02-27 15:53:34 +01:00
|
|
|
description = "Make use of the clipboard for default yank and paste operations. Don't use * and +";
|
|
|
|
};
|
|
|
|
|
|
|
|
lineNumberMode = mkOption {
|
2024-03-24 01:14:39 +01:00
|
|
|
type = enum ["relative" "number" "relNumber" "none"];
|
2023-02-27 15:53:34 +01:00
|
|
|
default = "relNumber";
|
2024-11-10 23:38:52 +01:00
|
|
|
example = "none";
|
2024-04-14 14:09:13 +02:00
|
|
|
description = "How line numbers are displayed.";
|
2023-02-27 15:53:34 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
preventJunkFiles = mkOption {
|
2024-03-24 01:14:39 +01:00
|
|
|
type = bool;
|
2023-02-27 15:53:34 +01:00
|
|
|
default = false;
|
2024-04-07 16:16:08 +02:00
|
|
|
description = "Prevent swapfile and backupfile from being created";
|
2023-02-27 15:53:34 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
bell = mkOption {
|
2024-03-24 01:14:39 +01:00
|
|
|
type = enum ["none" "visual" "on"];
|
2023-02-27 15:53:34 +01:00
|
|
|
default = "none";
|
|
|
|
description = "Set how bells are handled. Options: on, visual or none";
|
|
|
|
};
|
|
|
|
|
2023-10-28 14:53:06 +02:00
|
|
|
searchCase = mkOption {
|
2024-03-24 01:14:39 +01:00
|
|
|
type = enum ["ignore" "smart" "sensitive"];
|
2023-10-28 14:53:06 +02:00
|
|
|
default = "sensitive";
|
|
|
|
description = "Set the case sensitivity of search";
|
|
|
|
};
|
2024-09-19 21:07:25 +02:00
|
|
|
|
|
|
|
undoFile = {
|
|
|
|
enable = mkEnableOption "undofile for persistent undo behaviour";
|
|
|
|
path = mkOption {
|
|
|
|
type = either str luaInline;
|
|
|
|
default = mkLuaInline "vim.fn.stdpath('state') .. '/undo'";
|
|
|
|
defaultText = literalMD ''
|
|
|
|
```nix
|
|
|
|
mkLuaInline "vim.fn.stdpath('state') .. '/undo'"
|
|
|
|
```
|
|
|
|
'';
|
|
|
|
example = literalMD ''
|
|
|
|
```nix
|
|
|
|
mkLuaInline "os.getenv('XDG_DATA_HOME') .. '/nvf/undo'"
|
|
|
|
```
|
|
|
|
'';
|
|
|
|
description = "Path to the directory in which undo history will be stored";
|
|
|
|
};
|
|
|
|
};
|
2023-02-27 15:53:34 +01:00
|
|
|
};
|
2024-04-07 16:16:08 +02:00
|
|
|
|
2024-11-10 23:38:52 +01:00
|
|
|
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;
|
|
|
|
};
|
|
|
|
|
|
|
|
# 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"] ''
|
2024-12-02 22:53:22 +01:00
|
|
|
-- Settings that are set for everything
|
|
|
|
vim.opt.shortmess:append("c")
|
2024-09-19 21:07:25 +02:00
|
|
|
|
2024-12-02 22:53:22 +01:00
|
|
|
${optionalString cfg.undoFile.enable ''
|
2024-09-19 21:07:25 +02:00
|
|
|
vim.o.undofile = true
|
|
|
|
vim.o.undodir = ${toLuaObject cfg.undoFile.path}
|
|
|
|
''}
|
|
|
|
|
|
|
|
${optionalString cfg.preventJunkFiles ''
|
|
|
|
vim.o.swapfile = false
|
|
|
|
vim.o.backup = false
|
|
|
|
vim.o.writebackup = false
|
|
|
|
''}
|
|
|
|
|
2024-12-02 22:53:22 +01:00
|
|
|
${optionalString (cfg.bell == "none") ''
|
2024-09-19 21:07:25 +02:00
|
|
|
vim.o.errorbells = false
|
|
|
|
vim.o.visualbell = false
|
|
|
|
''}
|
|
|
|
|
2024-12-02 22:53:22 +01:00
|
|
|
${optionalString (cfg.bell == "on") ''
|
2024-09-19 21:07:25 +02:00
|
|
|
vim.o.visualbell = false
|
|
|
|
''}
|
|
|
|
|
2024-12-02 22:53:22 +01:00
|
|
|
${optionalString (cfg.bell == "visual") ''
|
2024-09-19 21:07:25 +02:00
|
|
|
vim.o.errorbells = false
|
|
|
|
''}
|
|
|
|
|
2024-12-02 22:53:22 +01:00
|
|
|
${optionalString (cfg.lineNumberMode == "relative") ''
|
2024-09-19 21:07:25 +02:00
|
|
|
vim.o.relativenumber = true
|
|
|
|
''}
|
|
|
|
|
2024-12-02 22:53:22 +01:00
|
|
|
${optionalString (cfg.lineNumberMode == "number") ''
|
2024-09-19 21:07:25 +02:00
|
|
|
vim.o.number = true
|
|
|
|
''}
|
|
|
|
|
2024-12-02 22:53:22 +01:00
|
|
|
${optionalString (cfg.lineNumberMode == "relNumber") ''
|
2024-09-19 21:07:25 +02:00
|
|
|
vim.o.number = true
|
|
|
|
vim.o.relativenumber = true
|
|
|
|
''}
|
|
|
|
|
2024-12-02 22:53:22 +01:00
|
|
|
${optionalString cfg.useSystemClipboard ''
|
2024-09-19 21:07:25 +02:00
|
|
|
vim.opt.clipboard:append("unnamedplus")
|
|
|
|
''}
|
|
|
|
|
2024-12-02 22:53:22 +01:00
|
|
|
${optionalString cfg.syntaxHighlighting ''
|
2024-09-19 21:07:25 +02:00
|
|
|
vim.cmd("syntax on")
|
|
|
|
''}
|
|
|
|
|
2024-12-02 22:53:22 +01:00
|
|
|
${optionalString cfg.hideSearchHighlight ''
|
2024-09-19 21:07:25 +02:00
|
|
|
vim.o.hlsearch = false
|
|
|
|
vim.o.incsearch = true
|
|
|
|
''}
|
|
|
|
|
2024-12-02 22:53:22 +01:00
|
|
|
${optionalString (cfg.searchCase == "ignore") ''
|
2024-09-19 21:07:25 +02:00
|
|
|
vim.o.smartcase = false
|
|
|
|
vim.o.ignorecase = true
|
|
|
|
''}
|
|
|
|
|
2024-12-02 22:53:22 +01:00
|
|
|
${optionalString (cfg.searchCase == "smart") ''
|
2024-09-19 21:07:25 +02:00
|
|
|
vim.o.smartcase = true
|
|
|
|
vim.o.ignorecase = true
|
|
|
|
''}
|
|
|
|
|
2024-12-02 22:53:22 +01:00
|
|
|
${optionalString (cfg.searchCase == "sensitive") ''
|
2024-09-19 21:07:25 +02:00
|
|
|
vim.o.smartcase = false
|
|
|
|
vim.o.ignorecase = false
|
|
|
|
''}
|
|
|
|
'';
|
|
|
|
};
|
2023-02-27 15:53:34 +01:00
|
|
|
}
|