dotfiles/nix/home-manager/modules/packages/neovim.nix
Anthony Cicchetti e5df0b93cc better updater
2024-04-16 15:05:18 -04:00

269 lines
7 KiB
Nix

{
config,
lib,
pkgs,
...
}: {
programs.nixneovim = {
enable = true;
defaultEditor = true;
viAlias = true;
vimAlias = true;
extraLuaPreConfig = builtins.readFile ./neovim/pre.lua;
extraConfigLua = builtins.readFile ./neovim/core.lua;
colorscheme = "onedark";
colorschemes = {
onedark.enable = true;
};
plugins = {
fugitive = {
enable = true;
};
gitsigns = {
enable = true;
};
lualine = {
enable = true;
# theme = "bubbles_theme"; # Currently doesn't work
componentSeparators = {
left = "";
right = "";
};
sectionSeparators = {
left = "";
right = "";
};
sections = {
lualine_a = ["mode" {separator = {left = "";};} {right_padding = 2;}];
lualine_b = ["filename" "branch"];
lualine_c = ["%="];
lualine_x = [];
lualine_y = ["filetype" "progress"];
lualine_z = ["location" {separator = {right = "";};} {left_padding = 2;}];
};
};
luasnip = {
enable = true;
};
lsp-lines = {
enable = true;
};
lspconfig = {
enable = true;
preConfig = ''
'';
servers = {
bashls.enable = true;
gopls.enable = true;
jsonls.enable = true;
pyright.enable = true; # In preference to attempting to use pylyzer
nil.enable = true;
rust-analyzer.enable = true;
taplo.enable = true;
terraform-ls.enable = true;
};
};
lspkind = {
enable = true;
mode = "symbol";
};
mini = {
enable = true;
ai.enable = true;
align.enable = true;
animate.enable = true;
comment.enable = true;
completion.enable = true;
indentscope.enable = true;
jump.enable = true;
jump2d = {
enable = true;
extraConfig = {
mappings.start_jumping = "<leader>a";
};
};
splitjoin.enable = true;
surround.enable = true;
tabline.enable = true;
};
nvim-cmp = {
enable = true;
formatting = {
format = ''
function(entry, vim_item)
vim_item.kind = string.format("%s %s", kind_icons[vim_item.kind], vim_item.kind)
vim_item.menu = ({
buffer = "[Buffer]",
nvim_lsp = "[LSP]",
luasnip = "[LuaSnip]",
nvim_lua = "[Lua]",
latex_symbols = "[LaTeX]",
})[entry.source.name]
return vim_item
end
'';
};
mappingPresets = ["insert"];
mapping = {
"<CR>" = "cmp.mapping.confirm({ select = true})";
"<C-Space>" = "cmp.mapping.complete()";
"<Tab>" = {
modes = ["i" "s" "c"];
action = ''
function(fallback)
local entry = cmp.get_selected_entry()
if not entry then
cmp.select_next_item({ behavior = cmp.SelectBehavior.Select })
cmp.confirm()
elseif entry then
cmp.confirm()
elseif luasnip.expandable() then
luasnip.expand()
elseif luasnip.expand_or_jumpable() then
luasnip.expand_or_jump()
elseif check_backspace() then
fallback()
else
fallback()
end
end
'';
};
"<S-Tab>" = {
modes = ["i" "s" "c"];
action = ''
function(fallback)
if cmp.visible() then
cmp.select_prev_item()
elseif luasnip.jumpable(-1) then
luasnip.jump(-1)
else
fallback()
end
end
'';
};
};
snippet = {
luasnip.enable = true;
};
sources = {
cmdline = {
enable = true;
};
emoji.enable = true;
fuzzy_path.enable = true;
luasnip.enable = true;
nvim_lsp.enable = true;
nvim_lsp_document_symbol.enable = true;
nvim_lsp_signature_help.enable = true;
treesitter.enable = true;
};
view = {
entries = "custom";
};
};
project-nvim = {
enable = true;
};
telescope = {
enable = true;
extraLua = {
post = builtins.readFile ./neovim/telescope.lua;
};
};
treesitter = {
enable = true;
indent = true;
folding = true;
incrementalSelection = {
enable = true;
};
};
trouble = {
enable = true;
};
undotree = {
enable = true;
};
which-key = {
enable = true;
groups = {
normal = {
"<leader>f" = "Telescope - Find";
"<leader>r" = "View registers";
"<leader>p" = "Telescope - LSP";
};
};
};
};
extraPlugins =
(
with pkgs.vimPlugins; [
fuzzy-nvim
nvim-ts-context-commentstring
telescope-zf-native-nvim
vim-ReplaceWithRegister
vim-bbye
vim-dispatch-neovim
vim-expand-region
]
)
++ (with pkgs.vimExtraPlugins; [
rainbow-delimiters-nvim
gitlinker-linrongbin16
telescope-symbols-nvim
nvim-web-devicons
lsp-signature-nvim
nvim-rg
telescope-egrepify-nvim
]);
mappings = {
normal = {
"<leader>u" = {
action = "vim.cmd.UndotreeToggle";
desc = "Toggle undotree";
};
"<leader>h" = {
action = "function() vim.api.nvim_command('wincmd h') end";
desc = "Cursor - Window left";
};
"<leader>j" = {
action = "function() vim.api.nvim_command('wincmd j') end";
desc = "Cursor - Window down";
};
"<leader>k" = {
action = "function() vim.api.nvim_command('wincmd k') end";
desc = "Cursor - Window up";
};
"<leader>l" = {
action = "function() vim.api.nvim_command('wincmd l') end";
desc = "Cursor - Window right";
};
"<c-k>" = {
action = "'<c-u>'";
};
"<c-j>" = {
action = "'<c-d>'";
};
"<leader>n" = {
action = "function() vim.api.nvim_command('nohl') end";
desc = "nohl";
};
"<leader>t" = {
action = "'<cmd>Telescope<cr>'";
desc = "Open Telescope";
};
};
visual = {
"<c-k>" = {
action = "'<c-u>'";
};
"<c-j>" = {
action = "'<c-d>'";
};
};
};
};
}