rszyma / vscode-kanata

Language support for kanata configuration files in VS Code
https://marketplace.visualstudio.com/items?itemName=rszyma.vscode-kanata
GNU Lesser General Public License v3.0
16 stars 0 forks source link

Bug: LSP crashes when using `defaliasenvcond` in kanata config #24

Closed pro470 closed 6 months ago

pro470 commented 7 months ago

I use your plugin to crate my configuration file but the LSP is not working. I have syntax highlighting but it doesn't show an error. The auto-detect defaultkeys are also not working, but I can choose them myself. For context, I have auto-save on in vscode. I use Windows 11. The file I am using is the default configure file in the Kanata docs repo because I was testing it.

rszyma commented 7 months ago

The auto-detect defaultkeys are also not working

This is intended, there's no way on Windows to reliably auto-detect which deflocalkeys variant should be used.

The file I am using is the default configure file in the Kanata docs repo because I was testing it.

  1. Have you opened a containing folder in vscode or just file?
  2. Have you checked if there are any errors is extension logs?
pro470 commented 7 months ago

If I reload the window it parses and shows me the error. I turned autosave off for a time and saved manually, but that doesn't work it looks like it only parsed when I reloaded the window. For your question, I opened it in just file and folder both only work with reload. I send the extension log because it seems there is an error:

first one: starting with 1 opened workspaces

Settings changed but vscode-kanata configuration hasn't changed
Settings changed but vscode-kanata configuration hasn't changed
Settings changed but vscode-kanata configuration hasn't changed
Settings changed but vscode-kanata configuration hasn't changed
Config { includes_and_workspaces: Single, main_config_file: "kanata.kbd", def_local_keys_variant: Win, format: ExtensionFormatterOptions { enable: true, use_defsrc_layout_on_deflayers: true } }
workspace root: file:///c%3A/Users/reyno/kanata_keyboard
notification: initialized
notification: textDocument/didOpen
opening: file:///c%3A/Users/reyno/kanata_keyboard/kanata.kbd
Settings changed but vscode-kanata configuration hasn't changed
parsing file `/c%3A/Users/reyno/kanata_keyboard/kanata.kbd` resulted in error: `Found unknown configuration item`
added diagnostic for document: file:///c%3A/Users/reyno/kanata_keyboard/kanata.kbd
sending diagnostics for 1 files
notification: textDocument/didOpen
opening: file:///c%3A/Users/reyno/kanata_keyboard/Reynolds.kbd
parsing file `/c%3A/Users/reyno/kanata_keyboard/Reynolds.kbd` resulted in error: `Referenced unknown alias grl. Note that order of declarations matter.`
parsing file `/c%3A/Users/reyno/kanata_keyboard/kanata.kbd` resulted in error: `Found unknown configuration item`
added diagnostic for document: file:///c%3A/Users/reyno/kanata_keyboard/Reynolds.kbd
added diagnostic for document: file:///c%3A/Users/reyno/kanata_keyboard/kanata.kbd
sending diagnostics for 2 files
Settings changed but vscode-kanata configuration hasn't changed
notification: textDocument/didChange
notification: textDocument/didChange
notification: textDocument/didChange
notification: textDocument/didSave
parsing file `/c%3A/Users/reyno/kanata_keyboard/Reynolds.kbd` resulted in error: `Referenced unknown alias grl. Note that order of declarations matter.`
panicked at library/std/src/sys/wasm/../unsupported/os.rs:92:5:
not supported on this platform

Stack:

Error
    at S.exports.__wbg_new_abda76e883ba8a5f (c:\Users\reyno\.vscode\extensions\rszyma.vscode-kanata-0.9.17\out\server.js:34:2247)
    at wasm://wasm/004ab8a2:wasm-function[1088]:0xd1b39
    at wasm://wasm/004ab8a2:wasm-function[505]:0xbdc70
    at wasm://wasm/004ab8a2:wasm-function[763]:0xcd67f
    at wasm://wasm/004ab8a2:wasm-function[73]:0x49d23
    at wasm://wasm/004ab8a2:wasm-function[366]:0xb3bbd
    at wasm://wasm/004ab8a2:wasm-function[59]:0x13508
    at wasm://wasm/004ab8a2:wasm-function[66]:0x2845b
    at as.onNotification (c:\Users\reyno\.vscode\extensions\rszyma.vscode-kanata-0.9.17\out\server.js:34:718)
    at c:\Users\reyno\.vscode\extensions\rszyma.vscode-kanata-0.9.17\out\server.js:34:6311

