Closed adrianchong518 closed 11 months ago
The error might come from here: https://github.com/jeapostrophe/racket-langserver/blob/3f23f437eac0206a45abe79e0edc2d1a3ed48161/doc.rkt#L276
indenter
is a function of this type:
(-> (is-a?/c racket:text<%>)
exact-nonnegative-integer?
(or/c #f exact-nonnegative-integer?))
but doc-text
is a lsp-editor%
object. I think add a new method to lsp-editor%
called like indent
can solve it.
I made a change: https://github.com/6cdh/racket-langserver/tree/fix-formatting please try it
I've tried it and it works! (It looks like a simple fix in hindsight, but I just couldn't get my head around how all the things go together 🙃 )
In an older version, doc-text
is a text%
object, and the code is correct.
But then I refactored that wrapped text%
object in lsp-editor%
class, that is the core
variable.
That was a mistake to leave that line of code unchanged.
So this change basically replace doc-text
with core
. core
is a class private variable, so I added a new method.
I have set up racket-langserver with neovim via nvim-lspconfig.
When I try to format code via
:lua vim.lsp.buf.format()
, the code is not formatted and a "method not found" exception can be seen in the logs.Here is the complete log (
:LspLog
):And a formatted version:
After a brief look at the relevant code, I assume that the
position-paragraph
method should be called on aracket:text%
object, but somehow anlsp-editor%
is used. I believe that there are some issues with how theindenter
passed intoindent-line!
works.However, my limited experience with Racket (as I'm still starting out) prevented me to dive deeper into how the whole thing works. Some help is greatly appreciated!