-
Notifications
You must be signed in to change notification settings - Fork 35
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
Code action constantly suggests 'Update the Table of Contents', even when it is updated #52
Comments
@David-Else yeah, we definitely should do it! @keynmol do you think you'll get to #22 soonish? If not, I can take a stab at this issue myself. |
Once #22 is merged and no further regressions are found (the whole damn thing is a regression), I can take a look at this a) it was detected in the workspace It will be a bit harder than I initially assumed because on first opening of the document one will need to parse and reconstruct the TOC, and do that on every document change (because nothing stops you from manually modifying the TOC) |
So it will auto-update the TOC on save? That would be better, then there is no need for the update TOC code action. Nobody wants a wrong TOC, and having to remember to update it all the time, auto-update is a much better solution :) |
That's a good point. I guess we could hook into willSaveWaitUntil request to do the necessary TOC update on save. But I think we'll still need a standalone code action too. |
Yeah, it can be a configurable thing - I'm about 50/50 on automatically updated TOC, as I prefer to be in control of edits sent from the LSP, but also I like the convenience. |
@keynmol you gotta let go and submit to the machines man 😉 Seriously tho, I'm fine with a config in this case but we need to keep in mind that every config option adds more variability to the server's behavior, hence less testing and eyeballing for a particular set of configurations. |
The original problem with constantly suggesting to "Update TOC" is resolved now. Updating TOC "on save" feels like a separate feature. @David-Else feel free to open an issue for this if it's something you care about. |
Cheers! I will test it when it gets released in a new version. You can close the issue, or I will after I test the fix. |
Great work, thanks! Unfortunately I do have a small problem, not sure the best solution. If Marksman creates a TOC, for example:
All is well, no code action spam... but when I format with Prettier using default settings it inserts a space at the top:
Now marksman sees it as a change and starts the update spam. I have tried adding As I have format on save enabled this is a real problem. I hate to ask, but any chance it could be addressed? As Prettier is the main tool used by many to format markdown, maybe the space could be added when the TOC is created? It would be best formatted with spaces on either side, as that is what Prettier will do if you create many spaces before
|
I had no idea there are formatters for markdown :) This seems to be a very strange formatting on Prettier side - do you know what is it trying to do? I.e. what is the particular benefit of producing this newline after comment but not after the end of block of links.. Also, I just found this issue: prettier/prettier#10128 which seems to me that this behaviour of Prettier causes issues in other extensions as well. Both adding newlines and preserving them when detecting TOC is probably not a massive amount of work, I just feel it will be done for the wrong reasons (circumventing a 3rd party plugin behaviour which is seen as a problem by others) |
Let's fork this into a separate issue #60 |
Cool language server! :)
With marksman
2022-08-19
on Linux and Neovim I create a table of contents. I have nvim-lightbulb installed. Now the lightbulb is constantly lit (wherever my cursor is) telling me there is a code action to 'Update the Table of Contents', even when non of the headings have changed.Is it possible to only announce this code action when a relevant item has changed? Thanks.
The text was updated successfully, but these errors were encountered: