Skip to content

Commit

Permalink
add NixEdit command to naviage nixpkgs by attribute name
Browse files Browse the repository at this point in the history
  • Loading branch information
LnL7 committed Aug 18, 2018
1 parent ec65cf2 commit 9b2e5c5
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions plugin/nix.vim
Original file line number Diff line number Diff line change
@@ -0,0 +1,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]
endif
endfunction

command! -bang -nargs=* NixEdit call nix#edit(<q-args>)

0 comments on commit 9b2e5c5

Please sign in to comment.