Asaf Katz
Asaf Katz

Reputation: 4688

How to enable TernJS in sublime text with ES6 modules (Import Statements) on macOS

It is really unclear how to setup tern to work with Sublime Text and ES6 Modules.

What steps should I need to take to enable it?

Upvotes: 1

Views: 1545

Answers (1)

Asaf Katz
Asaf Katz

Reputation: 4688

  1. Install tern_for_sublime using Sublime's Package Control
  2. Also, install Fix Mac Path using Sublime's Package Control (why?)
  3. Create a file named .tern-config in you Home directory (not your project):

    /Users/<your-username>/.tern-config

    {
      "plugins": {
        "node": {},
        "es_modules": {}
      },
      "libs": [
        "ecma5",
        "ecma6"
      ],
      "ecmaVersion": 6
    }
    
  4. To automatically show completions after "." is typed, open your sublime preferences (found in Sublime Text > Preferences > Settings - User) and add this line:

    "auto_complete_triggers": [{ "characters": ".", "selector": "source.js"}]
    
  5. Optionally, you can override settings per project by creating a .tern-project file in the root of your project.

Enjoy.

Upvotes: 3

Related Questions