nixos-config/modules/workstation/home-manager/neovim/default.nix

170 lines
4.5 KiB
Nix
Raw Normal View History

2024-04-11 20:15:47 +02:00
{
lib,
config,
pkgs,
...
}:
with lib;
{
options.desktop.enableNeovim = mkOption {
type = types.bool;
default = true;
example = false;
description = ''
Whether to use Neovim and its config.
'';
};
config.home.sessionVariables."EDITOR" = mkIf config.desktop.enableNeovim "${pkgs.neovim}/bin/nvim";
config.programs.neovim = mkIf config.desktop.enableNeovim {
enable = true;
viAlias = true;
vimAlias = true;
vimdiffAlias = true;
extraConfig = ''
luafile ${./luaconfig/settings.lua}
luafile ${./luaconfig/keybindings.lua}
luafile ${./luaconfig/lspconfig.lua}
'';
extraPackages = with pkgs; [
nixfmt
nil
ripgrep
entr
];
plugins = with pkgs.vimPlugins; [
# Theming
{
plugin = onenord-nvim;
type = "lua";
config = ''
require('onenord').setup()
'';
}
{
plugin = lualine-nvim;
type = "lua";
config = ''
require('lualine').setup()
'';
}
vim-devicons
# Utility plugins
{
plugin = nerdtree;
type = "lua";
config = ''
vim.g.NERDTreeShowHidden = 1
vim.keymap.set('n', '<C-t>', ':NERDTreeToggle<CR>', { desc = 'Toogle NERDTree pane' })
vim.keymap.set('n', '<C-s>', ':NERDTreeFind<CR>', { desc = 'Search file in NERDTree' })
vim.keymap.set('n', '<C-f>', ':NERDTreeFocus<CR>', { desc = 'Focus on the NERDTreePane' })
2024-04-11 20:15:47 +02:00
-- Keep the same NERDTree pane on each window
vim.api.nvim_create_autocmd("BufWinEnter", { pattern = "*", command = "if getcmdwintype() == \'\' | silent NERDTreeMirror | endif" })
'';
}
nerdtree-git-plugin
{
plugin = toggleterm-nvim;
type = "lua";
config = ''
require("toggleterm").setup{}
vim.keymap.set('n', 'tf', ':ToggleTerm direction=float<CR>', { desc = 'Open a new terminal in float buffer' })
vim.keymap.set('n', 'tt', ':ToggleTerm direction=tab<CR>', { desc = 'Open a new terminal in a new tab' })
vim.keymap.set('n', 'tv', ':ToggleTerm direction=vertical<CR>', { desc = 'Open in a vertical splitted buffer' })
vim.keymap.set('n', 'th', ':ToggleTerm<CR>', { desc = 'Open in a horizontal splitted buffer' })
'';
}
{
plugin = neogit;
type = "lua";
config = ''
require('neogit').setup {}
'';
}
{
plugin = gitsigns-nvim;
type = "lua";
config = ''
require('gitsigns').setup()
'';
}
vim-multiple-cursors
vim-sleuth
vim-commentary
{
plugin = telescope-nvim;
type = "lua";
config = ''
local telescope = require('telescope.builtin')
2024-04-11 20:15:47 +02:00
vim.keymap.set('n', 'ff', telescope.find_files, { desc = 'Search file with Telescope' })
vim.keymap.set('n', 'fg', telescope.live_grep, { desc = 'Live grep with Telescope'})
vim.keymap.set('n', 'fb', telescope.buffers, { desc = 'Search amongst current buffers (opened files)'})
vim.keymap.set('n', 'fh', telescope.help_tags, { desc = 'Search within nvim manual'})
vim.keymap.set('n', 'fs', telescope.lsp_workspace_symbols, { desc = 'Search symbol' })
'';
}
plenary-nvim
telescope-fzy-native-nvim
# Language support plugins
vim-nix
vim-nixhash
{
plugin = rust-vim;
type = "lua";
config = ''
vim.g.rustfmt_autosave = 1
'';
}
vim-markdown
markdown-preview-nvim
{
plugin = vimtex;
type = "viml";
config = ''
let g:vimtex_view_method = 'zathura'
let g:vimtex_compiler_method = 'tectonic'
2024-04-11 20:15:47 +02:00
let g:vimtex_compiler_tectonic = {
\'out_dir' : ' ',
\'hooks' : [],
\'options' : [
\ '--keep-logs',
\ '--synctex',
\ '-Zshell-escape',
\ '-Zshell-escape-cwd=$PWD'
\],
\}
'';
}
# Autocompletion and LSP server
nvim-lspconfig
nvim-cmp
cmp-path
cmp-cmdline
cmp-buffer
cmp-nvim-lsp
vim-vsnip
];
};
config.xdg.configFile.nvim = mkIf config.desktop.enableNeovim {
source = ./luaconfig;
recursive = true;
};
}