tern_for_vim icon indicating copy to clipboard operation
tern_for_vim copied to clipboard

tern_for_vim does not work for Node React+Three.js Project

Open yiakwy opened this issue 8 years ago • 1 comments

Here is my project hierarchy

.
├── assets
├── dist
├── node_modules
├── package-lock.json
├── package.json
├── setup.sh
├── src
└── webpack.config.js

I have a local standard .tern-project file in the root

{
  "libs": [ "browser", "ecma6" ],
  "plugins": {
    "node": {},
    "complete_strings": {},
    "es_modules": {}
  }
}

And now I am writing a three.js project

import * as THREE from "three"
import OrbitControls from "three/examples/js/controls/OrbitControls.js"
import SETTINGS from "settings.yaml"
import * as React from "react"

class Renderer {
	constructor() {
		this.renderer = new THREE.WebGLRenderer()
		this.scene = new THREE.Scene()
		this.camera = new THREE.PerspectiveCamera(
			SETTINGS.camera.NORMAL.Angle_View,
			window.innerWidth / window.innerHeight, // aspect
			SETTINGS.camera.NORMAL.NEAR,
			SETTINGS.camera.NORMAL.FAR

It seems that completer plugin cannot see the file "settings.yaml" residing in "src/" and cannot complete when I type THREE. But it works good with react.

It cannot complete any file when I try to import.

All the dependencies in package.jason are valid and I can work well with python and C.

So I have no idea why this happened.

yiakwy avatar Dec 25 '17 10:12 yiakwy

Hi @marijnh, I played with logs files from output of YcmDebugInfo . I got something from them :

(1) ERROR 1

/Users/lei.wang1/.vim/bundle/YouCompleteMe/third_party/ycmd/third_party/tern_runtime/node_modules/tern/plugin/doc_comment.js:95
        var proto = node.objType.getProp("prototype").getObjType()
                                 ^

TypeError: Cannot read property 'getProp' of undefined
    at Class (/Users/lei.wang1/.vim/bundle/YouCompleteMe/third_party/ycmd/third_party/tern_runtime/node_modules/tern/plugin/doc_comment.js:95:34)
    at c (/Users/lei.wang1/.vim/bundle/YouCompleteMe/third_party/ycmd/third_party/tern_runtime/node_modules/acorn/dist/walk.js:30:16)
    at Object.base.ClassDeclaration.base.ClassExpression (/Users/lei.wang1/.vim/bundle/YouCompleteMe/third_party/ycmd/third_party/tern_runtime/node_modules/acorn/dist/walk.js:336:80)
    at c (/Users/lei.wang1/.vim/bundle/YouCompleteMe/third_party/ycmd/third_party/tern_runtime/node_modules/acorn/dist/walk.js:29:15)
    at Object.skipThrough (/Users/lei.wang1/.vim/bundle/YouCompleteMe/third_party/ycmd/third_party/tern_runtime/node_modules/acorn/dist/walk.js:162:37)
    at c (/Users/lei.wang1/.vim/bundle/YouCompleteMe/third_party/ycmd/third_party/tern_runtime/node_modules/acorn/dist/walk.js:29:15)
    at Object.base.ThrowStatement.base.SpreadElement (/Users/lei.wang1/.vim/bundle/YouCompleteMe/third_party/ycmd/third_party/tern_runtime/node_modules/acorn/dist/walk.js:201:35)
    at c (/Users/lei.wang1/.vim/bundle/YouCompleteMe/third_party/ycmd/third_party/tern_runtime/node_modules/acorn/dist/walk.js:29:15)
    at Object.skipThrough (/Users/lei.wang1/.vim/bundle/YouCompleteMe/third_party/ycmd/third_party/tern_runtime/node_modules/acorn/dist/walk.js:162:37)
    at c (/Users/lei.wang1/.vim/bundle/YouCompleteMe/third_party/ycmd/third_party/tern_runtime/node_modules/acorn/dist/walk.js:29:15)

(2) ERROR 2


2018-01-02 18:45:33,277 - ERROR - No semantic completer exists for filetypes: [u'nerdtree']
Traceback (most recent call last):
  File "/Users/lei.wang1/.vim/bundle/YouCompleteMe/third_party/ycmd/ycmd/../ycmd/handlers.py", line 238, in DebugInfo
    request_data ).DebugInfo( request_data )
  File "/Users/lei.wang1/.vim/bundle/YouCompleteMe/third_party/ycmd/ycmd/../ycmd/handlers.py", line 285, in _GetCompleterForRequestData
    return _server_state.GetFiletypeCompleter( request_data[ 'filetypes' ] )
  File "/Users/lei.wang1/.vim/bundle/YouCompleteMe/third_party/ycmd/ycmd/../ycmd/server_state.py", line 89, in GetFiletypeCompleter
    current_filetypes ) )
ValueError: No semantic completer exists for filetypes: [u'nerdtree']

Something that I hope can help you :

  1. I used webpack, and I used alias pattern {module_name} -> src/{module_name}
  2. react works well
  3. I install all packages locally using my generated file (automatically execute npm with either --save-dev or --save)
  4. completer does not work when "import", i.e.: complete module names

I also reported bugs to YCM project

yiakwy avatar Jan 02 '18 11:01 yiakwy