valentjn / ltex-ls

LTeX Language Server: LSP language server for LanguageTool :mag::heavy_check_mark: with support for LaTeX :mortar_board:, Markdown :pencil:, and others
https://valentjn.github.io/ltex
Mozilla Public License 2.0
716 stars 33 forks source link

Set `ltex.dictionary` and `ltex.disabledRules` in magic comments #271

Open igordertigor opened 10 months ago

igordertigor commented 10 months ago

I occasionally use files in which I have tables or uncommon acronyms. In these files, ltex complains: For tables, it warns me about having too many spaces, for acronyms, it believes that I have a spelling mistake. I could address both of these issues by globally setting ltex.disabledRules = ["WHITESPACE_RULE"] and ltex.dictionary = {"en-US": ["ACNY"]}. However, that would mean that multiple whitespaces will never be detected, which I want to avoid. Similarly, it would mean that my acronym is always accepted, although it would likely be a spelling mistake in almost all other contexts. As a result, I keep getting tons of error messages from ltex that I try to ignore and as a result I occasionally ignore something that I shouldn't have ignored.

For me it seems that the most straight forward solution here would be to allow more (all?) options to be set in magic comments. This would allow inserting a comment to disable the whitespace rule right before a table and revert to the old behaviour right after. It would also allow setting acronyms that only make sense in some documents but not in others.

For the whitespace behaviour, I could also see that attempting to detect tables and accepting whitespace in tables automatically would be an option, but that doesn't solve the other use case (or for example a case where one has item lists with non-sentence bullet points that should start lowercase).