From ef14fdab716dee86ab1a80429377835357132656 Mon Sep 17 00:00:00 2001 From: idearat Date: Fri, 21 Mar 2014 14:20:41 -0600 Subject: [PATCH 1/2] Fallback to using normal gf to leverage user's path/suffixadds. --- autoload/node.vim | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/autoload/node.vim b/autoload/node.vim index 287344c..701664b 100644 --- a/autoload/node.vim +++ b/autoload/node.vim @@ -53,10 +53,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, ...) From 10cb4c088377c212141122d10ed241b1ca4b3cba Mon Sep 17 00:00:00 2001 From: idearat Date: Fri, 21 Mar 2014 14:21:00 -0600 Subject: [PATCH 2/2] Don't force a mapping, export commands the user can map. --- autoload/node.vim | 28 +++++++++------------------- plugin/node.vim | 1 + 2 files changed, 10 insertions(+), 19 deletions(-) diff --git a/autoload/node.vim b/autoload/node.vim index 701664b..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, ...) 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