system/nix/progs/nvim/default.nix

85 lines
2.4 KiB
Nix

{ lib, config, pkgs, ... }:
with lib;
let
cfg = config.progs.nvim;
customPlugins = pkgs.callPackage ./custom_plugins.nix {
inherit (pkgs.vimUtils) buildVimPlugin;
};
plugins = pkgs.vimPlugins // customPlugins;
myVimPlugins = with plugins; [
coc-nvim # LSP client + autocompletion plugin
coc-tsserver # typescript LSP
coc-eslint # eslint LSP
coc-rust-analyzer # rust LSP
editorconfig-vim # use project .editorconfig to configure editor
lightline-vim # configurable status line
material-vim # modern theme with true colors support
vim-nix # nix support
vim-easymotion # highlights keys to move quickly
vim-gitgutter # shows git diff markers in the sign column
nerdtree # tree explorer
nerdtree-git-plugin # shows files git status on the NerdTree
neoformat # formating code
nvim-treesitter # treesitter configurations and abstraction layer
fzf-vim # fuzzy finder
blamer-nvim # A git blame plugin
];
# Additional language servers that we should install mannually
lspPackages = with pkgs; [ rnix-lsp ];
# Additional tools
toolsPackages = with pkgs; [
fzf ripgrep # required for `fzf-vim` plugin
];
additionalPackages = lspPackages ++ toolsPackages;
baseConfig = builtins.readFile ./config.vim;
pluginsConfig = builtins.readFile ./plugins.vim;
cocConfig = builtins.readFile ./coc.vim;
cocSettings = builtins.toJSON (import ./coc_settings.nix);
vimConfig = baseConfig + pluginsConfig + cocConfig;
in
{
options.progs.nvim = {
enable = mkOption {
type = types.bool;
default = false;
description = "Add and configure neovim";
};
default = mkOption {
type = types.bool;
default = false;
description = "Set neovim as default editor";
};
};
config = mkIf cfg.enable {
home.packages = additionalPackages;
programs.neovim = {
enable = true;
extraConfig = vimConfig;
plugins = myVimPlugins;
viAlias = true;
vimAlias = true;
};
xdg.configFile = {
"nvim/lua".source = ./lua;
"nvim/coc-settings.json".text = cocSettings;
};
home.sessionVariables = mkIf cfg.default {
EDITOR = "${pkgs.neovim}/bin/nvim";
};
};
}