euporie.core.widgets.inputs.PygmentsLexer

class euporie.core.widgets.inputs.PygmentsLexer(pygments_lexer_cls: type[PygmentsLexerCls], sync_from_start: FilterOrBool = True, syntax_sync: SyntaxSync | None = None)

Lexer that calls a pygments lexer.

Example:

from pygments.lexers.html import HtmlLexer
lexer = PygmentsLexer(HtmlLexer)

Note: Don’t forget to also load a Pygments compatible style. E.g.:

from prompt_toolkit.styles.from_pygments import style_from_pygments_cls
from pygments.styles import get_style_by_name
style = style_from_pygments_cls(get_style_by_name('monokai'))
Parameters:
  • pygments_lexer_cls – A Lexer from Pygments.

  • sync_from_start – Start lexing at the start of the document. This will always give the best results, but it will be slow for bigger documents. (When the last part of the document is display, then the whole document will be lexed by Pygments on every key stroke.) It is recommended to disable this for inputs that are expected to be more than 1,000 lines.

  • syntax_syncSyntaxSync object.