forked from ungod/LuaCWC-LuaAutoComplete
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.py
More file actions
34 lines (26 loc) · 853 Bytes
/
utils.py
File metadata and controls
34 lines (26 loc) · 853 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import os
import re
import sublime
def isLuaFile(file):
ext = os.path.splitext(file)[1][1:]
return ext == "lua"
# find all value with "val = v" like
def findValues(prefix, strg):
vals = {}
valMat = re.finditer(prefix + "([\w\d]+)\s*=\s*(.+)", strg, re.MULTILINE)
for valItem in valMat:
val = valItem.group(1)
itemMat = re.match("([\w\d]+)\.New.+", valItem.group(2))
if itemMat:
vals[val] = "val:" + itemMat.group(1)
else:
itemMat = re.search(".+\[type:([\w\d].+)\]", valItem.group(2))
if itemMat:
vals[val] = "val:" + itemMat.group(1)
else:
vals[val] = "val:nil"
return vals
def isST3():
return sublime.version()[0] == '3'
def loadSettings(name):
return sublime.load_settings(name+".sublime-settings")