Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Detect Node project on VimEnter.

  • Loading branch information...
commit b54af09795282ff688d35a97084a0afd24ad37a9 1 parent 122fcdf
@moll authored
View
1  CHANGELOG.md
@@ -4,6 +4,7 @@
- Adds `:Nopen` command which behaves like `:Nedit`, but also `:lcd`s to the module's directory.
- Makes `<Plug>NodeGotoFile` available for your mapping in any Node project file, but maps it to `gf` automatically only on JavaScript files.
- Maps `gf` also for JSON files for easy jumping to modules.
+- Makes `:Nedit` and `:Nopen` available immediately when starting Vim in a directory of a Node project.
## 0.5.1 (Aug 8, 2013)
- Adds `Node` autocommand.
View
1  plugin/node.vim
@@ -19,5 +19,6 @@ endfunction
augroup Node
au!
+ au VimEnter * if empty(expand("<amatch>")) | call s:detect(getcwd()) | endif
au BufRead,BufNewFile * call s:detect(expand("<amatch>:p"))
augroup end
View
4 test/helper.rb
@@ -11,8 +11,8 @@
rescue LoadError
end
-vimrc = File.expand_path("../vimrc", __FILE__)
-$vim = Vimrunner::Server.new(:vimrc => vimrc).start
+$vimrc = File.expand_path("../vimrc", __FILE__)
+$vim = Vimrunner::Server.new(:vimrc => $vimrc).start
Minitest::Unit.after_tests { $vim.kill }
module WithTemporaryDirectory
View
13 test/plugin_test.rb
@@ -68,5 +68,18 @@
$vim.edit File.join(nested, "index_test.js")
$vim.echo("b:node_root").must_equal nested
end
+
+ it "must detect directory as Node's when opening Vim" do
+ begin
+ Dir.chdir @dir
+ FileUtils.touch File.join(@dir, "package.json")
+
+ vim = Vimrunner::Server.new(:vimrc => $vimrc).start
+ vim.command("pwd").must_equal @dir
+ vim.echo("b:node_root").must_equal @dir
+ ensure
+ vim.kill if vim
+ end
+ end
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.