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

feat: add GlobalLspListener #2523

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open

feat: add GlobalLspListener #2523

wants to merge 9 commits into from

Conversation

rchl
Copy link
Member

@rchl rchl commented Sep 29, 2024

I've been thinking a bit on how to support support sublimelsp/LSP-volar#221

My latest idea is to not do any magic to make LSP-typescript initialize for Vue files and instead when LSP-volar is initialized on a vue file, and LSP-typescript is not running, add a Phantom at the top of the file that tells the user to initialize LSP-typescript to get the full experience. Clicking on the phantom triggers a window command that modifies project settings that enables LSP-typescript for Vue files and also enables the vue plugin by referencing it from the LSP-volar storage path. Would look something like:

Screenshot 2024-09-29 at 22 02 23

To implement that idea I need some global listener that will tell me whenever a session initializes or shuts down on a view thus this API. It would be used like this:

from LSP.plugin import GlobalLspListener
from LSP.plugin import Session
from LSP.plugin import windows

class SessionListener(GlobalLspListener):

    def __init__(self) -> None:
        self._phantoms: dict[int, sublime.PhantomSet] = dict()

    def on_session_initialized_async(self, view_listener: AbstractViewListener, session: Session) -> None:
        pass

    def on_session_shutdown_async(self, view_listener: AbstractViewListener, session: Session) -> None:
        pass


session_listener = SessionListener()


def plugin_loaded():
    LspVolarPlugin.setup()
    windows.add_global_listener(session_listener)


def plugin_unloaded():
    windows.remove_global_listener(session_listener)
    LspVolarPlugin.cleanup()

Let me know if you have any better idea on how this could be handled.

rchl and others added 9 commits September 29, 2024 21:57
* origin/main:
  Use orjson to de-/serialize json-rpc messages (#2513)
* fix/remove-generators:
  Use orjson to de-/serialize json-rpc messages (#2513)
  remove unnecessary use of generators for session retrieval
* origin/main:
  feat: make DebouncerNonThreadSafe public (#2525)
* main:
  style change
  Don't restart servers when userprefs change (#2448)
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.

1 participant