2

Problem

I'm currently trying to build a 3D web app based on three.js.

I'm using neovim as my development environment and YouCompleteMe as a completion system.

I installed tern to complete JS, and I added .tern-project file like this.

{
    "libs": [
        "browser",
        "ecmascript",
    ],
    "loadEagerly": [
    ],
    "plugins": {
        "threejs": {}
    }
}

I also copied threejs.js and threejs.json to my project's directory generated by tern-threejs.

However, YouCompleteMe doesn't show semantic completion compared to tern-threejs's demo codemirror

Comparison:

codemirror:

codemirror

neovim:

neovim

Note: I can't see any completion at all.

What seems to be the problem?

sohnryang
  • 725
  • 2
  • 13
  • 27

1 Answers1

0

threejs.js is a tern plugin file and threejs.json is a tern library file. plugin files should be copied in tern/plugin directory and library files needs to be placed within tern/defs directory. These two directory exists within tern directory.

With 'YouCompleteMe' installed this dir path is: ~/.vim/YouCompleteMe/third_party/ycmd/third_party/tern-runtime/node‌​_modules/tern. You only need to copy one of aforementioned files. Plugin file or lib file; and update your .tern-project file accordingly. so:

  1. First ensure that you have enabled the Tern completer on YouCompleteMe. For example on my Mac, I had to run the following:

    cd ~/.vim/bundle/YouCompleteMe
    ./install.py --tern-completer
    

    See YouCompleteMe installation guide for details on how to do it on other environments.

  2. Copy threejs.js then navigate to

    ~/.vim/YouCompleteMe/third_party/ycmd/third_party/tern-runtime/node‌​_modules/tern/plugin/
    

    and paste.

  3. Update your project's .tern-project file as follows:

    {
        "libs": [
            "browser",
            "ecmascript",
        ],
        "plugins": {
            "es_modules": {},
            "threejs": {}
        }
    }
    

    Note that i've also included es_modules plugin (which is a plugin shipped with tern itself) as you are using ES6 module pattern system.

dNitro
  • 5,145
  • 2
  • 20
  • 45
  • Well, it didn't work. For starters, there was no such directory like `YouCompleteMe/third_party/ycmd/third_party/tern`. I managed to find `YouCompleteMe/third_party/ycmd/third_party/tern-runtime/node_modules/tern`, so I copied `threejs.js` to `plugin` directory, but It didn't work. – sohnryang Aug 07 '17 at 08:24
  • The problem persists even though I run `./install.py` with `--tern-completer`. – sohnryang Aug 07 '17 at 08:27
  • @sohnryang, Your tern path is correct; so i updated the answer. By the way did you also copied `.tern-project` file into your project directory. All your `.js` files should be placed within or with the descendants of the directory where `.tern-project` has been placed. – dNitro Aug 07 '17 at 09:20
  • I already updated `.tern-project` file, but I can't see any completion. – sohnryang Aug 07 '17 at 09:47