Skip to content

Commit 1e8d3cc

Browse files
authored
Merge pull request #34 from Freed-Wu/master
Fix #33
2 parents d7a86f1 + 2fc254b commit 1e8d3cc

File tree

2 files changed

+23
-24
lines changed

2 files changed

+23
-24
lines changed

autoload/nix.vim

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
function! nix#find_drv_position()
2+
let line = search("description")
3+
if line == 0
4+
let line = search("name")
5+
endif
6+
if line == 0
7+
echo "error: could not find derivation"
8+
return
9+
endif
10+
11+
return expand("%") . ":" . line
12+
endfunction
13+
14+
function! nix#edit(attr)
15+
let output = system("nix-instantiate --eval ./. -A " . a:attr . ".meta.position")
16+
if match(output, "^error:") == -1
17+
let position = split(split(output, '"')[0], ":")
18+
execute "edit " . position[0]
19+
execute position[1]
20+
" Update default command to nix-build.
21+
let b:dispatch = 'nix-build --no-out-link -A ' . a:attr
22+
endif
23+
endfunction

plugin/nix.vim

-24
Original file line numberDiff line numberDiff line change
@@ -1,25 +1 @@
1-
function! nix#find_drv_position()
2-
let line = search("description")
3-
if line == 0
4-
let line = search("name")
5-
endif
6-
if line == 0
7-
echo "error: could not find derivation"
8-
return
9-
endif
10-
11-
return expand("%") . ":" . line
12-
endfunction
13-
14-
function! nix#edit(attr)
15-
let output = system("nix-instantiate --eval ./. -A " . a:attr . ".meta.position")
16-
if match(output, "^error:") == -1
17-
let position = split(split(output, '"')[0], ":")
18-
execute "edit " . position[0]
19-
execute position[1]
20-
" Update default command to nix-build.
21-
let b:dispatch = 'nix-build --no-out-link -A ' . a:attr
22-
endif
23-
endfunction
24-
251
command! -bang -nargs=* NixEdit call nix#edit(<q-args>)

0 commit comments

Comments
 (0)