Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clashes with parinfer? #77

Open
fosskers opened this issue Apr 14, 2022 · 7 comments
Open

Clashes with parinfer? #77

fosskers opened this issue Apr 14, 2022 · 7 comments

Comments

@fosskers
Copy link

fosskers commented Apr 14, 2022

Hi there, thanks for a great project.

I've hit a situation where the LSP and what I think is parinfer are getting into fights, and this is confusing the LSP. Every few minutes, the LSP seems to lose track of matched parens, and I get errors like the following that won't go away until I restart the LSP:

lsp

As you can see, there are no actual mismatched parens in the buffer. If I attempt to save the buffer in this state, the code is often reformatted very strangely (as if there had been a missing paren) and I have to manually correct everything, restart the LSP, then continue.

Do you have an idea as to what might be happening here? Thank you kindly. 🙏

@fosskers fosskers changed the title Clashes with paredit? Clashes with parinfer? Apr 14, 2022
@dannypsnl
Copy link
Contributor

Is parinfer a LSP client? How did it provide buffer to server? It's hard to answer your question without these. And maybe magic-racket would be a nice reference?

@fosskers
Copy link
Author

Is parinfer a LSP client?

It's not, but it does watch the buffer and make automatic corrections based on where parens go. I should have mentioned that I'm using Emacs (so Magic Racket is not available to me), and parinfer is well-used there.

@dannypsnl
Copy link
Contributor

I think I'm lost now, does the problem come from parinfer cooperating with racket-langserver? If so, then how does it pass the buffer? I don't think racket-langserver works with a partial buffer.

And On Emacs, a choice is racket-mode.

@fosskers
Copy link
Author

Ah let me clarify. I am using racket-mode, which is a "major mode", but Emacs also has "minor modes" which run alongside the majors. parinfer is such a minor mode. Its job is to guarantee that parens always match, and it will automatically rebalance parens when an opening paren is added/deleted.

To my knowledge, parinfer and racket-langserver don't directly interact. I reported the issue here because it's the LSP that's reporting the weird errors and "stalling", but there's a chance it's not solely at fault. It's also the LSP that's doing the strange reformatting based on confusion over parens, and I only notice it doing that immediately after parinfer has added/deleted parens on its own.

Did that clarify the issue?

@fosskers
Copy link
Author

A comment from the Doom Emacs maintainer:

Just a hunch, but it sounds like parinfer is modifying the buffer without triggering the modification hooks lsp-mode uses to report buffer changes to the server, so the server is operating on a stale buffer.

@jryans
Copy link
Contributor

jryans commented Apr 15, 2022

AFAIK, racket-mode doesn’t use LSP (or this library), so are you using both racket-mode and some Emacs LSP client at the same time?

@fosskers
Copy link
Author

fosskers commented Apr 15, 2022

Yes. The full answer is that I'm using the racket module in Doom Emacs, which includes lsp-mode. It's this lsp-mode that hooks into racket-langserver when in an .rkt buffer.

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

No branches or pull requests

3 participants