Skip to content

Commit c7ba0e6

Browse files
committed
Checks and replace the old syntax file after load the plugin (Issue: #133)
1 parent c3a2766 commit c7ba0e6

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

Deviot.py

+9
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
from __future__ import unicode_literals
88

99
from os import path
10+
from sublime import windows
1011
from sublime_plugin import EventListener
1112

1213
from .commands import *
@@ -18,7 +19,15 @@
1819
from .libraries.project_check import ProjectCheck
1920

2021
def plugin_loaded():
22+
# Load or fix the right deviot syntax file
23+
for window in windows():
24+
for view in window.views():
25+
set_deviot_syntax(view)
26+
27+
# Install PlatformIO
2128
PioInstall()
29+
30+
# Search updates
2231
Update().check_update_async()
2332

2433
menu_path = getMainMenuPath()

libraries/tools.py

+8-2
Original file line numberDiff line numberDiff line change
@@ -162,16 +162,22 @@ def set_deviot_syntax(view):
162162
if(not ProjectCheck().is_iot()):
163163
return
164164

165+
d_syntax = 'Packages/Deviot/deviot.sublime-syntax'
166+
165167
syntax = view.settings().get('syntax')
166168

169+
if(syntax.endswith('Arduino.tmLanguage')):
170+
view.settings().set('syntax', d_syntax)
171+
return
172+
167173
if(not syntax or not syntax.endswith('/deviot.sublime-syntax')):
168-
from .path import getPluginPath
174+
from .paths import getPluginPath
169175

170176
deviot_syntax = getPluginPath()
171177
deviot_syntax = path.join(deviot_syntax, 'deviot.sublime-syntax')
172178

173179
if(path.exists(deviot_syntax)):
174-
view.settings().set('syntax', 'Packages/Deviot/deviot.sublime-syntax')
180+
view.settings().set('syntax', d_syntax)
175181

176182

177183
def singleton(cls):

0 commit comments

Comments
 (0)