diff --git a/kallithea/lib/pygmentsutils.py b/kallithea/lib/pygmentsutils.py --- a/kallithea/lib/pygmentsutils.py +++ b/kallithea/lib/pygmentsutils.py @@ -78,3 +78,15 @@ def get_index_filenames(): filenames.append(f) return filenames + + +def get_custom_lexer(extension): + """ + returns a custom lexer if it's defined in rcextensions module, or None + if there's no custom lexer defined + """ + import kallithea + #check if we didn't define this extension as other lexer + if kallithea.EXTENSIONS and extension in kallithea.EXTENSIONS.EXTRA_LEXERS: + _lexer_name = kallithea.EXTENSIONS.EXTRA_LEXERS[extension] + return lexers.get_lexer_by_name(_lexer_name)