nixvim: add diffview, gitsigns, which-key. re-enable treesitter. document some keymaps
This commit is contained in:
parent
bb811f4f16
commit
b950eb138e
4 changed files with 162 additions and 143 deletions
|
|
@ -1,79 +1,71 @@
|
||||||
[
|
[
|
||||||
# cursor navigation
|
|
||||||
{
|
{
|
||||||
# scroll down, recenter
|
options.desc = "scroll down, recenter";
|
||||||
key = "<C-d>";
|
key = "<C-d>";
|
||||||
action = "<C-d>zz";
|
action = "<C-d>zz";
|
||||||
mode = "n";
|
mode = "n";
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
# scroll up, recenter
|
options.desc = "scroll up, recenter";
|
||||||
key = "<C-u>";
|
key = "<C-u>";
|
||||||
action = "<C-u>zz";
|
action = "<C-u>zz";
|
||||||
mode = "n";
|
mode = "n";
|
||||||
}
|
}
|
||||||
|
|
||||||
# searching
|
|
||||||
{
|
{
|
||||||
# center cursor after search next
|
options.desc = "center cursor after search next";
|
||||||
key = "n";
|
key = "n";
|
||||||
action = "nzzzv";
|
action = "nzzzv";
|
||||||
mode = "n";
|
mode = "n";
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
# center cursor after search previous
|
options.desc = "center cursor after search previous";
|
||||||
key = "N";
|
key = "N";
|
||||||
action = "Nzzzv";
|
action = "Nzzzv";
|
||||||
mode = "n";
|
mode = "n";
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
# ex command
|
options.desc = "ex command";
|
||||||
key = "<leader>pv";
|
key = "<leader>pv";
|
||||||
action = "<cmd>Ex<CR>";
|
action = "<cmd>Ex<CR>";
|
||||||
mode = "n";
|
mode = "n";
|
||||||
}
|
}
|
||||||
|
|
||||||
# search and replace
|
|
||||||
{
|
{
|
||||||
# search and replace word under cursor
|
options.desc = "search and replace word under cursor";
|
||||||
key = "<leader>s";
|
key = "<leader>s";
|
||||||
action = ":%s/<C-r><C-w>/<C-r><C-w>/gI<Left><Left><Left>";
|
action = ":%s/<C-r><C-w>/<C-r><C-w>/gI<Left><Left><Left>";
|
||||||
mode = "n";
|
mode = "n";
|
||||||
}
|
}
|
||||||
# search and replace selected text
|
|
||||||
{
|
{
|
||||||
key = "<leader>s";
|
key = "<leader>s";
|
||||||
action = "y:%s/<C-r>0/<C-r>0/gI<Left><Left><Left>";
|
action = "y:%s/<C-r>0/<C-r>0/gI<Left><Left><Left>";
|
||||||
mode = "v";
|
mode = "v";
|
||||||
}
|
}
|
||||||
|
|
||||||
# clipboard operations
|
|
||||||
{
|
{
|
||||||
# copy to system clipboard in visual mode
|
options.desc = "copy to system clipboard in visual mode";
|
||||||
key = "<C-c>";
|
key = "<C-c>";
|
||||||
action = ''"+y '';
|
action = ''"+y '';
|
||||||
mode = "v";
|
mode = "v";
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
# paste from system clipboard in visual mode
|
options.desc = "paste from system clipboard in visual mode";
|
||||||
key = "<C-v>";
|
key = "<C-v>";
|
||||||
action = ''"+p '';
|
action = ''"+p '';
|
||||||
mode = "v";
|
mode = "v";
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
# yank to system clipboard
|
options.desc = "yank to system clipboard";
|
||||||
key = "<leader>Y";
|
key = "<leader>Y";
|
||||||
action = "+Y";
|
action = "+Y";
|
||||||
mode = "n";
|
mode = "n";
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
# replace selected text with clipboard content
|
options.desc = "replace selected text with clipboard content";
|
||||||
key = "<leader>p";
|
key = "<leader>p";
|
||||||
action = "_dP";
|
action = "_dP";
|
||||||
mode = "x";
|
mode = "x";
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
# delete without copying to clipboard
|
options.desc = "delete without copying to clipboard";
|
||||||
key = "<leader>d";
|
key = "<leader>d";
|
||||||
action = "_d";
|
action = "_d";
|
||||||
mode = [
|
mode = [
|
||||||
|
|
@ -81,267 +73,184 @@
|
||||||
"v"
|
"v"
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
# line operations
|
|
||||||
{
|
{
|
||||||
# move lines down in visual mode
|
options.desc = "move lines down in visual mode";
|
||||||
key = "J";
|
key = "J";
|
||||||
action = ":m '>+1<CR>gv=gv";
|
action = ":m '>+1<CR>gv=gv";
|
||||||
mode = "v";
|
mode = "v";
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
# move lines up in visual mode
|
options.desc = "move lines up in visual mode";
|
||||||
key = "K";
|
key = "K";
|
||||||
action = ":m '<-2<CR>gv=gv";
|
action = ":m '<-2<CR>gv=gv";
|
||||||
mode = "v";
|
mode = "v";
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
# join lines
|
options.desc = "join lines";
|
||||||
key = "J";
|
key = "J";
|
||||||
action = "mzJ`z";
|
action = "mzJ`z";
|
||||||
mode = "n";
|
mode = "n";
|
||||||
}
|
}
|
||||||
|
|
||||||
# quickfix
|
|
||||||
{
|
{
|
||||||
# Run make command
|
options.desc = "Run make command";
|
||||||
key = "<leader>m";
|
key = "<leader>m";
|
||||||
action = "<cmd>:make<CR>";
|
action = "<cmd>:make<CR>";
|
||||||
mode = "n";
|
mode = "n";
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
# previous quickfix item
|
options.desc = "previous quickfix item";
|
||||||
key = "<C-A-J>";
|
key = "<C-A-J>";
|
||||||
action = "<cmd>cprev<CR>zz";
|
action = "<cmd>cprev<CR>zz";
|
||||||
mode = "n";
|
mode = "n";
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
# next quickfix item
|
options.desc = "next quickfix item";
|
||||||
key = "<C-A-K>";
|
key = "<C-A-K>";
|
||||||
action = "<cmd>cnext<CR>zz";
|
action = "<cmd>cnext<CR>zz";
|
||||||
mode = "n";
|
mode = "n";
|
||||||
}
|
}
|
||||||
|
|
||||||
# location list navigation
|
|
||||||
{
|
{
|
||||||
# previous location list item
|
options.desc = "previous location list item";
|
||||||
key = "<leader>j";
|
key = "<leader>j";
|
||||||
action = "<cmd>lprev<CR>zz";
|
action = "<cmd>lprev<CR>zz";
|
||||||
mode = "n";
|
mode = "n";
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
# next location list item
|
options.desc = "next location list item";
|
||||||
key = "<leader>k";
|
key = "<leader>k";
|
||||||
action = "<cmd>lnext<CR>zz";
|
action = "<cmd>lnext<CR>zz";
|
||||||
mode = "n";
|
mode = "n";
|
||||||
}
|
}
|
||||||
|
|
||||||
# disabling keys
|
|
||||||
{
|
{
|
||||||
# disable the 'Q' key
|
options.desc = "disable the 'Q' key";
|
||||||
key = "Q";
|
key = "Q";
|
||||||
action = "<nop>";
|
action = "<nop>";
|
||||||
mode = "n";
|
mode = "n";
|
||||||
}
|
}
|
||||||
|
|
||||||
# text selection
|
|
||||||
{
|
{
|
||||||
# select whole buffer
|
options.desc = "select whole buffer";
|
||||||
key = "<C-a>";
|
key = "<C-a>";
|
||||||
action = "ggVG";
|
action = "ggVG";
|
||||||
mode = "n";
|
mode = "n";
|
||||||
}
|
}
|
||||||
|
|
||||||
# window operations
|
|
||||||
{
|
{
|
||||||
# focus next window
|
options.desc = "focus next window";
|
||||||
key = "<C-j>";
|
key = "<C-j>";
|
||||||
action = ":wincmd W<CR>";
|
action = ":wincmd W<CR>";
|
||||||
options = {
|
|
||||||
noremap = true;
|
|
||||||
silent = true;
|
|
||||||
};
|
|
||||||
mode = "n";
|
mode = "n";
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
# focus previous window
|
options.desc = "focus next window";
|
||||||
|
key = "<Tab>";
|
||||||
|
action = ":wincmd W<CR>";
|
||||||
|
mode = "n";
|
||||||
|
}
|
||||||
|
{
|
||||||
|
options.desc = "focus previous window";
|
||||||
key = "<C-k>";
|
key = "<C-k>";
|
||||||
action = ":wincmd w<CR>";
|
action = ":wincmd w<CR>";
|
||||||
options = {
|
|
||||||
noremap = true;
|
|
||||||
silent = true;
|
|
||||||
};
|
|
||||||
mode = "n";
|
mode = "n";
|
||||||
}
|
}
|
||||||
|
|
||||||
# window size adjustments
|
|
||||||
{
|
{
|
||||||
# increase window width
|
options.desc = "focus previous window";
|
||||||
|
key = "<S-Tab>";
|
||||||
|
action = ":wincmd w<CR>";
|
||||||
|
mode = "n";
|
||||||
|
}
|
||||||
|
{
|
||||||
|
options.desc = "increase window width";
|
||||||
key = "<C-l>";
|
key = "<C-l>";
|
||||||
action = ":vertical resize +5<CR>";
|
action = ":vertical resize +5<CR>";
|
||||||
options = {
|
|
||||||
noremap = true;
|
|
||||||
silent = true;
|
|
||||||
};
|
|
||||||
mode = "n";
|
mode = "n";
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
# decrease window width
|
options.desc = "decrease window width";
|
||||||
key = "<C-h>";
|
key = "<C-h>";
|
||||||
action = ":vertical resize -5<CR>";
|
action = ":vertical resize -5<CR>";
|
||||||
options = {
|
|
||||||
noremap = true;
|
|
||||||
silent = true;
|
|
||||||
};
|
|
||||||
mode = "n";
|
mode = "n";
|
||||||
}
|
}
|
||||||
|
|
||||||
# window closing and opening
|
|
||||||
{
|
{
|
||||||
# close current window
|
options.desc = "close current window";
|
||||||
key = "<leader-S>c";
|
key = "<leader-S>c";
|
||||||
action = ":q<CR>";
|
action = ":q<CR>";
|
||||||
options = {
|
|
||||||
noremap = true;
|
|
||||||
silent = true;
|
|
||||||
};
|
|
||||||
mode = "n";
|
mode = "n";
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
# new vertical split at $HOME
|
options.desc = "new vertical split at $HOME";
|
||||||
key = "<leader>n";
|
key = "<leader>n";
|
||||||
action = ":vsp $HOME<CR>";
|
action = ":vsp $HOME<CR>";
|
||||||
options = {
|
|
||||||
noremap = true;
|
|
||||||
silent = true;
|
|
||||||
};
|
|
||||||
mode = "n";
|
mode = "n";
|
||||||
}
|
}
|
||||||
|
|
||||||
# window split orientation toggling
|
|
||||||
{
|
{
|
||||||
# toggle split orientation
|
options.desc = "toggle split orientation";
|
||||||
key = "<leader>t";
|
key = "<leader>t";
|
||||||
action = ":wincmd T<CR>";
|
action = ":wincmd T<CR>";
|
||||||
options = {
|
|
||||||
noremap = true;
|
|
||||||
silent = true;
|
|
||||||
};
|
|
||||||
mode = "n";
|
mode = "n";
|
||||||
}
|
}
|
||||||
|
|
||||||
# spell checking
|
|
||||||
{
|
{
|
||||||
# toggle spell checking
|
options.desc = "toggle spell checking";
|
||||||
key = "<leader>ss";
|
key = "<leader>ss";
|
||||||
action = ":setlocal spell!<CR>";
|
action = ":setlocal spell!<CR>";
|
||||||
options = {
|
|
||||||
noremap = true;
|
|
||||||
silent = true;
|
|
||||||
};
|
|
||||||
mode = "n";
|
mode = "n";
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
# switch to english spell checking
|
options.desc = "switch to english spell checking";
|
||||||
key = "<leader>se";
|
key = "<leader>se";
|
||||||
action = ":setlocal spelllang=en_us<CR>";
|
action = ":setlocal spelllang=en_us<CR>";
|
||||||
options = {
|
|
||||||
noremap = true;
|
|
||||||
silent = true;
|
|
||||||
};
|
|
||||||
mode = "n";
|
mode = "n";
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
# switch to german spell checking
|
options.desc = "switch to german spell checking";
|
||||||
key = "<leader>sg";
|
key = "<leader>sg";
|
||||||
action = ":setlocal spelllang=de_20<CR>";
|
action = ":setlocal spelllang=de_20<CR>";
|
||||||
options = {
|
|
||||||
noremap = true;
|
|
||||||
silent = true;
|
|
||||||
};
|
|
||||||
mode = "n";
|
mode = "n";
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
# move to next misspelling
|
options.desc = "move to next misspelling";
|
||||||
key = "]s";
|
key = "]s";
|
||||||
action = "]szz";
|
action = "]szz";
|
||||||
options = {
|
|
||||||
noremap = true;
|
|
||||||
silent = true;
|
|
||||||
};
|
|
||||||
mode = "n";
|
mode = "n";
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
# move to previous misspelling
|
options.desc = "move to previous misspelling";
|
||||||
key = "[s";
|
key = "[s";
|
||||||
action = "[szz";
|
action = "[szz";
|
||||||
options = {
|
|
||||||
noremap = true;
|
|
||||||
silent = true;
|
|
||||||
};
|
|
||||||
mode = "n";
|
mode = "n";
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
# correction suggestions for a misspelled word
|
options.desc = "correction suggestions for a misspelled word";
|
||||||
key = "z=";
|
key = "z=";
|
||||||
action = "z=";
|
action = "z=";
|
||||||
options = {
|
|
||||||
noremap = true;
|
|
||||||
silent = true;
|
|
||||||
};
|
|
||||||
mode = "n";
|
mode = "n";
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
# adding words to the dictionary
|
options.desc = "adding words to the dictionary";
|
||||||
key = "zg";
|
key = "zg";
|
||||||
action = "zg";
|
action = "zg";
|
||||||
options = {
|
|
||||||
noremap = true;
|
|
||||||
silent = true;
|
|
||||||
};
|
|
||||||
mode = "n";
|
mode = "n";
|
||||||
}
|
}
|
||||||
|
|
||||||
# buffer navigation
|
|
||||||
{
|
{
|
||||||
# next buffer
|
options.desc = "next buffer";
|
||||||
key = "<C-S-J>";
|
key = "<C-S-J>";
|
||||||
action = ":bnext<CR>";
|
action = ":bnext<CR>";
|
||||||
options = {
|
|
||||||
noremap = true;
|
|
||||||
silent = true;
|
|
||||||
};
|
|
||||||
mode = "n";
|
mode = "n";
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
# previous buffer
|
options.desc = "previous buffer";
|
||||||
key = "<C-S-K>";
|
key = "<C-S-K>";
|
||||||
action = ":bprevious<CR>";
|
action = ":bprevious<CR>";
|
||||||
options = {
|
|
||||||
noremap = true;
|
|
||||||
silent = true;
|
|
||||||
};
|
|
||||||
mode = "n";
|
mode = "n";
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
# close current buffer
|
options.desc = "close current buffer";
|
||||||
key = "<leader>bd";
|
key = "<leader>bd";
|
||||||
action = ":bdelete<CR>";
|
action = ":bdelete<CR>";
|
||||||
options = {
|
|
||||||
noremap = true;
|
|
||||||
silent = true;
|
|
||||||
};
|
|
||||||
mode = "n";
|
mode = "n";
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
# apply code action
|
options.desc = "apply code action";
|
||||||
key = "<leader>ca";
|
key = "<leader>ca";
|
||||||
action = ":lua vim.lsp.buf.code_action()<CR>";
|
action = ":lua vim.lsp.buf.code_action()<CR>";
|
||||||
options = {
|
|
||||||
noremap = true;
|
|
||||||
silent = true;
|
|
||||||
};
|
|
||||||
mode = "n";
|
mode = "n";
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
|
||||||
|
|
@ -3,14 +3,17 @@
|
||||||
{
|
{
|
||||||
imports = [
|
imports = [
|
||||||
./cmp.nix
|
./cmp.nix
|
||||||
|
./diffview.nix
|
||||||
./lsp.nix
|
./lsp.nix
|
||||||
|
./gitsigns.nix
|
||||||
./lualine.nix
|
./lualine.nix
|
||||||
./telescope.nix
|
./telescope.nix
|
||||||
# ./treesitter.nix # HOTFIX: does not build
|
./treesitter.nix
|
||||||
./trouble.nix
|
./trouble.nix
|
||||||
];
|
];
|
||||||
|
|
||||||
config.programs.nixvim.plugins = {
|
config.programs.nixvim.plugins = {
|
||||||
|
which-key.enable = lib.mkDefault true;
|
||||||
markdown-preview.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`
|
# 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;
|
web-devicons.enable = true;
|
||||||
|
|
|
||||||
59
modules/home/nixvim/plugins/diffview.nix
Normal file
59
modules/home/nixvim/plugins/diffview.nix
Normal file
|
|
@ -0,0 +1,59 @@
|
||||||
|
{ 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 = "<leader>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";
|
||||||
|
};
|
||||||
|
}
|
||||||
|
];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
48
modules/home/nixvim/plugins/gitsigns.nix
Normal file
48
modules/home/nixvim/plugins/gitsigns.nix
Normal file
|
|
@ -0,0 +1,48 @@
|
||||||
|
{ config, lib, ... }:
|
||||||
|
|
||||||
|
let
|
||||||
|
cfg = config.programs.nixvim;
|
||||||
|
plugin = cfg.plugins.fugitive;
|
||||||
|
|
||||||
|
inherit (lib) mkDefault mkIf;
|
||||||
|
in
|
||||||
|
{
|
||||||
|
config = {
|
||||||
|
programs.nixvim = {
|
||||||
|
plugins.gitsigns = {
|
||||||
|
enable = mkDefault true;
|
||||||
|
settings = {
|
||||||
|
current_line_blame = mkDefault false;
|
||||||
|
current_line_blame_opts = mkDefault {
|
||||||
|
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;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue