2

I've been trying to get my Vim setup similar to other IDE's (pycharm, webstorm) and I'm hoping to get the functionality of having code completion for injected objects. I have YouCompleteMe and tern_for_vim properly installed and configured so I'm able to get in-file code completion and general javascript syntax completion, but I'm wondering if it's possible to get this kind of code completion as well:

enter image description here

For reference, here's my .tern-project file at the root of my project hierarchy:

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

    "plugins": {
        "requirejs": {
            "baseURL": "./pytrader/static/scripts/",
            "paths": {
                "core": "./pytrader/static/scripts/core.js",
                "libs": "./pytrader/static/scripts/lib",
                "jquery": "./pytrader/static/scripts/lib/jquery",
                "lodash": "./pytrader/static/scripts/lib/lodash",
                "backbone": "./pytrader/static/scripts/lib/backbone",
                "stxKernel": "./pytrader/static/scripts/lib/chartIQ",
                "bootstrap": "./pytrader/static/scripts/lib/bootstrap"
            }
        },
        "node": {}
    }
}

And here's the list of plugins I'm using in my .vimrc:

Plugin 'gmarik/Vundle.vim' " Plugin Management
Plugin 'tmhedberg/matchit' " Matching configuration for %
Plugin 'jelera/vim-javascript-syntax' " Additional JS syntax highlighting
Plugin 'tpope/vim-surround' "provides mappings to easily delete, change and add surroundings like quotes, parenths etc
Plugin 'plasticboy/vim-markdown' "Markdown support
Plugin 'davidoc/taskpaper.vim' "Taskpaper support
Plugin 'tpope/vim-commentary' " Simple commenting in vim 
Plugin 'scrooloose/nerdtree' "Tree navigation
Plugin 'Xuyuanp/nerdtree-git-plugin' "Nerdtree git tags for files support
Plugin 'scrooloose/syntastic' "Syntax check
Plugin 'majutsushi/tagbar' "Browse the tags of the current file and get an overview of its structure.
Plugin 'ctrlpvim/ctrlp.vim' "Full path fuzzy file, buffer, mru, tag, ... finder for Vim.
Plugin 'bling/vim-airline' "Statusbar 
Plugin 'tpope/vim-fugitive' "Vim wrapper, allow for git viewing in airline
Plugin 'vim-airline/vim-airline-themes' "Airline themes
Plugin 'burnettk/vim-angular' " Angular functionality
Plugin 'jiangmiao/auto-pairs' "Insert or delete brackets, parens, quotes in pair
Plugin 'Yggdroot/indentLine' "A vim plugin to display the indention levels with thin vertical lines
Plugin 'altercation/vim-colors-solarized' "Solarized color theme
Plugin 'chriskempson/vim-tomorrow-theme' "Tomorrow color theme
Plugin 'w0ng/vim-hybrid' "Hybrid Solarized, codecademy, Jellybeans, and Tomorrow-Night
Plugin 'Valloric/YouCompleteMe' " Code completion 
Plugin 'marijnh/tern_for_vim' "Vim tern usage, greatly improves YouCompleteMe JS use
Plugin 'elzr/vim-json' " JSON highlighting 
Plugin 'rking/ag.vim' " Advanced searching 
"For JavaScript development
Plugin 'pangloss/vim-javascript' "Javascript syntax highlighting
Plugin 'moll/vim-node' " Node js 
Plugin 'groenewege/vim-less' " Less syntax
Plugin 'othree/javascript-libraries-syntax.vim' " Javascript syntax library highlighting
Plugin 'othree/jspc.vim' " Javascript parameter completion
Plugin '1995eaton/vim-better-javascript-completion' " Expansion of vim's javascript syntax file for HTML5

Please let me know if I need to put any more details or information.

  • 2
    "similar to other IDE's" Vim has never been, is not, can't be, will never be an IDE or even an alternative to an IDE. Use an IDE if you need IDE features. Also, what do you call "injected objects"? The whole point of tern is to provide "smart" completion. If it doesn't, describe what you want and/or use their issue tracker. – romainl May 31 '16 at 15:04
  • Injected objects I'm meaning as the dependency injection found at the top of the file when you have define(['jquery'], function($){}). $ represents the inject jquery object that is injected into my function scope. Tern does not resolve the injected objects, thus failing (in what I think should be) in it's "smart" completion. And that's what I'm asking, is it possible to configure Tern to provide "smart" completion for these injected objects so that I can see what methods are available for that object? – Grant A Jun 1 '16 at 19:58
  • IIRC you had to include those modules to your tern config file but that was a long time ago. – romainl Jun 1 '16 at 20:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.