Skip to content

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

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

JeanCASPAR
Copy link

@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:

Copy link

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.

Copy link

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`.
Copy link

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
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ace/autocomplete: Autocompletion does not trigger when typing \ in latex mode
1 participant