Skip to content
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

Improve LTeX support #2979

Merged
merged 5 commits into from
Jan 31, 2024
Merged

Improve LTeX support #2979

merged 5 commits into from
Jan 31, 2024

Conversation

metiulekm
Copy link
Contributor

This adds ConTeXt support as requested in #2663. It also makes LTeX work correctly in rnoweb, HTML, XHTML and git commit messages, as well as in plaintext (though this is not enabled by default).

Unfortunately language code `sweave` will not be understood by LTeX and
`rsweave` must be used, as can be seen in the source code here:
https://github.com/valentjn/ltex-ls/blob/16.0.0/src/main/kotlin/org/bsplines/ltexls/parsing/CodeFragmentizer.kt#L61
and here:
https://github.com/valentjn/ltex-ls/blob/16.0.0/src/main/kotlin/org/bsplines/ltexls/settings/Settings.kt#L185
LTeX will fall back to plaintext, but this will emit a warning and
provide slightly worse suggestions.
This mapping does not do anything, the `get_language_id` function will
just return `xhtml` by default.
LTeX will only understand `plaintext`:
https://github.com/valentjn/ltex-ls/blob/16.0.0/src/main/kotlin/org/bsplines/ltexls/parsing/CodeFragmentizer.kt#L70
though it will fall back to plain text when provided `text` as mapping,
but will output a warning when doing so.

Note that we do not enable the `text` filetype by default, as LTeX
itself does not do so. However, this filetype will not be useable
without this mapping anyway, so doing this makes using enabling this
manually slightly easier.
LTeX is launched whenever the filetype is on the preset list, but will
then verify the language ID against its list and will refuse to run if
the language ID is not on the list. The default can be seen in
https://github.com/valentjn/ltex-ls/blob/16.0.0/src/main/kotlin/org/bsplines/ltexls/settings/Settings.kt#L175
and somewhat matches the supported markup languages list.

The issue resolved by this commit comes from the fact that LTeX will
accept several aliases for each language, for instance it will handle
`gitcommit` and `git-commit` the same way. However, only `git-commit`
appears on the default enabled list. Since there is no `gitcommit ->
git-commit` mapping in `language_id_mapping`, LTeX will ignore
`gitcommit`. This could also be solved by adding this mapping, however
setting a default value of `ltex.enabled` has smaller change of breaking
existing configuration. Same situation happens for `xhtml`.
ConTeXt was requested in neovim#2663. LTeX is documented to enable it by
default, but this is not consistent with the default in the code:
https://github.com/valentjn/ltex-ls/blob/16.0.0/src/main/kotlin/org/bsplines/ltexls/settings/Settings.kt#L175
Regardless of this we will enable it by ourselves anyway.

We also enable HTML and XHTML as there already has been an attempt to
enable them previously, as there has been a mapping for `xhtml` in the
`language_id_mapping` array. HTML support is enabled in LTeX by default
anyway.
@metiulekm
Copy link
Contributor Author

Lint failed due to URLs in some commit messages. Should I remove them?

@glepnir glepnir merged commit 4f34f6f into neovim:master Jan 31, 2024
8 of 9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants