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

Support multiple language servers for single file/workspace #424

Closed
yyoncho opened this issue Sep 14, 2018 · 32 comments
Closed

Support multiple language servers for single file/workspace #424

yyoncho opened this issue Sep 14, 2018 · 32 comments
Assignees

Comments

@yyoncho
Copy link
Member

yyoncho commented Sep 14, 2018

LSP mode must support multiple LSP servers for single file/workspace similar to what the other implementations(Che/VSCode) already do.

See eclipse-che/che#4609

@TysonAndre
Copy link

Possible duplicate of #105

@yyoncho
Copy link
Member Author

yyoncho commented Sep 15, 2018

@TysonAndre no, #105 is to support different servers for the same mode per workspace. This bug is to support multiple simultaneous servers running in the same file and providing data for the file simultaneously, e.g. running HTML and JS LSP servers in one file.

@yyoncho
Copy link
Member Author

yyoncho commented Sep 17, 2018

@vibhavp can you share your thoughts? If there are no volunteers to implement this feature I will work on it, but this is not going to happen anytime soon. Since this would require some bit restructuring on lsp-mode side I want to discuss it upfront. I think that it would be good to address some of the lsp-mode flaws related to process management.

@yyoncho
Copy link
Member Author

yyoncho commented Oct 23, 2018

@vibhavp @MaskRay
I am investigating whether sesman could be a good fit for our usecase which is used by cider for a similar use case. I believe that it could improve the user experience related to visibility what are the currently running servers(check sesman-browser), it will cleanup a lot of code related to session management which complexity is going to increase. Also, it will make the writing of extension against LSP mode much easier compared to current ad-hoc session management with lsp--workspaces hash table.

(cc sesman owner @vspinu)

yyoncho added a commit to yyoncho/lsp-mode that referenced this issue Nov 10, 2018
Fixes emacs-lsp#225 emacs-lsp#424 emacs-lsp#376 emacs-lsp#360 emacs-lsp#280 emacs-lsp#285 emacs-lsp#264 emacs-lsp#229 emacs-lsp#117 emacs-lsp#111 emacs-lsp#335

The following things are implemented:

1. 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`

2. 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.

3. Refactored 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
yyoncho added a commit to yyoncho/lsp-mode that referenced this issue Nov 10, 2018
Fixes emacs-lsp#225 emacs-lsp#424 emacs-lsp#376 emacs-lsp#360 emacs-lsp#280 emacs-lsp#285 emacs-lsp#264 emacs-lsp#229 emacs-lsp#117 emacs-lsp#111 emacs-lsp#335

The following things are implemented:

1. 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`

2. 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.

3. Refactored 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
yyoncho added a commit to yyoncho/lsp-mode that referenced this issue Nov 10, 2018
Fixes emacs-lsp#225 emacs-lsp#424 emacs-lsp#376 emacs-lsp#360 emacs-lsp#280 emacs-lsp#285 emacs-lsp#264 emacs-lsp#229 emacs-lsp#117 emacs-lsp#111 emacs-lsp#335 emacs-lsp#392 emacs-lsp#390 emacs-lsp#359 emacs-lsp#340 emacs-lsp#225

The following things are implemented:

1. 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`

2. 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.

3. 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
yyoncho added a commit to yyoncho/lsp-mode that referenced this issue Nov 10, 2018
Fixes emacs-lsp#225 emacs-lsp#424 emacs-lsp#376 emacs-lsp#360 emacs-lsp#280 emacs-lsp#285 emacs-lsp#264 emacs-lsp#229 emacs-lsp#117 emacs-lsp#111 emacs-lsp#335 emacs-lsp#392 emacs-lsp#390 emacs-lsp#359 emacs-lsp#340 emacs-lsp#225

The following things are implemented:

1. 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`

2. 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.

3. 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

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

5. Implemented frontend for reviewing what servers are running, which buffers
are managed, and so on.

6. Reworked the modeline so it can provide info for the servers currently
handling current file.
yyoncho added a commit to yyoncho/lsp-mode that referenced this issue Nov 13, 2018
Fixes emacs-lsp#225 emacs-lsp#424 emacs-lsp#376 emacs-lsp#360 emacs-lsp#280 emacs-lsp#285 emacs-lsp#264 emacs-lsp#229 emacs-lsp#117 emacs-lsp#111 emacs-lsp#335 emacs-lsp#392 emacs-lsp#390 emacs-lsp#359 emacs-lsp#340 emacs-lsp#225

The following things are implemented:

1. Moved `lsp-mode` related code into single file. Now clients should either
require `lsp-mode` or `lsp`. I am still trying to figure out what is the best
way to to this conditional require.

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.

