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 lsp-mode and/or racket-langserver? #59

Open
fosskers opened this issue Apr 15, 2022 · 1 comment
Open

Clashes with lsp-mode and/or racket-langserver? #59

fosskers opened this issue Apr 15, 2022 · 1 comment

Comments

@fosskers
Copy link

Hi there, thanks for this great project; it makes writing Lisps a lot more pleasureful.

I've hit a situation where some or all of racket-mode, lsp-mode, parinfer-rust-mode, and the underlying Racket LSP racket-langserver seem to be fighting. Here's the sister issue to this that I opened with the LSP.

Basically, I've noticed that sometimes following a paren change made by parinfer, the LSP thinks I have unbalanced parens. Upon save (and thus auto-reformat) the code gets reformatted by the LSP quite strangely, as if a paren had indeed been missing. The LSP then won't go back to normal operation until I restart it completely. Since this happens every few minutes, it's making the dev experience a bit jarring 😆

Theorizing elsewhere, peers have pointed out:

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.
I recall that being an issue with some other editing package, but can't remember which. aggressive-indent, maybe?

and

It's not unusual to do:
(let ((inhibit-modification-hooks t))
...do the thing...)
To prevent clobbering hooks or infinite recursion, but rarely are they triggered afterwards, which would resolve this issue. Using combine-change-calls or combine-after-change-calls would get around that.

Does any of this sound familiar? Thank you kindly.

@justinbarclay
Copy link
Owner

Hi @fosskers,
I disable inhibit-modification-hooks specifically for the reason to avoid clobbering hooks or causing infinite recursion. Though, I am not sure if my use case is entirely valid.

Unfortunately my next 3 weeks are kind of full and I don't have much time to look into this. However, if you want to, you could look at https://github.com/justinbarclay/parinfer-rust-mode/blob/main/parinfer-rust-mode.el#L404 and either completely remove that line. Or wrap L404-427 in a combine-after-change-calls. If you do either of those and they work for you, I'm happy to look at a PR when I have free time again :)

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

2 participants