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
:PhpactorImportClass not finding class , though autocompletion shows the FQDN #1128
So the first thing to understand is that there is two different protocols: LSP and RPC
LSP is used by CoC: CoC is the client and phpactor is the server
RPC is used by our custom vim plugin
When you call the command PhpactorImportClass you're using RPC, when you're completing you're using LSP.
Since they are different and use different configuration it's possible than one work but not the other.
Given your previous issue I think you have still have some trouble with the project root.
If I remember correctly you have defined it in your vimrc with let g:PhpactorRootDirectoryStrategy = {-> '/vagrant'}
Which means that the full path to access your project is /vagrant, is this path correct ?
In order to have a better understanding of what is going on can you:
tell us if you have a phpactor config file ? If yes, is it a global one or do you have one in your project directory ?
i'm going to check your workaround, and yes it's /vagrant :)
Seems a bit odd, just to be sure: the expected path should correspond to where the sources are on your local computer.
If you deploy on a docker container and /vagrant is the path of your project inside the container it will not work since we don't even know about it :)
actually my vim is in a "docker as a vm" (i.e a docker in which i ssh in it ) https://github.com/allan-simon/docker-devbox-php
so that each of my project are in a dockerized environment ( i.e my python project are in docker with a neovim with all the plugin needed to make python development and all the tools etc. )
so when I develop i'm inside the docker in which the code is mounted in /vagrant
What's the output of :PhpactorStatus (or $ phpactor status from your project root? Your other issue indicated that it couldn't find composer.json and so wasn't being run in the project root which can affect your ability to import classes over RPC etc (and possibly also the range of the indexing for the Language Server)
I think the best way for us to debug this is to reproduce it locally by starting with directly from a sub-directory of a project root.
I'm not sure I will have the time soon though...
Activity
camilledejoye commentedon Nov 15, 2020
Hi again,
So the first thing to understand is that there is two different protocols: LSP and RPC
LSP is used by CoC: CoC is the client and phpactor is the server
RPC is used by our custom vim plugin
When you call the command
PhpactorImportClassyou're using RPC, when you're completing you're using LSP.Since they are different and use different configuration it's possible than one work but not the other.
One temporary workaround, until we can understand your problem and fix it, is for you to use CoC to import the class when you complete it.
In order to import the class with auto completion you need to validate your choice with
<C-y>, which is the vim notation forCtrl + y.You can find an example of mapping to be able to complete "correctly" with enter here: https://phpactor.readthedocs.io/en/develop/lsp/vim.html
You can also find more information about that in CoC's wiki: https://github.com/neoclide/coc.nvim/wiki/Completion-with-sources#limitation-of-cocnvims-completion
Given your previous issue I think you have still have some trouble with the project root.
If I remember correctly you have defined it in your vimrc with
let g:PhpactorRootDirectoryStrategy = {-> '/vagrant'}Which means that the full path to access your project is
/vagrant, is this path correct ?In order to have a better understanding of what is going on can you:
StripeWebhookControllerclassAbstractControllerand execute thePhpactorImportClasscommandphpactor rpc --replay --verboseallan-simon commentedon Nov 15, 2020
i'm going to check your workaround, and yes it's
/vagrant:)allan-simon commentedon Nov 15, 2020
no config file at all
camilledejoye commentedon Nov 15, 2020
Seems a bit odd, just to be sure: the expected path should correspond to where the sources are on your local computer.
If you deploy on a docker container and
/vagrantis the path of your project inside the container it will not work since we don't even know about it :)allan-simon commentedon Nov 15, 2020
actually my vim is in a "docker as a vm" (i.e a docker in which i ssh in it ) https://github.com/allan-simon/docker-devbox-php
so that each of my project are in a dockerized environment ( i.e my python project are in docker with a neovim with all the plugin needed to make python development and all the tools etc. )
so when I develop i'm inside the docker in which the code is mounted in /vagrant
dantleech commentedon Nov 15, 2020
What's the output of
:PhpactorStatus(or$ phpactor statusfrom your project root? Your other issue indicated that it couldn't findcomposer.jsonand so wasn't being run in the project root which can affect your ability to import classes over RPC etc (and possibly also the range of the indexing for the Language Server)allan-simon commentedon Nov 15, 2020
Here's the replay
allan-simon commentedon Nov 15, 2020
indeed C-y works :)
dantleech commentedon Nov 15, 2020
☝️ The above is a successful import response, indicating a problem with the CWD in VIM I think ... 🤔
allan-simon commentedon Nov 15, 2020
indeed , removing the
set autochdirand opening vim from/vagrant, and the PhpactorImportClass works correctlycamilledejoye commentedon Nov 15, 2020
That was expected 😄
The problem was with the autochdir or opening from a sub-directory, the error message is generated from the handler:
phpactor/lib/Extension/CodeTransformExtra/Rpc/ImportClassHandler.php
Line 84 in f66fe79
So I think your first idea about composer not being found might be right.
Unfortunately the status won't help us yet because it's not fixed, see the PR: #1127
@allan-simon if you are in the mood for playing I guess you could try from the branch: https://github.com/elythyr/phpactor/tree/fix/%231085-status-does-not-use-correct-working-directory
I think the best way for us to debug this is to reproduce it locally by starting with directly from a sub-directory of a project root.
I'm not sure I will have the time soon though...
allan-simon commentedon Nov 15, 2020
I will check your branch , thanks for the help ! at least as I have the c-y now it's less of a problem