Skip to content
This repository has been archived by the owner on Nov 5, 2024. It is now read-only.

index out of range error when using semanticTokens #521

Open
koopa1338 opened this issue Oct 20, 2024 · 1 comment
Open

index out of range error when using semanticTokens #521

koopa1338 opened this issue Oct 20, 2024 · 1 comment

Comments

@koopa1338
Copy link

  • Component:
    • LSP used with neovim
      NVIM v0.10.2
      Build type: Release
      LuaJIT 2.1.1713484068
  • LSP version:
    Version: 0.13.0, commit 69cdef3bd74a908dc2677d8a7edbc7ce533edbaa (Typst version 0.11.0)
  • OS version and name: Gentoo Linux with kernel version 6.6.47

Issue

When opening a typ file I get this error:

Error executing vim.schedule lua callback: .../share/nvim/runtime/lua/vim/lsp/semantic_tokens.lua:308: .../share/nvim/runtime/lua/vim/lsp/semantic_tokens.lua:153: index out of range
stack traceback:
	[builtin#36]: at 0x558343e5ae70
	.../share/nvim/runtime/lua/vim/lsp/semantic_tokens.lua:308: in function 'handler'
	.../share/nvim/runtime/lua/vim/lsp/client.lua:687: in function ''
	vim/_editor.lua: in function <vim/_editor.lua:0>

The issue is triggered in the function tokens_to_range, when converting the column index to a byte index regarding the encoding provided by the client. In some cases the converted index is out of range and results in an error. I am unsure if this is a bug in neovim or in how the semantic tokens mode of typst-lsp is handling this. I don't know which lsp has also semantic tokens mode that I could test with my environment, if someone has one in mind, I would test it.

I tried to disable the mode but that didn't work for unknown reasons:

settings = {
  exportPdf = "never",
  semanticTokens = "disable",
}

Logs

The lsp logs only show a warning that shouldn't be related to this issue:

[START][2024-10-20 22:04:21] LSP logging initiated
[WARN][2024-10-20 22:04:21] ...lsp/handlers.lua:135	"The language server typst_lsp triggers a registerCapability handler for workspace/didChangeConfiguration despite dynamicRegistration set to false. Report upstream, this warning is harmless"
@CuSO4Deposit
Copy link

Downgrading neovim may mitigate this problem.

Related: neovim/neovim#30675

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants