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
764 stars 33 forks source link

Support additional LaTeX commands and environments in ltex-ls #285

Open m-haug opened 10 months ago

m-haug commented 10 months ago

Is your feature request related to a problem? Please describe.

I'm using ltex-ls with LaTeX and the csquotes package in a German document. When using the csquotes command \foreignquote to insert quoted text in a foreign language, i.e., \foreignquote{british}{Some English text here}, I get diagnostics from ltex-ls in the English text. The diagnostic messages indicate that ltex-ls does not recognize the language change and is still applying the German ruleset.

Describe the solution you'd like

I would like ltex-ls to recognize the language changing commands and environments in the csquotes package.

Describe alternatives you've considered

I recognize that it may not be feasible for ltex-ls to support individual packages. As an alternative, I think my use case, and similar use cases, would be fulfilled by configuration options to add additional language changing commands and environments to ltex-ls. These could work by specifying a command and either a hardcoded or dynamic language to switch to inside a text argument.

For now, I'm working around the issue by using the roughly equivalent command sequence \foreignlanguage{british}{\enquote{Some English text here}}. However, the nested commands are not as nice as using a single command to do both things.