Skip to content

Instantly share code, notes, and snippets.

@xebecnan
Last active October 25, 2016 03:16
Show Gist options
  • Save xebecnan/de4ea2bdc531e1e443f267f1bfcaec8f to your computer and use it in GitHub Desktop.
Save xebecnan/de4ea2bdc531e1e443f267f1bfcaec8f to your computer and use it in GitHub Desktop.
lua require jumper
"LUA REQUIRE JUMPER {
function! JumpRequire()
let kws = ["require", "g_class", "show_ui", "notify_ui", "hide_ui", "get_ui", "call_ui"]
let prefix="\\(\\<" . join(kws, "\\>\\|\\<") . "\\>\\)"
let line=getline('.')
if line =~ prefix . "\\s*(\\?\\s*['\"][^'\"]\\+['\"]"
let path = substitute(line, "^.*" . prefix . "\\s*(\\?\\s*['\"]\\([^'\"]\\+\\)['\"].*$", '\2', 'g')
let target = substitute(path, '\.', '/', 'g') . '.lua'
if &mod['ified']
execute "vs " . target
else
execute "e " . target
end
else
echo "bad line"
endif
endfunction
nmap <C-j> :call JumpRequire()<CR>
"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment