Skip to content

refactor: initialize version manager before plugin registration - #290

Merged
jfcherng merged 1 commit into
sublimelsp:masterfrom
nugged:codex/init-version-manager-before-register
Jul 2, 2026
Merged

refactor: initialize version manager before plugin registration#290
jfcherng merged 1 commit into
sublimelsp:masterfrom
nugged:codex/init-version-manager-before-register

Conversation

@nugged

@nugged nugged commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Initialize the Copilot language server version manager before registering the LSP plugin.
  • Keep the existing storage path and server version sources unchanged.

Rationale

CopilotPlugin.register() can make the plugin available for LSP session startup. on_pre_start_async() checks version_manager.is_installed, which depends on plugin_storage_dir and server_version already being initialized. Setting those fields before registration avoids an AttributeError if startup is triggered before the remaining plugin_loaded() setup has completed.

Validation

  • Syntax-checked plugin/__init__.py with Python compile(...).

@jfcherng

Copy link
Copy Markdown
Collaborator

Makes sense to me. Wondering will this resolves any existing issue?

@nugged

nugged commented Jun 12, 2026

Copy link
Copy Markdown
Contributor Author

Couldn't find an existing issue, ... can't live without ST, and this started to annoy me without Copilot and blocked other LSP things to start. So Fixed for myself,
and then... straight to PR! :)

In my case, and I suspect this was triggered by Sublime Text updating to a newer Python runtime, LSP-copilot failed during startup with:

image

Console:

Unable to initialize language server for LSP-copilot
Traceback (most recent call last):
  File ".../Library/Application Support/Sublime Text/Installed Packages/LSP.sublime-package/plugin/core/windows.py", line 303, in start_async
    plugin_class.on_pre_start_async(context)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^
  File ".../Library/Application Support/Sublime Text/Installed Packages/LSP-copilot.sublime-package/plugin/client.py", line 172, in on_pre_start_async
    if not version_manager.is_installed:
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File ".../Library/Application Support/Sublime Text/Installed Packages/LSP-copilot.sublime-package/plugin/version_manager.py", line 64, in is_installed
    return self.server_path.is_file()
           ^^^^^^^^^^^^^^^^
  File ".../Library/Application Support/Sublime Text/Installed Packages/LSP-copilot.sublime-package/plugin/version_manager.py", line 59, in server_path
    return self.versioned_server_dir / self.THIS_TARBALL_BIN_PATH
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File ".../Library/Application Support/Sublime Text/Installed Packages/LSP-copilot.sublime-package/plugin/version_manager.py", line 54, in versioned_server_dir
    return self.plugin_storage_dir / f"v{self.server_version}"
           ^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'VersionManager' object has no attribute 'plugin_storage_dir'

The failure happened before the server process was launched, while on_pre_start_async() was checking version_manager.is_installed.

@rchl

rchl commented Jun 12, 2026

Copy link
Copy Markdown
Member

I think this bug is a side effect of the bug that was just fixed (but not released as of now) - sublimelsp/LSP#2951

@rchl

rchl commented Jul 2, 2026

Copy link
Copy Markdown
Member

The fix in LSP was released so this shouldn't happen anymore.

Up to maintainers whether they want this change or not. I guess it makes sense nonetheless.

@jfcherng

jfcherng commented Jul 2, 2026

Copy link
Copy Markdown
Collaborator

I am fine to merge this since it makes sense even if it fixes nothing.

Thanks you all.

@jfcherng
jfcherng marked this pull request as ready for review July 2, 2026 19:52
@jfcherng jfcherng changed the title Initialize version manager before plugin registration refactor: initialize version manager before plugin registration Jul 2, 2026
@jfcherng
jfcherng merged commit 8a0f3bd into sublimelsp:master Jul 2, 2026
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.

3 participants