From 0bb5981f3aafb554f07e67101b7823251edc3dda Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Geoffrey=20=E2=80=9CFrogeye=E2=80=9D=20Preud=27homme?= Date: Thu, 25 Jan 2024 23:53:59 +0100 Subject: [PATCH] vim: Fix tabline bindings --- hm/vim/decoration.nix | 283 +++++++++++++++++++++--------------------- 1 file changed, 143 insertions(+), 140 deletions(-) diff --git a/hm/vim/decoration.nix b/hm/vim/decoration.nix index b5f51bc..a80e8b4 100644 --- a/hm/vim/decoration.nix +++ b/hm/vim/decoration.nix @@ -1,154 +1,157 @@ { pkgs, lib, config, ... }: { config = { - programs.nixvim = { - autoCmd = [ - # Turn off relativenumber only for insert mode - { event = "InsertEnter"; pattern = "*"; command = "set norelativenumber"; } - { event = "InsertLeave"; pattern = "*"; command = "set relativenumber"; } - ]; - extraPlugins = with pkgs.vimPlugins; [ - nvim-scrollview # Scroll bar - ]; - keymaps = [ - # barbar - { key = ""; action = "BufferPrevious"; options = { silent = true; }; } - { key = ""; action = "BufferNext"; options = { silent = true; }; } - # TODO https://www.reddit.com/r/neovim/comments/mbj8m5/how_to_setup_ctrlshiftkey_mappings_in_neovim_and/ - { key = ""; action = "BufferMovePrevious"; options = { silent = true; }; } - { key = ""; action = "BufferMoveNext"; options = { silent = true; }; } - # TODO gotos don't work - { key = ""; action = "BufferGoto 1"; options = { silent = true; }; } - { key = ""; action = "BufferGoto 2"; options = { silent = true; }; } - { key = ""; action = "BufferGoto 3"; options = { silent = true; }; } - { key = ""; action = "BufferGoto 4"; options = { silent = true; }; } - { key = ""; action = "BufferGoto 5"; options = { silent = true; }; } - { key = ""; action = "BufferGoto 6"; options = { silent = true; }; } - { key = ""; action = "BufferGoto 7"; options = { silent = true; }; } - { key = ""; action = "BufferGoto 8"; options = { silent = true; }; } - { key = ""; action = "BufferGoto 9"; options = { silent = true; }; } - { key = ""; action = "BufferLast"; options = { silent = true; }; } - { key = "gb"; action = "BufferPick"; options = { silent = true; }; } - # TODO Other useful options? - ]; - options = { - showmode = false; - number = true; - relativenumber = true; - title = true; - }; - plugins = { - # Tabline - barbar.enable = true; - # TODO Investigate bufferline? - # Status line - lualine = with config.lib.stylix.colors.withHashtag; let - normal = { fg = base05; bg = base01; }; - inverted = { fg = base00; bg = base03; }; - normal_ina = { fg = base02; bg = base01; }; - inverted_ina = { fg = base00; bg = base02; }; - in - rec { - enable = true; - inactiveSections = sections; - sections = { - lualine_a = [{ - name = ''string.format('%d', vim.fn.line('$'))''; - }]; - lualine_b = [ - "mode" - ]; - lualine_c = [{ - name = "filename"; - color = { - __raw = '' - function(section) - return { fg = vim.bo.modified and '${base08}' or '${normal.fg}' } - end - ''; - }; - extraConfig = { - path = 1; # Relative path - symbols = { - modified = "●"; - newfile = "󰻭"; - readonly = "󰏯"; - unnamed = "󱀶"; + programs = { + # https://www.reddit.com/r/neovim/comments/mbj8m5/how_to_setup_ctrlshiftkey_mappings_in_neovim_and/ + alacritty.settings.key_bindings = [ + { key = "H"; mods = "Control|Shift"; chars = "\\x1b[72;5u"; } + { key = "L"; mods = "Control|Shift"; chars = "\\x1b[76;5u"; } + ] ++ (map + (n: { key = "Key${builtins.toString n}"; mods = "Control"; chars = "\\x1b[${builtins.toString (48+n)};5u"; }) + (lib.lists.range 0 9)); + # Ctrl+ doesn't get interpreted, but Ctrl+Shift+ does, so let's use that + nixvim = { + autoCmd = [ + # Turn off relativenumber only for insert mode + { event = "InsertEnter"; pattern = "*"; command = "set norelativenumber"; } + { event = "InsertLeave"; pattern = "*"; command = "set relativenumber"; } + ]; + extraPlugins = with pkgs.vimPlugins; [ + nvim-scrollview # Scroll bar + ]; + keymaps = + let + options = { silent = true; }; + in + [ + # barbar + { key = "gb"; action = "BufferPick"; inherit options; } + { key = ""; action = "BufferPrevious"; inherit options; } + { key = ""; action = "BufferNext"; inherit options; } + { key = ""; action = "BufferMovePrevious"; inherit options; } + { key = ""; action = "BufferMoveNext"; inherit options; } + { key = ""; action = "BufferLast"; inherit options; } + ] ++ (map + (n: { key = ""; action = "BufferGoto ${builtins.toString n}"; inherit options; }) + (lib.lists.range 1 9)); + options = { + showmode = false; + number = true; + relativenumber = true; + title = true; + }; + plugins = { + # Tabline + barbar.enable = true; + # Status line + lualine = with config.lib.stylix.colors.withHashtag; let + normal = { fg = base05; bg = base01; }; + inverted = { fg = base00; bg = base03; }; + normal_ina = { fg = base02; bg = base01; }; + inverted_ina = { fg = base00; bg = base02; }; + in + rec { + enable = true; + inactiveSections = sections; + sections = { + lualine_a = [{ + name = ''string.format('%d', vim.fn.line('$'))''; + }]; + lualine_b = [ + "mode" + ]; + lualine_c = [{ + name = "filename"; + color = { + __raw = '' + function(section) + return { fg = vim.bo.modified and '${base08}' or '${normal.fg}' } + end + ''; }; - }; - } - "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 ]; + 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 = { + 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; - 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 = " "; - }; + 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; }; }; - } - "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 - treesitter-context = { - enable = true; - maxLines = 5; + # Show context on top if scrolled out + treesitter-context = { + enable = true; + maxLines = 5; + }; }; }; };