dotfiles/hm/vim/decoration.nix

265 lines
7.9 KiB
Nix
Raw Normal View History

2024-12-15 00:29:51 +01:00
{
pkgs,
lib,
config,
nixvimLib,
...
}:
2024-12-03 23:07:46 +01:00
let
nv = nixvimLib.nixvim;
in
2024-01-12 18:08:11 +01:00
{
config = {
2024-01-25 23:53:59 +01:00
programs = {
# https://www.reddit.com/r/neovim/comments/mbj8m5/how_to_setup_ctrlshiftkey_mappings_in_neovim_and/
2024-12-15 00:29:51 +01:00
alacritty.settings.keyboard.bindings =
[
{
key = "H";
mods = "Control|Shift";
chars = "\\u001b[72;5u";
}
{
key = "L";
mods = "Control|Shift";
chars = "\\u001b[76;5u";
}
]
++ (map (n: {
key = "Key${builtins.toString n}";
mods = "Control";
chars = "\\u001b[${builtins.toString (48 + n)};5u";
}) (lib.lists.range 0 9));
2024-01-25 23:53:59 +01:00
# Ctrl+<number> doesn't get interpreted, but Ctrl+Shift+<number> does, so let's use that
nixvim = {
autoCmd = [
# Turn off relativenumber only for insert mode
2024-12-15 00:29:51 +01:00
{
event = "InsertEnter";
pattern = "*";
command = "set norelativenumber";
}
{
event = "InsertLeave";
pattern = "*";
command = "set relativenumber";
}
2024-01-25 23:53:59 +01:00
];
extraPlugins = with pkgs.vimPlugins; [
nvim-scrollview # Scroll bar
];
keymaps =
let
2024-12-15 00:29:51 +01:00
options = {
silent = true;
};
2024-01-25 23:53:59 +01:00
in
[
# barbar
2024-12-15 00:29:51 +01:00
{
key = "gb";
action = "<Cmd>BufferPick<CR>";
inherit options;
}
{
key = "<C-H>";
action = "<Cmd>BufferPrevious<CR>";
inherit options;
}
{
key = "<C-L>";
action = "<Cmd>BufferNext<CR>";
inherit options;
}
{
key = "<C-S-H>";
action = "<Cmd>BufferMovePrevious<CR>";
inherit options;
}
{
key = "<C-S-L>";
action = "<Cmd>BufferMoveNext<CR>";
inherit options;
}
{
key = "<C-0>";
action = "<Cmd>BufferLast<CR>";
inherit options;
}
]
++ (map (n: {
key = "<C-${builtins.toString n}>";
action = "<Cmd>BufferGoto ${builtins.toString n}<CR>";
inherit options;
}) (lib.lists.range 1 9));
2024-06-01 21:32:11 +02:00
opts = {
2024-01-25 23:53:59 +01:00
showmode = false;
number = true;
relativenumber = true;
title = true;
};
plugins = {
# Tabline
barbar.enable = true;
2024-01-27 14:23:26 +01:00
# TODO Reload make it use the preset colorscheme
2024-01-25 23:53:59 +01:00
# Status line
2024-12-15 00:29:51 +01:00
lualine =
with config.lib.stylix.colors.withHashtag;
let
normal = {
fg = base05;
bg = base01;
};
inverted = {
fg = base00;
bg = base03;
};
2024-12-15 00:29:51 +01:00
normal_ina = {
fg = base02;
bg = base01;
};
inverted_ina = {
fg = base00;
bg = base02;
};
in
{
enable = true;
settings = rec {
inactive_sections = sections;
sections = {
lualine_a = [
(nv.listToUnkeyedAttrs [ "string.format('%d', vim.fn.line('$'))" ])
];
lualine_b = [ "mode" ];
lualine_c = [
(
(nv.listToUnkeyedAttrs [ "filename" ])
// {
color = nv.mkRaw ''
function(section)
return { fg = vim.bo.modified and '${base08}' or '${normal.fg}' }
end
'';
path = 1; # Relative path
symbols = {
modified = "";
newfile = "󰻭";
readonly = "󰏯";
unnamed = "󱀶";
};
}
)
"location"
];
lualine_x =
[
(
(nv.listToUnkeyedAttrs [ ''(next(vim.lsp.buf_get_clients()) == nil) and "󰒲 " or ""'' ])
// {
separator = {
left = "";
right = "";
};
}
)
]
++ (lib.mapAttrsToList
(
diag_name: diag_color:
(
(nv.listToUnkeyedAttrs [ "diagnostics" ])
// {
color.bg = diag_color;
colored = false;
separator = {
left = "";
right = "";
};
sections = [ diag_name ];
}
)
)
{
error = base08;
warn = base0A;
hint = base0C;
info = base0B;
}
);
lualine_y = [
(
(nv.listToUnkeyedAttrs [ "diff" ])
// {
diff_color = {
added.fg = base0B;
modified.fg = base0A;
removed.fg = base08;
};
symbols = {
added = " ";
modified = " ";
removed = " ";
};
}
)
"branch"
];
lualine_z = [
"filetype"
"fileformat"
"encoding"
];
};
2024-12-15 00:29:51 +01:00
options.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;
};
};
};
};
};
2024-01-25 23:53:59 +01:00
# Show context on top if scrolled out
treesitter-context = {
enable = true;
2024-06-01 21:32:11 +02:00
settings.max_lines = 5;
2024-01-25 23:53:59 +01:00
};
web-devicons.enable = true; # TODO Check out plugins.mini.enable
2024-01-23 23:38:48 +01:00
};
2024-01-12 18:08:11 +01:00
};
};
};
}