Skip to content

Add snippet support for LaTeX and custom macro completer.#5840

Open
JeanCASPAR wants to merge 1 commit intoajaxorg:masterfrom
JeanCASPAR:latex-completer
Open

Add snippet support for LaTeX and custom macro completer.#5840
JeanCASPAR wants to merge 1 commit intoajaxorg:masterfrom
JeanCASPAR:latex-completer

Conversation

@JeanCASPAR
Copy link
Copy Markdown
Contributor

@JeanCASPAR JeanCASPAR commented Jul 5, 2025

Issue #, if available:
Fix #5834.

Description of changes:
The snippets are copied from the snippets for TeX. The default keywordCompleter is unused in LaTeX mode because the highlight rules do not give a list of keywords, but color every LaTeX macro, so the completer cannot use the rules to provide completion. This macro completer is inspired from the text completer, but complete only macros (the current text completer do not consider \ to be a part of a word).

The interface of Completer is changed so that the keywordCompleter can forward the triggerCharacters and identifiersRegexps of session.$mode.completer. I don't know if this change is backward compatible, but I do not see any other way to achieve this goal. Maybe we can provide a better way for a mode to propose a completer than using keywordCompleter ?

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Pull Request Checklist:

@github-actions
Copy link
Copy Markdown

github-actions bot commented Jul 6, 2025

One of the public type files has been updated, plase make sure there are no backwards incompatible changes done in the PR.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Jul 6, 2025

One of the public type files has been updated, plase make sure there are no backwards incompatible changes done in the PR.

@JeanCASPAR JeanCASPAR marked this pull request as ready for review July 6, 2025 10:16
The snippets are copied from the snippets for TeX. The current keywordCompleter for LaTeX is unused because the highlight rules do not give a list of keywords, but color every LaTeX macro, so the completer cannot use the rules to provide completion. This macro completer is inspired by the text completer, but autocomplete only macros (the current text completer do not consider \ to be a part of a word). The interface of Completer is changed so that the keywordCompleter can forward the triggerCharacters and identifiersRegexps of `session.$mode.completer`.
@github-actions
Copy link
Copy Markdown

github-actions bot commented Jul 6, 2025

One of the public type files has been updated, plase make sure there are no backwards incompatible changes done in the PR.

@JeanCASPAR
Copy link
Copy Markdown
Contributor Author

Also, the current mechanism of identifierRegexps is quite unsatisfactory : as we pass a macro that test every character separately, is it impossible for the function getCompletionPrefix in src/autocomplete/util.js to return only \macro2 if I type \macro1\macro2, so I cannot get autocompletion when typing \macro2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant