-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvim.nix
153 lines (123 loc) · 4.07 KB
/
vim.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
{ config, pkgs, lib, ... }:
let myNeovim = (pkgs.neovim.override {
configure = {
inherit (config.vim) beforePlugins;
customRC = with lib;
(concatStringsSep
"\n"
(mapAttrsToList
(variable: value: "let g:${variable} = ${value}")
config.vim.variables))
+ "\n" + builtins.readFile ./dotfiles/vimrc.vim + config.vim.extraConfig;
vam = with pkgs; {
knownPlugins = let
releaseInfo = pluginName: builtins.fromJSON (builtins.readFile (./packages/vim-plugins + "/${pluginName}.json"));
vimPluginFromGit = pluginName: vimUtils.buildVimPluginFrom2Nix {
name = pluginName;
src = fetchgit {
inherit (releaseInfo pluginName) url rev sha256;
};
};
in vimPlugins // {
CamelCaseMotion = vimPluginFromGit "CamelCaseMotion";
deoplete-zsh = vimPluginFromGit "deoplete-zsh";
tmux-complete = vimPluginFromGit "tmux-complete";
};
pluginDictionaries = [
# UI
{ name = "undotree"; }
{ name = "gruvbox-community"; }
{ name = "gitgutter"; }
{ name = "lightline-vim"; }
{ name = "vim-dirvish"; }
# Motions
{ name = "CamelCaseMotion"; }
{ name = "surround"; }
{ name = "targets-vim"; }
# Frameworks
{ name = "deoplete-nvim"; }
{ name = "neosnippet"; }
{ name = "neosnippet-snippets"; }
{ name = "neoformat"; }
{ name = "ctrlp"; }
# Syntax generic completion for deoplete
{ name = "neco-syntax"; }
# Languages
{ name = "vim-polyglot"; }
{ name = "editorconfig-vim"; }
# Vim completion for deoplete
{ name = "neco-vim"; }
{ name = "deoplete-zsh"; }
{ name = "vim-pandoc"; }
{ name = "vim-pandoc-syntax"; }
# Languages (but not programming languages)
{ name = "vim-grammarous"; }
# Other
{ name = "tmux-complete"; }
{ name = "fugitive"; }
{ name = "rhubarb"; }
{ name = "repeat"; }
{ name = "vim-unimpaired"; }
{ name = "tabular"; }
{ name = "vimwiki"; }
{ name = "vim-abolish"; }
] ++ config.vim.extraPlugins;
};
};
});
in {
imports = [
./theme.nix
];
options.vim = with lib; {
variables = mkOption {
type = types.attrsOf types.str;
default = {
dominant_color = "'${config.theme.colors.dominant}'";
ripgrep_path = "'${pkgs.ripgrep}/bin/rg'";
fd_path = "'${pkgs.fd}/bin/fd'";
};
description = ''
Extra global variables to add at the beginning of the vim configuration.
Remember to escape strings with single-quotes.
'';
};
extraPlugins = mkOption {
type = types.listOf (types.attrsOf types.str);
default = [];
description = "Names of extra plugins to add";
};
extraRepoPlugins = mkOption {
type = types.listOf (types.attrsOf types.str);
default = [];
description = "Names of extra plugins to add that are present in the local repository";
};
beforePlugins = mkOption {
type = types.lines;
default = "";
description = "Extra lines to add in the vim configuration before loading plugins";
};
extraConfig = mkOption {
type = types.lines;
default = "";
description = "Extra lines to add at the end of the vim configuration";
};
};
config = {
nixpkgs.overlays = let
unstable = import <nixpkgs-unstable> {};
in [
(self: super: {
inherit (unstable) gnvim vimPlugins neovim;
})
];
environment.systemPackages = with pkgs; [
myNeovim
(neovim-qt.override { neovim = myNeovim; })
(gnvim.override { neovim = myNeovim; })
];
environment.sessionVariables = {
EDITOR = "nvim";
};
};
}