7. Reworked the modeline so it can provide info for the servers currently
handling current file.
yyoncho added a commit to yyoncho/lsp-mode that referenced this issue Nov 13, 2018
Fixes emacs-lsp#225 emacs-lsp#424 emacs-lsp#376 emacs-lsp#360 emacs-lsp#280 emacs-lsp#285 emacs-lsp#264 emacs-lsp#229 emacs-lsp#117 emacs-lsp#111 emacs-lsp#335 emacs-lsp#392 emacs-lsp#390 emacs-lsp#359 emacs-lsp#340 emacs-lsp#225

The following things are implemented:

1. Moved `lsp-mode` related code into single file. Now clients should either
require `lsp-mode` or `lsp`. I am still trying to figure out what is the best
way to to this conditional require.

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.

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.
yyoncho added a commit to yyoncho/lsp-mode that referenced this issue Nov 15, 2018
Fixes emacs-lsp#225 emacs-lsp#424 emacs-lsp#376 emacs-lsp#360 emacs-lsp#280 emacs-lsp#285 emacs-lsp#264 emacs-lsp#229 emacs-lsp#117 emacs-lsp#111 emacs-lsp#335 emacs-lsp#392 emacs-lsp#390 emacs-lsp#359 emacs-lsp#340 emacs-lsp#225

The following things are implemented:

1. Moved `lsp-mode` related code into single file. Now clients should either
require `lsp-mode` or `lsp`. I am still trying to figure out what is the best
way to to this conditional require.

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.

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.
yyoncho added a commit to yyoncho/lsp-mode that referenced this issue Nov 16, 2018
Fixes emacs-lsp#225 emacs-lsp#424 emacs-lsp#376 emacs-lsp#360 emacs-lsp#280 emacs-lsp#285 emacs-lsp#264 emacs-lsp#229 emacs-lsp#117 emacs-lsp#111 emacs-lsp#335 emacs-lsp#392 emacs-lsp#390 emacs-lsp#359 emacs-lsp#340 emacs-lsp#225

The following things are implemented:

1. Moved `lsp-mode` related code into single file. Now clients should either
require `lsp-mode` or `lsp`. I am still trying to figure out what is the best
way to to this conditional require.

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.

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.
yyoncho added a commit to yyoncho/lsp-mode that referenced this issue Nov 18, 2018
Fixes emacs-lsp#225 emacs-lsp#424 emacs-lsp#376 emacs-lsp#360 emacs-lsp#280 emacs-lsp#285 emacs-lsp#264 emacs-lsp#229 emacs-lsp#117 emacs-lsp#111 emacs-lsp#335 emacs-lsp#392 emacs-lsp#390 emacs-lsp#359 emacs-lsp#340 emacs-lsp#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`

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`.
yyoncho added a commit to yyoncho/lsp-mode that referenced this issue Nov 18, 2018
Fixes emacs-lsp#225 emacs-lsp#424 emacs-lsp#376 emacs-lsp#360 emacs-lsp#280 emacs-lsp#285 emacs-lsp#264 emacs-lsp#229 emacs-lsp#117 emacs-lsp#111 emacs-lsp#335 emacs-lsp#392 emacs-lsp#390 emacs-lsp#359 emacs-lsp#340 emacs-lsp#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`

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`.
yyoncho added a commit to yyoncho/lsp-mode that referenced this issue Nov 21, 2018
Fixes emacs-lsp#225 emacs-lsp#424 emacs-lsp#376 emacs-lsp#360 emacs-lsp#280 emacs-lsp#285 emacs-lsp#264 emacs-lsp#229 emacs-lsp#117 emacs-lsp#111 emacs-lsp#335 emacs-lsp#392 emacs-lsp#390 emacs-lsp#359 emacs-lsp#340 emacs-lsp#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`

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
Copy link
Member Author

yyoncho commented Aug 17, 2020

This feature is not for embedded source blocks. I mean, if the server (in this case typescript language server) supports working in blocks that are embedded in another language, then it will work. You may test that by doing M-x lsp-disconnect and then C-u M-x lsp and pick ts-ls. If the server works, then we can arrange lsp-mode to start both ts-ls and vue-ls in this file.

@RKBK
Copy link
Contributor

RKBK commented Jan 14, 2021

I was able to define a polymode to use different major modes in each part of a vue file:
AdamNiederer/vue-mode#109
With this setup, I get vetur via lsp working, for all three sections (typescript, the vue-html part, and the scss part). I guess vetur is used just because it is suggested for .vue files, and I have installed it.

