flocon/home/base/programs/nixvim/default.nix

285 lines
7.8 KiB
Nix
Raw Normal View History

2024-08-25 19:58:12 +00:00
{ ... }:
{
programs.nixvim = {
enable = true;
viAlias = true;
vimAlias = true;
performance.byteCompileLua.enable = true;
clipboard.providers.wl-copy.enable = true;
globals.mapleader = " ";
2024-08-25 19:58:12 +00:00
opts = {
smartindent = false;
relativenumber = true;
clipboard = "unnamedplus";
};
files = {
"ftplugin/nix.lua" = {
opts = {
expandtab = true;
shiftwidth = 2;
tabstop = 2;
};
};
};
autoCmd = [{
event = [ "BufWritePre" ];
callback = {
__raw = ''
function()
vim.lsp.buf.format { async = false }
end
'';
};
desc = "Auto format buffer before save using LSP";
}];
keymaps = [
{
action = "<cmd>Telescope find_files<CR>";
key = "<leader>ff";
options = {
desc = "Find files";
};
}
{
action = "<cmd>Telescope projects<CR>";
key = "<leader>fp";
options = {
desc = "Find projects";
};
}
{
action = "<cmd>Neotree toggle<CR>";
key = "<leader>ft";
options = {
desc = "Toggle neo-tree";
};
}
{
action = ''
<cmd>lua vim.lsp.buf.code_action({ apply = true })<CR>
'';
2024-08-25 19:58:12 +00:00
key = "<leader>lc";
options = {
desc = "Apply code actions";
};
}
{
action = ''
<cmd>lua vim.lsp.buf.format()<CR>
'';
2024-08-25 19:58:12 +00:00
key = "<leader>lf";
options = {
desc = "Format buffer";
};
}
];
plugins = {
alpha = {
enable = true;
layout = [
{
type = "padding";
val = 2;
}
{
opts = {
hl = "Keyword";
position = "center";
};
type = "text";
val = [
""
""
""
""
""
""
""
""
""
""
""
""
""
""
];
}
{
type = "padding";
val = 2;
}
{
type = "group";
val = let
mkButton = shortcut: cmd: val: hl: {
type = "button";
inherit val;
opts = {
inherit hl shortcut;
keymap = [ "n" shortcut cmd { } ];
position = "center";
cursor = 0;
width = 40;
align_shortcut = "right";
hl_shortcut = "Keyword";
};
};
in [
(mkButton "f" "<CMD>:Telescope find_files<CR>" " Find File"
"Operator")
(mkButton "p" "<CMD>:Telescope projects<CR>" " Projects"
"Operator")
(mkButton "q" "<CMD>qa<CR>" "󰈆 Quit" "Error")
];
}
];
};
lualine = {
enable = true;
extensions = [ "neo-tree" ];
globalstatus = true;
};
treesitter = {
enable = true;
settings = {
auto_install = true;
highlight = {
additional_vim_regex_highlighting = true;
custom_captures = { };
enable = true;
};
incremental_selection = {
enable = true;
keymaps = {
init_selection = false;
node_decremental = "grm";
node_incremental = "grn";
scope_incremental = "grc";
};
};
indent = {
enable = true;
};
parser_install_dir = {
__raw = "vim.fs.joinpath(vim.fn.stdpath('data'), 'treesitter')";
};
2024-08-25 19:58:12 +00:00
};
};
treesitter-context.enable = true;
indent-blankline.enable = true;
lsp = {
enable = true;
servers = {
gopls.enable = true;
nixd.enable = true;
lua-ls.enable = true;
};
};
cmp = {
enable = true;
autoEnableSources = true;
settings = {
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({ select = true })";
2024-08-27 13:25:58 +00:00
"<S-Tab>" = ''
cmp.mapping(function (fallback)
local luasnip = require('luasnip')
if cmp.visible() then
cmp.select_prev_item()
elseif luasnip.jumpable(-1) then
luasnip.jump(-1)
else
fallback()
end
end, {'i', 's'})
'';
"<Tab>" = ''
cmp.mapping(function (fallback)
local luasnip = require('luasnip')
if luasnip.expandable() then
luasnip.expand()
elseif cmp.visible() then
cmp.select_next_item()
elseif luasnip.jumpable(1) then
luasnip.jump(1)
else
fallback()
end
end, {'i', 's'})
'';
2024-08-25 19:58:12 +00:00
};
sources =
2024-08-27 13:25:58 +00:00
[ { name = "nvim_lsp"; } { name = "path"; } { name = "buffer"; } { name = "luasnip"; } ];
2024-08-25 19:58:12 +00:00
};
};
cmp-nvim-lsp.enable = true;
cmp-nvim-lsp-signature-help.enable = true;
telescope = {
enable = true;
};
2024-08-27 13:25:58 +00:00
luasnip.enable = true;
friendly-snippets.enable = true;
2024-08-25 19:58:12 +00:00
neo-tree = {
enable = true;
useDefaultMappings = true;
};
nvim-autopairs.enable = true;
project-nvim = {
enable = true;
enableTelescope = true;
};
2024-08-26 13:08:43 +00:00
direnv.enable = true;
2024-08-25 19:58:12 +00:00
which-key = {
enable = true;
settings = {
delay = 200;
expand = 1;
notify = false;
preset = false;
replace = {
desc = [
[ "<space>" "SPACE" ]
[ "<leader>" "SPACE" ]
[ "<[cC][rR]>" "RETURN" ]
[ "<[tT][aA][bB]>" "TAB" ]
[ "<[bB][sS]>" "BACKSPACE" ]
];
};
spec = [
{
__unkeyed = "<leader>f";
group = "Find";
}
{
__unkeyed = "<leader>l";
group = "LSP";
}
];
};
};
tmux-navigator.enable = true;
};
};
}