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

update for pygls 0.10 #3

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

bollwyvl
Copy link

@bollwyvl bollwyvl commented Apr 20, 2021

Hi lovely larkers! I was just thinking to myself, heck, it would be great if there was an example of using lark and pygls for a language server, and lo: it doesn't get much better than a language server that will help me write my grammar!

This PR:

  • updates to the pygls 0.10 API.
    • Since 0.8, it's
      • fixed a bunch of bugs
      • dropped psutil
      • uses pydantic, replacing a lot of hand-made validation and types
  • adds a lark-language-server console script so that it's a touch easier to launch.
  • moves some mocks into the test server constructor to appease mypy

Longer con: I tinker with jupyterlab-lsp, and see a lot of benefit to being able to quickly (and potentially interactively) gin up a language server and start using it immediately from basically one python and one lark file making use of a "construction set" that would offer boilerplate around basic LSP tasks... the dream would be:

class FooLanguageServer(LarkuageServer):
    CONFIGURATION_SECTION = 'FooLanguageServer'
    GRAMMER = Lark(""""start:""", ...)

...and it's off to the races for diagnostics, basic hover, built-ins completion, symbol tree, etc. with relatively easy access to your token types for making nice messages, etc. Food for thought!

@erezsh
Copy link
Member

erezsh commented Apr 23, 2021

Thanks for the PR!

The changes seem okay, but I can't get the error reporting to work anymore. (Maybe it stopped working before? I'm not sure)

and it's off to the races for diagnostics, basic hover, built-ins completion, symbol tree, etc. with relatively easy access to your token types for making nice messages, etc. Food for thought!

That's the dream! And that's definitely the direction I'd like to see this project moving towards.

However, I don't think it will be quite as easy as that. Grammars don't capture the entire semantics of a program, only the syntax. It's not obvious how to extract symbols, and distinguish between definition and reference, in an automatic manner. What about scoping, and control flow? They require their own implementation. And what if the language uses a unique mechanic?

I think out best chance is to offer a few ready-made template classes for the users (PythonConf, YamlConf, etc.), which the users will be able to inherit from and extend with code.

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.

2 participants