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
786 stars 38 forks source link

Make ltex.latex.commands more expressive #159

Open hchmr opened 2 years ago

hchmr commented 2 years ago

Is your feature request related to a problem? Please describe. TeX has weird hyphenation rules that prevents it from breaking hyphenated compound words such as 'high-performance'. The hyphenat package is used to trick TeX into hyphenating the constituent words in a hyphenated compound word. In my LaTeX document, I can write high\hyp{}performance and TeX will be able to hyphenate 'per·for·mance'. But because LTeX's parser replaces \hyp{} by an empty string I get the following diagnostic in my document:

'highperformance': Possible spelling mistake found. LTeX(MORFOLOGIK_RULE_EN_US)

In LTeX's settings, ltex.latex.commands can be used to change how the LaTeX parser should treat commands in the prose, but it is not expressive enough to give a rule for replacing \hyp{} with '-'.

Describe the solution you'd like Extend parser configuration to support arbitrary replacements, including replacing \hyp{} with '-'.

Describe alternatives you've considered I tried adding the rule "\\hyp{}": "dummy", but that prevents LanguageTool from checking the spelling of the individual words.

ainar commented 1 year ago

I agree. On top of that, replacing some environments and commands with "Dummy" or "Jimmy" is insufficient or can raise other problems related to genre (Jimmy is masculine), number (see PR https://github.com/valentjn/ltex-ls/pull/178), or just unknown words in some languages (example: commit https://github.com/valentjn/ltex-ls/commit/06b36051d28fd2c6ca832cd11880d1be1723c5c4 or issue https://github.com/valentjn/ltex-ls/issues/167).

Making dummy words (Dummy and Jimmy) configurable is a very simple, scalable, and durable solution. Let the user choose which word to use for which replacement. Then, language-specific placeholders could be added or configured by users.