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

YCM/Tern does not pick up .tern-project correctly. #2822

Closed
dimhatz opened this issue Nov 8, 2017 · 2 comments
Closed

YCM/Tern does not pick up .tern-project correctly. #2822

dimhatz opened this issue Nov 8, 2017 · 2 comments

Comments

@dimhatz
Copy link

dimhatz commented Nov 8, 2017

Issue Prelude

[x] Tick to all the boxes

The issue itself

Hi guys! First of all big thanks for your code!

Here is the thing:
When creating/loading the a javascript file, YCM/Tern does not look for .tern-project in the current working dir, but in the initial dir (in which vim started). This is annoying when working with multiple projects that need different Tern configurations.

System: Windows 7 x64, GVIM 8.01272 x64 (tux), python 3.6 x64, YCM latest (fresh reinstall, just in case)
(Haven't tested on linux)

Steps to reproduce on Windows:

  1. Make sure gvim starts in a folder other than the javascript project's. (Right-click on gvim shortcut -> "Properties" -> "Start in:").

  2. Create a folder testproject and put a .tern-project file in it.

  3. From gvim :cd testproject and :e testfile.js (a new file). See the error message:

Warning: Unable to detect a .tern-project file in the hierarchy before C:\path\to\our\initial_folder and no global .tern-config file was found. This is required for accurate JavaScript completion. Please see the User Guide for details.

This error should not occur. YCM/tern tries to find .tern-project in our initial directory (the one gvim was started in - as seen from the error message), even though we :cd'd into another dir containing .tern-project file.

The error is sometimes swallowed by vim, but still present in YCM errlog. When this happens, I confirm that Tern could not locate the .tern-project file (by feeding a .tern-project with non-existing library on purpose, and checking for an error in Tern's log - normally it would be there).

Also found a workaround: :YcmResartServer after :cd'ing.

Attached are all the logs/info files as requested in the prelude.

Minimal _vimrc:

set nocompatible               " Be iMproved

if !has('nvim') && (has('win32') || has('win64'))
	set runtimepath=$HOME/.vim,$VIM/vimfiles,$VIMRUNTIME,$VIM/vimfiles/after,$HOME/.vim/after
	let g:plughome='~/.vim/plugged'
else
	let g:plughome='~/.vim/plugged'
endif

call plug#begin(g:plughome)
Plug 'Valloric/YouCompleteMe', {'commit': 'bade99f5e9c5ba2f848cffb2d1a905e85d3ddb05'}
call plug#end()

ycmd_50433_stdout_rj_qxqvq.log
ycmdebuginfo.txt
tern_50447_stdout_rcs9z95a.log
vim-version.txt
ycm_1c013g7g.log
ycmd_50433_stderr_4d6ezzd_.log
dot_tern-project.txt

@micbou
Copy link
Collaborator

micbou commented Dec 3, 2017

Thanks for the report. The documentation was mentioning the following:

Multiple Tern servers, are not supported. To switch to a different JavaScript project, you can do one of the following:

  • start a new instance of Vim from the new project's directory
  • change Vim's working directory (:cd /path/to/new/project) and restart the ycmd server (:YcmRestartServer)
  • change Vim's working directory (:cd /path/to/new/project), open a JavaScript file (or set filetype to JavaScript) and restart the Tern server using YCM completer subcommand :YcmCompleter RestartServer.

but the second method was not working. We fixed that in PR ycm-core/ycmd#875 as well as the issue you reported and updated the docs. Can you confirm it is now working as expected (after updating YCM)?

@dimhatz
Copy link
Author

dimhatz commented Dec 6, 2017

I confirm it now works exactly as expected (and described in docs), including searching the parent directories for .tern-project file and not being dependent on vim's initial starting dir.
Thank you very much for the fix!
Again, great job!

@dimhatz dimhatz closed this as completed Dec 6, 2017
@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 19, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants