we have successful JSON parsing, object query, object construction and serialization.
now to provide an actual service. the most important thing is colorization, so that's first.
we have successful JSON parsing, object query, object construction and serialization.
now to provide an actual service. the most important thing is colorization, so that's first.
it's beginning to work!
numbers and strings are not being highlighted correctly yet, don't know why.
also, apparently tokens are not allowed to span multiple lines¹, so i need to fix up this part as well.
more tomorrow.
—
¹ multiline tokens can be supported by clients, but the server needs coverage for the fallback so why maintain two paths?
how does LSP encode text file positions: UTF-8? (what sxpp uses) UTF-32? (also sensible i guess)
neither. (well since 3.17 yes, but only if the client feels that way)
it's UTF-16. UTF-16 support is mandatory. why? because it's a damn microsoft protocol that's why¹. 😫
fortunately character offsets are line-relative so fixing that up is not too expensive.
—
¹ yes it's also because Javascript.
the way sxpp's streaming lexer (tokenizer) works, UTF-16 and UTF-32 input streams are already supported.
since all controlling characters are well below 0x7f, and the lexer doesn't output strings, only token types and locations, you can just feed it 0xff clamped chars, and then offsets and positions are implicitly correct.
i went on IRC and asked around on the kate channel, and we browsed a bit of source code together, and --
so it turns out Kate's LSP client simply doesn't highlight strings, numbers and operators.
i filed a ticket with the project, let's see how it goes.
@lritter arguably, for constructs produced by the tokenizer or the parser, but not the semantic analyzer, that's not the LSP's job.
LSP is supposed to give _semantic_ highlighting (so e.g. for C++, for an identifier, clangd will assign a semantic category like "data member", "parameter", "local variable", etc.).
for _syntax_ highlighting, we only need the abstract syntax tree, and for that, modern editors depend on tree-sitter.
@JamesWidman
it absolutely is the LSP's job - or else "string", "number" and "operator" wouldn't be officially recognized tokens.
but i understand the history of it. by now it's just history though. because this is the fucking pitch they give:
@lritter this is a little tangential, but: lots of interesting language-agnostic editor features have been enabled for the case where the editor has a syntax tree provided by the treesitter API; e.g.:
- text selection based on the range of a tree node;
- the ability to move the cursor to certain kinds of nodes (e.g. "jump to next/previous parameter")
-search-and-replace based on tree structure patterns;
etc.
it might be nice if the editor could get that parse tree from the LSP server though.
@lritter THAT i strongly feel. i old-school wrote text log files with all the interactions and tried to find the issues.
You did advertise that you support semantic tokens in your initialize msg, right? (see img)
in vscode you need to have "editor.semanticHighlighting.enabled": true (but that's the default)
depending on range/full you should either see textDocument/semanticTokens/full or textDocument/semanticTokens/range messages for your open document
@lritter Try testing it with emacs? It's LSP packages have some diagnostic abilities. And since the callers of the lsp code are just add on lisp packages with source, you can single step, look at variables in the lsp-calling code, interactively call functions used for lsp and see the results, etc.
@lritter and this, kids, is a great example of a repeating pattern in all kinds of domains:
LSP the idea: great
LSP the reality: questionable
We can now continue our discussion of if mediocre realizations of good ideas are a net win or a net loss for the community. This has a lot of nuance and I expect 3 scrolls until next Tuesday, dismissed!
@lritter I meant that sometimes it's not easy to build abstractions that keep the questionable design decisions at bay.
Like, if you try to abstract OpenGL (before direct state access) in a way that doesn't leak global state dependency, you only had bad choices basically. Slower perf, not playing ball with 3rd party code, etc..
That means OpenGL's "bad decisions" are your problem as well, in a viral way.
But LSP's "bad decisions" were confined to a corner in my code.
@artificialmind i see.
well it could always be worse: https://lv2plug.in/ (the linux VST analog from hell)
@lritter
> LV2 has a simple core interface
it can't be bad if it's simple right!! because simple == good!
@lritter I step into things and inspect state quite often, multiple times a day at least.
I guess if there was a good graphical external debugger that I could get used to that would work as well.