Skip to content

Instantly share code, notes, and snippets.

@xebecnan
Created January 6, 2016 03:20
Show Gist options
  • Save xebecnan/3483042280650f5a4755 to your computer and use it in GitHub Desktop.
Save xebecnan/3483042280650f5a4755 to your computer and use it in GitHub Desktop.
"LUA REQUIRE JUMPER {
function! JumpRequire()
let line=getline('.')
if line =~ "\\<require\\>\\s*(\\?\\s*['\"][^'\"]\\+['\"]\\s*)\\?\\s*$"
let path = substitute(line, "^.*\\<require\\>\\s*(\\?\\s*['\"]\\([^'\"]\\+\\)['\"]\\s*)\\?\\s*$", '\1', '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