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

language selection via \documentclass[german]{article} and similar #295

Open Reissner opened 8 months ago

Reissner commented 8 months ago

Is your feature request related to a problem? Please describe. The way ltex prefers to set the language for latex is to define it as a babel option. There is also a way to do with \selectlanguage or that like, but this is more with multi-language documents. For single language documents where \selectlanguage is not natural. Documentation of babel itself suggests to specify language via \documentclass as described in the headline because that way, language like german is set for related packages simultaneously. In my special case, I have a header file which shall be uniform and so I load babel without language option to keep generality. But exactly the form \documentclass[german]{article} preferred by babel is not recognized by ltex.

My workaround is to specify \selectlanguage{german} in addition to \documentclass[german]{article}, which is against single source principle and may introduce inconsistencies.

Describe the solution you'd like I would like ltex to recognize language options in \documentclass and switch language accordingly. For details see the documentation of babel.

Describe alternatives you've considered There is not much alternative. Maybe an addition: \PassOptionsToPackage{german}{babel} which preceeds \documentclass should work as well.

Additional context I think no further context is needed.