system/nix/progs/nvim/default.nix

87 lines
2.3 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
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
];
# Additional language servers that we should install mannually
lspPackages = with pkgs; [
rnix-lsp
];
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;
# I get an error if I try copying lua script to lua folder
# TODO: think about this solution
luaConfig = builtins.readFile ./config.lua;
in
{
options.progs.nvim = {
enable = mkOption {
type = types.bool;
default = false;
description = "Add and configure exa, a modern replacement for ls";
};
default = mkOption {
type = types.bool;
default = false;
description = "Set neovim as default editor";
};
};
config = mkIf cfg.enable {
home.packages = lspPackages;
programs.neovim = {
enable = true;
extraConfig = vimConfig;
plugins = myVimPlugins;
viAlias = true;
vimAlias = true;
};
xdg.configFile = {
"nvim/coc-settings.json".text = cocSettings;
};
# home.sessionVariables = mkIf cfg.default {
# EDITOR = bin;
# };
# programs.zsh.shellAliases = mkIf config.shell.zsh.enable {
# vi = bin;
# vim = bin;
# };
};
}