Call node file detection less often (fix #37) #38
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The expression used for
'includeexpr'
(which is triggerd by [+I or insertion completion, as specified by default in 'complete') fails ifb:node_root
is undefined.The
b:node_root
variable is created by thenode#initialize()
, which is called from s:detect() when it detects that the file is part of Node.js project.A possible solution is to avoid change anything (as the
'includeexpr'
option) if a file isn't detected as node file. Maybe it is also possible to improve the detection by searching the buffer for some node specific keywords (such asrequire
) and setting the b:node_root to the env variable$NODE_PATH
instead of leaving it undefined.In any case, I didn't understood the need for all the autocmds in the end of the
plugin/node.vim
, and while debugging the E121 error I noticed thats:detect()
is called for every buffer opened, including the help files, which causes unnecessary overhead. I've implemented a simpler solution, but it is possible it missed some corner case.I intended to run the automated tests, but I'm not familiar with ruby. Did you have the chance to write the post explaining the tests which is mentioned in #4?