config-perso/kat/users/neovim.nix

319 lines
7.6 KiB
Nix
Raw Normal View History

2024-09-26 11:51:04 +02:00
{
config,
lib,
...
}:
with lib;
2024-11-16 22:03:25 +01:00
let
basecfg = {
enable = true;
defaultEditor = true;
vimdiffAlias = true;
vimAlias = true;
viAlias = true;
colorschemes.dracula-nvim = {
2024-09-26 11:51:04 +02:00
enable = true;
2024-11-16 22:03:25 +01:00
settings = {
colors = {
bg = "#000000";
black = "#000000";
};
transparent_bg = true;
overrides.__raw = ''
function (colors) return {
LineNr = { bg = "#181818", fg = colors.purple },
CursorLine = { },
CursorLineNr = { fg = "#FFFF00", bg = colors.black, bold = true },
StatusLine = { fg = colors.bright_white, bg = colors.black },
} end
'';
};
};
opts = {
foldlevelstart = 99;
number = true;
relativenumber = true;
cursorline = true;
tabstop = 2;
shiftwidth = 2;
expandtab = true;
};
globals.mapleader = ",";
autoCmd = [
{
command = "set relativenumber";
event = [ "InsertLeave" ];
}
{
command = "set norelativenumber";
event = [ "InsertEnter" ];
}
];
keymaps = [
{
action = ":set number!<CR>";
key = "<F2>";
}
{
action = ":set relativenumber!<CR>";
key = "<F3>";
}
{
action = ''"*ygv'';
key = "<LeftRelease>";
mode = [ "v" ];
}
];
plugins = {
nix.enable = true;
treesitter = {
2024-11-01 15:11:35 +01:00
enable = true;
2024-11-16 22:03:25 +01:00
folding = true;
settings.highlight.enable = true;
};
telescope = {
enable = true;
keymaps = {
"ff".action = "find_files";
"fg".action = "live_grep";
"fb".action = "buffers";
};
settings.pickers.buffers.mappings = rec {
i."<c-d>".__raw = "require('telescope.actions').delete_buffer";
n = i;
2024-11-01 15:11:35 +01:00
};
};
2024-09-26 11:51:04 +02:00
2024-11-16 22:03:25 +01:00
web-devicons.enable = true;
which-key = {
enable = true;
settings.triggers =
2024-11-28 15:44:53 +01:00
map
(key: {
__unkeyed = key;
2024-11-16 22:03:25 +01:00
mode = "nxsot";
2024-11-28 15:44:53 +01:00
})
[
"<leader>"
"f"
"c"
"d"
"y"
];
2024-11-01 15:11:35 +01:00
};
2024-09-26 11:51:04 +02:00
2024-11-16 22:03:25 +01:00
todo-comments = {
enable = true;
keymaps.todoTelescope.key = "ft";
};
markview.enable = true;
nvim-surround.enable = true;
};
};
adv-editor = {
plugins = {
which-key.settings.spec = [
2024-11-01 15:11:35 +01:00
{
2024-11-16 22:03:25 +01:00
__unkeyed = "<leader>l";
desc = "Lsp keymaps";
2024-11-01 15:11:35 +01:00
}
{
2024-11-16 22:03:25 +01:00
__unkeyed = "<leader>lK";
desc = "Hover information";
}
{
__unkeyed = "<leader>la";
desc = "Apply code action";
}
{
__unkeyed = "<leader>ls";
desc = "Show signature help";
}
{
__unkeyed = "<leader>lg";
desc = "Go to";
2024-11-01 15:11:35 +01:00
}
{
2024-11-16 22:03:25 +01:00
__unkeyed = "<leader>lgD";
desc = "References";
2024-11-01 15:11:35 +01:00
}
{
2024-11-16 22:03:25 +01:00
__unkeyed = "<leader>lgd";
desc = "Definition";
2024-11-01 15:11:35 +01:00
}
{
2024-11-16 22:03:25 +01:00
__unkeyed = "<leader>lgi";
desc = "Implementation";
}
{
__unkeyed = "<leader>lgt";
desc = "Type definition";
2024-11-01 15:11:35 +01:00
}
2024-09-26 11:51:04 +02:00
];
2024-11-01 15:11:35 +01:00
2024-11-28 15:44:53 +01:00
luasnip.enable = true;
cmp_luasnip.enable = true;
cmp-nvim-lsp.enable = true;
cmp-buffer.enable = true;
cmp-cmdline.enable = true;
cmp-path.enable = true;
cmp-latex-symbols.enable = true;
cmp = {
enable = true;
autoEnableSources = false;
cmdline =
let
slash-qu = {
mapping.__raw = "cmp.mapping.preset.cmdline()";
sources = [
{ name = "buffer"; }
];
};
in
{
"/" = slash-qu;
"?" = slash-qu;
":" = {
mapping.__raw = "cmp.mapping.preset.cmdline()";
sources = [
{ name = "path"; }
{ name = "cmdline"; }
];
matching = {
disallow_symbol_nonprefix_matching = false;
};
};
};
settings = {
snippet.expand = ''
function(args)
require('luasnip').lsp_expand(args.body)
end
'';
sources = map (name: { inherit name; }) [
"luasnip"
"nvim_lsp"
"buffer"
] ++ [
{ name = "latex_symbols"; option.strategy = 2; }
];
mapping = {
"<C-Space>" = "cmp.mapping.complete()";
"<C-d>" = "cmp.mapping.scroll_docs(-4)";
"<C-e>" = "cmp.mapping.close()";
"<C-f>" = "cmp.mapping.scroll_docs(4)";
"<CR>" = "cmp.mapping.confirm({ behavior = cmp.ConfirmBehavior.Insert, select = true })";
"<S-Tab>" = ''
cmp.mapping(
function(fallback)
if cmp.visible() then
cmp.select_prev_item()
elseif require("luasnip").jumpable(-1) then
vim.fn.feedkeys(
vim.api.nvim_replace_termcodes(
"<Plug>luasnip-jump-prev",
true, true, true),
"")
else
fallback()
end
end,
{'i', 's'})'';
"<Tab>" = ''
cmp.mapping(
function(fallback)
if cmp.visible() then
cmp.select_next_item()
elseif require("luasnip").expand_or_jumpable() then
vim.fn.feedkeys(
vim.api.nvim_replace_termcodes(
"<Plug>luasnip-expand-or-jump",
true, true, true),
"")
else
fallback()
end
end,
{ 'i', 's' })
'';
};
};
};
2024-11-16 22:03:25 +01:00
lsp-lines.enable = true;
2024-11-01 15:11:35 +01:00
2024-11-16 22:03:25 +01:00
lsp = {
enable = true;
keymaps = {
diagnostic = {
"lj" = "goto_next";
"lk" = "goto_prev";
2024-11-01 15:11:35 +01:00
};
2024-11-16 22:03:25 +01:00
lspBuf = {
"<leader>lK" = "hover";
"<leader>la" = "code_action";
"<leader>ls" = "signature_help";
"<leader>lgD" = "references";
"<leader>lgd" = "definition";
"<leader>lgi" = "implementation";
"<leader>lgt" = "type_definition";
2024-11-01 15:11:35 +01:00
};
2024-11-16 22:03:25 +01:00
extra = [
{
action = "<CMD>LspStop<Enter>";
key = "<leader>lx";
}
{
action = "<CMD>LspStart<Enter>";
key = "<leader>ls";
}
{
action = "<CMD>LspRestart<Enter>";
key = "<leader>lr";
}
];
2024-11-01 15:11:35 +01:00
};
2024-11-16 22:03:25 +01:00
servers = {
nixd.enable = true;
pylsp.enable = true;
clangd.enable = true;
ltex.enable = true;
rust_analyzer = {
enable = true;
installCargo = true;
installRustc = true;
2024-11-01 16:07:45 +01:00
};
2024-11-28 15:44:53 +01:00
hls = {
enable = true;
installGhc = true;
};
2024-11-01 16:07:45 +01:00
};
2024-11-01 15:11:35 +01:00
};
2024-09-26 11:51:04 +02:00
};
};
2024-11-16 22:03:25 +01:00
in
{
options.kat.neovim = {
enable = mkEnableOption "neovim configuration" // {
default = true;
};
lsp = mkEnableOption "neovim LSPs";
};
config = mkIf config.kat.neovim.enable {
programs.nixvim = mkMerge [
basecfg
(mkIf config.kat.neovim.lsp adv-editor)
];
};
2024-09-26 11:51:04 +02:00
}