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

Add standalone language server executable for other editors to consume #99

Closed
dsifford opened this issue Apr 29, 2019 · 12 comments
Closed
Labels
addressed in next version Issue is fixed and will appear in next published version enhancement request New feature or request

Comments

@dsifford
Copy link

Hi there. Awesome project!

Is your feature request related to a problem? Please describe.

Perhaps this is already possible in the distributed package but I wasn't able to figure it out. What I'd like to do is consume the LSP server this project defines in vim (using ALE).

As an example, here's how the pylint LSP server is able to be consumed in ALE... https://github.com/w0rp/ale/blob/master/ale_linters/python/pyls.vim

Describe the solution you'd like

Add an ability to invoke the language server from the command line. (If not there already).

@dsifford dsifford added the enhancement request New feature or request label Apr 29, 2019
@erictraut
Copy link
Collaborator

This is outside the scope of this project. If you want to start another project to provide the necessary glue to host Pyright or other LSP servers in other editors, please feel free to do so.

@w0rp
Copy link
Contributor

w0rp commented May 2, 2019

Could you offer any advice on how to build a command line utility for starting the language server? Without a CLI utility, the language server cannot be used outside of VSCode, or in some other editors not written in JavaScript.

@erictraut
Copy link
Collaborator

Here are a couple of pointers...

The pyright.ts code file implements the command-line interface provided by Pyright today. It's a small wrapper around the analyzer service.

The language server is implemented in server.ts and is also a small wrapper around the analyzer service. The language server uses VS Code APIs to communicate with the VS Code language client.

If you want to support other editors, you can create a new project and specify pyright as a dependency through the package.json file. Then create a new top-level code file that imports the analyzer service. You'll need to instantiate it (it's a singleton class) and call it as appropriate (e.g. in response to various events from your language service client). You can use pyright.ts and server.ts as examples of how to call it.

Hope that helps!

@w0rp
Copy link
Contributor

w0rp commented May 2, 2019

Cool, thank you for the information.

@lkgarrison
Copy link

@erictraut I'm unclear why a separate project needs to be created in order to use the Language Server instead of being able to run it from this project. Is it too tightly coupled with VSCode? Or would it need an additional CLI command to start up the language server that is undesirable to add? I was surprised to see you push for a separate project that would expose the language server for other IDEs. It seems a bit silly and against the spirit of LSP to develop a tool like this that is only compatible with VSCode?

@erictraut
Copy link
Collaborator

I'm not familiar with what it takes to package an LSP independently and integrate it with other editors.

It's likely that there will be some compatibility issues with other language server clients, since the current pyright code assumes that certain features are available in the client. That could certainly be addressed, but I don't plan to investigate, maintain or test compatibility with other clients.

My goal with this project was to create a great VS Code plugin plus a stand-alone CLI. If you want to use it for something other than this, you're welcome to do so.

@w0rp
Copy link
Contributor

w0rp commented Sep 10, 2019

I think it would make sense to create a separate package for a CLI, which could read and write JSON via stdin and stdout. I have seen other projects that work the same way.

@fannheyward
Copy link
Contributor

Hello all, you can use pyright in vim/neovim with coc-pyright+coc.nvim. https://github.com/fannheyward/coc-pyright

heejaechang added a commit to heejaechang/pyright that referenced this issue Feb 20, 2020
04a01c7 Merge pull request microsoft#510 from microsoft/erictr/debugging
f6bb03b Fixed debug builds. Recent changes broke debugging (setting breakpoints, etc.).
2aa319f 3 fourslash improvement to support custom lib/typeshed folders (microsoft#514)
50b0d32 added a hook to ImportResolver for custom importing logic. (microsoft#515)
de41104 Merge pull request microsoft#511 from microsoft/erictr/clean
c57fafd Fixed ordering of build script — npm install needs to happen before clean because the latter depends on a node module.
46bb90c Added "clean" command to build script. Fixed bug in build script for debug version of server.
f3a4aed Revert "Added "clean" build command that deletes artifacts from previous build actions."
e22c661 Added "clean" build command that deletes artifacts from previous build actions.
a5e3b37 Merge pull request microsoft#509 from heejaechang/fixRootDirectoryIssue
bdcd372 previously added assert was using wrong path (__dirname rather than __dirname/..)
b1e0ff8 made reportMissingTypeStub diagnostics warning by default and some refactoring around code actions. (microsoft#507)

git-subtree-dir: server/pyright
git-subtree-split: 04a01c7
@WhyNotHugo
Copy link

I'm a bit confused as to what the issue would be in providing support for running the language server as a CLI.

  • The LSP itself is implemented.
  • There's a CLI already implemented.

It just seems like a CLI command to start the server is all that's needed. Adding this into this project would seem to be trivial, but creating a separate project would require all the scaffold of a cli application (which is already in-place here), and that project would do nothing of its own, just start the server (which is already in-place here too).

In short, that project ("pyright-lsp") would really do nothing of its own, just provide an entry point, which is one does all the actual work. Not only does this require a lot of scaffold and add extra complexity, it'd provide an extremely confusing end-user experience.

Would you be willing to accept a PR that adds the command into pyright? Right now pyright implements a standard protocol which can be reused by any editor, but merely lacks the ability to run it unless the editor is written in node.

@erictraut
Copy link
Collaborator

I won't commit to accepting a PR before I see it, but I'll consider it. It will depend on the amount of complexity and maintenance burden it adds to the project. If it's as trivial as you seem to think it is, then it sounds reasonable. If it's moderately complex, then I still think it would be better for it to be part of its own project that imports pyright as a dependency.

@zeronone
Copy link
Contributor

zeronone commented Jul 8, 2020

I created a PR related to this issue, please let me know what you think about it.
#810

@erictraut
Copy link
Collaborator

Thanks for the contribution. I haven't tested it, but I presume you have. The changes looks good to me.

heejaechang added a commit to heejaechang/pyright that referenced this issue Nov 3, 2021
04a01c7 Merge pull request microsoft#510 from microsoft/erictr/debugging
f6bb03b Fixed debug builds. Recent changes broke debugging (setting breakpoints, etc.).
2aa319f 3 fourslash improvement to support custom lib/typeshed folders (microsoft#514)
50b0d32 added a hook to ImportResolver for custom importing logic. (microsoft#515)
de41104 Merge pull request microsoft#511 from microsoft/erictr/clean
c57fafd Fixed ordering of build script — npm install needs to happen before clean because the latter depends on a node module.
46bb90c Added "clean" command to build script. Fixed bug in build script for debug version of server.
f3a4aed Revert "Added "clean" build command that deletes artifacts from previous build actions."
e22c661 Added "clean" build command that deletes artifacts from previous build actions.
a5e3b37 Merge pull request microsoft#509 from heejaechang/fixRootDirectoryIssue
bdcd372 previously added assert was using wrong path (__dirname rather than __dirname/..)
b1e0ff8 made reportMissingTypeStub diagnostics warning by default and some refactoring around code actions. (microsoft#507)

git-subtree-dir: server/pyright
git-subtree-split: 04a01c7
@erictraut erictraut added the addressed in next version Issue is fixed and will appear in next published version label Dec 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
addressed in next version Issue is fixed and will appear in next published version enhancement request New feature or request
Projects
None yet
Development

No branches or pull requests

7 participants