Last active
October 25, 2016 03:16
-
-
Save xebecnan/de4ea2bdc531e1e443f267f1bfcaec8f to your computer and use it in GitHub Desktop.
lua require jumper
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"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