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

Multi LSP Server support #469

Merged
merged 2 commits into from
Nov 28, 2018
Merged

Multi LSP Server support #469

merged 2 commits into from
Nov 28, 2018

Conversation

yyoncho
Copy link
Member

@yyoncho yyoncho commented Nov 10, 2018

Fixes #225 #424 #376 #360 #280 #285 #264 #229 #117 #111 #335 #392 #390 #359 #340 #225

Higher level goals:

  • Allow multiple servers to work in one project and in one file
  • Make finding of project roots easier and more explicit for the users.
  • Removed all synchronous calls from the server startup.
  • Improved hadling of status messages.
  • Implemented workspace folders support as a first class citisen instead of
    being a patch in the existing configuration.
  • Simplified the code as much as possible

The following things are implemented:

  1. Moved lsp-mode related code into single file. Now clients should either
    require lsp-mode or lsp. After this CL lsp-mode.el and lsp.el extesions
    like ccls and lsp-ui will be able to work against either of these.
    lsp-mode will be used by default and if you want to use the new lsp.el you
    should do (require 'lsp) before loading lsp-mode.

  2. Introduced lsp-session which will be resposible for handling project
    session configuration like:

  • What currently imported projects.
  • What server are running and the folders that are associated with the session.
  • What folders are ignored and wont be used to initialize a project in it. The
    session is persisted and automatically loaded the first time user calls lsp
  1. Introduced lsp-language-id-configuration which will hold the configuration
    "language" -> emacs major mode. This map is used to render eldoc information and
    also to determine the language id when sending various notifications to the
    server.

  2. Restructored lsp--client by removing the runtime related
    stuff (like last-id) so it can be used as a template for registration. This will
    simplify the way lsp client registration and it will make easier to add new
    functionality

  3. lsp-ui and company-lsp should be adapted as well. I will prepare separate CLs.

  4. Implemented frontend for reviewing what servers are running, which buffers
    are managed, and so on the method have replaced the existing lsp-capabilities
    method.

  5. Reworked the modeline so it can provide info for the servers currently
    handling current file.

  6. Moved snippet configuration into lsp-mode from company-lsp since snippet
    support will be needed as part of implementing snippet support in lsp-mode Snippet support in completion-at-point #350.
    Aa a result it was possible to clean registration related methods since they
    where used only by company-lsp.

  7. Added the option each client to define the location of its libraries and thus
    avoid starting LSP servers for library folders.

  8. Method selection based on the configuration in lsp-method->capabilities.

Sample client implementation:

(lsp-register-client
 (make-lsp-client
  :new-connection (lsp-stdio-connection "pyls")
  :major-modes '(python-mode)
  :server-id 'pyls
  :library-folders-fn (lambda (_workspace)
                        (list "/usr/"))))

lsp.el Outdated Show resolved Hide resolved
@FirstLoveLife
Copy link

FirstLoveLife commented Nov 13, 2018

lsp-ui-peek-jump-backward/forward will mess up when opening multiples projects in different workspaces(persp-mode + ccls). For example,

  1. projectA:lsp-ui-peek-jump-forward
  2. switch to projectB workspace/buffers
  3. projectB: lsp-ui-peek-jump-forward
  4. return to projectA workspace/buffers
  5. lsp-ui-peek-jump-backward => jump into projectB's buffers, which is not what I want.

Can lsp-session fix this problem?

Thanks in advance.

@yyoncho
Copy link
Member Author

yyoncho commented Nov 13, 2018

@FirstLoveLife I will have to take a look what is causing that issue. For the record, I am using C-o/C-i and they work fine for moving backward/forward after jumping. If the problem is caused by per project jump ring I guess it would be possible to solve if it is moved in lsp-session since it will contain multiple sessions.

@vibhavp
Copy link
Member

vibhavp commented Nov 16, 2018

I still haven't examined all of this, unfortunately. Thanks for submitting this, I'll be sure to have a complete review ready by next week.

@yyoncho
Copy link
Member Author

yyoncho commented Nov 16, 2018

@vibhavp thanks, it still not 100% ready, some parts are missing, I have posted it only for reviewing the general idea. I do a PR for lsp-ui and company-lsp which do work with this CL. I will ping you when it it ready to be tried. As a side note, should be reviewed from the bottom up.

yyoncho added a commit to yyoncho/company-lsp that referenced this pull request Nov 18, 2018
- contains the changes needed so `company-lsp` work against emacs-lsp/lsp-mode#469
yyoncho added a commit to yyoncho/company-lsp that referenced this pull request Nov 18, 2018
- contains the changes needed so `company-lsp` work against emacs-lsp/lsp-mode#469

Do not merge until emacs-lsp/lsp-mode#469 is in.
yyoncho added a commit to yyoncho/lsp-ui that referenced this pull request Nov 18, 2018
- contains the changes needed so `lsp-ui` work against emacs-lsp/lsp-mode#469

Do not merge until emacs-lsp/lsp-mode#469 is in.
yyoncho added a commit to yyoncho/lsp-mode that referenced this pull request Nov 18, 2018
The packages like `lsp-ui` and `company-lsp` do use some internal `lsp-mode`
functions. This CL defines them so then can be implmeneted by `lsp.el` (see emacs-lsp#469)

This will allow `lsp-ui` and `company-lsp` to work aganst both `lsp.el` and
`lsp-mode.el`.
@yyoncho yyoncho changed the title [WIP] First cut on lsp-mode restructoring First cut on lsp-mode restructoring Nov 21, 2018
@yyoncho yyoncho changed the title First cut on lsp-mode restructoring Multi LSP Server support Nov 21, 2018
@MaskRay
Copy link
Member

MaskRay commented Nov 21, 2018

Since merging lsp-*.el is a separate step, can you create a separate PR/commit for it? I'm totally fine with it. That will make the diff smaller and easier to review.

@yyoncho
Copy link
Member Author

yyoncho commented Nov 21, 2018

I will try to do that. Not sure whether this is going to result in better diff.

Copy link
Member

@MaskRay MaskRay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this merges the existing lsp-*.el files, LG

yyoncho added a commit that referenced this pull request Nov 22, 2018
The packages like `lsp-ui` and `company-lsp` do use some internal `lsp-mode`
functions. This CL defines them so then can be implmeneted by `lsp.el` (see #469)

This will allow `lsp-ui` and `company-lsp` to work aganst both `lsp.el` and
`lsp-mode.el`.
yyoncho added a commit to yyoncho/company-lsp that referenced this pull request Nov 28, 2018
- contains the changes needed so `company-lsp` work against emacs-lsp/lsp-mode#469
Fixes emacs-lsp#462 emacs-lsp#444 emacs-lsp#424 emacs-lsp#419 emacs-lsp#392 emacs-lsp#390 emacs-lsp#376 emacs-lsp#360 emacs-lsp#359 emacs-lsp#340 emacs-lsp#335 emacs-lsp#333 emacs-lsp#285 emacs-lsp#280 emacs-lsp#229
Fixes emacs-lsp#225 emacs-lsp#153 emacs-lsp#111 emacs-lsp#117 emacs-lsp#140 emacs-lsp#77

Higher level goals:

* Allow multiple servers to work in one project and in one file
* Make finding of project roots easier and more explicit for the users.
* Removed all synchronous calls from the server startup.
* Improved hadling of status messages.
* Implemented workspace folders support as a first class citisen instead of
  being a patch in the existing configuration.
* Simplified the code as much as possible

The following things are implemented:

1. Moved `lsp-mode` related code into single file. Now clients should either
require `lsp-mode` or `lsp`. After this CL `lsp-mode.el` and `lsp.el` extesions
like `ccls` and `lsp-ui` will be able to work against either of these.
`lsp-mode` will be used by default and if you want to use the new `lsp.el` you
should do `(require 'lsp)` before loading lsp-mode.

2. Introduced `lsp-session` which will be resposible for handling project
session configuration like:
* What currently imported projects.
* What server are running and the folders that are associated with the session.
* What folders are ignored and wont be used to initialize a project in it. The
session is persisted and automatically loaded the first time user calls `lsp`

3. Introduced `lsp-language-id-configuration` which will hold the configuration
"language" -> emacs major mode. This map is used to render eldoc information and
also to determine the language id when sending various notifications to the
server.

4. Restructored `lsp--client` by removing the runtime related
stuff (like last-id) so it can be used as a template for registration. This will
simplify the way lsp client registration and it will make easier to add new
functionality

5. lsp-ui and company-lsp should be adapted as well. I will prepare separate CLs.

6. Implemented frontend for reviewing what servers are running, which buffers
are managed, and so on the method have replaced the existing `lsp-capabilities`
method.

7. Reworked the modeline so it can provide info for the servers currently
handling current file.

8. Moved snippet configuration into `lsp-mode` from `company-lsp` since snippet
support will be needed as part of implementing snippet support in lsp-mode emacs-lsp#350.
Aa a result it was possible to clean registration related methods since they
where used only by company-lsp.

9. Added the option each client to define the location of its libraries and thus
avoid starting LSP servers for library folders.

10. Method selection based on the configuration in `lsp-method->capabilities`.

Sample client implementation:

``` emacs-lisp
(lsp-register-client
 (make-lsp-client
  :new-connection (lsp-stdio-connection "pyls")
  :major-modes '(python-mode)
  :server-id 'pyls
  :library-folders-fn (lambda (_workspace)
                        (list "/usr/"))))
```
@yyoncho yyoncho merged commit 00e7019 into emacs-lsp:master Nov 28, 2018
tigersoldier pushed a commit to tigersoldier/company-lsp that referenced this pull request Dec 2, 2018
- contains the changes needed so `company-lsp` work against emacs-lsp/lsp-mode#469
nasyxx added a commit to nasyxx/emacs.d that referenced this pull request Dec 7, 2018
@tsoernes
Copy link

How do I make use of this?
I want to use both pyls and pyright LSP servers for Python. They do different functions.
I've tried to do

       (python            ; beautiful is better than ugly
        +lsp
        +pyright
        )

In my init.el but pyright is not enabled.

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

Successfully merging this pull request may close these issues.

Reuse LSP session of "caller" file after jumping to system header file (or files outside of the project)
6 participants