Skip to content

Commit

Permalink
fix problems on_hover_description, updated README.md, first version t…
Browse files Browse the repository at this point in the history
…estable v0.1.0 released
  • Loading branch information
pichillilorenzo committed Jan 1, 2018
1 parent 3a850a7 commit 07df298
Show file tree
Hide file tree
Showing 9 changed files with 195 additions and 30 deletions.
15 changes: 6 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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!)
Expand All @@ -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)

Expand Down Expand Up @@ -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:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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() :
Expand Down Expand Up @@ -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("""
<html><head></head><body>
"""+js_css+"""
Expand Down Expand Up @@ -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 style="padding: 0px; margin: 0px; background-color: rgba(255,255,255,1);"><body style="font-size: 0.75em; font-weight: bold; padding: 5px; background-color: #F44336; margin: 0px;">'+html+'<br><a style="margin-top: 10px; display: block; color: #000;" href="copy_to_clipboard">Copy</a></body></html>', 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 style="padding: 0px; margin: 0px; background-color: rgba(255,255,255,1);"><body style="font-size: 0.8em; font-weight: bold; padding: 5px; background-color: #F44336; margin: 0px;">'+html+'<br><a style="margin-top: 10px; display: block; color: #000;" href="copy_to_clipboard">Copy</a></body></html>', 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) :

Expand Down Expand Up @@ -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:
Expand All @@ -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()
Expand All @@ -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"})

74 changes: 74 additions & 0 deletions changelog/0.1.0.txt
Original file line number Diff line number Diff line change
@@ -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: [email protected]

Thanks for your support! 😄😄

MIT License
73 changes: 68 additions & 5 deletions changelog/install.txt
Original file line number Diff line number Diff line change
@@ -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: [email protected]

Thanks for your support! 😄😄

MIT License
Original file line number Diff line number Diff line change
Expand Up @@ -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() :
Expand Down Expand Up @@ -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("""
<html><head></head><body>
"""+js_css+"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 style="padding: 0px; margin: 0px; background-color: rgba(255,255,255,1);"><body style="font-size: 0.75em; font-weight: bold; padding: 5px; background-color: #F44336; margin: 0px;">'+html+'<br><a style="margin-top: 10px; display: block; color: #000;" href="copy_to_clipboard">Copy</a></body></html>', 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 style="padding: 0px; margin: 0px; background-color: rgba(255,255,255,1);"><body style="font-size: 0.8em; font-weight: bold; padding: 5px; background-color: #F44336; margin: 0px;">'+html+'<br><a style="margin-top: 10px; display: block; color: #000;" href="copy_to_clipboard">Copy</a></body></html>', 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) :

Expand Down
19 changes: 15 additions & 4 deletions make/_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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()
Expand All @@ -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"})
3 changes: 2 additions & 1 deletion messages.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"install": "changelog/install.txt"
"install": "changelog/install.txt",
"0.1.0": "changelog/0.1.0.txt"
}
2 changes: 1 addition & 1 deletion project/npm/Main_disabled.sublime-menu
Original file line number Diff line number Diff line change
@@ -1 +1 @@
[{"id": "tools", "children": [{"id": "npm_scripts", "children": [], "caption": "Npm/Yarn Scripts"}], "caption": "Tools"}]
[{"caption": "Tools", "children": [{"caption": "Npm/Yarn Scripts", "children": [], "id": "npm_scripts"}], "id": "tools"}]

0 comments on commit 07df298

Please sign in to comment.