[Error - 12:19:08 PM] Notification handler 'textDocument/didSave' failed with message: unreachable
error: Canceled: Canceled

second one: starting with 1 opened workspaces

Settings changed but vscode-kanata configuration hasn't changed
Settings changed but vscode-kanata configuration hasn't changed
Settings changed but vscode-kanata configuration hasn't changed
Settings changed but vscode-kanata configuration hasn't changed
Settings changed but vscode-kanata configuration hasn't changed
Config { includes_and_workspaces: Single, main_config_file: "kanata.kbd", def_local_keys_variant: Win, format: ExtensionFormatterOptions { enable: true, use_defsrc_layout_on_deflayers: true } }
workspace root: file:///c%3A/Users/reyno/kanata_keyboard
notification: initialized
notification: textDocument/didOpen
opening: file:///c%3A/Users/reyno/kanata_keyboard/kanata.kbd
panicked at library/std/src/sys/wasm/../unsupported/os.rs:92:5:
not supported on this platform

Stack:

Error
    at S.exports.__wbg_new_abda76e883ba8a5f (c:\Users\reyno\.vscode\extensions\rszyma.vscode-kanata-0.9.17\out\server.js:34:2247)
    at wasm://wasm/004ab8a2:wasm-function[1088]:0xd1b39
    at wasm://wasm/004ab8a2:wasm-function[505]:0xbdc70
    at wasm://wasm/004ab8a2:wasm-function[763]:0xcd67f
    at wasm://wasm/004ab8a2:wasm-function[73]:0x49d23
    at wasm://wasm/004ab8a2:wasm-function[366]:0xb3bbd
    at wasm://wasm/004ab8a2:wasm-function[59]:0x13398
    at wasm://wasm/004ab8a2:wasm-function[66]:0x2937f
    at as.onNotification (c:\Users\reyno\.vscode\extensions\rszyma.vscode-kanata-0.9.17\out\server.js:34:718)
    at c:\Users\reyno\.vscode\extensions\rszyma.vscode-kanata-0.9.17\out\server.js:34:6311

[Error - 12:18:32 PM] Notification handler 'textDocument/didOpen' failed with message: unreachable
[Error - 12:18:32 PM] Notification handler 'textDocument/didOpen' failed with message: recursive use of an object detected which would lead to unsafe aliasing in rust
Settings changed but vscode-kanata configuration hasn't changed
[Error - 12:18:40 PM] Notification handler 'textDocument/didChange' failed with message: recursive use of an object detected which would lead to unsafe aliasing in rust
[Error - 12:18:41 PM] Notification handler 'textDocument/didChange' failed with message: recursive use of an object detected which would lead to unsafe aliasing in rust
[Error - 12:18:42 PM] Notification handler 'textDocument/didSave' failed with message: recursive use of an object detected which would lead to unsafe aliasing in rust
[Error - 12:18:48 PM] Notification handler 'textDocument/didChange' failed with message: recursive use of an object detected which would lead to unsafe aliasing in rust
[Error - 12:18:49 PM] Notification handler 'textDocument/didSave' failed with message: recursive use of an object detected which would lead to unsafe aliasing in rust
[Error - 12:18:53 PM] Notification handler 'textDocument/didChange' failed with message: recursive use of an object detected which would lead to unsafe aliasing in rust
[Error - 12:18:54 PM] Notification handler 'textDocument/didSave' failed with message: recursive use of an object detected which would lead to unsafe aliasing in rust
[Error - 12:18:55 PM] Notification handler 'textDocument/didChange' failed with message: recursive use of an object detected which would lead to unsafe aliasing in rust
[Error - 12:18:56 PM] Notification handler 'textDocument/didSave' failed with message: recursive use of an object detected which would lead to unsafe aliasing in rust
error: Canceled: Canceled

