Skip to content

Language server import class #1116

Closed
Closed

Description

@indeedhat

Hi im probably missing something here but how do i import a class when using the language server?

In the docs on the develop branch it states that the import class code action is available (https://phpactor.readthedocs.io/en/develop/lsp/support.html) but i cant for the life of me work out what i need to do to run it.

my assumption would be something along the lines of nmap <Leader>u <Plug>(coc-import-class)

Thanks.

Activity

  1. dantleech commented on Oct 27, 2020

    @dantleech
    Collaborator

    code actions, for example

    nmap <Leader>ca <Plug>(coc-codeaction)
    xmap <Leader>ca  v<Plug>(coc-codeaction-selected)
    nmap <Leader>ca  v<Plug>(coc-codeaction-selected)
    

    I use <Leader>ca to calculate the code actions for the entire document. It will offer to "fix" various things (note this currently only works in develop ), if there are missing classes it will offer to import them.

    In addition, classes should be imported automatically when you select them from the auto-complete.

  2. indeedhat commented on Oct 27, 2020

    @indeedhat
    Author

    Thanks, the code action works perfectly.

    I did notice that there was a PR that mentioned it auto importing but that didnt work for me.
    After some further investigation it seems to be due to me having remapped the keys for the pop up menu.

  3. dantleech commented on Oct 27, 2020

    @dantleech
    Collaborator

    Then I guess this ticket should be re-purposed to updating the support document to link to the relevant sections of the doc (if they exist)

  4. indeedhat commented on Oct 27, 2020

    @indeedhat
    Author

    i tried greping the project and i don't think that they do

  5. camilledejoye commented on Oct 31, 2020

    @camilledejoye
    Contributor

    For CoC:

    I don't think we should gave too much information about how to configure a client, otherwise the burden of maintaining this information will be on us.
    Maybe we can instead add links to relevant parts in the clients documentation, even then if the links are dead we will have to maintain them.

    @dantleech up to you, if you want I will do a PR to add the above links, otherwise I think we can close the issue.

  6. dantleech commented on Oct 31, 2020

    @dantleech
    Collaborator

    But it's not clear that you need code-actions in order to import classes, etc.

    • code-action short cuts should be added to the example CoC configuration (or we can remove it in favor of a link to CoC, but the Phpactor example is a lot less daunting)
    • There should be documentation on the currently available code-actions (import class, implement contracts etc) and diagnostics - and we should hyperlink to these from the lsp-support page.
  7. camilledejoye commented on Oct 31, 2020

    @camilledejoye
    Contributor

    I agree a list of available code actions would be nice.
    I will try to do it and add it in the LSP support page.

    For the doc I will update the CoC configuration we have to add links.

  8. dantleech commented on Oct 31, 2020

    @dantleech
    Collaborator

    Probably better as a separate page - lsp/code-actions.rst or similar, with links as necessary from the support page.

  9. camilledejoye commented on Nov 1, 2020

    @camilledejoye
    Contributor

    @dantleech I think we can close it.

  10. dantleech commented on Nov 2, 2020

    @dantleech
    Collaborator

    Thanks, I updated to link to the new page from the lsp-support page.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions