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 LSP-pyvoice #117

Merged
merged 4 commits into from
Jul 22, 2024
Merged

Add LSP-pyvoice #117

merged 4 commits into from
Jul 22, 2024

Conversation

mpourmpoulis
Copy link
Contributor

This is a language client wrapper around the pyvoice-language-server pypi package
and acts as editor portion of the pyvoice for sublime text. Quoting from the organization's home page

pyvoice is an experimental project that is aimed at developers that are writing python code using their voice instead of/alongside with a traditional keyboard. It attempts to provide them with specialized IDE features tailored at their use case, more specifically, it tries to

  • primarily improve the dictation accuracy for coding tasks by extracting information from the user's codebase via static analysis and utilizing it as context for the speech recognition engine

  • secondarily allow for fine-grained, yet more high level editing

The project follows a 3 tier architecture

  • at its core lies a customized language server, where all the heavy business logic takes place. It employs static analysis to determine what module names are available for importing, what variables and what attributes/methods they have etc..., and generates dictation hints for them. It can also being instructed to perform (for the time being limited) edits

  • a plugin for the users code editor, that is responsible for packaging/installing language_server ,launching it as a separate process and to exchange messages with it via appropriate extensions to LSP. It acts as a middleman forwarding generated hints to and commands from the final component of the system, which is

  • an add-on/plugin/grammar file for the user's programming by voice system, that customize the system in a manner appropriate to take advantage of the functionality provided by the language server.

This plugin corresponds to the second tier described above

Originally developed for private usage by myself, after more than two years, I have finally gotten the time to publish it for distribution.

Copy link

@STReviewBot STReviewBot left a comment

Choose a reason for hiding this comment

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

Automated testing result: WARNING

Repo link: LSP-pyvoice
Results help

Packages added:
  - LSP-pyvoice

Processing package "LSP-pyvoice"
  - WARNING: It looks like you're using platform-dependent code. Make sure you thought about the platform key in your pull request.
    - File: plugin.py
    - Line: 33, Column: 12

Copy link

@STReviewBot STReviewBot left a comment

Choose a reason for hiding this comment

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

Automated testing result: WARNING

Repo link: LSP-pyvoice
Results help

Packages added:
  - LSP-pyvoice

Processing package "LSP-pyvoice"
  - WARNING: It looks like you're using platform-dependent code. Make sure you thought about the platform key in your pull request.
    - File: plugin.py
    - Line: 33, Column: 12

@mpourmpoulis mpourmpoulis requested a review from STReviewBot July 12, 2024 16:15
Copy link

@STReviewBot STReviewBot left a comment

Choose a reason for hiding this comment

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

Automated testing result: WARNING

Repo link: LSP-pyvoice
Results help

Packages added:
  - LSP-pyvoice

Processing package "LSP-pyvoice"
  - WARNING: It looks like you're using platform-dependent code. Make sure you thought about the platform key in your pull request.
    - File: plugin.py
    - Line: 33, Column: 12

repository.json Outdated Show resolved Hide resolved
repository.json Outdated Show resolved Hide resolved
@rchl
Copy link
Member

rchl commented Jul 17, 2024

Do I understand it correctly that this code:

https://github.com/PythonVoiceCodingPlugin/LSP-pyvoice/blob/341ef27c0fd232ff5ce55d7afe404ce340a6f59e/quick_install_grammars.py#L144-L151

will trigger the quick_install_grammars command which trigger a quick panel? If so then doing that automatically on plugin load doesn't sound like a good idea.

@rchl
Copy link
Member

rchl commented Jul 17, 2024

You shouldn't care about ST3 in the readme or default settings: https://github.com/PythonVoiceCodingPlugin/LSP-pyvoice/blob/341ef27c0fd232ff5ce55d7afe404ce340a6f59e/README.md?plain=1#L158-L169

Your package will only run in ST4+ anyway.

@rchl
Copy link
Member

rchl commented Jul 17, 2024

What's the reason for not sending notification through LSP custom notification in https://github.com/PythonVoiceCodingPlugin/LSP-pyvoice/blob/341ef27c0fd232ff5ce55d7afe404ce340a6f59e/ipc.py#L38-L56? Is it not the LSP server you are sending the data to?

Copy link

@STReviewBot STReviewBot left a comment

Choose a reason for hiding this comment

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

Automated testing result: WARNING

Repo link: LSP-pyvoice
Results help

Packages added:
  - LSP-pyvoice

Processing package "LSP-pyvoice"
  - WARNING: It looks like you're using platform-dependent code. Make sure you thought about the platform key in your pull request.
    - File: plugin.py
    - Line: 33, Column: 12

@mpourmpoulis
Copy link
Contributor Author

Starting from the main one

What's the reason for not sending notification through LSP custom notification in https://github.com/PythonVoiceCodingPlugin/LSP-pyvoice/blob/341ef27c0fd232ff5ce55d7afe404ce340a6f59e/ipc.py#L38-L56? Is it not the LSP server you are sending the data to?

No the notifications sent via the ipc module are not meant for the language server. Instead they are meant To be sent to the user's preferred programming by voice system

As i explain in their readme of the org home page, pyvoice is not a standard language server (that adds For example auto complete for a new language). Instead, it offers Specialized functionality aimed at developers using voice input in order to write code rather than a keyboard due to Repetitive Strain Injury(RSI) or other health issues. As a consequence, it goes beyond classical two tier ( client/server) LSP Architecture and adds a third layer. Essentially at any given time you have 2 plugins running

  • one inside your editor
  • one inside your voice coding system

At the moment, I have support for the following voice coding systems

Now back to the notifications and the ipc module, what is essentially going on is the following

  • There is a listener Inside sublime waiting for a variety of events
  • When appropriate, it triggers via workspace/executeCommand the get_spoken cmd on the language server. This prompts it To analyze your code base and generate speech hints, Like what module names Are available, what symbols are in scope, what attributes or methods those symbols have along with their corresponding spoken form
  • The server responds with this information via LSP notifications voice/sendRpc for which I have registered Custom handlers in plugin.py via lsp_utils
  • The data received by those lsp notifications Is then forwarded to the programming by voice system (Caster or Talonvoice) where you can be utilized in order to improve Accuracy of the speech recognition etc

I hope this clears up the situation, if you have any more questions let me know!

@mpourmpoulis
Copy link
Contributor Author

Do I understand it correctly that this code:

https://github.com/PythonVoiceCodingPlugin/LSP-pyvoice/blob/341ef27c0fd232ff5ce55d7afe404ce340a6f59e/quick_install_grammars.py#L144-L151

will trigger the quick_install_grammars command which trigger a quick panel? If so then doing that automatically on plugin load doesn't sound like a good idea.

Thanks for the feedback! That piece of code has been long forgotten there and I agree that we should not be running upon loading. Bad idea indeed, will remove it

You shouldn't care about ST3 in the readme or default settings: https://github.com/PythonVoiceCodingPlugin/LSP-pyvoice/blob/341ef27c0fd232ff5ce55d7afe404ce340a6f59e/README.md?plain=1#L158-L169

Your package will only run in ST4+ anyway.

Again correct! copy pasted from LSP-pylsp a long time ago, this will also go

@mpourmpoulis
Copy link
Contributor Author

Do I understand it correctly that this code:
https://github.com/PythonVoiceCodingPlugin/LSP-pyvoice/blob/341ef27c0fd232ff5ce55d7afe404ce340a6f59e/quick_install_grammars.py#L144-L151
will trigger the quick_install_grammars command which trigger a quick panel? If so then doing that automatically on plugin load doesn't sound like a good idea.

Thanks for the feedback! That piece of code has been long forgotten there and I agree that we should not be running upon loading. Bad idea indeed, will remove it

You shouldn't care about ST3 in the readme or default settings: https://github.com/PythonVoiceCodingPlugin/LSP-pyvoice/blob/341ef27c0fd232ff5ce55d7afe404ce340a6f59e/README.md?plain=1#L158-L169
Your package will only run in ST4+ anyway.

Again correct! copy pasted from LSP-pylsp a long time ago, this will also go

Updated my main branch with these modifications as well!

@rwols
Copy link
Member

rwols commented Jul 17, 2024

It’s hard for me to understand what this even has to do with the language server protocol. Why can’t this be a plugin for ST that inserts/removes text based on voice commands?

@mpourmpoulis
Copy link
Contributor Author

It’s hard for me to understand what this even has to do with the language server protocol. Why can’t this be a plugin for ST that inserts/removes text based on voice commands?

That's very understandable, and in all honesty I had some reservations on whether I should be submitting these package to the LSP repository or to the main channel directly.

To put things in perspective, This project was originally conceived as a sister project/supplement to another (now defunct) voice coding related sublime package I had published years ago PythonVoiceCodingPlugin dealing more with things ast based navigation related.The latter was following the approach of putting all of the business logic Inside sublime text with the caveat that fellow voice coders who were using different editors were unable to use it.

With pyvoice, I wanted that functionality to be available cross editor ( and to the extent possible cross voice system but that's not of interest right now) with the minimum friction possible. My Initial release, For example will include a plug-in for VS code In order to achieve that the core business logic involving analyzing your codebase etc had to be separated from sublime into its own component.

While at the moment, the interactions between the two components are by design simple enough that a custom communication protocol between them would be sufficient (and in fact my earliest experiments were in that approach) switching to extending the LSP (even if a small subset thereof is currently used) was quite a quality of life improvement development and tooling wise. Furthermore, that decision resonated with my long term vision to add support for more languages and expand the featureset provided (in a language and editor agnostic manner), while also formalizing things

Again, if the mainteners of this repository feel that this is not the right place for this package, I could submit it to the main channel directly instead.

@rwols
Copy link
Member

rwols commented Jul 17, 2024

Okay. So the functionality depends on parsing some kind of AST for the specific language? Then it starts to make sense to me why you’d use a language server. It does feel like a tremendous effort to support more languages. Overall yeah I’m fine with going ahead with this (but I’m deferring to @rchl and @predragnikolic further issues)

@mpourmpoulis
Copy link
Contributor Author

Okay. So the functionality depends on parsing some kind of AST for the specific language?

Yes! In fact I am building heavily on top of jedi, the same static analysis library employed by pylsp, in order to infer types of variables, what attributes they have, what attributes those attributes have, taking your whole codebase into context. In a loose sense, you could draw a fair number of parallels between the process of generatiing the afforementioned "speech hints" and how a more typical Language server would go about in order to provide standard autocompletion.

repository.json Outdated Show resolved Hide resolved
Copy link

@STReviewBot STReviewBot left a comment

Choose a reason for hiding this comment

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

Automated testing result: WARNING

Repo link: LSP-pyvoice
Results help

Packages added:
  - LSP-pyvoice

Processing package "LSP-pyvoice"
  - WARNING: It looks like you're using platform-dependent code. Make sure you thought about the platform key in your pull request.
    - File: plugin.py
    - Line: 33, Column: 12

@rchl rchl merged commit 63df230 into sublimelsp:main Jul 22, 2024
1 check passed
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.

4 participants