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

PR: Migrate introspection services to use the Language Server Protocol (LSP) #4751

Merged
merged 127 commits into from
Aug 20, 2018

Conversation

andfoy
Copy link
Member

@andfoy andfoy commented Jul 15, 2017

Fixes #4742

On this PR we will adapt editor code introspection and linting functionality to comply with Microsoft/language-server-protocol specifications. During this PR, the following tasks must be accomplished:

  • Write a simple TCP/ZMQ transport proxy that communicates between an LSP server and our client.
  • Write a generic TCP v3.0 Language Server Protocol Client (lsp-client) that communicates with any given language server
  • Improve ZMQ interprocess communication
  • Start specific language LSP server when a file of that language is first opened
  • Close specific language LSP server when there aren't any files of that language opened
  • Integrate lsp-client to our existing introspection calls
  • Integrate lsp-client to handle linting functionality
  • Handle hover calls
  • Integrate lsp-client to perform symbol searching
  • Integrate lsp-client to retrieve function definitions and documentation
  • Integrate lsp-client to handle go-to-definition requests
  • Integrate lsp-client to handle code formatting
  • Add file save and file close calls
  • Improve teardown and application exit closing behaviour
  • Add a settings panel to configure and add different Language-servers
  • Add client/transport tests

Note: Crossed out features of this list are to be implemented/discussed on subsequent PRs, please see: #4751 (comment)

@andfoy andfoy self-assigned this Jul 15, 2017
@andfoy andfoy added this to the v4.0beta2 milestone Jul 15, 2017
@andfoy andfoy requested review from ccordoba12 and goanpeca July 15, 2017 00:41

# Spyder editor capabilities
EDITOR_CAPABILITES = {
"workspace": {
Copy link
Member Author

@andfoy andfoy Jul 15, 2017

Choose a reason for hiding this comment

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

Does the editor supports all the following functionalities?

Copy link
Member

Choose a reason for hiding this comment

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

I don't know what these terms refer to. Could you add a comment above each one to understand what they mean?

Copy link
Member Author

@andfoy andfoy left a comment

Choose a reason for hiding this comment

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

Editor functionalities feedback



parser = argparse.ArgumentParser(
description='ZMQ Python-based MS Language-Server v3.0 client for Spyder')
Copy link
Member

Choose a reason for hiding this comment

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

So do you plan to use zmq sockets? Why not regular sockets?

Copy link
Member Author

Choose a reason for hiding this comment

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

Well I saw that the current implementation is based on ZMQ, but we could use also dedicated sockets per each editor connection, what do you prefer @ccordoba12 @goanpeca?

Copy link
Member Author

@andfoy andfoy Jul 18, 2017

Choose a reason for hiding this comment

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

Shall we continue using zmq? @ccordoba12 @goanpeca

Copy link
Member

Choose a reason for hiding this comment

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

I have no opinion, if using zmq makes the core easier to read and write, then why not?

Copy link
Member

Choose a reason for hiding this comment

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

Yes, please do. I think Zmq sockets are more robust than plain sockets.

Copy link
Member Author

Choose a reason for hiding this comment

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

ZMQ will be then!

# WorkspaceClientCapabilities define capabilities the
# editor / tool provides on the workspace

WORKSPACE_CAPABILITIES = {
Copy link
Member Author

Choose a reason for hiding this comment

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

@ccordoba12 Are the capabilities descriptions more clear than the last time?

pass
client.stop()
sig_manager.restore()
os.kill(os.getpid(), signal.SIGTERM)
Copy link
Member

Choose a reason for hiding this comment

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

This doesn't work on Windows, i.e. processes can't be killed this way there. If you want a cross-platform way of doing this, please take a look at psutil.kill.

@andfoy andfoy force-pushed the language_server_adapter branch from c2685b0 to db63b91 Compare July 21, 2017 18:13
# code lenses for a given text document.
# A code lens represents a command that should be shown along with
# source text, like the number of references, a way to run tests, etc.
"codeLens": {
Copy link
Member Author

Choose a reason for hiding this comment

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

I think Spyder doesn't support code lens, does it?

Copy link
Member

Choose a reason for hiding this comment

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

ehhh not sure I understand what it does?

Copy link
Member Author

Choose a reason for hiding this comment

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

For example, showing who was the last one that modified a line

Copy link
Member

@rlaverde rlaverde Sep 21, 2017

Choose a reason for hiding this comment

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

No, although It'll be a great addition, (and integration with git), I'll look forward to implement this after you finish this PR 😄

@ccordoba12
Copy link
Member

@andfoy, this is terrific! Finally all is green, yay!!

However, this PR will add almost 3400 lines! What modules or files do you want us to review in depth?

@andfoy
Copy link
Member Author

andfoy commented Jun 28, 2018

However, this PR will add almost 3400 lines! What modules or files do you want us to review in depth?

It would be good to review the changes done on codeeditor, as they represent the final achievement of this PR. Also, it would be nice to do some kind of beta testing for the feature replacement on a real scenario, such that we can test the actual performance of the client and to certify that it does not hang when performing several requests concurrently.

@andfoy
Copy link
Member Author

andfoy commented Jun 28, 2018

@ccordoba12 Could you please give this PR a try?

@andfoy
Copy link
Member Author

andfoy commented Jun 30, 2018

@ccordoba12 I've added an option to set LSP options as a JSON object on the LSP configuration panel. With this addition, the PR should be complete.

captura de pantalla de 2018-06-29 19-47-23

@andfoy andfoy force-pushed the language_server_adapter branch from 9636fe9 to 9b0b29f Compare June 30, 2018 01:29
@ccordoba12
Copy link
Member

ccordoba12 commented Jul 17, 2018

Tasks before merging this PR:

  1. Revert blank removed spaces.
  2. Remove unwanted dependencies (coloredlogs).
  3. Put lsp logs in Spyder config dir and always create them, i.e. not only in DEV.
  4. Ask to pyls devs why Rope is not taking precedence over Jedi when Rope is faster.
  5. Fix Rope completions on untitled files in pyls (deactivate Rope for now in Spyder).

@ccordoba12
Copy link
Member

Also:

  1. Deactivate every plugin except Jedi and pyflakes.

@andfoy andfoy force-pushed the language_server_adapter branch from d023e33 to 41b5563 Compare August 11, 2018 02:48
@ccordoba12
Copy link
Member

@andfoy, the error in Circle seems valid, unless you prefer to skip testing spyder/utils/code_analysis/lsp_client.py.

@andfoy andfoy force-pushed the language_server_adapter branch from d09306d to 41b5563 Compare August 16, 2018 22:11
@andfoy
Copy link
Member Author

andfoy commented Aug 17, 2018

@ccordoba12 This one should be ready

Copy link
Member

@ccordoba12 ccordoba12 left a comment

Choose a reason for hiding this comment

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

Great job @andfoy!! Thanks a lot for helping us with this one!!

Fingers crossed, this is going in!

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

Successfully merging this pull request may close these issues.

Adapt code introspection, autocompletion and linting to comply with the Language Server Protocol
6 participants