diff --git a/modules/home/nixvim/keymaps.nix b/modules/home/nixvim/keymaps.nix index c791995..aaefaa0 100644 --- a/modules/home/nixvim/keymaps.nix +++ b/modules/home/nixvim/keymaps.nix @@ -1,71 +1,79 @@ [ + # cursor navigation { - options.desc = "scroll down, recenter"; + # scroll down, recenter key = ""; action = "zz"; mode = "n"; } { - options.desc = "scroll up, recenter"; + # scroll up, recenter key = ""; action = "zz"; mode = "n"; } + + # searching { - options.desc = "center cursor after search next"; + # center cursor after search next key = "n"; action = "nzzzv"; mode = "n"; } { - options.desc = "center cursor after search previous"; + # center cursor after search previous key = "N"; action = "Nzzzv"; mode = "n"; } { - options.desc = "ex command"; + # ex command key = "pv"; action = "Ex"; mode = "n"; } + + # search and replace { - options.desc = "search and replace word under cursor"; + # search and replace word under cursor key = "s"; action = ":%s///gI"; mode = "n"; } + # search and replace selected text { key = "s"; action = "y:%s/0/0/gI"; mode = "v"; } + + # clipboard operations { - options.desc = "copy to system clipboard in visual mode"; + # copy to system clipboard in visual mode key = ""; action = ''"+y ''; mode = "v"; } { - options.desc = "paste from system clipboard in visual mode"; + # paste from system clipboard in visual mode key = ""; action = ''"+p ''; mode = "v"; } { - options.desc = "yank to system clipboard"; + # yank to system clipboard key = "Y"; action = "+Y"; mode = "n"; } { - options.desc = "replace selected text with clipboard content"; + # replace selected text with clipboard content key = "p"; action = "_dP"; mode = "x"; } { - options.desc = "delete without copying to clipboard"; + # delete without copying to clipboard key = "d"; action = "_d"; mode = [ @@ -73,184 +81,267 @@ "v" ]; } + + # line operations { - options.desc = "move lines down in visual mode"; + # move lines down in visual mode key = "J"; action = ":m '>+1gv=gv"; mode = "v"; } { - options.desc = "move lines up in visual mode"; + # move lines up in visual mode key = "K"; action = ":m '<-2gv=gv"; mode = "v"; } { - options.desc = "join lines"; + # join lines key = "J"; action = "mzJ`z"; mode = "n"; } + + # quickfix { - options.desc = "Run make command"; + # Run make command key = "m"; action = ":make"; mode = "n"; } { - options.desc = "previous quickfix item"; + # previous quickfix item key = ""; action = "cprevzz"; mode = "n"; } { - options.desc = "next quickfix item"; + # next quickfix item key = ""; action = "cnextzz"; mode = "n"; } + + # location list navigation { - options.desc = "previous location list item"; + # previous location list item key = "j"; action = "lprevzz"; mode = "n"; } { - options.desc = "next location list item"; + # next location list item key = "k"; action = "lnextzz"; mode = "n"; } + + # disabling keys { - options.desc = "disable the 'Q' key"; + # disable the 'Q' key key = "Q"; action = ""; mode = "n"; } + + # text selection { - options.desc = "select whole buffer"; + # select whole buffer key = ""; action = "ggVG"; mode = "n"; } + + # window operations { - options.desc = "focus next window"; + # focus next window key = ""; action = ":wincmd W"; + options = { + noremap = true; + silent = true; + }; mode = "n"; } { - options.desc = "focus next window"; - key = ""; - action = ":wincmd W"; - mode = "n"; - } - { - options.desc = "focus previous window"; + # focus previous window key = ""; action = ":wincmd w"; + options = { + noremap = true; + silent = true; + }; mode = "n"; } + + # window size adjustments { - options.desc = "focus previous window"; - key = ""; - action = ":wincmd w"; - mode = "n"; - } - { - options.desc = "increase window width"; + # increase window width key = ""; action = ":vertical resize +5"; + options = { + noremap = true; + silent = true; + }; mode = "n"; } { - options.desc = "decrease window width"; + # decrease window width key = ""; action = ":vertical resize -5"; + options = { + noremap = true; + silent = true; + }; mode = "n"; } + + # window closing and opening { - options.desc = "close current window"; + # close current window key = "c"; action = ":q"; + options = { + noremap = true; + silent = true; + }; mode = "n"; } { - options.desc = "new vertical split at $HOME"; + # new vertical split at $HOME key = "n"; action = ":vsp $HOME"; + options = { + noremap = true; + silent = true; + }; mode = "n"; } + + # window split orientation toggling { - options.desc = "toggle split orientation"; + # toggle split orientation key = "t"; action = ":wincmd T"; + options = { + noremap = true; + silent = true; + }; mode = "n"; } + + # spell checking { - options.desc = "toggle spell checking"; + # toggle spell checking key = "ss"; action = ":setlocal spell!"; + options = { + noremap = true; + silent = true; + }; mode = "n"; } { - options.desc = "switch to english spell checking"; + # switch to english spell checking key = "se"; action = ":setlocal spelllang=en_us"; + options = { + noremap = true; + silent = true; + }; mode = "n"; } { - options.desc = "switch to german spell checking"; + # switch to german spell checking key = "sg"; action = ":setlocal spelllang=de_20"; + options = { + noremap = true; + silent = true; + }; mode = "n"; } { - options.desc = "move to next misspelling"; + # move to next misspelling key = "]s"; action = "]szz"; + options = { + noremap = true; + silent = true; + }; mode = "n"; } { - options.desc = "move to previous misspelling"; + # move to previous misspelling key = "[s"; action = "[szz"; + options = { + noremap = true; + silent = true; + }; mode = "n"; } { - options.desc = "correction suggestions for a misspelled word"; + # correction suggestions for a misspelled word key = "z="; action = "z="; + options = { + noremap = true; + silent = true; + }; mode = "n"; } { - options.desc = "adding words to the dictionary"; + # adding words to the dictionary key = "zg"; action = "zg"; + options = { + noremap = true; + silent = true; + }; mode = "n"; } + + # buffer navigation { - options.desc = "next buffer"; + # next buffer key = ""; action = ":bnext"; + options = { + noremap = true; + silent = true; + }; mode = "n"; } { - options.desc = "previous buffer"; + # previous buffer key = ""; action = ":bprevious"; + options = { + noremap = true; + silent = true; + }; mode = "n"; } { - options.desc = "close current buffer"; + # close current buffer key = "bd"; action = ":bdelete"; + options = { + noremap = true; + silent = true; + }; mode = "n"; } + { - options.desc = "apply code action"; + # apply code action key = "ca"; action = ":lua vim.lsp.buf.code_action()"; + options = { + noremap = true; + silent = true; + }; mode = "n"; } ] diff --git a/modules/home/nixvim/plugins/default.nix b/modules/home/nixvim/plugins/default.nix index 508d3c7..1941f43 100644 --- a/modules/home/nixvim/plugins/default.nix +++ b/modules/home/nixvim/plugins/default.nix @@ -3,17 +3,14 @@ { imports = [ ./cmp.nix - ./diffview.nix ./lsp.nix - ./gitsigns.nix ./lualine.nix ./telescope.nix - ./treesitter.nix + # ./treesitter.nix # HOTFIX: does not build ./trouble.nix ]; config.programs.nixvim.plugins = { - which-key.enable = lib.mkDefault true; markdown-preview.enable = lib.mkDefault true; # warning: Nixvim: `plugins.web-devicons` was enabled automatically because the following plugins are enabled. This behaviour is deprecated. Please explicitly define `plugins.web-devicons.enable` web-devicons.enable = true; diff --git a/modules/home/nixvim/plugins/diffview.nix b/modules/home/nixvim/plugins/diffview.nix deleted file mode 100644 index e405578..0000000 --- a/modules/home/nixvim/plugins/diffview.nix +++ /dev/null @@ -1,59 +0,0 @@ -{ config, lib, ... }: - -let - cfg = config.programs.nixvim; - plugin = cfg.plugins.diffview; - - inherit (lib) mkDefault mkIf; -in -{ - config = { - programs.nixvim = { - plugins.diffview = { - enable = mkDefault true; - }; - - # highlight = mkIf plugin.enable { - # DiffAdd = { - # bg = "#2d4a2d"; - # fg = "NONE"; - # }; - # DiffDelete = { - # bg = "#4a2d2d"; - # fg = "NONE"; - # }; - # DiffChange = { - # bg = "#2d3a4a"; - # fg = "NONE"; - # }; - # DiffText = { - # bg = "#1a5a1a"; - # fg = "NONE"; - # }; - # }; - - keymaps = mkIf plugin.enable [ - { - mode = "n"; - key = "gd"; - action.__raw = '' - function() - local lib = require("diffview.lib") - local view = lib.get_current_view() - if view then - vim.cmd("DiffviewClose") - else - vim.cmd("DiffviewOpen") - end - end - ''; - options = { - noremap = true; - silent = true; - desc = "toggle git diff"; - }; - } - ]; - }; - }; -} diff --git a/modules/home/nixvim/plugins/gitsigns.nix b/modules/home/nixvim/plugins/gitsigns.nix deleted file mode 100644 index 651b83d..0000000 --- a/modules/home/nixvim/plugins/gitsigns.nix +++ /dev/null @@ -1,104 +0,0 @@ -{ config, lib, ... }: - -let - cfg = config.programs.nixvim; - plugin = cfg.plugins.gitsigns; - - inherit (lib) mkDefault mkIf; -in -{ - config = { - programs.nixvim = { - plugins.gitsigns = { - enable = mkDefault true; - settings = { - current_line_blame = mkDefault false; - current_line_blame_opts = { - virt_text = mkDefault true; - virt_text_pos = mkDefault "eol"; - }; - signcolumn = mkDefault true; - signs = { - add.text = mkDefault "+"; - change.text = mkDefault "│"; - changedelete.text = mkDefault "~"; - delete.text = mkDefault "-"; - topdelete.text = mkDefault "-"; - untracked.text = mkDefault "?"; - }; - watch_gitdir.follow_files = mkDefault true; - }; - }; - keymaps = mkIf plugin.enable [ - { - mode = "n"; - key = "hs"; - action.__raw = "function() require('gitsigns').stage_hunk() end"; - options = { - noremap = true; - silent = true; - desc = "stage hunk"; - }; - } - { - mode = "v"; - key = "hs"; - action.__raw = '' - function() - require('gitsigns').stage_hunk({vim.fn.line('.'), vim.fn.line('v')}) - end - ''; - options = { - noremap = true; - silent = true; - desc = "stage selected hunks"; - }; - } - { - mode = "n"; - key = "hu"; - action.__raw = "function() require('gitsigns').undo_stage_hunk() end"; - options = { - noremap = true; - silent = true; - desc = "undo stage hunk"; - }; - } - { - mode = "n"; - key = "hS"; - action.__raw = "function() require('gitsigns').stage_buffer() end"; - options = { - noremap = true; - silent = true; - desc = "stage buffer"; - }; - } - { - mode = "n"; - key = "hr"; - action.__raw = "function() require('gitsigns').reset_hunk() end"; - options = { - noremap = true; - silent = true; - desc = "reset hunk"; - }; - } - { - mode = "v"; - key = "hr"; - action.__raw = '' - function() - require('gitsigns').reset_hunk({vim.fn.line('.'), vim.fn.line('v')}) - end - ''; - options = { - noremap = true; - silent = true; - desc = "reset selected hunks"; - }; - } - ]; - }; - }; -}