vim: Fix tabline bindings

This commit is contained in:
Geoffrey Frogeye 2024-01-25 23:53:59 +01:00
parent dfc8d68495
commit 0bb5981f3a
Signed by: geoffrey
GPG key ID: C72403E7F82E6AD8

View file

@ -1,154 +1,157 @@
{ pkgs, lib, config, ... }: { pkgs, lib, config, ... }:
{ {
config = { config = {
programs.nixvim = { programs = {
autoCmd = [ # https://www.reddit.com/r/neovim/comments/mbj8m5/how_to_setup_ctrlshiftkey_mappings_in_neovim_and/
# Turn off relativenumber only for insert mode alacritty.settings.key_bindings = [
{ event = "InsertEnter"; pattern = "*"; command = "set norelativenumber"; } { key = "H"; mods = "Control|Shift"; chars = "\\x1b[72;5u"; }
{ event = "InsertLeave"; pattern = "*"; command = "set relativenumber"; } { key = "L"; mods = "Control|Shift"; chars = "\\x1b[76;5u"; }
]; ] ++ (map
extraPlugins = with pkgs.vimPlugins; [ (n: { key = "Key${builtins.toString n}"; mods = "Control"; chars = "\\x1b[${builtins.toString (48+n)};5u"; })
nvim-scrollview # Scroll bar (lib.lists.range 0 9));
]; # Ctrl+<number> doesn't get interpreted, but Ctrl+Shift+<number> does, so let's use that
keymaps = [ nixvim = {
# barbar autoCmd = [
{ key = "<C-H>"; action = "<Cmd>BufferPrevious<CR>"; options = { silent = true; }; } # Turn off relativenumber only for insert mode
{ key = "<C-L>"; action = "<Cmd>BufferNext<CR>"; options = { silent = true; }; } { event = "InsertEnter"; pattern = "*"; command = "set norelativenumber"; }
# TODO https://www.reddit.com/r/neovim/comments/mbj8m5/how_to_setup_ctrlshiftkey_mappings_in_neovim_and/ { event = "InsertLeave"; pattern = "*"; command = "set relativenumber"; }
{ key = "<Space><C-H>"; action = "<Cmd>BufferMovePrevious<CR>"; options = { silent = true; }; } ];
{ key = "<Space><C-L>"; action = "<Cmd>BufferMoveNext<CR>"; options = { silent = true; }; } extraPlugins = with pkgs.vimPlugins; [
# TODO gotos don't work nvim-scrollview # Scroll bar
{ key = "<C-1>"; action = "<Cmd>BufferGoto 1<CR>"; options = { silent = true; }; } ];
{ key = "<C-2>"; action = "<Cmd>BufferGoto 2<CR>"; options = { silent = true; }; } keymaps =
{ key = "<C-3>"; action = "<Cmd>BufferGoto 3<CR>"; options = { silent = true; }; } let
{ key = "<C-4>"; action = "<Cmd>BufferGoto 4<CR>"; options = { silent = true; }; } options = { silent = true; };
{ key = "<C-5>"; action = "<Cmd>BufferGoto 5<CR>"; options = { silent = true; }; } in
{ key = "<C-6>"; action = "<Cmd>BufferGoto 6<CR>"; options = { silent = true; }; } [
{ key = "<C-7>"; action = "<Cmd>BufferGoto 7<CR>"; options = { silent = true; }; } # barbar
{ key = "<C-8>"; action = "<Cmd>BufferGoto 8<CR>"; options = { silent = true; }; } { key = "gb"; action = "<Cmd>BufferPick<CR>"; inherit options; }
{ key = "<C-9>"; action = "<Cmd>BufferGoto 9<CR>"; options = { silent = true; }; } { key = "<C-H>"; action = "<Cmd>BufferPrevious<CR>"; inherit options; }
{ key = "<C-0>"; action = "<Cmd>BufferLast<CR>"; options = { silent = true; }; } { key = "<C-L>"; action = "<Cmd>BufferNext<CR>"; inherit options; }
{ key = "gb"; action = "<Cmd>BufferPick<CR>"; options = { silent = true; }; } { key = "<C-S-H>"; action = "<Cmd>BufferMovePrevious<CR>"; inherit options; }
# TODO Other useful options? { key = "<C-S-L>"; action = "<Cmd>BufferMoveNext<CR>"; inherit options; }
]; { key = "<C-0>"; action = "<Cmd>BufferLast<CR>"; inherit options; }
options = { ] ++ (map
showmode = false; (n: { key = "<C-${builtins.toString n}>"; action = "<Cmd>BufferGoto ${builtins.toString n}<CR>"; inherit options; })
number = true; (lib.lists.range 1 9));
relativenumber = true; options = {
title = true; showmode = false;
}; number = true;
plugins = { relativenumber = true;
# Tabline title = true;
barbar.enable = true; };
# TODO Investigate bufferline? plugins = {
# Status line # Tabline
lualine = with config.lib.stylix.colors.withHashtag; let barbar.enable = true;
normal = { fg = base05; bg = base01; }; # Status line
inverted = { fg = base00; bg = base03; }; lualine = with config.lib.stylix.colors.withHashtag; let
normal_ina = { fg = base02; bg = base01; }; normal = { fg = base05; bg = base01; };
inverted_ina = { fg = base00; bg = base02; }; inverted = { fg = base00; bg = base03; };
in normal_ina = { fg = base02; bg = base01; };
rec { inverted_ina = { fg = base00; bg = base02; };
enable = true; in
inactiveSections = sections; rec {
sections = { enable = true;
lualine_a = [{ inactiveSections = sections;
name = ''string.format('%d', vim.fn.line('$'))''; sections = {
}]; lualine_a = [{
lualine_b = [ name = ''string.format('%d', vim.fn.line('$'))'';
"mode" }];
]; lualine_b = [
lualine_c = [{ "mode"
name = "filename"; ];
color = { lualine_c = [{
__raw = '' name = "filename";
function(section) color = {
return { fg = vim.bo.modified and '${base08}' or '${normal.fg}' } __raw = ''
end function(section)
''; return { fg = vim.bo.modified and '${base08}' or '${normal.fg}' }
}; end
extraConfig = { '';
path = 1; # Relative path
symbols = {
modified = "";
newfile = "󰻭";
readonly = "󰏯";
unnamed = "󱀶";
}; };
};
}
"location"];
lualine_x = [{
name = ''(next(vim.lsp.buf_get_clients()) == nil) and "󰒲 " or ""'';
extraConfig.separator = { left = ""; right = ""; };
}] ++ (lib.mapAttrsToList
(diag_name: diag_color: {
name = "diagnostics";
extraConfig = { extraConfig = {
color.bg = diag_color; path = 1; # Relative path
colored = false; symbols = {
separator = { left = ""; right = ""; }; modified = "";
sections = [ diag_name ]; newfile = "󰻭";
readonly = "󰏯";
unnamed = "󱀶";
};
}; };
}
"location"];
lualine_x = [{
name = ''(next(vim.lsp.buf_get_clients()) == nil) and "󰒲 " or ""'';
extraConfig.separator = { left = ""; right = ""; };
}] ++ (lib.mapAttrsToList
(diag_name: diag_color: {
name = "diagnostics";
extraConfig = {
color.bg = diag_color;
colored = false;
separator = { left = ""; right = ""; };
sections = [ diag_name ];
};
})
{
error = base08;
warn = base0A;
hint = base0C;
info = base0B;
});
lualine_y = [{
name = "diff";
extraConfig = {
diff_color = {
added.fg = base0B;
modified.fg = base0A;
removed.fg = base08;
};
symbols = {
added = " ";
modified = " ";
removed = " ";
};
};
}
"branch"];
lualine_z = [
"filetype"
"fileformat"
"encoding"
];
};
theme = (lib.mapAttrs
(mode_name: mode_color: {
a = inverted;
b = inverted // { bg = mode_color; gui = "bold"; };
c = normal;
x = inverted;
y = normal;
z = inverted // { bg = mode_color; };
}) })
{ {
error = base08; normal = base0D;
warn = base0A; insert = base0B;
hint = base0C; visual = base0F;
info = base0B; replace = base08;
}); command = base0E;
lualine_y = [{ }) // {
name = "diff"; inactive = {
extraConfig = { a = inverted_ina;
diff_color = { b = normal_ina // { bg = base00; gui = "bold"; };
added.fg = base0B; c = normal_ina;
modified.fg = base0A; x = inverted_ina;
removed.fg = base08; y = normal_ina;
}; z = normal_ina // { bg = base00; };
symbols = {
added = " ";
modified = " ";
removed = " ";
};
}; };
}
"branch"];
lualine_z = [
"filetype"
"fileformat"
"encoding"
];
};
theme = (lib.mapAttrs
(mode_name: mode_color: {
a = inverted;
b = inverted // { bg = mode_color; gui = "bold"; };
c = normal;
x = inverted;
y = normal;
z = inverted // { bg = mode_color; };
})
{
normal = base0D;
insert = base0B;
visual = base0F;
replace = base08;
command = base0E;
}) // {
inactive = {
a = inverted_ina;
b = normal_ina // { bg = base00; gui = "bold"; };
c = normal_ina;
x = inverted_ina;
y = normal_ina;
z = normal_ina // { bg = base00; };
}; };
}; };
}; # Show context on top if scrolled out
# Show context on top if scrolled out treesitter-context = {
treesitter-context = { enable = true;
enable = true; maxLines = 5;
maxLines = 5; };
}; };
}; };
}; };