From be1cc38bdb83e6716b08d24cc1201fffc6649311 Mon Sep 17 00:00:00 2001 From: Soispha Date: Thu, 3 Aug 2023 21:34:16 +0200 Subject: Feat(hm/conf/nvim): Add basic nix config [REBASE TARGET] --- .../config/neovim/nixvim/autocmds/default.nix | 67 ++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 home-manager/soispha/config/neovim/nixvim/autocmds/default.nix (limited to 'home-manager/soispha/config/neovim/nixvim/autocmds/default.nix') diff --git a/home-manager/soispha/config/neovim/nixvim/autocmds/default.nix b/home-manager/soispha/config/neovim/nixvim/autocmds/default.nix new file mode 100644 index 00000000..d736443e --- /dev/null +++ b/home-manager/soispha/config/neovim/nixvim/autocmds/default.nix @@ -0,0 +1,67 @@ +{...}: { + programs.nixvim = { + autoGroups = { + cursor_off = {clear = true;}; + numbertoggle = {clear = true;}; + }; + autoCmd = [ + { + event = ["BufWritePre"]; + pattern = ["*"]; + command = '' + ks | if search("\\s\\+$", 'n') != 0 :%s/\s\+//g endif | 's"; + ''; + description = '' + Remove trailing whitespace on safe + :%s/\s\+$\| \+\ze\t//g >> For trailing spaces and spaces before tabstops + ''; + } + { + event = ["WinLeave"]; + pattern = ["*"]; + command = "set nocursorline"; # TODO possible also nocursorcolumn + group = "cursor_off"; + description = "Display cursorline and cursorcolumn ONLY in active window."; + } + { + event = ["WinEnter"]; + pattern = ["*"]; + command = "set cursorline"; # TODO possible also cursorcolumn + group = "cursor_off"; + description = "Display cursorline and cursorcolumn ONLY in active window."; + } + + { + event = ["BufEnter" "FocusGained" "InsertLeave" "WinEnter"]; + pattern = ["*"]; + command = "if &nu && mode() != \"i\" | set rnu | endif"; + group = "numbertoggle"; + description = "Change line numbers, when not focused"; + } + { + event = ["BufLeave" "FocusLost" "InsertEnter" "WinLeave"]; + pattern = ["*"]; + command = "if &nu | set nornu | endif"; + group = "numbertoggle"; + description = "Change line numbers, when not fucused"; + } + + { + # Override LineNr + event = ["ColorScheme"]; + pattern = ["*"]; + command = "highlight LineNr ctermfg=DarkGrey guifg=DarkGrey "; + group = "coloroverride"; + description = "Changes Line number colors"; + } + { + # Override CursorLineNr + event = ["ColorScheme"]; + pattern = ["*"]; + command = "highlight CursorLineNr ctermfg=White guifg=White "; + group = "coloroverride"; + description = "Changes Line number colors"; + } + ]; + }; +} -- cgit 1.4.1