From 07df298e4e3086e9b4d39a6d1eec18ed59d3e038 Mon Sep 17 00:00:00 2001 From: pichillilorenzo Date: Tue, 2 Jan 2018 00:51:04 +0100 Subject: [PATCH] fix problems on_hover_description, updated README.md, first version testable v0.1.0 released --- README.md | 15 ++-- ...py => _generated_2018_01_02_at_00_50_45.py | 29 ++++++-- changelog/0.1.0.txt | 74 +++++++++++++++++++ changelog/install.txt | 73 ++++++++++++++++-- .../on_hover_description_event_listener.py | 6 +- .../show_flow_errors_view_event_listener.py | 4 +- make/_init.py | 19 ++++- messages.json | 3 +- project/npm/Main_disabled.sublime-menu | 2 +- 9 files changed, 195 insertions(+), 30 deletions(-) rename _generated_2018_01_01_at_21_08_47.py => _generated_2018_01_02_at_00_50_45.py (98%) create mode 100644 changelog/0.1.0.txt diff --git a/README.md b/README.md index 4254259..364f478 100755 --- a/README.md +++ b/README.md @@ -2,14 +2,11 @@ **JavaScript Enhancements** is a plugin for **Sublime Text 3**. -I'm implementing new features thanks to **[Flow](https://github.com/facebook/flow)** (javascript static type checker from Facebook). +This plugin uses **[Flow](https://github.com/facebook/flow)** (javascript static type checker from Facebook) under the hood. -This is in **Beta version**. +This is in **Beta** version for testing. -I'm going to **release** a first testable version these days, so **WATCH** the repository to stay tuned for any news! - -It will offer not only a better **javascript autocomplete** but a lot of features about creating, -developing and managing **javascript projects**, such as: +It offers better **javascript autocomplete** and also a lot of features about creating, developing and managing **javascript projects**, such as: - Cordova projects (run cordova emulate, build, compile, serve, etc. directly from Sublime Text!) - Ionic v1 and v2 projects (same as Cordova projects!) @@ -23,7 +20,7 @@ developing and managing **javascript projects**, such as: You could use it also in **existing projects** (see the [Wiki](https://github.com/pichillilorenzo/JavaScriptEnhancements/wiki))! -It will turn Sublime Text into a **JavaScript IDE** like! +It turns Sublime Text into a **JavaScript IDE** like! This project is based on my other Sublime Text plugin [JavaScript Completions](https://github.com/pichillilorenzo/JavaScript-Completions) @@ -59,9 +56,9 @@ You can find more information about Flow on [flow.org](https://flow.org) ## Installation -~~With [Package Control](https://packagecontrol.io/):~~ +With [Package Control](https://packagecontrol.io/): -~~- Run “Package Control: Install Package” command or click to the `Preferences > Package Control` menu item, find and install `JavaScript Enhancements` plugin.~~ +- Run “Package Control: Install Package” command or click to the `Preferences > Package Control` menu item, find and install `JavaScript Enhancements` plugin. Manually: diff --git a/_generated_2018_01_01_at_21_08_47.py b/_generated_2018_01_02_at_00_50_45.py similarity index 98% rename from _generated_2018_01_01_at_21_08_47.py rename to _generated_2018_01_02_at_00_50_45.py index 5aea30d..83f32aa 100644 --- a/_generated_2018_01_01_at_21_08_47.py +++ b/_generated_2018_01_02_at_00_50_45.py @@ -3383,6 +3383,10 @@ def on_hover_description_async(self, view, point, hover_zone, popup_position) : if hover_zone != sublime.HOVER_TEXT : return + for region in view.get_regions("flow_error"): + if region.contains(point): + return + region = view.word(point) word = view.substr(region) if not word.strip() : @@ -3567,7 +3571,7 @@ def on_hover_description_async(self, view, point, hover_zone, popup_position) : func_action = lambda x: view.run_command("go_to_def", args={"point": point}) if x == "go_to_def" else "" - if html and not view.is_popup_visible() : + if html: view.show_popup(""" """+js_css+""" @@ -3988,8 +3992,8 @@ def on_hover(self, point, hover_zone) : row_region, col_region = view.rowcol(region_hover_error.begin()) row_region, endcol_region = view.rowcol(region_hover_error.end()) - - view.show_popup(''+html+'
Copy', sublime.COOPERATE_WITH_AUTO_COMPLETE | sublime.HIDE_ON_MOUSE_MOVE_AWAY, region_hover_error.begin(), 1150, 80, lambda action: sublime.set_clipboard(error) or view.hide_popup() ) + + view.show_popup(''+html+'
Copy', sublime.COOPERATE_WITH_AUTO_COMPLETE | sublime.HIDE_ON_MOUSE_MOVE_AWAY, region_hover_error.begin(), 1150, 80, lambda action: sublime.set_clipboard(error) or view.hide_popup() ) def on_selection_modified_async(self, *args) : @@ -4852,10 +4856,16 @@ def start(): sublime.error_message("Windows is not supported by this plugin for now.") return + if platform.architecture()[0] != "64bit": + sublime.error_message("Your architecture is not supported by this plugin. This plugin supports only 64bit architectures.") + return + try: sys.modules["TerminalView"] except Exception as err: - sublime.error_message("TerminalView plugin is missing. TerminalView is required to be able to use this plugin.") + response = sublime.yes_no_cancel_dialog("TerminalView plugin is missing. TerminalView is required to be able to use \"JavaScript Enhancements\" plugin. Do you want open the github repo of it?", "Yes, open it", "No") + if response == sublime.DIALOG_YES: + sublime.active_window().run_command("open_url", args={"url": "https://github.com/Wramberg/TerminalView"}) return try: @@ -4869,7 +4879,11 @@ def start(): try: node.getCurrentNodeJSVersion() except Exception as err: - sublime.error_message("Error during installation: node.js is not installed on your system.") + response = sublime.yes_no_cancel_dialog("Error during installation: node.js is not installed on your system. Node.js and npm are required to be able to use JavaScript Enhancements plugin. Do you want open the website of node.js?", "Yes, open it", "Or use nvm") + if response == sublime.DIALOG_YES: + sublime.active_window().run_command("open_url", args={"url": "https://nodejs.org"}) + elif response == sublime.DIALOG_NO: + sublime.active_window().run_command("open_url", args={"url": "https://github.com/creationix/nvm"}) return mainPlugin.init() @@ -4879,6 +4893,7 @@ def plugin_loaded(): if int(sublime.version()) >= 3124 : sublime.set_timeout_async(start, 1000) else: - sublime.error_message("JavaScript Enhancements plugin requires Sublime Text 3 (build 3124 or newer). Your version build is: " + sublime.version()) - + response = sublime.yes_no_cancel_dialog("JavaScript Enhancements plugin requires Sublime Text 3 (build 3124 or newer). Your build is: " + sublime.version() + ". Do you want open the download page?", "Yes, open it", "No") + if response == sublime.DIALOG_YES: + sublime.active_window().run_command("open_url", args={"url": "https://www.sublimetext.com/3"}) diff --git a/changelog/0.1.0.txt b/changelog/0.1.0.txt new file mode 100644 index 0000000..ac3f73c --- /dev/null +++ b/changelog/0.1.0.txt @@ -0,0 +1,74 @@ +v0.1.0 + +================================================================= +** THIS PLUGIN IS IN BETA! Thanks for your support in advance! ** +================================================================= + +If you like it, remember to star it ⭐ on GitHub: https://github.com/pichillilorenzo/JavaScriptEnhancements + +** USAGE ** +=========== + +See how it works on the Wiki: 👉👉 https://github.com/pichillilorenzo/JavaScriptEnhancements/wiki 👈👈 + + +** WHAT IS THIS? ** +=================== + +This plugin uses Flow (javascript static type checker from Facebook) under the hood. + +It offers better javascript autocomplete and a lot of features about creating, +developing and managing javascript projects, such as: + +- Cordova projects (run cordova emulate, build, compile, serve, etc. directly from Sublime Text!) +- Ionic v1 and v2 projects (same as Cordova projects!) +- Angular v1 and v2 projects +- React projects +- Express projects +- Yeoman generators +- Local bookmarks project +- JavaScript real-time errors +- etc. + +You could use it also in existing projects (see the Wiki - https://github.com/pichillilorenzo/JavaScriptEnhancements/wiki)! + +It turns Sublime Text into a JavaScript IDE like! + +This project is based on my other Sublime Text plugin JavaScript Completions (https://github.com/pichillilorenzo/JavaScript-Completions) + +** NOTE ** +If you want use this plugin, you may want uninstall/disable the JavaScript Completions plugin, if installed. + +** OS SUPPORTED NOW ** +====================== + +👉 Linux (64-bit) +👉 Mac OS X + +❗❗ Dependencies ❗❗ +======================= + +In order to work properly, this plugin has some dependencies: + +👉 Sublime Text 3 (build 3124 or newer) +👉 Node.js and npm (https://nodejs.org or nvm (https://github.com/creationix/nvm)) +👉 TerminalView sublime text plugin (https://github.com/Wramberg/TerminalView) + +Not required, but useful for typescript files (Flow wont work on this type of files): + +👉 TypeScript sublime text plugin (https://github.com/Microsoft/TypeScript-Sublime-Plugin) + +** Flow Requirements ** +======================= + +It use [Flow](https://github.com/facebook/flow) for type checking and auto-completions. + +👉 Mac OS X +👉 Linux (64-bit) +👉 Windows (64-bit) + +Email me for any questions or doubts about this new project on: pichillilorenzo@gmail.com + +Thanks for your support! 😄😄 + +MIT License \ No newline at end of file diff --git a/changelog/install.txt b/changelog/install.txt index ba6fc14..2c2e04b 100755 --- a/changelog/install.txt +++ b/changelog/install.txt @@ -1,9 +1,72 @@ -JavaScript Enhancements Package -=============================== +================================================================= +** THIS PLUGIN IS IN BETA! Thanks for your support in advance! ** +================================================================= -How To USE -========== +If you like it, remember to star it ⭐ on GitHub: https://github.com/pichillilorenzo/JavaScriptEnhancements +** USAGE ** +=========== +See how it works on the Wiki: 👉👉 https://github.com/pichillilorenzo/JavaScriptEnhancements/wiki 👈👈 -MIT License + +** WHAT IS THIS? ** +=================== + +This plugin uses Flow (javascript static type checker from Facebook) under the hood. + +It offers better javascript autocomplete and a lot of features about creating, +developing and managing javascript projects, such as: + +- Cordova projects (run cordova emulate, build, compile, serve, etc. directly from Sublime Text!) +- Ionic v1 and v2 projects (same as Cordova projects!) +- Angular v1 and v2 projects +- React projects +- Express projects +- Yeoman generators +- Local bookmarks project +- JavaScript real-time errors +- etc. + +You could use it also in existing projects (see the Wiki - https://github.com/pichillilorenzo/JavaScriptEnhancements/wiki)! + +It turns Sublime Text into a JavaScript IDE like! + +This project is based on my other Sublime Text plugin JavaScript Completions (https://github.com/pichillilorenzo/JavaScript-Completions) + +** NOTE ** +If you want use this plugin, you may want uninstall/disable the JavaScript Completions plugin, if installed. + +** OS SUPPORTED NOW ** +====================== + +👉 Linux (64-bit) +👉 Mac OS X + +❗❗ Dependencies ❗❗ +======================= + +In order to work properly, this plugin has some dependencies: + +👉 Sublime Text 3 (build 3124 or newer) +👉 Node.js and npm (https://nodejs.org or nvm (https://github.com/creationix/nvm)) +👉 TerminalView sublime text plugin (https://github.com/Wramberg/TerminalView) + +Not required, but useful for typescript files (Flow wont work on this type of files): + +👉 TypeScript sublime text plugin (https://github.com/Microsoft/TypeScript-Sublime-Plugin) + +** Flow Requirements ** +======================= + +It use [Flow](https://github.com/facebook/flow) for type checking and auto-completions. + +👉 Mac OS X +👉 Linux (64-bit) +👉 Windows (64-bit) + +Email me for any questions or doubts about this new project on: pichillilorenzo@gmail.com + +Thanks for your support! 😄😄 + +MIT License \ No newline at end of file diff --git a/helper/javascript_completions/on_hover_description_event_listener.py b/helper/javascript_completions/on_hover_description_event_listener.py index 338a41f..3130654 100644 --- a/helper/javascript_completions/on_hover_description_event_listener.py +++ b/helper/javascript_completions/on_hover_description_event_listener.py @@ -52,6 +52,10 @@ def on_hover_description_async(self, view, point, hover_zone, popup_position) : if hover_zone != sublime.HOVER_TEXT : return + for region in view.get_regions("flow_error"): + if region.contains(point): + return + region = view.word(point) word = view.substr(region) if not word.strip() : @@ -236,7 +240,7 @@ def on_hover_description_async(self, view, point, hover_zone, popup_position) : func_action = lambda x: view.run_command("go_to_def", args={"point": point}) if x == "go_to_def" else "" - if html and not view.is_popup_visible() : + if html: view.show_popup(""" """+js_css+""" diff --git a/helper/javascript_completions/show_flow_errors_view_event_listener.py b/helper/javascript_completions/show_flow_errors_view_event_listener.py index e0097f4..aeea911 100644 --- a/helper/javascript_completions/show_flow_errors_view_event_listener.py +++ b/helper/javascript_completions/show_flow_errors_view_event_listener.py @@ -174,8 +174,8 @@ def on_hover(self, point, hover_zone) : row_region, col_region = view.rowcol(region_hover_error.begin()) row_region, endcol_region = view.rowcol(region_hover_error.end()) - - view.show_popup(''+html+'
Copy', sublime.COOPERATE_WITH_AUTO_COMPLETE | sublime.HIDE_ON_MOUSE_MOVE_AWAY, region_hover_error.begin(), 1150, 80, lambda action: sublime.set_clipboard(error) or view.hide_popup() ) + + view.show_popup(''+html+'
Copy', sublime.COOPERATE_WITH_AUTO_COMPLETE | sublime.HIDE_ON_MOUSE_MOVE_AWAY, region_hover_error.begin(), 1150, 80, lambda action: sublime.set_clipboard(error) or view.hide_popup() ) def on_selection_modified_async(self, *args) : diff --git a/make/_init.py b/make/_init.py index 4c05f80..9853e17 100755 --- a/make/_init.py +++ b/make/_init.py @@ -106,10 +106,16 @@ def start(): sublime.error_message("Windows is not supported by this plugin for now.") return + if platform.architecture()[0] != "64bit": + sublime.error_message("Your architecture is not supported by this plugin. This plugin supports only 64bit architectures.") + return + try: sys.modules["TerminalView"] except Exception as err: - sublime.error_message("TerminalView plugin is missing. TerminalView is required to be able to use this plugin.") + response = sublime.yes_no_cancel_dialog("TerminalView plugin is missing. TerminalView is required to be able to use \"JavaScript Enhancements\" plugin. Do you want open the github repo of it?", "Yes, open it", "No") + if response == sublime.DIALOG_YES: + sublime.active_window().run_command("open_url", args={"url": "https://github.com/Wramberg/TerminalView"}) return try: @@ -123,7 +129,11 @@ def start(): try: node.getCurrentNodeJSVersion() except Exception as err: - sublime.error_message("Error during installation: node.js is not installed on your system.") + response = sublime.yes_no_cancel_dialog("Error during installation: node.js is not installed on your system. Node.js and npm are required to be able to use JavaScript Enhancements plugin. Do you want open the website of node.js?", "Yes, open it", "Or use nvm") + if response == sublime.DIALOG_YES: + sublime.active_window().run_command("open_url", args={"url": "https://nodejs.org"}) + elif response == sublime.DIALOG_NO: + sublime.active_window().run_command("open_url", args={"url": "https://github.com/creationix/nvm"}) return mainPlugin.init() @@ -133,5 +143,6 @@ def plugin_loaded(): if int(sublime.version()) >= 3124 : sublime.set_timeout_async(start, 1000) else: - sublime.error_message("JavaScript Enhancements plugin requires Sublime Text 3 (build 3124 or newer). Your version build is: " + sublime.version()) - + response = sublime.yes_no_cancel_dialog("JavaScript Enhancements plugin requires Sublime Text 3 (build 3124 or newer). Your build is: " + sublime.version() + ". Do you want open the download page?", "Yes, open it", "No") + if response == sublime.DIALOG_YES: + sublime.active_window().run_command("open_url", args={"url": "https://www.sublimetext.com/3"}) diff --git a/messages.json b/messages.json index 32ad868..5967cf9 100755 --- a/messages.json +++ b/messages.json @@ -1,3 +1,4 @@ { - "install": "changelog/install.txt" + "install": "changelog/install.txt", + "0.1.0": "changelog/0.1.0.txt" } \ No newline at end of file diff --git a/project/npm/Main_disabled.sublime-menu b/project/npm/Main_disabled.sublime-menu index 2c6a28b..4aef1eb 100644 --- a/project/npm/Main_disabled.sublime-menu +++ b/project/npm/Main_disabled.sublime-menu @@ -1 +1 @@ -[{"id": "tools", "children": [{"id": "npm_scripts", "children": [], "caption": "Npm/Yarn Scripts"}], "caption": "Tools"}] \ No newline at end of file +[{"caption": "Tools", "children": [{"caption": "Npm/Yarn Scripts", "children": [], "id": "npm_scripts"}], "id": "tools"}] \ No newline at end of file