dotfiles/nix/home/programs/nvim/default.nix
2026-03-19 12:05:33 -07:00

225 lines
5.9 KiB
Nix

{ pkgs, ... }:
let
vim-nix = pkgs.vimUtils.buildVimPlugin {
name = "vim-nix";
src = pkgs.fetchFromGitHub {
owner = "LnL7";
repo = "vim-nix";
rev = "d733cb96707a2a6bdc6102b6d89f947688e0e959";
sha256 = "12k2gwm8b1n02361gpjhsldql99yd7qsh80a3lbwc5c5gz5j8jsb";
};
};
vim-precognition = pkgs.vimUtils.buildVimPlugin {
name = "vim-precognition";
version = "2024-05-26";
src = pkgs.fetchFromGitHub {
owner = "tris203";
repo = "precognition.nvim";
rev = "b40c3539f95504bea2ac4ac4dc866a95edba6d4d";
sha256 = "sha256-fyaMWL0MsmWJ8KcY1QkbtoZ7tDbIbFbEYgA/ZsOoVSk=";
};
};
in
with builtins;
{
programs.neovim = {
enable = true;
vimAlias = true;
plugins = with pkgs.vimPlugins; [
vim-sensible
{
plugin = vim-precognition;
config = ''
lua << EOF
require("precognition").setup({})
EOF
noremap ? :lua require("precognition").peek()<CR>
'';
}
plenary-nvim
{
plugin = nvim-treesitter-legacy.withAllGrammars;
config = ''
lua << EOF
require'nvim-treesitter.configs'.setup {
highlight = {
enable = true,
},
}
EOF
'';
}
# cosmetic improvements
catppuccin-nvim
vim-illuminate # highlight cursor-word
nvim-web-devicons
{
plugin = rainbow;
config = ''
let g:rainbow_conf = {
\ 'guifgs': ['RoyalBlue3', 'SeaGreen3', 'DarkOrchid3', 'firebrick3', 'RoyalBlue3', 'SeaGreen3', 'DarkOrchid3', 'firebrick3', 'RoyalBlue3', 'DarkOrchid3', 'firebrick3', 'RoyalBlue3', 'SeaGreen3', 'DarkOrchid3', 'firebrick3'],
\ 'ctermfgs': ['red', 'brown', 'blue', 'gray', 'green', 'magenta', 'cyan', 'darkred', 'brown', 'darkblue', 'gray', 'darkgreen', 'darkmagenta', 'darkcyan', 'red'],
\ 'parentheses': ['start=/(/ end=/)/ fold', 'start=/\[/ end=/\]/ fold', 'start=/{/ end=/}/ fold']
\}
let g:rainbow_active = 1
'';
}
{
plugin = vim-indent-guides;
config = ''
let g:indent_guides_enable_on_vim_startup = 1
let g:indent_guides_start_level = 2
'';
}
# language-agnostic editor improvements
{
plugin = fzf-vim;
config = ''
noremap <leader>fc :BCommits<CR>
'';
}
which-key-nvim
{
plugin = alpha-nvim;
config = ''
lua << EOF
local alpha = require("alpha");
local dashboard = require("alpha.themes.startify");
alpha.setup(dashboard.config);
EOF
'';
}
{
plugin = nvim-autopairs;
config = ''
lua << EOF
require("nvim-autopairs").setup {}
EOF
'';
}
{
plugin = lualine-nvim;
config = ''
lua << EOF
require('lualine').setup()
EOF
'';
}
{
plugin = comment-nvim;
config = ''
lua << EOF
require('Comment').setup()
EOF
'';
}
vim-surround
{
# file explorer
plugin = oil-nvim;
config = ''
lua << EOF
require("oil").setup()
vim.keymap.set("n", "-", "<CMD>Oil<CR>", { desc = "Open parent directory" })
EOF
'';
}
{
plugin = undotree;
config = ''
nnoremap <leader>u :UndotreeToggle<CR>
let g:undotree_SetFocusWhenToggle = 1
if has("persistent_undo")
let target_path = expand('~/.undodir')
" create the directory and any parent directories
" if the location does not exist.
if !isdirectory(target_path)
call mkdir(target_path, "p", 0700)
endif
let &undodir=target_path
set undofile
endif
'';
}
{
plugin = telescope-nvim;
config = ''
nnoremap <leader>ff <cmd>lua require('telescope.builtin').find_files()<cr>
nnoremap <leader>fg <cmd>lua require('telescope.builtin').live_grep()<cr>
nnoremap <leader>fb <cmd>lua require('telescope.builtin').buffers()<cr>
nnoremap <leader>fh <cmd>lua require('telescope.builtin').help_tags()<cr>
'';
}
nvim-dap
nvim-dap-ui
# Git stuff
{
plugin = vim-fugitive;
config = ''
nnoremap gb :Git blame<CR>
'';
}
{
plugin = git-blame-nvim;
config = ''
let g:gitblame_date_format = '%Y-%m-%d'
nnoremap gC :GitBlameOpenCommitURL<CR>
'';
}
{
plugin = gitsigns-nvim;
config = ''
lua << EOF
require('gitsigns').setup()
EOF
'';
}
# Language servers
cmp-nvim-lsp
{
plugin = nvim-lspconfig;
config = ''
lua << EOF
${readFile (
pkgs.replaceVars ./nvim-lspconfig.lua {
# since both of these are used for actually configuring the system,
# we'll probably always want them around.
lua_ls = pkgs.lua-language-server;
nixd = pkgs.nixd;
# Nearly always want the diagnostic server
diagnostic_server = pkgs.nodePackages.diagnostic-languageserver;
}
) }
EOF
'';
}
# language-specific plugins
vim-nix
vim-json
dart-vim-plugin
# have the completion plugin get loaded last just in case anything above
# needs to do setup work before completions get set up.
{
plugin = nvim-cmp;
config = ''
lua << EOF
${ readFile ./nvim-cmp.lua }
EOF
'';
}
];
extraConfig = readFile ./init.vim;
};
}