mirror of
https://github.com/wakatime/sublime-wakatime.git
synced 2023-08-10 21:13:02 +03:00
Compare commits
9 Commits
Author | SHA1 | Date | |
---|---|---|---|
a290e5d86d | |||
d5b922bb10 | |||
ec7b5e3530 | |||
aa3f2e8af6 | |||
f4e53cd682 | |||
aba72b0f1e | |||
5b9d86a57d | |||
fa40874635 | |||
6d4a4cf9eb |
1
AUTHORS
1
AUTHORS
@ -13,3 +13,4 @@ Patches and Suggestions
|
||||
|
||||
- Jimmy Selgen Nielsen <jimmy.selgen@gmail.com>
|
||||
- Patrik Kernstock <info@pkern.at>
|
||||
- Krishna Glick <krishnaglick@gmail.com>
|
||||
|
13
HISTORY.rst
13
HISTORY.rst
@ -3,6 +3,19 @@ History
|
||||
-------
|
||||
|
||||
|
||||
7.0.23 (2017-09-14)
|
||||
++++++++++++++++++
|
||||
|
||||
- Add "include" setting to bypass ignored files. #89
|
||||
|
||||
|
||||
7.0.22 (2017-06-08)
|
||||
++++++++++++++++++
|
||||
|
||||
- Upgrade wakatime-cli to v8.0.3.
|
||||
- Improve Matlab language detection.
|
||||
|
||||
|
||||
7.0.21 (2017-05-24)
|
||||
++++++++++++++++++
|
||||
|
||||
|
@ -50,4 +50,10 @@ Add the line: `"debug": true`
|
||||
Then, open your Sublime Console with `View → Show Console` ( CTRL + \` ) to see the plugin executing the wakatime cli process when sending a heartbeat.
|
||||
Also, tail your `$HOME/.wakatime.log` file to debug wakatime cli problems.
|
||||
|
||||
For more general troubleshooting information, see [wakatime/wakatime#troubleshooting](https://github.com/wakatime/wakatime#troubleshooting).
|
||||
The [How to Debug Plugins][how to debug] guide shows how to check when coding activity was last received from your editor using the [User Agents API][user agents api].
|
||||
For more general troubleshooting info, see the [wakatime-cli Troubleshooting Section][wakatime-cli-help].
|
||||
|
||||
|
||||
[wakatime-cli-help]: https://github.com/wakatime/wakatime#troubleshooting
|
||||
[how to debug]: https://wakatime.com/faq#debug-plugins
|
||||
[user agents api]: https://wakatime.com/developers#user_agents
|
||||
|
@ -7,7 +7,7 @@ Website: https://wakatime.com/
|
||||
==========================================================="""
|
||||
|
||||
|
||||
__version__ = '7.0.21'
|
||||
__version__ = '7.0.23'
|
||||
|
||||
|
||||
import sublime
|
||||
@ -462,6 +462,7 @@ class SendHeartbeatsThread(threading.Thread):
|
||||
self.debug = SETTINGS.get('debug')
|
||||
self.api_key = SETTINGS.get('api_key', '')
|
||||
self.ignore = SETTINGS.get('ignore', [])
|
||||
self.include = SETTINGS.get('include', [])
|
||||
self.hidefilenames = SETTINGS.get('hidefilenames')
|
||||
self.proxy = SETTINGS.get('proxy')
|
||||
|
||||
@ -520,6 +521,8 @@ class SendHeartbeatsThread(threading.Thread):
|
||||
cmd.extend(['--cursorpos', heartbeat['cursorpos']])
|
||||
for pattern in self.ignore:
|
||||
cmd.extend(['--exclude', pattern])
|
||||
for pattern in self.include:
|
||||
cmd.extend(['--include', pattern])
|
||||
if self.debug:
|
||||
cmd.append('--verbose')
|
||||
if self.hidefilenames:
|
||||
|
@ -17,6 +17,10 @@
|
||||
// POSIX regular expressions will not be logged.
|
||||
"ignore": ["^/tmp/", "^/etc/", "^/var/(?!www/).*", "COMMIT_EDITMSG$", "PULLREQ_EDITMSG$", "MERGE_MSG$", "TAG_EDITMSG$"],
|
||||
|
||||
// Include files; Files (including absolute paths) that match one of these
|
||||
// POSIX regular expressions will bypass your ignore setting.
|
||||
"include": [".*"],
|
||||
|
||||
// Status bar message. Set to false to hide status bar message.
|
||||
// Defaults to true.
|
||||
"status_bar_message": true,
|
||||
|
@ -1,7 +1,7 @@
|
||||
__title__ = 'wakatime'
|
||||
__description__ = 'Common interface to the WakaTime api.'
|
||||
__url__ = 'https://github.com/wakatime/wakatime'
|
||||
__version_info__ = ('8', '0', '2')
|
||||
__version_info__ = ('8', '0', '3')
|
||||
__version__ = '.'.join(__version_info__)
|
||||
__author__ = 'Alan Hamlett'
|
||||
__author_email__ = 'alan@wakatime.com'
|
||||
|
@ -11,8 +11,8 @@
|
||||
|
||||
|
||||
LANGUAGES = {
|
||||
'typescript': 0.01,
|
||||
'f#': 0.01,
|
||||
'perl': 0.01,
|
||||
'perl6': 0.01,
|
||||
'f#': 0.01,
|
||||
'typescript': 0.01,
|
||||
}
|
||||
|
@ -134,9 +134,9 @@ class MatlabLexer(RegexLexer):
|
||||
}
|
||||
|
||||
def analyse_text(text):
|
||||
if re.match('^\s*%', text, re.M): # comment
|
||||
if re.search(r'^\s*%', text, re.M): # comment
|
||||
return 0.2
|
||||
elif re.match('^!\w+', text, re.M): # system cmd
|
||||
elif re.search(r'^!\w+', text, re.M): # system cmd
|
||||
return 0.2
|
||||
|
||||
|
||||
|
@ -172,10 +172,7 @@ def get_language_from_extension(file_name):
|
||||
if os.path.exists(u('{0}{1}').format(u(filepart), u('.c'))) or os.path.exists(u('{0}{1}').format(u(filepart), u('.C'))):
|
||||
return 'C'
|
||||
|
||||
directory = os.path.dirname(file_name)
|
||||
available_files = os.listdir(directory)
|
||||
available_extensions = list(zip(*map(os.path.splitext, available_files)))[1]
|
||||
available_extensions = [ext.lower() for ext in available_extensions]
|
||||
available_extensions = extensions_in_same_folder(file_name)
|
||||
if '.cpp' in available_extensions:
|
||||
return 'C++'
|
||||
if '.c' in available_extensions:
|
||||
@ -300,7 +297,7 @@ def custom_pygments_guess_lexer_for_filename(_fn, _text, **options):
|
||||
rv = lexer.analyse_text(_text)
|
||||
if rv == 1.0:
|
||||
return lexer(**options)
|
||||
result.append((rv, customize_priority(lexer)))
|
||||
result.append(customize_lexer_priority(_fn, rv, lexer))
|
||||
|
||||
def type_sort(t):
|
||||
# sort by:
|
||||
@ -308,16 +305,33 @@ def custom_pygments_guess_lexer_for_filename(_fn, _text, **options):
|
||||
# - is primary filename pattern?
|
||||
# - priority
|
||||
# - last resort: class name
|
||||
return (t[0], primary[t[1]], t[1].priority, t[1].__name__)
|
||||
return (t[0], primary[t[2]], t[1], t[2].__name__)
|
||||
result.sort(key=type_sort)
|
||||
|
||||
return result[-1][1](**options)
|
||||
return result[-1][2](**options)
|
||||
|
||||
|
||||
def customize_priority(lexer):
|
||||
"""Return an integer priority for the given lexer object."""
|
||||
def customize_lexer_priority(file_name, accuracy, lexer):
|
||||
"""Customize lexer priority"""
|
||||
|
||||
priority = lexer.priority
|
||||
|
||||
lexer_name = lexer.name.lower().replace('sharp', '#')
|
||||
if lexer_name in LANGUAGES:
|
||||
lexer.priority = LANGUAGES[lexer_name]
|
||||
return lexer
|
||||
priority = LANGUAGES[lexer_name]
|
||||
elif lexer_name == 'matlab':
|
||||
available_extensions = extensions_in_same_folder(file_name)
|
||||
if '.mat' in available_extensions:
|
||||
priority = 0.06
|
||||
|
||||
return (accuracy, priority, lexer)
|
||||
|
||||
|
||||
def extensions_in_same_folder(file_name):
|
||||
"""Returns a list of file extensions from the same folder as file_name."""
|
||||
|
||||
directory = os.path.dirname(file_name)
|
||||
files = os.listdir(directory)
|
||||
extensions = list(zip(*map(os.path.splitext, files)))[1]
|
||||
extensions = set([ext.lower() for ext in extensions])
|
||||
return extensions
|
||||
|
Reference in New Issue
Block a user