elijah-potter / harper

The Grammar Checker for Developers
https://writewithharper.com
Apache License 2.0
1.51k stars 30 forks source link

[ Question ] Is it possible to stop the server if too many errors are found? #119

Closed OXY2DEV closed 2 months ago

OXY2DEV commented 2 months ago

Problem

When opening CHANGELOG.md files harper-ls can cause everything else to halt(most likely caused by Neovim waiting for the response from the LSP).

Is it possible for the server to stop sending more responses if there are too many errors detected?

Or is it possible to only send part of the buffer text(current context can be retrieved from tree-sitter, as it should be much faster) to the LSP instead of sending the entire buffers text?

elijah-potter commented 2 months ago

That's an excellent question. With current builds of Harper, this is not the case. I'd love a copy of the kinds of files you are opening, so I can get a better handle on the issue (and hopefully solve it!)

OXY2DEV commented 2 months ago

Any significantly largeCHANGELOG.md file should be enough.

In my case, noice.nvim's CHANGELOG.md file would cause it to get slow.

But you could also test it with other popular plugin's CHANGELOG files too.

elijah-potter commented 2 months ago

I looked into this and it seemed to be a pretty significant performance issue (some caches were getting busted WAY too often). I've made some changes that are in the v0.10.0 release. Once Mason has picked them up, would you give it spin?

OXY2DEV commented 2 months ago

Screenshot_2024-08-31-23-53-56-167_com termux-edit Diagnostics not being removed even though they are disabled on insert mode.

It looks like performance has improved by quite a bit. However, it still not bullet-proof yet, as diagnostics seems to struggle a bit(but that could be a hardware limitation).

I would have preferred if it was possible to only send part of the buffer(specifically 200 lines around the cursor) to make LSPs faster but I guess that's not a solution.

Anyway, thanks for fixing the issue! I will close the issue.


On a side note, is it possible to add my own dictionary to the LSP?

For example, @param commonly used in luaCATS annotations is picked up by this LSP leading to a lot of "misspelling" being shown on the screen on large files.

elijah-potter commented 2 months ago

On a side note, is it possible to add my own dictionary to the LSP?

There should be a code action on spelling errors to add to a personal dictionary. Let me know if that's not working for you.

For example, @param commonly used in luaCATS annotations is picked up by this LSP leading to a lot of "misspelling" being shown on the screen on large files.

This is a larger problem. Harper should ignore these by default. Would you mind opening a new issue with a couple examples of this?

OXY2DEV commented 2 months ago

There should be a code action on spelling errors to add to a personal dictionary. Let me know if that's not working for you.

I am quite new to programming so I wasn't aware of Code actions.

Yes, it works.

Would you mind opening a new issue with a couple examples of this?

I have opened a new issue about this.