@yyoncho How would I go about adding javascript-eslint in addition to vetur? Is there a file in lsp-mode that I could modify just to try it? Or is this somehow already handled (I see something related in the lsp-eslint.el, for applying fixes, but does that also show errors inline?)?

I've set flycheck to add on javascript-eslint. That works, but the checking is much slower than in vscode (results are instant in vscode, but take perhaps 2 s if run via flycheck). However, the lsp results from vetur (the indicator next to the lsp icon updates quickly) seem to be essentially instant, so I suspect that if I can get vetur+eslint via lsp, the feedback would be instant in emacs too.

@yyoncho
Copy link
Member Author

yyoncho commented Jan 14, 2021

@RKBK AFAICS eslint client is registered for vue files:

https://github.com/yyoncho/lsp-mode/blob/modes/clients/lsp-eslint.el#L270

Do you have the server installed? If not just do M-x lsp-install-server RET eslint RET

@RKBK
Copy link
Contributor

RKBK commented Jan 14, 2021

@yyoncho That's one weird thing about my emacs, I don't get that option for .vue files. I get:

image

@yyoncho
Copy link
Member Author

yyoncho commented Jan 14, 2021

@RKBK this means that it is most likely installed. Have you verified that eslint is not actually running when doing M-x lsp in vue file? Also you may force starting a server by doing C-u M-x lsp and then selecting a server.

@RKBK
Copy link
Contributor

RKBK commented Jan 14, 2021

@yyoncho You were right! Sorry. Thanks for pointing out the keybind. The server exits, but I suppose I have misconfigured something:

node:internal/modules/cjs/loader:928
  throw err;
  ^

Error: Cannot find module '/home/rasmus/Projects/todo/~/server/out/eslintServer.js'
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:925:15)
    at Function.Module._load (node:internal/modules/cjs/loader:769:27)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:76:12)
    at node:internal/main/run_main_module:17:47 {
  code: 'MODULE_NOT_FOUND',
  requireStack: []
}

@yyoncho
Copy link
Member Author

yyoncho commented Jan 14, 2021

@RKBK I suggest deleting this installation, reverting eslint related customization and installing it via M-x lsp-install-server.

@RKBK
Copy link
Contributor

RKBK commented Jan 14, 2021

@yyoncho
I have deleted all the lsp-* folders from .emacs.d/elpa, as well as emptied out .emacs.d/.cache . After allowing everything to reinstall, I am able to execute C-u M-x lsp and select eslint inside the .vue file. But still, the vls server is then started, not eslint! Also, I was never asked to download the vls server, so I guess there is something more I need to remove? In addition, the list of available servers to install is still the same as in the screenshot above.

@yyoncho
Copy link
Member Author

yyoncho commented Jan 14, 2021

@RKBK which lsp-mode version do you run? If you are on melpa-stable please switch to melpa.

@RKBK
Copy link
Contributor

RKBK commented Jan 14, 2021

@yyoncho Switching to melpa and cleaning again seemed to have done it. Eslint (and a ton of other lsps) was now installable, and I could switch to it. Eslint now seems to work, too.

Is melpa needed for any other related package too, e.g. company, posframe, treemacs?

How do I now go about and have vls and eslint both running at the same time?

@yyoncho
Copy link
Member Author

yyoncho commented Jan 14, 2021

Is melpa needed for any other related package too, e.g. company, posframe, treemacs?

flycheck for sure. For the rest, I don't know. For lsp-mode I generally recommend running melpa versions. Running melpa-stable version is tricky since you should install also the versions of the servers from that point in time.

How do I now go about and have vls and eslint both running at the same time?

It should work OOTB after doing M-x lsp.

@RKBK
Copy link
Contributor

RKBK commented Jan 14, 2021

Wow, now that the eslint server is installed, after restarting emacs (probably not necessary), and opening the file, lsp noted:

LSP :: vls:17199 initialized successfully
LSP :: eslint:17200 initialized successfully
LSP :: Connected to [vls:17199][eslint:17200]. [2 times]

And it seems to work, giving me the same sort of feedback, and similarly instantly, as in vscode! It also seems to work just as well in .ts files.

I've now pinned melpa for the lsp packages, so let's see how this goes.

Many thanks. This is truly impressive work.

@yyoncho
Copy link
Member Author

yyoncho commented Jan 14, 2021

Good.

And it seems to work, giving me the same sort of feedback, and similarly instantly, as in vscode! It also seems to work just as well in .ts files.

You might be interested in: https://emacs-lsp.github.io/lsp-mode/tutorials/reactjs-tutorial/

@RKBK
Copy link
Contributor

RKBK commented Jan 19, 2021

