ternjs / tern

A JavaScript code analyzer for deep, cross-editor language support
https://ternjs.net/
MIT License
4.25k stars 378 forks source link

[emacs plugin] Completion only for current file #327

Open macarenomarco opened 10 years ago

macarenomarco commented 10 years ago

I've been scouring the issus and docs and I haven't been able to get tern ac to make suggestions based on other files. My javascript setup is this:

;; Javascript thingies
(add-hook 'js-mode-hook 'js2-minor-mode)
(add-hook 'js2-mode-hook 'ac-js2-mode)

(setq js2-highlight-level 3)

(require 'yasnippet)
(add-hook 'prog-mode-hook
          '(lambda ()
             (yas-minor-mode)))

;;; auto complete mod
;;; should be loaded after yasnippet so that they can work together
(require 'auto-complete-config)
(add-to-list 'ac-dictionary-directories "~/.emacs.d/ac-dict")
(ac-config-default)
;;; set the trigger key so that it can work together with yasnippet on tab key,
;;; if the word exists in yasnippet, pressing tab will cause yasnippet to
;;; activate, otherwise, auto-complete will
(ac-set-trigger-key "TAB")
(ac-set-trigger-key "<tab>")

(add-hook 'js-mode-hook (lambda () (tern-mode t)))
(eval-after-load 'tern
   '(progn
      (require 'tern-auto-complete)
      (tern-ac-setup)))

(setq tern-command '("~/AppData/Roaming/npm/tern" "--verbose"))

And this is my .tern-project file:

{
    "libs": [
        "browser",
        "jquery"
    ],

    "loadEagerly": [
        "./*.js"
    ],

    "plugins": {
        "node": {},
        "requirejs": {
            "baseURL": "./",
            "paths": {}
        }
    }
}

I'm using emacs 24.3.1 for windows windows 7

Thanks.

marijnh commented 10 years ago

The node plugin will namespace each file, just like node's module system. Maybe that's what's going on?