diff --git a/autoload/node.vim b/autoload/node.vim index 287344c..19a59bc 100644 --- a/autoload/node.vim +++ b/autoload/node.vim @@ -3,25 +3,24 @@ let node#filetypes = ["javascript", "json"] function! node#initialize(root) let b:node_root = a:root - call s:initializeCommands() if index(g:node#filetypes, &ft) > -1 | call s:initializeJavaScript() | en silent doautocmd User Node endfunction -function! s:initializeCommands() +function! node#initializeCommands() command! -bar -bang -nargs=1 -buffer -complete=customlist,s:complete Nedit \ exe s:nedit(, bufname("%"), "edit") command! -bar -bang -nargs=1 -buffer -complete=customlist,s:complete Nopen \ exe s:nopen(, bufname("%"), "edit") - nnoremap NodeGotoFile - \ :call edit(expand(""), bufname("%")) - nnoremap NodeSplitGotoFile - \ :call edit(expand(""), bufname("%"), "split") - nnoremap NodeVSplitGotoFile - \ :call edit(expand(""), bufname("%"), "vsplit") - nnoremap NodeTabGotoFile - \ :call edit(expand(""), bufname("%"), "tab split") + command! -nargs=0 -complete=customlist,s:complete NodeGotoFile + \ :call edit(expand(""), bufname("%")) + command! -nargs=0 -complete=customlist,s:complete NodeSplitGotoFile + \ :call edit(expand(""), bufname("%"), "split") + command! -nargs=0 -complete=customlist,s:complete NodeVSplitGotoFile + \ :call edit(expand(""), bufname("%"), "vsplit") + command! -nargs=0 -complete=customlist,s:complete NodeTabGotoFile + \ :call edit(expand(""), bufname("%"), "tab split") endfunction function! s:initializeJavaScript() @@ -29,15 +28,6 @@ function! s:initializeJavaScript() let &l:suffixesadd .= "," . join(g:node#suffixesadd, ",") let &l:include = '\NodeGotoFile") - " Split gotofiles don't take a count for the new window's width, but for - " opening the nth file. Though Node.vim doesn't support counts atm. - nmap gf NodeGotoFile - nmap f NodeSplitGotoFile - nmap NodeSplitGotoFile - nmap gf NodeTabGotoFile - endif endfunction function! s:edit(name, from, ...) @@ -53,10 +43,10 @@ function! s:edit(name, from, ...) end if empty(path) - return s:error("E447: Can't find file \"" . a:name . "\" in path") + normal gf + else + exe command . " " . fnameescape(path) endif - - exe command . " " . fnameescape(path) endfunction function! s:nedit(name, from, ...) diff --git a/plugin/node.vim b/plugin/node.vim index ad07e5f..5c52ced 100644 --- a/plugin/node.vim +++ b/plugin/node.vim @@ -10,6 +10,7 @@ function! s:detect(path) let is_node = is_node || filereadable(path . "/package.json") let is_node = is_node || isdirectory(path . "/node_modules") if is_node | return node#initialize(path) | endif + call node#initializeCommands() let parent = fnamemodify(path, ":h") if parent == path | return | endif