-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathneovim.nix
321 lines (273 loc) · 9.43 KB
/
neovim.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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
self: super:
let
startPlugins = with super.pkgs.vimPlugins; [
# echodoc-vim
# to install manually with coc.nvim:
# - coc-vimtex coc-snippets
# use coc-yank for yank history
coc-git
coc-nvim
# coc-translator # not available yet
csv-vim
# replaced by coc
fugitive
far-vim
# fails with python module. Run `pip install neovim` to fix. For more info, :he nvim-python"
# floobits-neovim
fzf-vim
# defined in overrides: TODO this should be easier: like fzf-vim should be enough
fzfWrapper
gruvbox
# neomake
# LanguageClient-neovim
tagbar
# targets-vim
# vCoolor-vim
vim-dirvish
vim-fugitive
vim-signature
vim-signify
vim-startify
vim-scriptease
vim-sneak
vim-grepper
vim-nix
vim-obsession
vim-rsi
vim-sayonara
# deoplete-khard
# TODO this one will be ok once we patch it
# vim-markdown-composer # WIP
vim-markdown-preview # WIP
vim-highlightedyank
vim-commentary
# vimwiki
# reuse once https://github.com/neovim/neovim/issues/9390 is fixed
# vimtex
ultisnips
unicode-vim
]
# ++ [
# deoplete-nvim
# deoplete-jedi # keeps crashing
# deoplete-zsh # not available just yet
# echodoc-vim
# ]
;
in
rec {
/* for compatibility with passing extraPythonPackages as a list; added 2018-07-11 */
compatFun = funOrList: (if builtins.isList funOrList then (_: funOrList) else funOrList);
# this generates a config appropriate to work with the passed derivations
# for instance to develop on a software from a nix-shell
genNeovim = drvs: userConfig:
with super;
let
# isHaskellPkg
# lib.debug.traceVal
requiredPythonModules = (super.python3Packages.requiredPythonModules drvs );
# Get list of required Python modules given a list of derivations.
# TODO look into compiler.shellFor { packages= } to see how to get deps
# from pkgs/development/haskell-modules/make-package-set.nix
# Returns a derivation whose environment contains a GHC with only
# the dependencies of packages listed in `packages`, not the
# packages themselves. Using nix-shell on this derivation will
# give you an environment suitable for developing the listed
# packages with an incremental tool like cabal-install.
requiredHaskellPackages = drvs: let
# modules = lib.filter (x: x.isHaskellLibrary or false) drvs;
# # TODO foireux
# in lib.unique (lib.concatLists (lib.catAttrs "requiredPythonModules" modules));
# haskellPackages = pkgs.callPackage makePackageSet {
# package-set = initialPackages;
# inherit stdenv haskellLib ghc buildHaskellPackages extensible-self all-cabal-hashes;
# };
selected = drvs haskellPackages;
packageInputs = map getBuildInputs selected;
in
# might be possible to further refine
packageInputs;
extraHaskellPackages = hs: with hs; [
# hie
all-hies.versions.ghc864
gutenhasktags
haskdogs # seems to build on hasktags/ recursively import things
hasktags
]
# ++ requiredHaskellPackages drvs
;
# Here we generate a neovim config that allows to work with the passed 'drvs'
# for instance adding the python propagatedBuildInputs if needed
# or haskell ones if it's a haskell project etc.
generatedConfig = {
extraPython3Packages = compatFun (requiredPythonModules);
# haskellPackages
# TODO do the same for ruby / haskell
}
# // lib.optionalAttrs (requiredHaskellPackages != []) {
# withHaskell = true;
# inherit extraHaskellPackages;
# }
;
# buildInputs = []
finalConfig = super.neovimConfig (
super.lib.mkMerge [
# project specific user config
userConfig
# my miniimal global config, when I am out of a nix-shell
# the plugins/environments I always want available
self.neovimDefaultConfig
# a config generated from the input 'drvs' with an appropriate development
# environment.
generatedConfig
]
);
in
wrapNeovim neovim-unwrapped-master {
# extraMakeWrapperArgs
# rename configure ?
# TODO should be able to add some packages in PATH like jq
structuredConfigure = finalConfig;
};
libvterm-neovim-master = super.libvterm-neovim.overrideAttrs(oa: {
src = super.fetchFromGitHub {
owner = "neovim";
repo = "libvterm";
rev = "4a5fa43e0dbc0db4fe67d40d788d60852864df9e";
sha256 = "0hkzqng3zs8hz327wdlhzshcg0qr31fhsbi9mvifkyly6c3y78cx";
};
});
neovim-unwrapped-master = (super.neovim-unwrapped.override({libvterm-neovim = libvterm-neovim-master;})).overrideAttrs (oldAttrs: {
name = "neovim";
version = "official-master";
src = builtins.fetchGit {
url = https://github.com/neovim/neovim.git;
# rev = "3e58e60568c2acc765f3ee72295e2f15baa3cf52";
# url = https://github.com/teto/neovim.git;
# ref = "master";
# rev = "";
# rev = "d81b510ecf1890828caa653ebb2fa053131f3265";
# checksum = "1prmibvr5v1cri71miy08qd1pvbnxmy04irnrxan2ynv95w0q0qm";
};
});
neovim-unwrapped-treesitter = (super.neovim-unwrapped).overrideAttrs (oldAttrs: {
name = "neovim";
version = "treesitter";
# see https://discourse.nixos.org/t/announcing-tree-sitter-nix/2483/10
# https://github.com/neovim/neovim/pull/10124
src = builtins.fetchGit {
url = https://github.com/teto/neovim.git;
ref = "treesitter";
};
});
# neovimHaskellConfig = {
# withHaskell = true;
# haskellPackages = [
# haskellPackages.haskdogs # seems to build on hasktags/ recursively import things
# haskellPackages.hasktags
# haskellPackages.nvim-hs
# haskellPackages.nvim-hs-ghcid
# ];
# customRC = ''
# let g:LanguageClient_serverCommands = {
# 'haskell': ['hie', '--lsp', '-d', '--logfile', '/tmp/lsp_haskell.log' ]
# }
# '';
# };
# TODO pass args to the wrapper to get access to :
# - bash-language-server
# - digestif ?
neovimDefaultConfig = {
withPython3 = true;
withPython = false;
# withHaskell = false;
withRuby = false; # for vim-rfc/GhDashboard etc.
withNodeJs = true; # used by coc.vim
# TODO use them only if
customRC = ''
" always see at least 10 lines
set scrolloff=10
set hidden
autocmd BufReadPost *.pdf silent %!${self.pkgs.xpdf}/bin/pdftotext -nopgbrk -layout -q -eol unix "%" - | fmt -w78
''
# if we support coc.nvim
# + ''
# let g:coc_node_path = '${self.pkgs.nodejs}/bin/node'
# ''
# LanguageClient support
# + ''
# " fnamemodify( g:python3_host_prog, ':p:h')
# let g:LanguageClient_serverCommands = {
# \ 'python': [ g:python3_host_prog, '-mpyls', '-vv', '--log-file' , '/tmp/lsp_python.log']
# \ , 'haskell': ['hie-wrapper', '--lsp', '-d', '--vomit', '--logfile', '/tmp/lsp_haskell.log' ]
# \ , 'cpp': ['${super.pkgs.cquery}/bin/cquery', '--log-file=/tmp/cq.log']
# \ , 'c': ['${super.pkgs.cquery}/bin/cquery', '--log-file=/tmp/cq.log']
# \ , 'nix': ['nix-lsp']
# \ }
# ''
# # neomake support
# + ''
# let g:neomake_python_mypy_exe = fnamemodify( g:python3_host_prog, ':p:h').'/mypy'
# ''
;
# TODO provide an upper level
configure = {
packages.myVimPackage = {
# see examples below how to use custom packages
# loaded on launch
start = startPlugins;
# manually loadable by calling `:packadd $plugin-name`
opt = [ ];
};
};
plugins = startPlugins;
pluginsExperimental = {
vim-obsession = {
customRC = ''This is a test'';
};
};
extraPython3Packages = ps: with ps; [
pandas
jedi
urllib3
# pygments # for pygmentize and minted in latex
mypy
# generates https://github.com/tomv564/pyls-mypy/issues/22
pyls-mypy # can't find imports :s
python-language-server
pycodestyle
]
# ++ lib.optionals ( pkgs ? pyls-mypy) [ pyls-mypy ]
;
};
# TODO do a version with clang
neovim-dev = (super.pkgs.neovim-unwrapped.override {
# name = "neovim-test";
doCheck=true;
}).overrideAttrs(oa:{
cmakeBuildType="debug";
# -DMN_LOG_LEVEL
nativeBuildInputs = oa.nativeBuildInputs ++ [ self.pkgs.valgrind ];
shellHook = ''
export NVIM_PYTHON_LOG_LEVEL=DEBUG
export NVIM_LOG_FILE=/tmp/log
# export NVIM_PYTHON_LOG_FILE=/tmp/log
export VALGRIND_LOG="$PWD/valgrind.log"
echo "To run tests:"
echo "VALGRIND=1 TEST_FILE=test/functional/core/job_spec.lua TEST_TAG=env make functionaltest"
'';
});
neovim-dev-clang = (self.neovim-dev.override {
stdenv = super.clangStdenv;
}).overrideAttrs(oa:{
shellHook = oa.shellHook + ''
export CLANG_SANITIZER=ASAN_UBSAN
'';
});
# neovim-unwrapped-local = super.pkgs.neovim-unwrapped.overrideAttrs (oldAttrs: {
# name = "neovim-unwrapped-local";
# src = super.lib.cleanSource ~/neovim;
# cmakeBuildType="debug";
# meta.priority=0;
# });
}