class_docstr: 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'))
  
  :param pygments_lexer_cls: A `Lexer` from Pygments.
  :param 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.
  :param syntax_sync: `SyntaxSync` object.
class_docstr_tok: ["Lexer","that","calls","a","pygments","lexer",".","Example",":",":","from","pygments.lexers.html","import","HtmlLexer","lexer","=","PygmentsLexer","(","HtmlLexer",")","Note",":","Do","n'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","'",")",")",":","param","pygments_lexer_cls",":","A","`","Lexer","`","from","Pygments",".",":","param","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",".",":","param","syntax_sync",":","`","SyntaxSync","`","object","."]
docstr: Create a `Lexer` from a filename.
docstr_tok: ["Create","a","`","Lexer","`","from","a","filename","."]
code: def from_filename(
      cls, filename: str, sync_from_start: FilterOrBool = True
  ) -> Lexer:
      """
      Create a `Lexer` from a filename.
      """
      # Inline imports: the Pygments dependency is optional!
      from pygments.lexers import get_lexer_for_filename
      from pygments.util import ClassNotFound
  
      try:
          pygments_lexer = get_lexer_for_filename(filename)
      except ClassNotFound:
          return SimpleLexer()
      else:
          return cls(
              pygments_lexer.__class__, sync_from_start=sync_from_start
          )
  
imports: from __future__ import annotations
  import re
  from abc import ABCMeta, abstractmethod
  from typing import TYPE_CHECKING, Callable, Dict, Generator, Iterable, Tuple
  from prompt_toolkit.document import Document
  from prompt_toolkit.filters import FilterOrBool, to_filter
  from prompt_toolkit.formatted_text.base import StyleAndTextTuples
  from prompt_toolkit.formatted_text.utils import split_lines
  from prompt_toolkit.styles.pygments import pygments_token_to_classname
  from .base import Lexer, SimpleLexer
label_desc: Use image node_id 2 for calling the PygmentsLexer obj's underlying member method code with example usage: obj.from_filename(cls, filename, sync_from_start) and returns: cls, SimpleLexer