moll / vim-node

Tools and environment to make Vim superb for developing with Node.js. Like Rails.vim for Node.
http://www.vim.org/scripts/script.php?script_id=4674
Other
807 stars 59 forks source link

Improve s:resolve to also look in parent directories #48

Open cwis-public opened 5 years ago

cwis-public commented 5 years ago

Hi there,

I have recently switched one of my Node package to a “monorepo” structure, and noticed “gf” stopped working when trying to open modules contained within the monorepo.

Turned out, s:resolve wasn't exactly working like require(): in Node.JS, if some package isn't found at a point in path, Node will try all the parent folders, one by one: https://nodejs.org/api/modules.html#modules_loading_from_node_modules_folders

This PR changes s:resolve to mimic how Node.JS works, and also adds a test for this case.

Thanks for your hard work!

Cheers, cwis