Open smileboywtu opened 8 years ago
it seems the editor use the lexer to decide the file type:
return BufferControl(lexer=DocumentLexer(editor_buffer),
input_processors=input_processors,
highlighters=highlighters,
buffer_name=buffer_name,
preview_search=preview_search,
wrap_lines=wrap_lines,
focus_on_click=True)
lexer.py
def get_tokens(self, cli, text):
"""
Call the lexer and return the tokens.
"""
location = self.editor_buffer.location
if location:
# Create an instance of the correct lexer class.
try:
lexer = get_lexer_for_filename(location, stripnl=False, stripall=False, ensurenl=False)
except ClassNotFound:
pass
else:
return lexer.get_tokens(text)
return [(Token, text)]
how to change the lexer dynamically with key binding? anyone who can help me ?
when edit the source file, like example.py it work well, but when i rename the name to example with no suffix but the grammar is python, the editor with no highlight color. atom and vim plugin works well.