and the third one is possible when there is an  error in the kbd file: starting with 1 opened workspaces
Settings changed but vscode-kanata configuration hasn't changed
Settings changed but vscode-kanata configuration hasn't changed
Settings changed but vscode-kanata configuration hasn't changed
Settings changed but vscode-kanata configuration hasn't changed
Config { includes_and_workspaces: Single, main_config_file: "kanata.kbd", def_local_keys_variant: Win, format: ExtensionFormatterOptions { enable: true, use_defsrc_layout_on_deflayers: true } }
workspace root: file:///c%3A/Users/reyno/kanata_keyboard
notification: initialized
notification: textDocument/didOpen
opening: file:///c%3A/Users/reyno/kanata_keyboard/kanata.kbd
Settings changed but vscode-kanata configuration hasn't changed
parsing file `/c%3A/Users/reyno/kanata_keyboard/kanata.kbd` resulted in error: `Found unknown configuration item`
added diagnostic for document: file:///c%3A/Users/reyno/kanata_keyboard/kanata.kbd
sending diagnostics for 1 files
notification: textDocument/didOpen
opening: file:///c%3A/Users/reyno/kanata_keyboard/Reynolds.kbd
parsing file `/c%3A/Users/reyno/kanata_keyboard/Reynolds.kbd` resulted in error: `Referenced unknown alias grl. Note that order of declarations matter.`
parsing file `/c%3A/Users/reyno/kanata_keyboard/kanata.kbd` resulted in error: `Found unknown configuration item`
added diagnostic for document: file:///c%3A/Users/reyno/kanata_keyboard/Reynolds.kbd
added diagnostic for document: file:///c%3A/Users/reyno/kanata_keyboard/kanata.kbd
sending diagnostics for 2 files
Settings changed but vscode-kanata configuration hasn't changed
notification: textDocument/didChange
notification: textDocument/didChange
notification: textDocument/didChange
notification: textDocument/didSave
parsing file `/c%3A/Users/reyno/kanata_keyboard/Reynolds.kbd` resulted in error: `Referenced unknown alias grl. Note that order of declarations matter.`
panicked at library/std/src/sys/wasm/../unsupported/os.rs:92:5:
not supported on this platform

Stack:

Error
    at S.exports.__wbg_new_abda76e883ba8a5f (c:\Users\reyno\.vscode\extensions\rszyma.vscode-kanata-0.9.17\out\server.js:34:2247)
    at wasm://wasm/004ab8a2:wasm-function[1088]:0xd1b39
    at wasm://wasm/004ab8a2:wasm-function[505]:0xbdc70
    at wasm://wasm/004ab8a2:wasm-function[763]:0xcd67f
    at wasm://wasm/004ab8a2:wasm-function[73]:0x49d23
    at wasm://wasm/004ab8a2:wasm-function[366]:0xb3bbd
    at wasm://wasm/004ab8a2:wasm-function[59]:0x13508
    at wasm://wasm/004ab8a2:wasm-function[66]:0x2845b
    at as.onNotification (c:\Users\reyno\.vscode\extensions\rszyma.vscode-kanata-0.9.17\out\server.js:34:718)
    at c:\Users\reyno\.vscode\extensions\rszyma.vscode-kanata-0.9.17\out\server.js:34:6311

[Error - 12:19:08 PM] Notification handler 'textDocument/didSave' failed with message: unreachable
error: Canceled: Canceled
rszyma commented 7 months ago

I'm not able to reproduce. Can you try some minimal config and see if you get crash for it too?

rszyma commented 6 months ago

Got it. Having defaliasenvcond in config causes crash, because environment variables are not implemented in wasm.

The best solution I can think of is to allow specifying env variables in vscode-kanata settings. And also support on kanata side would be needed, to allow implementing env provider backend. Something similar is already done with FileConfigProvider.