Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Call node file detection less often (fix #37) #38

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

mMontu
Copy link

@mMontu mMontu commented Nov 1, 2016

The expression used for 'includeexpr' (which is triggerd by [+I or insertion completion, as specified by default in 'complete') fails if b:node_root is undefined.

The b:node_root variable is created by the node#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 as require) 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 that s: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?

@mMontu mMontu changed the title Call node file detection less times (fix #37) Call node file detection less often (fix #37) Nov 1, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant