Reputation: 1290
Omni Completion is only finding patterns for variables declared with the var
keyword. Variables declared with const
or let
cannot be found.
const apple
let blueberry
var carrot
// Omni Completion only finds patterns for 'carrot'
~/.vimrc
"Start pathogen plugin manager
execute pathogen#infect()
"Enable syntax, changing font/colors
syntax on
"FILETYPE DETECTION
"Enable file type detection
filetype on
"Enable loading file type plugins
filetype plugin on
"Enable loading indent file
filetype indent on
"TABS
"expand tabs to spaces
set expandtab
"spaces for automatic indents
set shiftwidth=2
"make existing tabs appear like 2 spaces
set softtabstop=2
"MAPS
"map jk to escape
:inoremap jk <Esc>
"map omnicompletion to space
"https://stackoverflow.com/questions/7722177/how-do-i-map-ctrl-x-ctrl-o-to-ctrl-space-in-terminal-vim
"For some reason <C-Space> is interpreted as <C-@>
inoremap <C-@> <C-x><C-o>
"APPEARANCE
"turn on relative line numbers
set number relativenumber
"Omnicompletion (autocompletion)
set omnifunc=syntaxcomplete#Complete
Upvotes: 0
Views: 195
Reputation: 1290
I after finding Tern, I deduce that Vim's Omni Completion feature simply lacks in depth JavaScript completion features. From the Tern home page:
Tern is a stand-alone code-analysis engine for JavaScript. It is intended to be used with a code editor plugin to enhance the editor's support for intelligent JavaScript editing. Features provided are:
- Autocompletion on variables and properties
- Function argument hints
- Querying the type of an expression
- Finding the definition of something
- Automatic refactoring
Tern is open-source (MIT license), written in JavaScript, and capable of running both on node.js and in the browser.
I then found the tern_for_vim GitHub repo, and a tutorial for setting it up.
In the case of using Pathogen as a Vim plugin manager, from the tern_for_vim GitHub repository readme file:
If you use Pathogen or something similar, you can clone this repository to your
~/.vim/bundle
(or equivalent) directory. Make sure you have node.js and npm installed (Tern is a JavaScript program), and install the tern server by runningnpm install
in thebundle/tern_for_vim
directory.
Upvotes: 0