system/nix/progs/nvim/default.nix

83 lines
2.1 KiB
Nix
Raw Normal View History

2022-06-23 10:45:58 +03:00
{ 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-tsserver # typescript LSP
coc-eslint # eslint LSP
coc-rust-analyzer # rust LSP
2022-06-23 10:45:58 +03:00
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
2022-06-23 14:49:13 +03:00
vim-gitgutter # shows git diff markers in the sign column
2022-06-23 10:45:58 +03:00
nerdtree # tree explorer
nerdtree-git-plugin # shows files git status on the NerdTree
neoformat # formating code
nvim-treesitter # treesitter configurations and abstraction layer
2022-06-23 23:04:59 +03:00
fzf-vim # fuzzy finder
2022-07-14 12:00:17 +03:00
blamer-nvim # A git blame plugin
2022-06-23 10:45:58 +03:00
];
# Additional language servers that we should install mannually
2022-06-23 23:04:59 +03:00
lspPackages = with pkgs; [ rnix-lsp ];
# Additional tools
toolsPackages = with pkgs; [
fzf ripgrep # required for `fzf-vim` plugin
2022-06-23 10:45:58 +03:00
];
2022-06-23 23:04:59 +03:00
additionalPackages = lspPackages ++ toolsPackages;
2022-06-23 10:45:58 +03:00
vimConfig = builtins.readFile ./config.vim;
2022-06-23 10:45:58 +03:00
in
{
options.progs.nvim = {
enable = mkOption {
type = types.bool;
default = false;
2022-06-23 23:04:59 +03:00
description = "Add and configure neovim";
2022-06-23 10:45:58 +03:00
};
default = mkOption {
type = types.bool;
default = false;
description = "Set neovim as default editor";
};
};
config = mkIf cfg.enable {
2022-06-23 23:04:59 +03:00
home.packages = additionalPackages;
2022-06-23 10:45:58 +03:00
programs.neovim = {
enable = true;
extraConfig = vimConfig;
plugins = myVimPlugins;
viAlias = true;
vimAlias = true;
coc = {
enable = true;
settings = ./coc_settings.nix;
};
2022-06-23 10:45:58 +03:00
};
xdg.configFile = {
"nvim/lua".source = ./lua;
2022-06-23 10:45:58 +03:00
};
2022-06-23 23:04:59 +03:00
home.sessionVariables = mkIf cfg.default {
EDITOR = "${pkgs.neovim}/bin/nvim";
};
2022-06-23 10:45:58 +03:00
};
}