forked from LnL7/vim-nix
-
Notifications
You must be signed in to change notification settings - Fork 0
/
nix.vim
23 lines (21 loc) · 627 Bytes
/
nix.vim
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
function! nix#find_drv_position()
let line = search("description")
if line == 0
let line = search("name")
endif
if line == 0
echo "error: could not find derivation"
return
endif
return expand("%") . ":" . line
endfunction
function! nix#edit(attr)
let output = system("nix-instantiate --eval ./. -A " . a:attr . ".meta.position")
if match(output, "^error:") == -1
let position = split(split(output, '"')[0], ":")
execute "edit " . position[0]
execute position[1]
" Update default command to nix-build.
let b:dispatch = 'nix-build --no-out-link -A ' . a:attr
endif
endfunction