You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
vim plugin not working with option set autochdir or when launching vim in a subfolder #1085
I'm using neovim and I have in my init.vim the line set autochdir , and it seems to not play nice with phpactor
is it possible for phpactor to try to find in the parent folders if there's a .git folder or composer file in order to choose the root of the project (like many other command line utilities do ) ?
@dantleech thanks for the quick answer, as I'm not familiar with anonymous function in vimscript, do you have a quick example of a dirty workaround that would just return always the same root path ?
@dantleech restarting is not needed. The function is executed each time we call to RPC. @allan-simon do you have the version that uses let g:PhpactorRootDirectoryStrategy? :Phpactorstatus or :checkhealth should print both the version and the working directory.
Version: 111c3e6 (4 days ago) 0.16.1-1083
Filesystems: simple
Working directory: /vagrant/src
I've tripled-checked , I have only g:PhpactorRootDirectoryStrategy defined
Here's my init.vim
setmouse=a" workaround https://github.com/neovim/neovim/issues/6041setguicursor="settabstop=4setsofttabstop=4setshiftwidth=4setsmarttabsetexpandtabsetsmartindentsetwildmode=longest,full
setautochdirsetshowcmdcolorscheme torte
"the status bar is always displayedsetlaststatus=2ifhas("statusline")
setstatusline=%<%f%h%m%r%=%l,%c\ %Pelseifhas("cmdline_info")
setruler" display cursor positionendif" Specify a directory for plugins" - For Neovim: ~/.local/share/nvim/plugged" - Avoid using standard Vim directory names like 'plugin'callplug#begin('~/.local/share/nvim/plugged')
" for autocompletion
Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' }
" for fuzzy completion
Plug 'Shougo/denite.nvim'
Plug 'Shougo/echodoc.vim'" to display in red extra whitespaces
Plug 'ntpeters/vim-better-whitespace'
Plug 'benekastah/neomake'
Plug 'evidens/vim-twig'
Plug 'phpactor/phpactor', {'for': 'php', 'branch': 'master', 'do': 'composer install --no-dev -o'}
Plug 'kristijanhusak/deoplete-phpactor'" Initialize plugin systemcallplug#end()
" for language server" used by deopletecalldeoplete#custom#option('ignore_sources', {'php': ['omni']})
letg:PhpactorRootDirectoryStrategy= {-> '/vagrant' }
OK, I reproduced this behaviour on Vim (as opposed to nvim). It seems that calling to RPC behaves with a correctly selected working directory, but we have a bug in status reporting. For test, please display the result of the function directly used for RPC call:
Version: 3324205 (12 days ago) Do-not-overwrite-stub_paths-config-if-key-exists-1122
Filesystems: simple
Working directory: /vagrant/src/Command
Config files (missing is not bad):
✘ /home/vagrant/.config/phpactor/phpactor.json
✘ /home/vagrant/.config/phpactor/phpactor.yml
✘ /vagrant/src/Command/.phpactor.json
✘ /vagrant/src/Command/.phpactor.yml
Diagnostics:
✔ XDebug is disabled. XDebug has a negative effect on performance.
✘ Composer not found - some functionality will not be available (e.g. class creation) and class location will fallback to scanning the filesystem if index not enabled - this can be slow. Make sure you've run `
composer install` in your project!
✘ Git not detected. Some operations which would have been better scoped to your project repository will now include vendor paths.
[Process exited 0]
(when I run PhpactorStatus , with or without putting let g:PhpactorRootDirectoryStrategy = {-> '/vagrant' } at the end of my init.vim )
However phpactor seems to work with Coc.vim as i have autocompletion working
OK, I just realized that I forgot to pass the working directory when calling the status command ><
Will try to fix that soon, but it should also only mean that the Working directory information is invalid in the result of this command.
However phpactor seems to work with Coc.vim as i have autocompletion working
The LSP client is responsible for provided the project root, CoC in your case, so it should indeed works without issue in this case.
I tested locally by starting vim from a sub-directory, the Working directory has the right value.
Then I realized we didn't used it when looking for possible config files at the root of the project, so I fixed that too.
But I don't know what else to test, you said that the status was not working properly (and you were right) but I don't think it should prevent phpactor to work with RPC.
Activity
dantleech commentedon Jul 7, 2020
Phpactor doesn't support this directly but you can provide an anonymous function to detect the project root by
g:PhpactorRootDirectoryStrategy(:help phpactoror https://phpactor.readthedocs.io/en/develop/vim-plugin/man.html).Maybe @przepompownia or @elythyr can recommend a way to use this in conjunction with a root-detection strategy/plugin?
allan-simon commentedon Jul 7, 2020
@dantleech thanks for the quick answer, as I'm not familiar with anonymous function in vimscript, do you have a quick example of a dirty workaround that would just return always the same root path ?
dantleech commentedon Jul 7, 2020
Me neither in complete honesty,
:help FuncrefI assume something like
g:PhpactorRootDirectoryStrategy = function () { return getcwd() }for example.allan-simon commentedon Jul 7, 2020
ok thanks, I've seen the "expr-lambda" help but adding in my init.vim
does not seem to work
:Phpactorstatusstill return the same working directory :(dantleech commentedon Jul 7, 2020
You'd need to restart VIM of course ?
allan-simon commentedon Jul 7, 2020
haha, I did :) but still does not seem to works
przepompownia commentedon Jul 7, 2020
@dantleech restarting is not needed. The function is executed each time we call to RPC. @allan-simon do you have the version that uses
let g:PhpactorRootDirectoryStrategy?:Phpactorstatusor:checkhealthshould print both the version and the working directory.przepompownia commentedon Jul 7, 2020
One detail: if you have set the buffer equivalent (
b:PhpactorRootDirectoryStrategy) then it takes precedence over the global.I noticed that we have this possibility undocumented.
Phpactor does not set this buffer variable itself.
allan-simon commentedon Jul 7, 2020
I've tripled-checked , I have only
g:PhpactorRootDirectoryStrategydefinedHere's my init.vim
przepompownia commentedon Jul 7, 2020
One low-level test (maybe to include in
checkhealthin another form):allan-simon commentedon Jul 7, 2020
I got
the type should be 2, is 2przepompownia commentedon Jul 7, 2020
OK, I reproduced this behaviour on Vim (as opposed to nvim). It seems that calling to RPC behaves with a correctly selected working directory, but we have a bug in status reporting. For test, please display the result of the function directly used for RPC call:
przepompownia commentedon Jul 7, 2020
@dantleech is possible that the directories: this given by
--working-dirand this resolved by'%project_root%'can differ?przepompownia commentedon Jul 7, 2020
But why would it depend on the caller...
I echoed (on Vim) the final command used to RPC call and it have the directory chosen by the strategy.
allan-simon commentedon Jul 7, 2020
->
i.e it displays (correctly?) the value defined there
(I've tried changing the value to be 100% sure)
dantleech commentedon Jul 7, 2020
yes when using the language server (language client has authority), no otherwise.
przepompownia commentedon Jul 7, 2020
phpactor#Status()executesphpactor statuswithout--working-dir. The fallback presentation methodworks correctly but usually (no
:terminalsupport) is not reached.dantleech commentedon Jul 7, 2020
ah, yeah, i think we should revert that fix
camilledejoye commentedon Nov 1, 2020
That was fixed since, @allan-simon can you confirm ?
Otherwise we can close.
allan-simon commentedon Nov 15, 2020
I will double check that .
allan-simon commentedon Nov 15, 2020
(when I run PhpactorStatus , with or without putting
let g:PhpactorRootDirectoryStrategy = {-> '/vagrant' }at the end of my init.vim )However phpactor seems to work with Coc.vim as i have autocompletion working
camilledejoye commentedon Nov 15, 2020
OK, I just realized that I forgot to pass the working directory when calling the status command ><
Will try to fix that soon, but it should also only mean that the
Working directoryinformation is invalid in the result of this command.camilledejoye commentedon Nov 15, 2020
#1127
I tested locally by starting vim from a sub-directory, the
Working directoryhas the right value.Then I realized we didn't used it when looking for possible config files at the root of the project, so I fixed that too.
But I don't know what else to test, you said that the
statuswas not working properly (and you were right) but I don't think it should prevent phpactor to work with RPC.I hope I did it right this time 😄
allan-simon commentedon Nov 15, 2020
ok make sense ^^ , thanks for your hardwork
Fix/#1085 status does not use correct working directory (#1127)
Fix/#1085 status does not use correct working directory (#1127)
Master 17 (#1203)