move language priorities into separate file
This commit is contained in:
parent
723dd42fa9
commit
0f02aa91b7
2 changed files with 21 additions and 8 deletions
18
wakatime/language_priorities.py
Normal file
18
wakatime/language_priorities.py
Normal file
|
@ -0,0 +1,18 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
wakatime.language_priorities
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Overwrite pygments Lexer.priority attribute for specific languages.
|
||||
|
||||
:copyright: (c) 2017 Alan Hamlett.
|
||||
:license: BSD, see LICENSE for more details.
|
||||
"""
|
||||
|
||||
|
||||
LANGUAGES = {
|
||||
'typescript': 0.11,
|
||||
'perl': 0.1,
|
||||
'perl6': 0.1,
|
||||
'f#': 0.1,
|
||||
}
|
|
@ -16,6 +16,7 @@ import sys
|
|||
|
||||
from .compat import u, open
|
||||
from .dependencies import DependencyParser
|
||||
from .language_priorities import LANGUAGES
|
||||
|
||||
from .packages.pygments.lexers import (
|
||||
_iter_lexerclasses,
|
||||
|
@ -307,15 +308,9 @@ def custom_pygments_guess_lexer_for_filename(_fn, _text, **options):
|
|||
return result[-1][1](**options)
|
||||
|
||||
|
||||
CUSTOM_PRIORITIES = {
|
||||
'typescript': 0.11,
|
||||
'perl': 0.1,
|
||||
'perl6': 0.1,
|
||||
'f#': 0.1,
|
||||
}
|
||||
def customize_priority(lexer):
|
||||
"""Return an integer priority for the given lexer object."""
|
||||
|
||||
if lexer.name.lower() in CUSTOM_PRIORITIES:
|
||||
lexer.priority = CUSTOM_PRIORITIES[lexer.name.lower()]
|
||||
if lexer.name.lower() in LANGUAGES:
|
||||
lexer.priority = LANGUAGES[lexer.name.lower()]
|
||||
return lexer
|
||||
|
|
Loading…
Reference in a new issue