pichillilorenzo / JavaScriptEnhancements

JavaScript Enhancements is a plugin for Sublime Text 3. It offers not only a smart javascript autocomplete but also a lot of features about creating, developing and managing javascript projects (real-time errors, code refactoring, etc.).
MIT License
639 stars 41 forks source link

Click go to definition #52

Open arnsa opened 6 years ago

arnsa commented 6 years ago

Is it possible to somehow add a shortcut (e.g. ctrl+click) to go to definition? The default one from Sublime doesn't work. :(

pichillilorenzo commented 6 years ago

To add a custom key binding go to Preferences > Key Bindings and add your keys. For example:

[
  {
    "keys": ["super+alt+g"], // This is the default key binding for Go to definition feature!
    "command": "javascript_enhancements_go_to_definition"
  }
]

Here the docs: http://docs.sublimetext.info/en/latest/reference/key_bindings.html

arnsa commented 6 years ago

@pichillilorenzo but what about ctrl+click? I've tried to set it up like this in Default (OSX).sublime-mousemap file, but it doesn't work :(

[ { "button": "button1", "count": 1, "modifiers": ["ctrl"], "press_command": "drag_select", "command": "javascript_enhancements_go_to_definition" } ]

helsus commented 6 years ago

@arnsa works for me:

[
     {
      "button": "button1",
      "count": 1,
      "modifiers": ["super"], // "super" is cmd button. "ctrl" also works fine
      "press_command": "drag_select",
      "command": "javascript_enhancements_go_to_definition",
      "context": [
           { "key": "selector", "operator": "equal", "operand": "source.js, source.jsx" }
      ]
   }
]
arnsa commented 6 years ago

@helsus thanks, it didn't work with super (probably because cmd+click adds new cursor on sublime, but it worked with ctrl! It doesn't open a file when I click on an import :(, any ideas why?