Dotfiles.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

26 lines
684 B

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
command! -bang -nargs=* NixEdit call nix#edit(<q-args>)