Skip to content

go2chenhua/completor.vim

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Completor

Build Status

Completor is an asynchronous code completion framework for vim8. New features of vim8 are used to implement the fast completion engine with low overhead. For using semantic completion, external completion tools should be installed.

Demo

Requirements

  • vim8,
  • compiled with python or python3

Install

  • vim8 builtin package manager:
$ mkdir -p ~/.vim/pack/completor/start
$ cd ~/.vim/pack/completor/start
$ git clone https://github.com/maralla/completor.vim.git
$ pack install maralla/completor.vim
Plug 'maralla/completor.vim'

Completers

Filename

When the input matches a file path pattern the file name will be automatically completed.

Buffer

This is the fallback completer. When no semantic completer found the buffer completer will be used and will complete based on the current buffers.

Ultisnips and neosnippet

Ultisnips is supported by default. If ultisnips is installed, the snips candidates will show on the completion popup menu.

Use this plugin completor-neosnippet for neosnippet support.

Python

Use jedi for completion. jedi should be installed for semantic completion. Install jedi to global environment or in virtualenv:

pip install jedi

The python executable can be specified using:

let g:completor_python_binary = '/path/to/python/with/jedi/installed'

Rust

Use racer for completion. Install racer first. To specify the racer executable path:

let g:completor_racer_binary = '/path/to/racer'

Javascript

Use tern for completion. To install tern you must have node and either npm or yarn installed. Then run:

make js

The node executable path can be specified using:

let g:completor_node_binary = '/path/to/node'

c/c++

Use clang for completion. Clang should be installed first. To specify clang path:

let g:completor_clang_binary = '/path/to/clang'

To pass extra clang arguments, you can create a file named .clang_complete under the project root directory or any parent directories. Every argument should be in a single line in the file. This is an example file:

-std=c++11
-I/Users/maralla/Workspace/src/dji-sdk/Onboard-SDK/lib/inc
-I/Users/maralla/Workspace/src/dji-sdk/Onboard-SDK/sample/Linux/inc

The key mapping <Plug>CompletorCppJumpToPlaceholder can be defined to jump to placeholders:

map <tab> <Plug>CompletorCppJumpToPlaceholder
imap <tab> <Plug>CompletorCppJumpToPlaceholder

go

Use gocode to provide omni completions. To specify the gocode executable path:

let g:completor_gocode_binary = '/path/to/gocode'

swift

Use completor-swift.

other languages

For other omni completions completor not natively implemented, auto completion can still be used if an omni function is defined for the file type. But an option should be defined to specify the trigger for triggering auto completion. The option name pattern:

let g:completor_{filetype}_omni_trigger = '<python regex>'

For example to use css omnifunc:

let g:completor_css_omni_trigger = '([\w-]+|@[\w-]*|[\w-]+:\s*[\w-]*)$'

Tips

Config tern for javascript completion

This is simple .tern-project file:

{
  "plugins": {
    "node": {},
    "es_modules": {}
  },
  "libs": [
    "ecma5",
    "ecma6"
  ],
  "ecmaVersion": 6
}

Use Tab to select completion

inoremap <expr> <Tab> pumvisible() ? "\<C-n>" : "\<Tab>"
inoremap <expr> <S-Tab> pumvisible() ? "\<C-p>" : "\<S-Tab>"
inoremap <expr> <cr> pumvisible() ? "\<C-y>\<cr>" : "\<cr>"

Use Tab to trigger completion (disable auto trigger)

let g:completor_auto_trigger = 0
inoremap <expr> <Tab> pumvisible() ? "<C-N>" : "<C-R>=completor#do('complete')<CR>"

Complete Options (completeopt)

By default completor.vim set some options to the completeopt. If you don't want these options you can use the following config to disable it:

let g:completor_set_options = 0

The default options:

set completeopt-=longest
set completeopt+=menuone
set completeopt-=menu
if &completeopt !~# 'noinsert\|noselect'
  set completeopt+=noselect
endif

About

Async completion framework made ease.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 70.9%
  • Vim Script 21.5%
  • JavaScript 7.4%
  • Makefile 0.2%