Skip to content

Instantly share code, notes, and snippets.

@spig
Created February 22, 2017 07:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save spig/87aa45af3e28d610ec7dbb1675554b2a to your computer and use it in GitHub Desktop.
Save spig/87aa45af3e28d610ec7dbb1675554b2a to your computer and use it in GitHub Desktop.
go to module/declare with vim
function! GetXqueryNamespace()
normal! yiw
return split(split(@", ":")[0], '\$')[0]
endfunction
function! GetXqueryDeclare()
normal! yiw
return split(@", ":")[1]
endfunction
function! GetXqueryModuleAt()
"execute '/at\s\+"'
execute "normal! /at\\s\\+\"\<cr>"
normal! y$
let eol = split(@", '"')[1]
return eol
endfunction
function! GotoXqueryModule()
let namespace = GetXqueryNamespace()
let declare = GetXqueryDeclare()
execute '/import\s\+module\s\+namespace\s\+' . namespace . '\s\+'
let at = GetXqueryModuleAt()
" if at starts with '/' then add '.' and attempt to open the file
if filereadable(at)
echom "if, edit " . at
execute "edit " . at
execute "normal! /" . declare . "\<cr>"
elseif filereadable('.' . at)
echom "else if, edit ." . at
execute "edit ." . at
execute "normal! /" . declare . "\<cr>"
else
echom "unable to edit " . at
endif
return 0
endfunction
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment