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

let g:rooter_change_directory_for_non_project_files = 'current' doesn't work when you have a package.json at ~ #125

Open
Lazerbeak12345 opened this issue Jan 18, 2022 · 3 comments

Comments

@Lazerbeak12345
Copy link

For some reason this has recently been behaving (seemingly) identical to the 'home' value in non-project files.

Neovim version: NVIM v0.7.0-dev+890-g574a58220

Simplest nvim/init.vim: (I didn't actually test this example, but I took out things I knew would effect it, so this should recreate it)

call plug#begin()
Plug 'airblade/vim-rooter'
call plug#end()
let g:rooter_change_directory_for_non_project_files = 'current'

to recreate

Opening a .git project still works as expected (the directory of that project is printed, and running :cd confirms.)

Open a folder that rooter would not call a project. Your home directory will be printed, and the output of :cd will also agree that it's in your home directory.

@airblade
Copy link
Owner

I can't reproduce this.

Perhaps your home directory is a "root"? I.e. does your home folder contain any of these?

.git, _darcs, .hg, .bzr, .svn, Makefile

If not, I can only suggest adding a few echom statements to the s:rootless() function to figure out what is going on.

@Lazerbeak12345
Copy link
Author

Lazerbeak12345 commented Jan 20, 2022

Ok so I figured it out.

I had a package.json in my home directory. This happens all the time when someone does npm i <package name> outside of a project, as this installs the package at a user-level scope. This is intentional behavior of npm, and very frequently used in guides for popular JavaScript libraries.

I'll leave this issue open in case you want to add a special-case for this, a change to the default settings, and/or something in the readme.

@Lazerbeak12345 Lazerbeak12345 changed the title bug with let g:rooter_change_directory_for_non_project_files = 'current' let g:rooter_change_directory_for_non_project_files = 'current' doesn't work when you have a package.json at ~ Jan 20, 2022
@airblade
Copy link
Owner

Good to hear you solved the problem.

The most recent commit (0415be8) added package.json to the README, after the previous commit introduced it (see #123).

In retrospect adding package.json as a default pattern caused more trouble than I expected (I rarely use npm so didn't have a view on it either way). However now it's there I don't want to remove it unless it becomes a big problem – it's annoying when there's churn in the defaults.

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

No branches or pull requests

2 participants