Skip to content

Commit

Permalink
Merge pull request #97 from trotzig/sublime-fixes
Browse files Browse the repository at this point in the history
Sublime fixes
  • Loading branch information
trotzig committed Jan 5, 2016
2 parents 2cf40b3 + 83dc078 commit ebd3b16
Show file tree
Hide file tree
Showing 8 changed files with 65 additions and 16 deletions.
30 changes: 30 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,33 @@ import-js to make it easier to try out your changes.
```bash
ln -s ~/import-js import-js
```

## Developing for Sublime

Here are a few tips to make it simpler to test a local copy of import-js in
Sublime:

### Symlink

Make a symlink inside your Sublime packages folder to the local copy of
import-js. Every time you change the `import_js.py` file the plugin will
reload.

```bash
cd ~/Library/Application Support/Sublime Text 3/Packages
ln -s ~/import-js import-js
```

### Build and install the gem locally

Since the Sublime plugin uses the `import-js` CLI tool, you need to rebuild and
install the `import_js` Ruby gem whenever you make changes to the Ruby code
powering import-js.

First, update `lib/import_js/version.rb` and bump the version number.

```
gem build import_js.gemspec && gem install --local import_js-__version__.gem
```

Replace `__version__` with the bumped version number.
3 changes: 1 addition & 2 deletions Default.sublime-commands
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
[
{
"caption": "ImportJS: fix all imports",
"command": "import_js",
"args": {"fix": true}
"command": "import_js"
},
{
"caption": "ImportJS: import word under cursor",
Expand Down
2 changes: 1 addition & 1 deletion ImportJS.sublime-settings
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"executable": "~/.rbenv/shims/import-js"
"executable": "import-js"
}
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import-js comes with plugins for the following editors:
- [Emacs](EMACS.md) (Thanks to
[@kevinkehl](https://github.com/kevinkehl)!)
- [Vim](VIM.md)
- [Sublime](Sublime.md) (Thanks to
- [Sublime](SUBLIME.md) (Thanks to
[@janpaul123](https://github.com/janpaul123))
- [(your editor here?)](CONTRIBUTING.md)

Expand Down
12 changes: 6 additions & 6 deletions SUBLIME.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# Running import-js in Sublime Text

1. Install import-js
* `gem install import-js`
2. Install eslint
1. Install the [ImportJS plugin via Package
Control](https://packagecontrol.io/packages/ImportJS)
2. Install the import_js gem
* `gem install import_js`
3. Install eslint
* `npm install -g eslint`
3. Configure import-js
4. Configure import-js
* See [Configuration](README.md#configuration)
4. Symlink ipmort-js (root folder) to your Sublime packages directory, e.g. `ln
-s ~/import-js import-js`.
5. Open the root of your project as a folder (Project -> Add Folder to Project…)
6. Import a file!
* Whenever you have undefined variables, open the Command Palette
Expand Down
5 changes: 1 addition & 4 deletions import-js.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,14 @@ def run(self, edit, **args):
project_root = self.view.window().extract_variables()['folder']
settings = sublime.load_settings('ImportJS.sublime-settings')

executable = os.path.expanduser(settings.get('executable'))
executable = settings.get('executable')
command = [executable]

if(args.get('word')):
word = self.view.substr(self.view.word(self.view.sel()[0]))
command.append('--word')
command.append(word)

if(args.get('fix')):
command.append('--fix')

if(args.get('goto')):
command.append('--goto')

Expand Down
2 changes: 1 addition & 1 deletion lib/import_js/version.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Defines the gem version.
module ImportJS
VERSION = '0.2.0'
VERSION = '0.2.1'
end
25 changes: 24 additions & 1 deletion sublime-messages/install.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,25 @@
Thanks for installing ImportJS! Before you can start using the plugin, you also
need to install the `import-js` binary. To do that, run `gem install import_js`.
need to install a few dependencies:

1. Install the import_js gem
* `gem install import_js`
2. Install eslint
* `npm install -g eslint`
3. Configure import-js
* See https://github.com/trotzig/import-js for more information
4. Open the root of your project as a folder (Project -> Add Folder to Project…)


When you are done with that, it's time to start importing files!

* Whenever you have undefined variables, open the Command Palette
(CTRL/CMD+SHIFT+P) and select "ImportJS: fix all imports",
or "ImportJS: import word under cursor".
* It will be helpful to bind `import_js` to easy-to-use bindings,
such as:

```
{ "keys": ["super+alt+i"], "command": "import_js" },
{ "keys": ["super+alt+j"], "command": "import_js", "args": { "word": true } },
{ "keys": ["super+alt+g"], "command": "import_js", "args": { "word": true, "goto": true } },
```

0 comments on commit ebd3b16

Please sign in to comment.