yegappan / lsp

Language Server Protocol (LSP) plugin for Vim9
MIT License
484 stars 56 forks source link

LspFold breaks on typst file using tinymist lsp #554

Closed jmdevin closed 1 month ago

jmdevin commented 2 months ago

Steps to Reproduce

  1. Using the (tinymist lsp), open the following file (it is only one line, no blank line after):
    # Heading
  2. Do :LspFold
  3. See this error:
    Error detected while processing function lsp#lsp#FoldDocument[12]..<SNR>56_FoldRange:
    line   23:
    E16: Invalid range: :2, 2fold

    I know that this probably counts as a tinymist bug as well, but I believe this plugin should check whether a range of lines exists before trying to fold it, that way it can be ignored or maybe a better error message can be displayed.

    Additional details

    Server setup

    g:LspAddServer(
    [
        {
            name: 'tinymist-typst-lsp',
            filetype: ['typ', 'typst',],
            path: $HOME .. '/bin/tinymist',
            initializationOptions: {
                'exportPdf': 'onType',
                'formatterMode': "typstyle",
            },
        },
    ]
    )

    Tinymist version

    Build Timestamp:     2024-08-26T16:22:10.986712173Z
    Build Git Describe:  v0.11.20
    Commit SHA:          1f9a42c2e863f6b1fe8624da796e47adf44a9a83
    Commit Date:         None
    Commit Branch:       None
    Cargo Target Triple: x86_64-unknown-linux-gnu
    Typst Version:       0.11.1

    Vim version

    9.1.0689

yegappan commented 1 month ago

Thanks for reporting the issue. This should be addressed by ce7ce83368439e146b20afe6f907076447d3eb0e.