forked from wiltaylor/neovim-flake
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
345 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,139 @@ | ||
{ pkgs, lib, config, ...}: | ||
with lib; | ||
with builtins; | ||
|
||
let | ||
cfg = config.vim; | ||
in { | ||
options.vim = { | ||
colourTerm = mkOption { | ||
default = true; | ||
description = "Set terminal up for 256 colours"; | ||
type = types.bool; | ||
}; | ||
|
||
disableArrows = mkOption { | ||
default = false; | ||
description = "Set to prevent arrow keys from moving cursor"; | ||
type = types.bool; | ||
}; | ||
|
||
hideSearchHighlight = mkOption { | ||
default = true; | ||
description = "Hide search highlight so it doesn't stay highlighted"; | ||
type = types.bool; | ||
}; | ||
|
||
scrollOffset = mkOption { | ||
default = 8; | ||
description = "Start scrolling this number of lines from the top or bottom of the page."; | ||
type = types.int; | ||
}; | ||
|
||
wordWrap = mkOption { | ||
default = false; | ||
description = "Enable word wrapping."; | ||
type = types.bool; | ||
}; | ||
|
||
syntaxHighlighting = mkOption { | ||
default = true; | ||
description = "Enable syntax highlighting"; | ||
type = types.bool; | ||
}; | ||
|
||
mapLeaderSpace = mkOption { | ||
default = true; | ||
description = "Map the space key to leader key"; | ||
type = types.bool; | ||
}; | ||
|
||
useSystemClipboard = mkOption { | ||
default = true; | ||
description = "Make use of the clipboard for default yank and paste operations. Don't use * and +"; | ||
type = types.bool; | ||
}; | ||
|
||
mouseSupport = mkOption { | ||
default = "a"; | ||
description = "Set modes for mouse support. a - all, n - normal, v - visual, i - insert, c - command"; | ||
type = types.str; | ||
}; | ||
|
||
lineNumberMode = mkOption { | ||
default = "relNumber"; | ||
description = "How line numbers are displayed. none, relative, number, relNumber"; | ||
type = with types; enum ["relative" "number" "relNumber" "none"]; | ||
}; | ||
|
||
config = ( | ||
let | ||
writeIf = cond: msg: if cond then msg else ""; | ||
in { | ||
|
||
vim.nmap = if (cfg.disableArrows) then { | ||
"<up>" = "<nop>"; | ||
"<down>" = "<nop>"; | ||
"<left>" = "<nop>"; | ||
"<right>" = "<nop>"; | ||
} else {}; | ||
|
||
vim.imap = if (cfg.disableArrows) then { | ||
"<up>" = "<nop>"; | ||
"<down>" = "<nop>"; | ||
"<left>" = "<nop>"; | ||
"<right>" = "<nop>"; | ||
} else {}; | ||
|
||
vim.nnoremap = if (cfg.mapLeaderSpace) then { | ||
"<space>" = "<nop>"; | ||
} else {}; | ||
|
||
vim.configRC = '' | ||
|
||
"Settings that are set for everything | ||
encoding=utf-8 | ||
set mouse=${mouseSupport} | ||
|
||
${writeIf (cfg.lineNumberMode == "relative") '' | ||
set relativenumber | ||
''} | ||
|
||
${writeIf (cfg.lineNumberMode == "number") '' | ||
set number | ||
''} | ||
|
||
${writeIf (cfg.lineNumberMode == "relNumber") '' | ||
set number relativenumber | ||
''} | ||
|
||
${writeIf cfg.useSystemClipboard '' | ||
set clipboard+=unnamedplus | ||
''} | ||
|
||
${writeIf cfg.mapLeaderSpace '' | ||
let mapleader=" " | ||
let maplocalleader=" " | ||
''} | ||
|
||
${writeIf cfg.syntaxHighlighting '' | ||
syntax on | ||
''} | ||
|
||
${writeIf (cfg.wordWrap == false) '' | ||
set nowrap | ||
''} | ||
|
||
${writeIf cfg.hideSearchHighlight '' | ||
set nohlsearch | ||
set incsearch | ||
''} | ||
|
||
${writeIf cfg.colourTerm '' | ||
set termguicolors | ||
set t_Co=256 | ||
''} | ||
|
||
''; | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters