From da267345222e3f00a62165c3a1a976147ee68f57 Mon Sep 17 00:00:00 2001 From: Ivan Buryak Date: Fri, 29 Nov 2019 18:44:36 +0500 Subject: [PATCH 1/4] Fix unknown variable TimeoutExpired --- TailwindCSSAutocomplete.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TailwindCSSAutocomplete.py b/TailwindCSSAutocomplete.py index 413e50b..a807937 100644 --- a/TailwindCSSAutocomplete.py +++ b/TailwindCSSAutocomplete.py @@ -39,7 +39,7 @@ def get_completions(self, view, folder): self.instances[folder]['items'] = self.get_items_from_class_names(class_names.get('classNames'), class_names.get('screens')) self.instances[folder]['config'] = class_names.get('config') self.instances[folder]['config_items'] = self.get_config_items(class_names.get('config')) - except TimeoutExpired: + except subprocess.TimeoutExpired: process.kill() process.communicate() except: From e89c0ae443c98e7a44f7aafb7e4262ed436be34d Mon Sep 17 00:00:00 2001 From: Ivan Buryak Date: Fri, 29 Nov 2019 18:45:49 +0500 Subject: [PATCH 2/4] Print stack trace to console when something happens during initialization --- TailwindCSSAutocomplete.py | 1 + 1 file changed, 1 insertion(+) diff --git a/TailwindCSSAutocomplete.py b/TailwindCSSAutocomplete.py index a807937..a1fe9d2 100644 --- a/TailwindCSSAutocomplete.py +++ b/TailwindCSSAutocomplete.py @@ -43,6 +43,7 @@ def get_completions(self, view, folder): process.kill() process.communicate() except: + print('TailwindCSSAutocomplete: ', sys.exc_info()) pass def get_items_from_class_names(self, class_names, screens, keys = []): From a1dd2261d8871a4092e017decd6962a8d2048403 Mon Sep 17 00:00:00 2001 From: Ivan Buryak Date: Fri, 29 Nov 2019 18:46:43 +0500 Subject: [PATCH 3/4] Add folder to self.instances only if it has tailwind configuration (prevents some errors down the line) --- TailwindCSSAutocomplete.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TailwindCSSAutocomplete.py b/TailwindCSSAutocomplete.py index a1fe9d2..c9ec95b 100644 --- a/TailwindCSSAutocomplete.py +++ b/TailwindCSSAutocomplete.py @@ -9,7 +9,6 @@ class TailwindCSSAutocomplete(sublime_plugin.EventListener): instances = {} def get_completions(self, view, folder): - self.instances[folder] = {} tw = self.find_file( folder, @@ -32,6 +31,7 @@ def get_completions(self, view, folder): path = output.decode('utf-8').splitlines()[-1] class_names = json.loads(path) + self.instances[folder] = {} self.instances[folder]['config_file'] = tw self.instances[folder]['separator'] = class_names.get('separator') self.instances[folder]['class_names'] = class_names.get('classNames') From fffd62e6cd1b0e9367647007c1de02c4258b8237 Mon Sep 17 00:00:00 2001 From: Ivan Buryak Date: Fri, 29 Nov 2019 19:03:24 +0500 Subject: [PATCH 4/4] Add jsx in typescript (or other sources) support --- TailwindCSSAutocomplete.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/TailwindCSSAutocomplete.py b/TailwindCSSAutocomplete.py index c9ec95b..4745d9e 100644 --- a/TailwindCSSAutocomplete.py +++ b/TailwindCSSAutocomplete.py @@ -134,7 +134,8 @@ def on_query_completions(self, view, prefix, locations): return [] isCss = view.match_selector(locations[0], 'source.css meta.property-list.css') - isHtml = view.match_selector(locations[0], 'text.html string.quoted') or view.match_selector(locations[0], 'string.quoted.jsx') + isHtml = view.match_selector(locations[0], 'text.html string.quoted') or view.match_selector(locations[0], 'string.quoted.jsx') \ + or view.match_selector(locations[0], 'meta.tag string.quoted') if isCss == False and isHtml == False: return []