mirror of
https://github.com/NotAShelf/nvf.git
synced 2026-01-13 22:17:49 +00:00
modules/neovim: separate options; move package into core/build
This commit is contained in:
parent
4083a74281
commit
199a8b06c5
9 changed files with 258 additions and 211 deletions
|
|
@ -1,5 +1,6 @@
|
||||||
{
|
{
|
||||||
config,
|
config,
|
||||||
|
pkgs,
|
||||||
lib,
|
lib,
|
||||||
...
|
...
|
||||||
}: let
|
}: let
|
||||||
|
|
@ -90,6 +91,14 @@
|
||||||
in {
|
in {
|
||||||
options = {
|
options = {
|
||||||
vim = {
|
vim = {
|
||||||
|
package = mkOption {
|
||||||
|
type = types.package;
|
||||||
|
default = pkgs.neovim-unwrapped;
|
||||||
|
description = ''
|
||||||
|
The neovim package to use. You will need to use an unwrapped package for this option to work as intended.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
viAlias = mkOption {
|
viAlias = mkOption {
|
||||||
description = "Enable vi alias";
|
description = "Enable vi alias";
|
||||||
type = types.bool;
|
type = types.bool;
|
||||||
|
|
|
||||||
|
|
@ -3,9 +3,12 @@
|
||||||
lib,
|
lib,
|
||||||
check ? true,
|
check ? true,
|
||||||
}: let
|
}: let
|
||||||
inherit (lib) mkDefault;
|
inherit (builtins) map;
|
||||||
|
inherit (lib.modules) mkDefault;
|
||||||
|
inherit (lib.lists) concatLists;
|
||||||
|
|
||||||
plugins = builtins.map (p: ./plugins + "/${p}") [
|
# map each plugin from our plugins module into a list
|
||||||
|
plugins = map (p: ./plugins + "/${p}") [
|
||||||
"completion"
|
"completion"
|
||||||
"theme"
|
"theme"
|
||||||
"statusline"
|
"statusline"
|
||||||
|
|
@ -32,14 +35,16 @@
|
||||||
"debugger"
|
"debugger"
|
||||||
];
|
];
|
||||||
|
|
||||||
core = builtins.map (p: ./core + "/${p}") [
|
core = map (p: ./core + "/${p}") [
|
||||||
"build"
|
"build"
|
||||||
"mappings"
|
"mappings"
|
||||||
"warnings"
|
"warnings"
|
||||||
];
|
];
|
||||||
|
|
||||||
modules = [
|
neovim = map (p: ./neovim + "/${p}") [
|
||||||
./neovim
|
"basic"
|
||||||
|
"maps"
|
||||||
|
"spellcheck"
|
||||||
];
|
];
|
||||||
|
|
||||||
pkgsModule = {config, ...}: {
|
pkgsModule = {config, ...}: {
|
||||||
|
|
@ -54,5 +59,7 @@
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
modules = concatLists [core neovim plugins] ++ [pkgsModule];
|
||||||
in
|
in
|
||||||
[pkgsModule] ++ (lib.concatLists [core modules plugins])
|
modules
|
||||||
|
|
|
||||||
134
modules/neovim/basic/default.nix
Normal file
134
modules/neovim/basic/default.nix
Normal file
|
|
@ -0,0 +1,134 @@
|
||||||
|
{
|
||||||
|
lib,
|
||||||
|
config,
|
||||||
|
...
|
||||||
|
}: let
|
||||||
|
inherit (lib) optionalString nvim;
|
||||||
|
|
||||||
|
cfg = config.vim;
|
||||||
|
in {
|
||||||
|
imports = [./options.nix];
|
||||||
|
config = {
|
||||||
|
vim = {
|
||||||
|
configRC.basic = nvim.dag.entryAfter ["globalsScript"] ''
|
||||||
|
" Settings that are set for everything
|
||||||
|
set encoding=utf-8
|
||||||
|
set mouse=${cfg.mouseSupport}
|
||||||
|
set tabstop=${toString cfg.tabWidth}
|
||||||
|
set shiftwidth=${toString cfg.tabWidth}
|
||||||
|
set softtabstop=${toString cfg.tabWidth}
|
||||||
|
set expandtab
|
||||||
|
set cmdheight=${toString cfg.cmdHeight}
|
||||||
|
set updatetime=${toString cfg.updateTime}
|
||||||
|
set shortmess+=c
|
||||||
|
set tm=${toString cfg.mapTimeout}
|
||||||
|
set hidden
|
||||||
|
set cursorlineopt=${toString cfg.cursorlineOpt}
|
||||||
|
set scrolloff=${toString cfg.scrollOffset}
|
||||||
|
|
||||||
|
${optionalString cfg.debugMode.enable ''
|
||||||
|
" Debug mode settings
|
||||||
|
set verbose=${toString cfg.debugMode.level}
|
||||||
|
set verbosefile=${cfg.debugMode.logFile}
|
||||||
|
''}
|
||||||
|
|
||||||
|
${optionalString cfg.splitBelow ''
|
||||||
|
set splitbelow
|
||||||
|
''}
|
||||||
|
|
||||||
|
${optionalString cfg.splitRight ''
|
||||||
|
set splitright
|
||||||
|
''}
|
||||||
|
|
||||||
|
${optionalString cfg.showSignColumn ''
|
||||||
|
set signcolumn=yes
|
||||||
|
''}
|
||||||
|
|
||||||
|
${optionalString cfg.autoIndent ''
|
||||||
|
set autoindent
|
||||||
|
''}
|
||||||
|
|
||||||
|
${optionalString cfg.preventJunkFiles ''
|
||||||
|
set noswapfile
|
||||||
|
set nobackup
|
||||||
|
set nowritebackup
|
||||||
|
''}
|
||||||
|
|
||||||
|
${optionalString (cfg.bell == "none") ''
|
||||||
|
set noerrorbells
|
||||||
|
set novisualbell
|
||||||
|
''}
|
||||||
|
|
||||||
|
${optionalString (cfg.bell == "on") ''
|
||||||
|
set novisualbell
|
||||||
|
''}
|
||||||
|
|
||||||
|
${optionalString (cfg.bell == "visual") ''
|
||||||
|
set noerrorbells
|
||||||
|
''}
|
||||||
|
|
||||||
|
${optionalString (cfg.lineNumberMode == "relative") ''
|
||||||
|
set relativenumber
|
||||||
|
''}
|
||||||
|
|
||||||
|
${optionalString (cfg.lineNumberMode == "number") ''
|
||||||
|
set number
|
||||||
|
''}
|
||||||
|
|
||||||
|
${optionalString (cfg.lineNumberMode == "relNumber") ''
|
||||||
|
set number relativenumber
|
||||||
|
''}
|
||||||
|
|
||||||
|
${optionalString cfg.useSystemClipboard ''
|
||||||
|
set clipboard+=unnamedplus
|
||||||
|
''}
|
||||||
|
|
||||||
|
${optionalString cfg.mapLeaderSpace ''
|
||||||
|
let mapleader=" "
|
||||||
|
let maplocalleader=" "
|
||||||
|
''}
|
||||||
|
|
||||||
|
${optionalString cfg.syntaxHighlighting ''
|
||||||
|
syntax on
|
||||||
|
''}
|
||||||
|
|
||||||
|
${optionalString (!cfg.wordWrap) ''
|
||||||
|
set nowrap
|
||||||
|
''}
|
||||||
|
|
||||||
|
${optionalString cfg.hideSearchHighlight ''
|
||||||
|
set nohlsearch
|
||||||
|
set incsearch
|
||||||
|
''}
|
||||||
|
|
||||||
|
${optionalString cfg.colourTerm ''
|
||||||
|
set termguicolors
|
||||||
|
set t_Co=256
|
||||||
|
''}
|
||||||
|
|
||||||
|
${optionalString (!cfg.enableEditorconfig) ''
|
||||||
|
let g:editorconfig = v:false
|
||||||
|
''}
|
||||||
|
|
||||||
|
${optionalString (cfg.leaderKey != null) ''
|
||||||
|
let mapleader = "${toString cfg.leaderKey}"
|
||||||
|
''}
|
||||||
|
|
||||||
|
${optionalString (cfg.searchCase == "ignore") ''
|
||||||
|
set nosmartcase
|
||||||
|
set ignorecase
|
||||||
|
''}
|
||||||
|
|
||||||
|
${optionalString (cfg.searchCase == "smart") ''
|
||||||
|
set smartcase
|
||||||
|
set ignorecase
|
||||||
|
''}
|
||||||
|
|
||||||
|
${optionalString (cfg.searchCase == "sensitive") ''
|
||||||
|
set nosmartcase
|
||||||
|
set noignorecase
|
||||||
|
''}
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
@ -7,14 +7,6 @@
|
||||||
inherit (lib.types) types;
|
inherit (lib.types) types;
|
||||||
in {
|
in {
|
||||||
options.vim = {
|
options.vim = {
|
||||||
package = mkOption {
|
|
||||||
type = types.package;
|
|
||||||
default = pkgs.neovim-unwrapped;
|
|
||||||
description = ''
|
|
||||||
The neovim package to use. You will need to use an unwrapped package for this option to work as intended.
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
|
|
||||||
debugMode = {
|
debugMode = {
|
||||||
enable = mkEnableOption "debug mode";
|
enable = mkEnableOption "debug mode";
|
||||||
level = mkOption {
|
level = mkOption {
|
||||||
|
|
@ -38,17 +30,6 @@ in {
|
||||||
description = "The leader key to be used internally";
|
description = "The leader key to be used internally";
|
||||||
};
|
};
|
||||||
|
|
||||||
spellChecking = {
|
|
||||||
enable = mkEnableOption "neovim's built-in spellchecking";
|
|
||||||
enableProgrammingWordList = mkEnableOption "vim-dirtytalk, a wordlist for programmers, that includes programming words";
|
|
||||||
languages = mkOption {
|
|
||||||
type = with types; listOf str;
|
|
||||||
description = "The languages to be used for spellchecking";
|
|
||||||
default = ["en"];
|
|
||||||
example = ["en" "de"];
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
colourTerm = mkOption {
|
colourTerm = mkOption {
|
||||||
type = types.bool;
|
type = types.bool;
|
||||||
default = true;
|
default = true;
|
||||||
|
|
@ -179,6 +160,7 @@ in {
|
||||||
default = true;
|
default = true;
|
||||||
description = "New splits will open to the right";
|
description = "New splits will open to the right";
|
||||||
};
|
};
|
||||||
|
|
||||||
enableEditorconfig = mkOption {
|
enableEditorconfig = mkOption {
|
||||||
type = types.bool;
|
type = types.bool;
|
||||||
default = true;
|
default = true;
|
||||||
|
|
@ -1,185 +0,0 @@
|
||||||
{
|
|
||||||
lib,
|
|
||||||
config,
|
|
||||||
...
|
|
||||||
}: let
|
|
||||||
inherit (builtins) concatStringsSep;
|
|
||||||
inherit (lib) optionalString mkIf nvim;
|
|
||||||
|
|
||||||
cfg = config.vim;
|
|
||||||
in {
|
|
||||||
config = {
|
|
||||||
vim.startPlugins = ["plenary-nvim"] ++ lib.optionals (cfg.spellChecking.enableProgrammingWordList) ["vim-dirtytalk"];
|
|
||||||
|
|
||||||
vim.maps.normal =
|
|
||||||
mkIf cfg.disableArrows {
|
|
||||||
"<up>" = {
|
|
||||||
action = "<nop>";
|
|
||||||
|
|
||||||
noremap = false;
|
|
||||||
};
|
|
||||||
"<down>" = {
|
|
||||||
action = "<nop>";
|
|
||||||
|
|
||||||
noremap = false;
|
|
||||||
};
|
|
||||||
"<left>" = {
|
|
||||||
action = "<nop>";
|
|
||||||
noremap = false;
|
|
||||||
};
|
|
||||||
"<right>" = {
|
|
||||||
action = "<nop>";
|
|
||||||
noremap = false;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
// mkIf cfg.mapLeaderSpace {
|
|
||||||
"<space>" = {
|
|
||||||
action = "<nop>";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
vim.maps.insert = mkIf cfg.disableArrows {
|
|
||||||
"<up>" = {
|
|
||||||
action = "<nop>";
|
|
||||||
noremap = false;
|
|
||||||
};
|
|
||||||
"<down>" = {
|
|
||||||
action = "<nop>";
|
|
||||||
noremap = false;
|
|
||||||
};
|
|
||||||
"<left>" = {
|
|
||||||
action = "<nop>";
|
|
||||||
noremap = false;
|
|
||||||
};
|
|
||||||
"<right>" = {
|
|
||||||
action = "<nop>";
|
|
||||||
noremap = false;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
vim.configRC.basic = nvim.dag.entryAfter ["globalsScript"] ''
|
|
||||||
" Settings that are set for everything
|
|
||||||
set encoding=utf-8
|
|
||||||
set mouse=${cfg.mouseSupport}
|
|
||||||
set tabstop=${toString cfg.tabWidth}
|
|
||||||
set shiftwidth=${toString cfg.tabWidth}
|
|
||||||
set softtabstop=${toString cfg.tabWidth}
|
|
||||||
set expandtab
|
|
||||||
set cmdheight=${toString cfg.cmdHeight}
|
|
||||||
set updatetime=${toString cfg.updateTime}
|
|
||||||
set shortmess+=c
|
|
||||||
set tm=${toString cfg.mapTimeout}
|
|
||||||
set hidden
|
|
||||||
set cursorlineopt=${toString cfg.cursorlineOpt}
|
|
||||||
set scrolloff=${toString cfg.scrollOffset}
|
|
||||||
|
|
||||||
${optionalString cfg.debugMode.enable ''
|
|
||||||
" Debug mode settings
|
|
||||||
set verbose=${toString cfg.debugMode.level}
|
|
||||||
set verbosefile=${cfg.debugMode.logFile}
|
|
||||||
''}
|
|
||||||
|
|
||||||
${optionalString cfg.splitBelow ''
|
|
||||||
set splitbelow
|
|
||||||
''}
|
|
||||||
|
|
||||||
${optionalString cfg.splitRight ''
|
|
||||||
set splitright
|
|
||||||
''}
|
|
||||||
|
|
||||||
${optionalString cfg.showSignColumn ''
|
|
||||||
set signcolumn=yes
|
|
||||||
''}
|
|
||||||
|
|
||||||
${optionalString cfg.autoIndent ''
|
|
||||||
set autoindent
|
|
||||||
''}
|
|
||||||
|
|
||||||
${optionalString cfg.preventJunkFiles ''
|
|
||||||
set noswapfile
|
|
||||||
set nobackup
|
|
||||||
set nowritebackup
|
|
||||||
''}
|
|
||||||
|
|
||||||
${optionalString (cfg.bell == "none") ''
|
|
||||||
set noerrorbells
|
|
||||||
set novisualbell
|
|
||||||
''}
|
|
||||||
|
|
||||||
${optionalString (cfg.bell == "on") ''
|
|
||||||
set novisualbell
|
|
||||||
''}
|
|
||||||
|
|
||||||
${optionalString (cfg.bell == "visual") ''
|
|
||||||
set noerrorbells
|
|
||||||
''}
|
|
||||||
|
|
||||||
${optionalString (cfg.lineNumberMode == "relative") ''
|
|
||||||
set relativenumber
|
|
||||||
''}
|
|
||||||
|
|
||||||
${optionalString (cfg.lineNumberMode == "number") ''
|
|
||||||
set number
|
|
||||||
''}
|
|
||||||
|
|
||||||
${optionalString (cfg.lineNumberMode == "relNumber") ''
|
|
||||||
set number relativenumber
|
|
||||||
''}
|
|
||||||
|
|
||||||
${optionalString cfg.useSystemClipboard ''
|
|
||||||
set clipboard+=unnamedplus
|
|
||||||
''}
|
|
||||||
|
|
||||||
${optionalString cfg.mapLeaderSpace ''
|
|
||||||
let mapleader=" "
|
|
||||||
let maplocalleader=" "
|
|
||||||
''}
|
|
||||||
|
|
||||||
${optionalString cfg.syntaxHighlighting ''
|
|
||||||
syntax on
|
|
||||||
''}
|
|
||||||
|
|
||||||
${optionalString (!cfg.wordWrap) ''
|
|
||||||
set nowrap
|
|
||||||
''}
|
|
||||||
|
|
||||||
${optionalString cfg.hideSearchHighlight ''
|
|
||||||
set nohlsearch
|
|
||||||
set incsearch
|
|
||||||
''}
|
|
||||||
|
|
||||||
${optionalString cfg.colourTerm ''
|
|
||||||
set termguicolors
|
|
||||||
set t_Co=256
|
|
||||||
''}
|
|
||||||
|
|
||||||
${optionalString (!cfg.enableEditorconfig) ''
|
|
||||||
let g:editorconfig = v:false
|
|
||||||
''}
|
|
||||||
|
|
||||||
${optionalString cfg.spellChecking.enable ''
|
|
||||||
set spell
|
|
||||||
set spelllang=${concatStringsSep "," cfg.spellChecking.languages}${optionalString cfg.spellChecking.enableProgrammingWordList ",programming"}
|
|
||||||
''}
|
|
||||||
|
|
||||||
${optionalString (cfg.leaderKey != null) ''
|
|
||||||
let mapleader = "${toString cfg.leaderKey}"
|
|
||||||
''}
|
|
||||||
|
|
||||||
${optionalString (cfg.searchCase == "ignore") ''
|
|
||||||
set nosmartcase
|
|
||||||
set ignorecase
|
|
||||||
''}
|
|
||||||
|
|
||||||
${optionalString (cfg.searchCase == "smart") ''
|
|
||||||
set smartcase
|
|
||||||
set ignorecase
|
|
||||||
''}
|
|
||||||
|
|
||||||
${optionalString (cfg.searchCase == "sensitive") ''
|
|
||||||
set nosmartcase
|
|
||||||
set noignorecase
|
|
||||||
''}
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
@ -1,4 +1,3 @@
|
||||||
_: {
|
|
||||||
imports = [
|
imports = [
|
||||||
./config.nix
|
./config.nix
|
||||||
./module.nix
|
./module.nix
|
||||||
|
|
|
||||||
61
modules/neovim/maps/default.nix
Normal file
61
modules/neovim/maps/default.nix
Normal file
|
|
@ -0,0 +1,61 @@
|
||||||
|
{
|
||||||
|
config,
|
||||||
|
lib,
|
||||||
|
...
|
||||||
|
}: let
|
||||||
|
inherit (lib) mkIf;
|
||||||
|
|
||||||
|
cfg = config.vim;
|
||||||
|
in {
|
||||||
|
config = {
|
||||||
|
vim.maps = {
|
||||||
|
# normal mode mappings
|
||||||
|
normal =
|
||||||
|
mkIf cfg.disableArrows {
|
||||||
|
"<up>" = {
|
||||||
|
action = "<nop>";
|
||||||
|
|
||||||
|
noremap = false;
|
||||||
|
};
|
||||||
|
"<down>" = {
|
||||||
|
action = "<nop>";
|
||||||
|
|
||||||
|
noremap = false;
|
||||||
|
};
|
||||||
|
"<left>" = {
|
||||||
|
action = "<nop>";
|
||||||
|
noremap = false;
|
||||||
|
};
|
||||||
|
"<right>" = {
|
||||||
|
action = "<nop>";
|
||||||
|
noremap = false;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
// mkIf cfg.mapLeaderSpace {
|
||||||
|
"<space>" = {
|
||||||
|
action = "<nop>";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
# insert mode mappings
|
||||||
|
insert = mkIf cfg.disableArrows {
|
||||||
|
"<up>" = {
|
||||||
|
action = "<nop>";
|
||||||
|
noremap = false;
|
||||||
|
};
|
||||||
|
"<down>" = {
|
||||||
|
action = "<nop>";
|
||||||
|
noremap = false;
|
||||||
|
};
|
||||||
|
"<left>" = {
|
||||||
|
action = "<nop>";
|
||||||
|
noremap = false;
|
||||||
|
};
|
||||||
|
"<right>" = {
|
||||||
|
action = "<nop>";
|
||||||
|
noremap = false;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
23
modules/neovim/spellcheck/default.nix
Normal file
23
modules/neovim/spellcheck/default.nix
Normal file
|
|
@ -0,0 +1,23 @@
|
||||||
|
{
|
||||||
|
lib,
|
||||||
|
config,
|
||||||
|
...
|
||||||
|
}: let
|
||||||
|
inherit (builtins) concatStringsSep;
|
||||||
|
inherit (lib) optionalString optionals mkIf nvim;
|
||||||
|
|
||||||
|
cfg = config.vim;
|
||||||
|
in {
|
||||||
|
imports = [./options.nix];
|
||||||
|
config = mkIf cfg.spellChecking.enable {
|
||||||
|
vim = {
|
||||||
|
startPlugins = optionals cfg.spellChecking.enableProgrammingWordList ["vim-dirtytalk"];
|
||||||
|
configRC.spellcheck = nvim.dag.entryAfter ["basic"] ''
|
||||||
|
${optionalString cfg.spellChecking.enable ''
|
||||||
|
set spell
|
||||||
|
set spelllang=${concatStringsSep "," cfg.spellChecking.languages}${optionalString cfg.spellChecking.enableProgrammingWordList ",programming"}
|
||||||
|
''}
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
17
modules/neovim/spellcheck/options.nix
Normal file
17
modules/neovim/spellcheck/options.nix
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
{lib, ...}: let
|
||||||
|
inherit (lib) mkEnableOption mkOption;
|
||||||
|
inherit (lib.types) types;
|
||||||
|
in {
|
||||||
|
options.vim = {
|
||||||
|
spellChecking = {
|
||||||
|
enable = mkEnableOption "neovim's built-in spellchecking";
|
||||||
|
enableProgrammingWordList = mkEnableOption "vim-dirtytalk, a wordlist for programmers, that includes programming words";
|
||||||
|
languages = mkOption {
|
||||||
|
type = with types; listOf str;
|
||||||
|
description = "The languages to be used for spellchecking";
|
||||||
|
default = ["en"];
|
||||||
|
example = ["en" "de"];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue