-
-
Notifications
You must be signed in to change notification settings - Fork 59
Add require() helper #4
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
Conversation
This code maps the commands :Require and :Unrequire to help with managing require() statements in Node.js code. Commands :R and :UR are also created if they don't already exist.
Hello, James! First off, thank you immensely for sharing your code with everyone! It looks like a useful refactoring tool for sure! I haven't, however, entirely decided which way Node.vim itself should go — what should it have in the core and what integration work should it do given other plugins. Refactoring tools are pretty large area themselves and they're often pretty subjective. I think we both wouldn't want things to turn into too bloated kitchen sinks. What would you say if we'd set Node.vim to also be an API into which you could call for common functionality? Functionality such as having Let me know what you think of that and what API functions would you need. Two small things I spotted scrolling down the code:
Oh, and one other thing regardless of how we proceed: Also, because we're writing software used by other people, any regression or recurring bug shows disrespect and sloppiness. I'll write a post about testing VimL and plugins in the near future, but till then you could check out Node.vim's tests as an example. As a general practice, writing your tests first helps you make sure every branch of your code is covered. |
Andri, thank you for your tactful and well-written feedback. I agree on all points raised. It looks like the only things I am using from your code are the list of core modules and It doesn't seem like there is a standard way of managing dependencies among vim plugins though - would we just tell users to install Node.vim, and pick from the list of available plugins? I have very little experience with writing tests. I'll try to figure it out when I have time. I write VBA for my day job, so I'm up for the occasional masochistic challenge, and Vimscript is refreshing by comparison. |
So, let's do it. I'm not sure about those other Vim plugin managers — maybe one of them does support dependencies. But I guess just saying so for starters would do the trick. I can add a link to your plugin in the README, too. |
I'm closing this pull request - I've submitted another one (#5) that has the changes I need to publish my plugin. I looked at the Node.vim tests and could not figure out how to make them work, due to my lack of Ruby experience. Let me know when you write that post and I will give it another shot. |
Node.js
require()
helperThis code maps the commands
:Require
and:Unrequire
to help with managingrequire()
statements in Node.js code. Commands:R
and:UR
are also created if they don't already exist.A brief usage example, starting in a blank node.js file:
Run these vim commands:
The file will go through these states:
Improvements
This has been very useful to me so far, but it's my first piece of serious vimscript, so changes and improvements welcome!