dotfiles/nix/home-manager/modules/packages/neovim.nix
2025-03-28 15:45:52 -04:00

375 lines
9.4 KiB
Nix

{ pkgs, ... }:
{
programs.nixvim = {
enable = true;
defaultEditor = true;
viAlias = true;
vimAlias = true;
extraConfigLuaPre = builtins.readFile ./neovim/pre.lua;
extraConfigLuaPost = builtins.readFile ./neovim/core.lua;
colorschemes = {
onedark.enable = true;
};
diagnostics = {
virtual_lines = true;
};
plugins = {
fugitive = {
enable = true;
};
gitsigns = {
enable = true;
};
lualine = {
enable = true;
# theme = "bubbles_theme"; # Currently doesn't work
settings = {
componentSeparators = {
left = "";
right = "";
};
sectionSeparators = {
left = "";
right = "";
};
sections = {
lualine_a = [
{
__unkeyed-1 = "mode";
separator = {
left = "";
};
padding = {
right = 2;
left = 0;
};
}
];
lualine_b = [
"filename"
"branch"
];
lualine_c = [ "%=" ];
lualine_x = [ ];
lualine_y = [
"filetype"
"progress"
];
lualine_z = [
{
__unkeyed-1 = "location";
separator = {
right = "";
};
padding = {
right = 0;
left = 2;
};
}
];
};
};
};
lsp = {
enable = true;
preConfig = '''';
servers = {
bashls.enable = true;
gopls.enable = true;
jsonls.enable = true;
pyright.enable = true; # In preference to attempting to use pylyzer
nil_ls.enable = true;
rust_analyzer =
let
fenix = fenix.latest.withComponents [
"cargo"
"rustc"
];
in
{
enable = true;
installCargo = false;
installRustc = false;
cargoPackage = fenix.cargo;
rustcPackage = fenix.rustc;
};
taplo.enable = true;
terraformls.enable = true;
yamlls.enable = true;
};
};
lspkind = {
enable = true;
mode = "symbol";
# cmp.enable = true;
symbolMap = {
# TODO
"Text" = "";
};
};
mini = {
enable = true;
modules = {
ai.enable = true;
align.enable = true;
animate.enable = true;
comment.enable = true;
completion.enable = true;
indentscope.enable = true;
jump.enable = true;
jump2d = {
enable = true;
mappings.start_jumping = "<leader>a";
};
splitjoin.enable = true;
surround.enable = true;
tabline.enable = true;
clue = {
triggers = [
{
mode = "n";
keys = "<leader>";
}
{
mode = "n";
keys = "z";
}
];
clues = [
{ __raw = "require('mini.clue').gen_clues.builtin_completion()"; }
{ __raw = "require('mini.clue').gen_clues.g()"; }
{ __raw = "require('mini.clue').gen_clues.marks()"; }
{ __raw = "require('mini.clue').gen_clues.registers()"; }
{ __raw = "require('mini.clue').gen_clues.windows()"; }
{ __raw = "require('mini.clue').gen_clues.z()"; }
];
};
};
};
blink-cmp = {
enable = true;
settings = {
keymap.preset = "super-tab";
appearance = {
nerd_font_variant = "mono";
};
completion = {
ghost_text.enabled = true;
accept = {
auto_brackets = {
enabled = true;
};
};
list = {
selection = {
auto_insert = false;
preselect = true;
};
};
menu = {
# draw == colorful-menu.nvim config
};
};
signature = {
enabled = true;
};
sources = {
default = [
"lsp"
"path"
"snippets"
"buffer"
# [TODO] Disabled until I figure this out, rust uses :: "emoji"
];
providers = {
emoji = {
module = "blink-emoji";
name = "Emoji";
score_offset = 15;
opts = {
insert = true;
};
};
};
};
};
};
blink-emoji.enable = true;
project-nvim = {
enable = true;
enableTelescope = true;
settings.detection_methods = [
"lsp"
"pattern"
];
};
telescope = {
enable = true;
extensions.live-grep-args.enable = true;
enabledExtensions = [
"zf-native" # TODO
"projects" # TODO
];
# extraLua = {
# post = builtins.readFile ./neovim/telescope.lua;
# };
keymaps = {
"<leader>ff" = {
mode = "n";
action = "find_files";
options.desc = "Find Files";
};
"<leader>fg" = {
mode = "n";
action = "live_grep";
options.desc = "Live Grep";
};
"<leader>fb" = {
mode = "n";
action = "buffers";
options.desc = "Find Buffers";
};
"<leader>r" = {
mode = "n";
action = "registers";
options.desc = "View Registers";
};
"<leader>pr" = {
mode = "n";
action = "lsp_references";
options.desc = "(LSP) References";
};
"<leader>pi" = {
mode = "n";
action = "lsp_implementations";
options.desc = "(LSP) Implementations";
};
"<leader>pd" = {
mode = "n";
action = "lsp_definitions";
options.desc = "(LSP) Definitions";
};
"<leader>ps" = {
mode = "n";
action = "lsp_document_symbols";
options.desc = "(LSP) Document Symbols";
};
"<leader>pws" = {
mode = "n";
action = "lsp_workspace_symbols";
options.desc = "(LSP) Workspace Symbols";
};
"<leader>pwd" = {
mode = "n";
action = "lsp_dynamic_workspace_symbols";
options.desc = "(LSP) Dynamic Workspace Symbols";
};
};
};
treesitter = {
enable = true;
settings = {
indent = {
enable = true;
};
incremental_selection = {
enable = true;
};
};
folding = true;
};
trouble = {
enable = true;
};
ts-context-commentstring = {
enable = true;
};
# ufo = { # TODO
# enable = true;
# extraLua.pre = ''
# require('ufo').setup({ provider_selector = function(bufnr, filetype, buftype)
# return {'treesitter', 'indent' }
# end
# })
# '';
# };
vim-bbye = {
enable = true;
};
web-devicons.enable = true;
};
extraPlugins =
(with pkgs.vimPlugins; [
rainbow-delimiters-nvim
telescope-symbols-nvim
overseer-nvim
nvim-web-devicons
telescope-zf-native-nvim
vim-ReplaceWithRegister
vim-dispatch-neovim
vim-expand-region
nvim-ufo
])
++ (with pkgs.awesomeNeovimPlugins; [
linrongbin16-gitlinker-nvim
officer-nvim
lsp-signature-nvim
nvim-biscuits
telescope-egrepify-nvim
]);
keymaps = [
{
action = "function() vim.api.nvim_command('wincmd h') end";
key = "<leader>h";
options.desc = "Cursor - Window left";
mode = "n";
}
{
action = "function() vim.api.nvim_command('wincmd j') end";
key = "<leader>j";
options.desc = "Cursor - Window down";
mode = "n";
}
{
action = "function() vim.api.nvim_command('wincmd k') end";
key = "<leader>k";
options.desc = "Cursor - Window up";
mode = "n";
}
{
action = "function() vim.api.nvim_command('wincmd l') end";
key = "<leader>l";
options.desc = "Cursor - Window right";
mode = "n";
}
{
key = "<c-k>";
action = "<c-u>";
mode = [
"n"
"v"
];
}
{
key = "<c-j>";
action = "<c-d>";
mode = [
"n"
"v"
];
}
{
key = "<leader>n";
action = "function() vim.api.nvim_command('nohl') end";
options.desc = "nohl";
mode = "n";
}
{
action = "<cmd>Telescope<cr>";
key = "<leader>t";
options.desc = "Open Telescope";
mode = "n";
}
];
};
}