There is one more thing that I don't manage to get working. In vue files, in html sections, in vue components, there is no validation information shown. E.g. if there was a .vue file (leaving out the details) like

<script lang='ts'>
// Various setup stuff
return parameter;
</script>
<template>
<div>
<my-component
  v-model="model"
  my-component-parameter: "paramter"
/>
</div>
</template>

I don't get any error text for "paramter" (it should be "parameter") being misspelled, although I do get that in vscode for the same project. Oddly, I also get the same sort of error in the typescript sections.

Other lsp errors do get reported in the exact same part of the file, e.g. we don't allow trailing spaces, and such errors get reported also in the template part. But, as said, things inside tags don't seem to be verified, or the error at least isn't reported.

@yyoncho
Copy link
Member Author

yyoncho commented Jan 19, 2021

we should crosscheck which language server is running in vscode and in emacs case.

@RKBK
Copy link
Contributor

RKBK commented Jan 20, 2021

Vetur is used in vscode. The following vetur-specific settings are applied (I removed the lines not specific to vetur):

{
    "vetur.experimental.templateInterpolationService": true,
    "vetur.useWorkspaceDependencies": true,
    "vetur.validation.templateProps": true,
    "vetur.grammar.customBlocks": {
      "docs": "md",
      "i18n": "json"
    },
}

Vetur is used also in lsp-emacs. The vetur.validation.templateProps: true part is, I guess, the same as the variable lsp-vetur-validation-template, which has the value t in my emacs.

However, I did not have the setting corresponding to
"vetur.experimental.templateInterpolationService": true,
set. After doing
(setq lsp-vetur-experimental-template-interpolation-service t)
and restarting the vls server, that check started to work in lsp-mode too!

I guess we simply had activated that feature, which is not enabled by default, so I suppose it makes sense for it not to be enabled by default in lsp-mode.

As for the other setting, "vetur.useWorkspaceDependencies": true, it turns out that is to use relative imports, i.e. import ../someOtherFolder/someTypescriptModule instead of import src/someOtherFolder/someTypescriptModule.

@yyoncho
Copy link
Member Author

yyoncho commented Jan 20, 2021

@RKBK feel free to provide a PR to change the defaults to more meaningful.

@RKBK
Copy link
Contributor

RKBK commented Jan 22, 2021

@yyoncho I'm sorry for being a bit unclear. I've come to realize that the settings I were missing were in fact simply non-default settings. So it makes sense that I would need to set them myself in emacs, too. I'm a bit new to both vue and lsp-emacs, so how to do that on the emacs end for vue was confusing at first. Now, I think I've understood how to get vls set up the same way as we have it set up in vscode.

It looks like the defaults for vls in lsp-emacs are in fact the same as in vscode.

Thank you for all your help!

@hectorhon
Copy link

I notice flymake (emacs 27.1, windows) does not "keep" all the errors when there are multiple lsp servers for the buffer. In my case, I am using flymake + ts-ls lsp + eslint lsp. Immediately after I make an edit, I can briefly see errors/warnings (from eslint, which has stricter eslintrc configured) being underlined before disappearing (as ts-ls output takes over). The workaround is to use flycheck, which keeps errors from both lsp servers in the buffer.

@yyoncho
Copy link
Member Author

yyoncho commented Apr 21, 2021

@hectorhon can you upgrade your flymake? I think that we had issues with older versions.

@hectorhon
Copy link

@yyoncho I just updated to the latest emacs 27.2 (with built in flymake 1.0.8) and the issue persists. Same after upgrading to flymake from 1.0.8 to 1.1.1. But I agree it's probably an issue with flymake, since flycheck is working fine.

@yyoncho
Copy link
Member Author

yyoncho commented Apr 22, 2021

@yyoncho I just updated to the latest emacs 27.2 (with built in flymake 1.0.8) and the issue persists. Same after upgrading to flymake from 1.0.8 to 1.1.1. But I agree it's probably an issue with flymake, since flycheck is working fine.

It is most likely issue with lsp-mode integration with flymake. Does it work if you have one server only?

@hectorhon
Copy link

Yes, flymake does work if I have only one of ts-ls or eslint installed.

@yyoncho
Copy link
Member Author

yyoncho commented Apr 23, 2021

@hectorhon then, can you open lsp-mode issue to track the problem(no need to fill the whole bug template).

@hectorhon
Copy link

@yyoncho Sure, created #2808 . Thank you!

wkirschbaum pushed a commit to wkirschbaum/lsp-mode that referenced this issue Jun 1, 2021
* do not insert end after do:

Fixes emacs-lsp#424

* Add a couple more tests

Co-authored-by: Jason Axelson <[email protected]>
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

No branches or pull requests

5 participants