typst-lsp
typst-lsp copied to clipboard
LSP Exits On Editing CJK Characters
- editor: neovim
- LSP Plugins: nvim-cmp, lspconfig, mason, mason-lspconfig
- LSP version: 0.9.5
- OS version and name: macOS 13.5.1
- I am on the latest stable version of the extension/LSP.
- I have searched the issues of this repo and believe that this is not a duplicate.
Issue
LSP exits on editing Chinese/Japanese/Korean characters.
Reproduction
- open a
.typfile with typst_lsp attached to the buffer - do nothing, lsp stays calm
- enter some English, lsp works fine
- enter, delete a CJK character, or enter insert mode on it, lsp exists
Note that this error may need a few attempts of step 4 to reproduce, but it would be very common in a context of editing CJK contents. Restarting lsp or neovim did not help.
I have not tested other languages, they might be bugged as well.
Logs
Logs are the same for errors on C, J and K chars.
[START][2023-08-30 23:03:10] LSP logging initiated
[WARN][2023-08-30 23:03:10] ...lsp/handlers.lua:137 "The language server typst_lsp triggers a registerCapability handler despite dynamicRegistration set to false. Report upstream, this warning is harmless"
[ERROR][2023-08-30 23:03:21] .../vim/lsp/rpc.lua:734 "rpc" "/Users/steve/.local/share/nvim/mason/bin/typst-lsp" "stderr" "thread 'main' panicked at 'called `Option::unwrap()` on a `None` value', src/lsp_typst_boundary.rs:97:58\nnote: run with `RUST_BACKTRACE=1` environment variable to display a backtrace\n"
This bug completely defeats CJK editing in typst, so help or fix is needed ASAP.
Current workaround using vscode built-in workspace task and typst watch file.typ:
"tasks": {
"version": "2.0.0",
"tasks": [
{
"label": "Typst - 编译当前文件",
"type": "shell",
"command": "typst",
"args": [
"compile",
"${fileBasename}",
"${fileBasenameNoExtension}.pdf"
],
"group": "build",
"presentation": {
"reveal": "always"
},
"options": {
"cwd": "${fileDirname}"
},
"problemMatcher":{
"owner": "typst",
"fileLocation":"absolute",
"pattern":[
{
"regexp": "^(error|info|hint|warning):\\s(.*:\\s.*)",
"message": 2,
"severity": 1,
},
{
"regexp": "(?:\\s+┌─\\s\\\\+\\?\\\\)(\\w:.*):(\\d+):(\\d+)",
"file": 1,
"line": 2,
"column": 3
}
]
}
},
{
"label": "Typst - 实时增量编译当前文件",
"type": "shell",
"command": "typst",
"isBackground": true,
"args": [
"watch",
"${fileBasename}"
],
"group": {
"kind": "test",
"isDefault": true
},
"presentation": {
"reveal": "silent"
},
"options": {
"cwd": "${fileDirname}"
},
"problemMatcher": {
"owner": "typst",
"fileLocation": "absolute",
"pattern": [
{
"regexp": "^(error|info|hint|warning):\\s(.*:\\s.*)",
"message": 2,
"severity": 1,
},
{
"regexp": "(?:\\s+┌─\\s\\\\+\\?\\\\)(\\w:.*):(\\d+):(\\d+)",
"file": 1,
"line": 2,
"column": 3
}
],
"background": {
"activeOnStart": true,
"beginsPattern": "^\\[\\d+:\\d+:\\d+\\]\\scompiled.*",
"endsPattern": "\\s+│.*\\^+$"
}
}
}
]
}
@lyc-Lacewing are there any more LSP logs, particularly logs from when the language server was initializing? This is likely an encoding issue, and the encoding is decided at initialization.
@lyc-Lacewing are there any more LSP logs, particularly logs from when the language server was initializing? This is likely an encoding issue, and the encoding is decided at initialization.
The log was obtained by :LspLog, which opens ~/.local/state/nvim/lsp.log. At the first line you can see [START], which is when I executed :LspStart, and lsp logging started from there. Please tell me if you know other locations.
And thanks, KagaJiankui, but I'm using neovim.
And thanks, KagaJiankui, but I'm using neovim.
Typst supports typst watch file.typ out.pdf, and the CLI output can be configured via CLI options(you may use typst watch --help). You can use LuaSnip to make an workaround.
Typst supports
typst watch file.typ out.pdf, and the CLI output can be configured via CLI options(you may usetypst watch --help). You can use LuaSnip to make an workaround.
Didn't know LuaSnip can do that, thanks again! However this approach does not enable LSP features, so a fix is still needed.
Update: the bug can be triggered by placing cursor on a CJK char, not even editing.