sublimelsp / LSP-volar

Vue support for Sublime's LSP plugin

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

LSP-volar error -32603 when creating a new ST window by dragging a tab

dsl101 opened this issue · comments

Identical error to #109 and I suspect the cause is not having the folder of the file open. But this is default behaviour when you drag a tab from an existing ST window to create a new window. This is common as a temporary way to view 2 files side by side for example. I'm hoping there's a more permanent way to fix than adding the folder to the side panel, as that kind of defeats the purpose of just dragging the tab (e.g. normal workflow for me would be drag a tab to create second window, work on 2 files, then drag the tab back to close the second window).

Clicking Resart LSP-volar does clear the error—until another tab is opened or dragged to the second window, then it ends up in an infinite loop of popping up the same error box until the ST app is closed.

image

Running LSP: Troubleshoot Server hangs until the Restart button is clicked, then returns the following:

Troubleshooting: LSP-volar

Version

  • LSP: 1.17.0
  • Sublime Text: 4134

Server Test Run

  • exit code: 0
  • output

Server Configuration

  • command
[
  "${node_bin}", 
  "${server_path}", 
  "--stdio"
]
  • shell command
"C:\Program Files\nodejs\node.EXE" "C:\PortableApps\SublimeText\Data\Package Storage\LSP-volar\14.19.0\server\node_modules\@volar\vue-language-server\bin\vue-language-server.js" --stdio
  • selector
text.html.vue | source.ts | source.tsx | source.js | source.jsx
  • priority_selector
(text.html.vue)
  • init_options
{
  "typescript": {}
}
  • settings
{
  "volar": {
    "autoCompleteRefs": false, 
    "autoWrapParentheses": true, 
    "codeLens": {
      "pugTools": false, 
      "references": true, 
      "scriptSetupTools": false
    }, 
    "completion": {
      "autoImportComponent": true, 
      "preferredAttrNameCase": "auto-kebab", 
      "preferredTagNameCase": "auto"
    }, 
    "vueserver": {
      "maxOldSpaceSize": null
    }
  }
}
  • env
{
  "PATH": "C:\\Program Files\\nodejs;C:\\Program Files\\nodejs;C:\\Program Files\\nodejs;C:\\Program Files\\nodejs;C:\\Program Files\\nodejs;C:\\Program Files\\nodejs;C:\\Program Files\\nodejs;C:\\Program Files\\nodejs;C:\\Program Files\\nodejs;C:\\Program Files\\nodejs;C:\\Program Files\\nodejs;C:\\Program Files\\nodejs;C:\\Program Files\\nodejs;C:\\Program Files\\nodejs;"
}

Active view

  • File name
D:\Syncthing\Development\KIStorm\Node\users\create_searchKeys.js
  • Settings
{
  "auto_complete_selector": "meta.tag, source - comment - string.quoted.double.block - string.quoted.single.block - string.unquoted.heredoc", 
  "lsp_active": true, 
  "syntax": "Packages/JavaScript/JavaScript.sublime-syntax"
}
  • base scope
source.js

Project / Workspace

  • folders
[]
  • is project: False

LSP configuration

{
  "show_diagnostics_count_in_view_status": true, 
  "show_diagnostics_in_view_status": false, 
  "show_diagnostics_panel_on_save": 0
}

Another workaround could be to use View > Layout from the top menu bar, or use the Origami package.

Yes, I have Origami, and it's great. But 2 windows on separate monitors is just easier sometimes.

I think we had a similar problem with LSP-typescript, but it was solved on the server with this PR typescript-language-server/typescript-language-server@fbf72dd .

FWIW in vs code if you just open a vue file (without a foder)
volar will not start.

https://github.com/johnsoncodehk/volar/blob/b54835ef6ccd317f1839c4727843a80995c1ee2a/packages/vue-language-server/src/common.ts#L46-L57

I think sometimes in the future, the volar server could support single file mode.

This fails because we do not provide a WorkspaceFolder to volar.
If we do provide it, the server will not fail.

    def is_allowed_to_start(
        cls,
        window: sublime.Window,
        initiating_view: Optional[sublime.View] = None,
        workspace_folders: Optional[List[WorkspaceFolder]] = None,
        configuration: Optional[ClientConfig] = None
    ):
-        if not workspace_folders or not configuration:
+        if not workspace_folders and initiating_view:
+            dir_path = os.path.dirname(initiating_view.file_name() or "")
+            basename = os.path.basename(dir_path)
+            workspace_folders = [WorkspaceFolder(basename, dir_path)]
+        if not configuration:
            return

We can always provide the first parent folder of the file.

It would be better to try to do an os.walk to find the first (tsconfig|jsconfig).json file in the parent dirs
and use the dir name where we found the config file.
Else provide the folder name of the opened file as a fallback.

Why trying to fix it on our side when this is clearly a bug in volar?

We currently prevent the server from being started when no workspace folders are present.