Giter Club home page Giter Club logo

completor.vim's Introduction

Completor

Test 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.

Neoinclude

Neoinclude is supported by default. If neoinclude is installed, the include candidates will show on the completion popup menu.

dictionary

Dictionary completion is supported by completor-dictionary.

shell

You can add some complete functions with shell command by completor-shell.

tmux

Completion from words in tmux panes is supported by completor-tmux.

syntax

Completion from syntax file is supported by completor-necosyntax.

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 go to the completor.vim directory and run:

make js

The node executable path can be specified using:

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

If you're using vim-plug, you can just use post install hook to do this for you.

Plug 'ternjs/tern_for_vim', { 'do': 'npm install' }
Plug 'maralla/completor.vim', { 'do': 'make js' }

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.

Elixir

Use alchemist.vim.

vim script

Use completor-necovim.

type script

Use completor-typescript.

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>"

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>"

A better way:

" Use TAB to complete when typing words, else inserts TABs as usual.  Uses
" dictionary, source files, and completor to find matching words to complete.

" Note: usual completion is on <C-n> but more trouble to press all the time.
" Never type the same word twice and maybe learn a new spellings!
" Use the Linux dictionary when spelling is in doubt.
function! Tab_Or_Complete() abort
  " If completor is already open the `tab` cycles through suggested completions.
  if pumvisible()
    return "\<C-N>"
  " If completor is not open and we are in the middle of typing a word then
  " `tab` opens completor menu.
  elseif col('.')>1 && strpart( getline('.'), col('.')-2, 3 ) =~ '^[[:keyword:][:ident:]]'
    return "\<C-R>=completor#do('complete')\<CR>"
  else
    " If we aren't typing a word and we press `tab` simply do the normal `tab`
    " action.
    return "\<Tab>"
  endif
endfunction

" Use `tab` key to select completions.  Default is arrow keys.
inoremap <expr> <Tab> pumvisible() ? "\<C-n>" : "\<Tab>"
inoremap <expr> <S-Tab> pumvisible() ? "\<C-p>" : "\<S-Tab>"

" Use tab to trigger auto completion.  Default suggests completions as you type.
let g:completor_auto_trigger = 0
inoremap <expr> <Tab> Tab_Or_Complete()

Complete Options (completeopt)

Completor try its best to not overwrite the config completeopt, so the config g:completor_complete_options is introduced to be the complete option when completor is triggered.

let g:completor_complete_options = 'menuone,noselect,preview'

If you explicitly set completeopt completor will not use this value for complete options.

Completor Actions

  • Jump to definition completor#do('definition')
  • Show documentation completor#do('doc')
  • Format code completor#do('format')
  • Hover info (lsp hover) completor#do('hover')
noremap <silent> <leader>d :call completor#do('definition')<CR>
noremap <silent> <leader>c :call completor#do('doc')<CR>
noremap <silent> <leader>f :call completor#do('format')<CR>
noremap <silent> <leader>s :call completor#do('hover')<CR>

Golang practices (without using lsp)

Use guru for jumping to definition:

let g:completor_go_guru_binary = 'guru'

Use goimports to format code:

let g:completor_go_gofmt_binary = 'goimports'

Format file after write to buffer:

autocmd BufWritePost *.go :call completor#do('format')

c/c++ practices (without using lsp)

Jump to completion placeholder:

map <c-\> <Plug>CompletorCppJumpToPlaceholder
imap <c-\> <Plug>CompletorCppJumpToPlaceholder

Disable completion placeholder:

let g:completor_clang_disable_placeholders = 1

Enable LSP

let g:completor_filetype_map = {}
" Enable lsp for go by using gopls
let g:completor_filetype_map.go = {'ft': 'lsp', 'cmd': 'gopls'}
" Enable lsp for rust by using rls
let g:completor_filetype_map.rust = {'ft': 'lsp', 'cmd': 'rls'}
" Enable lsp for c by using clangd
let g:completor_filetype_map.c = {'ft': 'lsp', 'cmd': 'clangd-7'}

completor.vim's People

Contributors

arp242 avatar arthurxavierx avatar bennyyip avatar bstaint avatar damnever avatar dependabot[bot] avatar dmotles avatar fatih avatar ferreum avatar fx-kirin avatar gaumala avatar graingert avatar huntrar avatar jceb avatar jdeuce avatar just-paja avatar kizzx2 avatar kmarc avatar konfekt avatar kris-steinhoff avatar kyouryuukunn avatar leocamelo avatar maralla avatar mikepqr avatar mvanderkamp avatar qazo avatar robinkjoy avatar stevenmaude avatar tobiwild avatar xndcn avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

completor.vim's Issues

Error detected while processing completor/utils.vim

Hi,

I've started getting this error today, not sure what caused it. I didn't update plugins for a while (using vim-plug). I did update brew packages, not sure if vim was on the list. Anyway, here's the error:

Error detected while processing /Users/predmijat/dotfiles/.vim/plugins/completor.vim/autoload/completor/utils.vim:
line   65:
E126: Missing :endfunction
Error detected while processing function <lambda>2[1]..<SNR>94_complete:
line    4:
E117: Unknown function: completor#utils#get_completer
E15: Invalid expression: completor#utils#get_completer(s:status.ft, s:status.input)
line    5:
E121: Undefined variable: info
E116: Invalid arguments for function empty(info) | return | endif
E15: Invalid expression: empty(info) | return | endif
line    6:
E121: Undefined variable: info
E15: Invalid expression: info
line    8:
E121: Undefined variable: is_sync

As far as I can tell, there's no endfuction missing, variable info is defined...

vim is installed via brew - brew install vim --with-luajit, I've tried to remove it with brew uninstall --force vim and reinstall it, error persists.

Thanks!

Go completion not working, but works with <C-x> <C-o>

I have vim-go installed and pressing <C-x> <C-o> opens autocompletion properly, otherwise nothing works.

I stopped gocode and ran it in debug mode and tested with both <C-x> <C-o> and simply by pressing .. When I press . I get the following output from gocode

2017/04/26 21:14:27 Import path "github.com/stretchr/testify/assert" was not resolved
2017/04/26 21:14:27 Gocode's build context is:
2017/04/26 21:14:27  GOROOT: /usr/local/Cellar/go/1.8.1/libexec
2017/04/26 21:14:27  GOPATH: /Users/brett/go
2017/04/26 21:14:27  GOOS: darwin
2017/04/26 21:14:27  GOARCH: amd64
2017/04/26 21:14:27  BzlProjectRoot: ""
2017/04/26 21:14:27  GBProjectRoot: ""
2017/04/26 21:14:27  lib-path: ""
2017/04/26 21:14:27 extracted expression tokens: b
2017/04/26 21:14:27 Offset: 0
2017/04/26 21:14:27 Number of candidates found: 0
2017/04/26 21:14:27 Candidates are:
2017/04/26 21:14:27 =======================================================

Without changing anything I can press <C-x> <C-o> and completion comes up and gocode prints the following

017/04/26 21:15:05 -------------------------------------------------------
2017/04/26 21:15:05 Found "testing" at "/usr/local/Cellar/go/1.8.1/libexec/pkg/darwin_amd64/testing.a"
2017/04/26 21:15:05 Found "github.com/stretchr/testify/assert" at "/Users/brett/go/pkg/darwin_amd64/github.com/blockloop/go-datastructures/vendor/github.com/stretchr/testify/assert.a"
2017/04/26 21:15:05 Error parsing input file (inner block):
2017/04/26 21:15:05  6:4: expected selector or type assertion, found ';'
2017/04/26 21:15:05  7:2: expected ';', found 'IDENT' assert
2017/04/26 21:15:05  8:2: expected ';', found 'EOF'
2017/04/26 21:15:05  8:2: expected '}', found 'EOF'
2017/04/26 21:15:05 extracted expression tokens: b
2017/04/26 21:15:05 Offset: 0
2017/04/26 21:15:05 Number of candidates found: 6
2017/04/26 21:15:05 Candidates are:
2017/04/26 21:15:05   func Size() int
2017/04/26 21:15:05   func findMin() *Node
2017/04/26 21:15:05   func insert(data int) *Node
2017/04/26 21:15:05   func search(data int) *Node
2017/04/26 21:15:05   var Root *Node
2017/04/26 21:15:05   var size int
2017/04/26 21:15:05 =======================================================

Is vim-go doing something different? Why is omnicomplete working, but the regular completion using . or <tab> not? The autocomplete is triggering, but gocode is reporting the vendor packages not resolving.

I have enabled tab completion as in the readme. This appears to be a problem with the command passed to gocode. github.com/stretchr/testify/assert is installed in vendor/.

Disable file and buffer completers

There is no way to disable these fallback completers. It slows down Vim for large files because it tries to complete for every single word. We should make them optional or provide a setting to disable it.

filename completion

would it be possible to make filename completion relative to file directory instead of current working directory? setting autochdir in vim breaks other things, so it isn't really an option.

thanks!

JavaComplete integration issues (cursor jumping to top)

So, when I tried to use completor with JavaComplete2, I experienced issue with cursor jumping to top of class when writing in insert mode. With completor disabled (or with wrong omni_trigger) when using just to trigger JavaComplete2 omnifunc, this issue is not present. Here is my current completor configuration:

let g:completor_auto_trigger = 0
let g:completor_min_chars = 1
let g:completor_java_omni_trigger = "\\w+$|[\\w\\)\\]\\}'\"]+\\.\\w*$"

I tried this also with auto_trigger enabled and min_chars at 3, nothing changed.

Tern completion doesn't work

Hi,

I have node and NPM installed. I installed the plugin via Vim-Plug and ran make js in plugin's directory (didn't get any errors), but when I try to use it with .js files I only get buffer's keywords as completion. I tested it on Mint 17.3 and WSL. I also tried c++ completion which works fine.

Btw, thank you for the plugin.

ship completeres externally

Shipping completers in external repository would allow users to reuse the server piece and add more features such as go to definition, rename. Useful for completions provided by Language Server Protocol such as typescript server. This would also mean only one instance of the server is running to provide IDE like features.

I think only some of the completers such as buffer, files should ship by default similar to how depoplete does it.

Add support for Swift via SourceKittenDaemon

SourceKittenDaemon works great on MacOS to provide what I believe is the necessary information to implement completion. It is done through a RESTish api. Details on the super simple protocol are as follows.

https://github.com/terhechte/SourceKittenDaemon/blob/master/Protocol.org

I am just not clear exactly on what the intended API is that you are providing to add support for other languages.

I am also not sure what the details of the sync and daemon options on the completor are really for.

I tried to look and see how to implement support for this. But, it wasn't super clear.

I know from just looking at the code I need to provide something like the following. However, the following causes vim to hang indefinitely when it triggers a completion. I can see the completion request show up in the SourceKittenDaemon logs. So, the request seems to be happening.

Anyways, any help you could provide would be great!!

import vim

from completor import Completor

class Swift(Completor):
    filetype = 'swift'
    trigger = r'(?:\w{2,}\w*|\.\w*)$'

    def offset(self):
        line, col = vim.current.window.cursor
        line2byte = vim.Function('line2byte')
        return line2byte(line) + col - 1

    def format_cmd(self):
        binary = self.get_option('completor_swiftsourcekittenclient_binary') or 'sourcekittenclient'
        return [binary, '{}'.format(self.tempname), self.offset()]

    def parse(self, items):
        print("DREW")
        print(items)
        print("DREW END")
        res = []
        # for item in items:
        #     parts = item.split(b',,')
        #     res.append({
        #         'word': parts[1],
        #         'menu': parts[2]
        #     })
        return res

sourcekittenclient

#!/usr/bin/env python

import sys
import urllib2

class SourceKittenDaemon(object):
    def __init__(self, port):
        self.__port = port

    def complete(self, path, offset):
        request = urllib2.Request("http://localhost:%d/complete" % self.__port)
        request.add_header("X-Path", path)
        request.add_header("X-Offset", offset)
        response = urllib2.urlopen(request).read()
        return response

s = SourceKittenDaemon(8081)
sys.stdout.write(s.complete(sys.argv[1], sys.argv[2]))

I guess it would also be helpful to know that I am running SourceKittenDaemon independently because I just want to see the thing work before I invest time getting the plugin to manage the life cycle of the SourceKittenDaemon and its configuration.

Auto trigger not triggered after backspace

Example:

  1. Type import (with a trailing space). It'll show the list of all modules
  2. Type a. It'll show all modules starting with a
  3. Type backspace. Expect same state as in 1., but nothing is shown

Using the following options:

let g:completor_python_omni_trigger = '.*'
let g:completor_min_chars = 1

Unable to find the file with `racer daemon` on Windows

It seems racer daemon can not take quoted filename as an argument. When I drop the quote, racer can successfully find the file and give out matches.
But another problem arises, that a filename containing spaces can't be found. Having tried to double quoted the filename or escape the spaces with \, but no luck, It can be an issue on the racer side.

I opened up a pull request #64 to partially fix this.

Custom triggers?

Good job here. :)

I'm not sure how this works behind the scenes, but vimtex has its own omni completion function (it completes bibliography entry names, source files to include and so on) and when using NeoComplete or YouCompleteMe you can set up custom triggers to call it, like this:

  let g:neocomplete#sources#omni#input_patterns.tex =
        \ '\v\\%('
        \ . '\a*cite\a*%(\s*\[[^]]*\]){0,2}\s*\{[^}]*'
        \ . '|\a*ref%(\s*\{[^}]*|range\s*\{[^,}]*%(}\{)?)'
        \ . '|hyperref\s*\[[^]]*'
        \ . '|includegraphics\*?%(\s*\[[^]]*\]){0,2}\s*\{[^}]*'
        \ . '|%(include%(only)?|input)\s*\{[^}]*'
        \ . '|\a*(gls|Gls|GLS)(pl)?\a*%(\s*\[[^]]*\]){0,2}\s*\{[^}]*'
        \ . '|includepdf%(\s*\[[^]]*\])?\s*\{[^}]*'
        \ . '|includestandalone%(\s*\[[^]]*\])?\s*\{[^}]*'
        \ . ')'

(The full documentation is here.)

Is there a way to do something like that here?

Also those other plugins work with UltiSnips too, completing the snippet triggers. That would be great!

Hook up Ultisnips Triggers to the completion popup

It would be a killer feature if one could have the ultisnips triggers shown at the completion popup, i think youcompleteme does that. But this is so lightweight i would rather use it here.
I mean, one could still use ultisnips w/o being shown the possible triggers, but i got so used to it being shown to me and i created a bunch of custom ones for different cases, which now makes it difficult for me to have it all in my head.

Well, i hope it can be integrated one day. Thanks for your already amazing plugin tho.

error while complete c++

Traceback (most recent call last):
  File "<string>", line 5, in <module>
  File "/home/wodesuck/.vim/plugged/completor.vim/pythonx/completor/__init__.py", line 121, in get_completions
    return self.parse(base)
  File "/home/wodesuck/.vim/plugged/completor.vim/pythonx/completers/cpp.py", line 66, in parse
    if not item.startswith('COMPLETION:'):
TypeError: startswith first arg must be bytes or a tuple of bytes, not str

environment:

VIM - Vi IMproved 8.0 (2016 Sep 12, compiled Oct 24 2016 17:33:26)
Included patches: 1-46
Compiled by Arch Linux

Customized shortcut?

Thanks for this plugin! Is it possible to customize the behavior of some keys? For example

  • tab to complete from candidate list (and further tab to travel down)
  • Enter to close the popup and do newline (instead of doing nothing)

Trigger completion with Ctrl+Space

Hi I've been trying to bind the completion trigger to <C-Space> but to no avail.

I'm quite the newb when it comes to bindings in vim, but after some Googling managed to come up with:

inoremap <expr> <C-@> pumvisible() ? "\<C-n>" : "\<C-x>\<C-u>\<C-p>"

Something still doesn't seem right however, I think my main problem is not fully understanding how the completions are triggered. If anyone could shed some light on this, it would be much appreciated.

Non-Latin triggers?

Is it possible to make buffer completion trigger also on non-Latin symbols? I use auto completion while writing some documentation, too, and that would be very helpful for me :).

Python completions not working

I only get normal identifier completions + UltiSnips completions and the completions show up with slight delay. Some facts:

  • Vim (8.0.311) is compiled with python3
  • Jedi is installed globally with sudo pip3 install jedi
  • Jedi is importable in python3 shell
  • In python3 shell print sys.executable gives /usr/bin/python3
  • I have let g:completor_python_binary = "/usr/bin/python3" in my .vimrc
  • :CompletorDisable makes the (identifier+UltiSnips) completions instant
  • :CompletorEnable makes the (identifier+UltiSnips) completions have slight delay
  • completor.vim version is e9897d6, latest as of writing
  • I have no other completers installed in Vim

What am I missing and how could I debug this more?

New completer: tmux

I was using deoplete before and I rather miss the tmux completion (tmux-complete). Any chance of getting a tmux completer?

Omni-completion results from vimtex for references

I'd like to have omni-completion for references in a latex document. Vimtex provides results via an omnifunc (https://github.com/lervag/vimtex/blob/master/doc/vimtex.txt#L1487).
I have added following pattern to my vimrc based on lervag/vimtex#453 (comment):

let g:completor_tex_omni_trigger =
        \   '\\(?:'
        \  .   '\w*cite\w*(?:\s*\[[^]]*\]){0,2}\s*{[^}]*'
        \  .  '|\w*ref(?:\s*\{[^}]*|range\s*\{[^,}]*(?:}{)?)'
        \  .  '|hyperref\s*\[[^]]*'
        \  .  '|includegraphics\*?(?:\s*\[[^]]*\]){0,2}\s*\{[^}]*'
        \  .  '|(?:include(?:only)?|input)\s*\{[^}]*'
        \  .')'

First of all, this works.

\documentclass{article}

% This is the sample bib file
\begin{filecontents}{demo.bib}
@book{Saussure1995,
    Author = {Ferdinand de Saussure},
    Origyear = {1916},
    Publisher = {Payot},
    Title = {Cours de Linguistique G{\'e}n{\'e}rale},
    Year = {1995}}

\end{filecontents}

\usepackage{natbib,bibentry}
\bibliographystyle{apalike}
\begin{document}
\bibliography{demo}
This is a complete citation in the middle of the text: 

\bibentry{Saussure1995}
\cite{

\end{document}

You have to compile this file once to generate the file demo.bib so that omni-completion can work (relies on the file specified in \bibliography{demo.bib}.

The issue:
After entering \cite{ the waiting time for the reference is a little bit too long. I suspect this is due to a slow vimtex-omnifunc. But I would have hoped, that there would be a caching to speed things up. However, things do not change when I want to enter a second citation. Does completor caches omni-completion results for the next invocation?

BTW, I do not like that you fix cot=menuone setting. I would prefer it if you would leave this to the user.

Options to enable/disable autocompletion for some filetypes

Currently autocompletion is enabled in all buffers. This is useful for coding, but not really necessary when you write prose, or use plugins like Unite.
There should be option to enable (or to disable) autocompletion only for some filetypes.

timer_stop not working on MacVim 8.0.46 with phpcomplete

Problems summary

The popup menu does not popup until I moved the mouse in GUI MacVim (mvim). But it works very well under terminal MacVim (vim)

I can't tell the problem is caused by Completor.vim, PhpComplete or MacVim it self.

Expected

Popup menu works both GUI and Terminal MacVim

Environment Information

  • OS: OSX 10.11.6
  • Vim version: 8.0.46 (MacVim)

Provide a minimal .vimrc with less than 50 lines (Required!)

set nocompatible
filetype off

execute 'source ~/.vim/bundle/vim-plug/plug.vim'
call plug#begin('~/.vim/bundle/')

Plug 'junegunn/vim-plug'

" Put your bundle below here
Plug 'maralla/completor.vim'
Plug 'shawncplus/phpcomplete.vim'
" Put your bundle above here

call plug#end()

syntax on
filetype plugin indent on

" Put your plugin settings below here
let g:completor_php_omni_trigger = '([$\w]+|use\s*|->[$\w]*|::[$\w]*|implements\s*|extends\s*|class\s+[$\w]+|new\s*)$'
" Put _our plugin settings above here

The reproduce ways from Vim starting (Required!)

  1. :e test.php or set ft=php
  2. Type the following code
<?php
    $date = new DateTime();  // Popup will show here
    $date-> // Popup will not show here, until you moved the mouse corsor

Screen shot (if possible)

Terminal MacVim with completor.vim & phpcomplete.vim, you can see the popup menu show up automatically.
terminal

GUI MacVim with completor.vim & phpcomplete.vim, you can see the popup menu show up until I move the mouse cursor.
macvim

breaks C-e

Hi

When i want to populate a line from below using C-e and the completion popup window is open it does not copy the text from below.

Thanks

Minimum character to trigger the completion

Right now completor tries to complete even if you write a single character. There should be an option to limit the input pattern. Example options from other plugins:

https://github.com/Shougo/deoplete.nvim/blob/master/doc/deoplete.txt#L648
https://github.com/Shougo/neocomplete.vim/blob/master/doc/neocomplete.txt#L290
https://github.com/Valloric/YouCompleteMe/blob/master/doc/youcompleteme.txt#L1861

Without this, it tries to complete everytime the user wants to write something, which is not performant.

Support NeoSnippet

Hi, thanks for this plugin.

Could you also support a Neosnippet source ?

Node module completion just completes core modules

When i require built in node modules like: path, http, ... i get all possible completion items on them after hitting . ( | is cursor position ):

var path = require('path');
path.|   // <-- Here i get all possible items as soon as i hit DOT

But if i require a module like: lodash i get nothing!

var lodash = require('lodash');
lodash.|   // <-- Here i get nothing after hitting DOT 
           //     Also manually feed <C-x><C-u> echos 'pattern not found'

Even using modules just do completions First Time that i require them, and if i close vim and come back to edit same file i don't get completions anymore:
foo.js

module.exports = {
  version: '0.1.0'
}

app.js

var foo = require('./foo');
foo.|   // <-- Here i get *version* just first time if i directly come from foo and require it
        //     and if i close vim and come back i get: 'pattern not found' on hitting DOT
        //     or <C-x><C-u> manually.

Can't re-enable a default blacklisted filetype

I have tried let g:completor_blacklist = ['tagbar', 'qf', 'netrw', 'unite'] and let g:completor_whitelist = ['vimwiki'], but those doesn't enable completion of vimwiki.

I tried those options individually and together.

Auto install tern module use vim-plug.

i'm used gvim 8.0 on windows.
haven't gnu make. so i can't run make js.

I'm too lazy to manually run the command cd path && npm install.
but vim-plug have a post-install hook can do it.

there is a sample:

function! TernInstall(info)
    if ( a:info.status ==# 'installed' || a:info.force ) && executable('npm')
        call system('cd ./pythonx/completers/javascript && npm install')
    endif
endfunction

Plug 'maralla/completor.vim', {
            \ 'do': function('TernInstall')
            \ }

then run PlugUpdate! completor.vim

for who need.

neovim windows support

echo has("job") 0
echo has("timers") 1
echo has("lambda") 0

how can i get job and lambda work on windows?

completor.vim freeze when complete c code

Rencently I start migrating some old plugin with the modern replacement.
Then I found completor.vim, it's very impressive.

But I meet an issue that c completion freeze on windows.

My environment is windows 10 + vim8 + python3.5

When I input some characters and the clang completion was triggered(no competion window showed up), vim will freeze until I press ctrl-c

I tried python completion it works fine.
And I can't reproduce this issue on linux and macos

Did anyone meet the same issue with me?
Thanks

Some problems with UltiSnips integration

Problems summary

  1. When popup menu show up, I type <C-N> to choose candidate, the characters before cursor will repeat.
  2. Some snippets does not end with [snip], it is not easy to recognize
  3. ForwardTrigger and BackwardTrigger not working

Environment Information

  • OS: OSX 10.11.6
  • Vim version: 8.0.46 (MacVim)

Provide a minimal .vimrc with less than 50 lines (Required!)

set nocompatible
filetype off

execute 'source ~/.vim/bundle/vim-plug/plug.vim'
call plug#begin('~/.vim/bundle/')

Plug 'junegunn/vim-plug'

" Put your bundle below here
Plug 'maralla/completor.vim'
Plug 'shawncplus/phpcomplete.vim'
Plug 'SirVer/ultisnips'
Plug 'honza/vim-snippets'
" Put your bundle above here

call plug#end()

syntax on
filetype plugin indent on

" Put your plugin settings below here
let g:completor_php_omni_trigger = '([$\w]+|use\s*|->[$\w]*|::[$\w]*|implements\s*|extends\s*|class\s+[$\w]+|new\s*)$'

let g:UltiSnipsUsePythonVersion = 2
let g:UltiSnipsExpandTrigger="<C-J>"
let g:UltiSnipsJumpForwardTrigger="<C-J>"
let g:UltiSnipsJumpBackwardTrigger="<C-K>"
" Put _our plugin settings above here

The reproduce ways from Vim starting (Required!)

  1. :e test.php or set ft=php
  2. type <? the popup menu will show up, and you can choose candidate by <C-N>, you will see the characters repeat before the curosr.
  3. type foreach the popup menu will show up, and you can see it not end with [snip], choose it and hit <C-J> to expand it, then you can't not use <C-J> to jump next position

Screen shot (if possible)

ultisnips

Occasional Results Flicker

So I have noticed an interesting phenomena that seems to occur rather inconsistently. I've created a small video that shows the issue - essentially it appears that sometimes as I type out characters, the results flicker a bit, as if they go away and re-appear with updated results.

Video

It would be nice if perhaps the results at least stuck around, even if they are not 100% accurate since I find the visual noise more annoying than anything.

Neovim (vimR) throws error when `has('python3') == 1`

When python 3 is installed ( checked with has('python3') and it returns 1 ), completor throws the following error and no omni-completion:

Error detected while processing function <SNR>90_complete[7]..completor#do_complete[2]..completor#trigger[6]..completor#utils#get_completions[1]..provider#python3#Call:
line   18:
Traceback (most recent call last):

  File "<string>", line 1, in <module>

  File "/Users/david/.vim/plugged/completor.vim/pythonx/completor/api.py", line 14, in wrapper
    return func(vim.bindeval('a:'))

  File "/Users/david/.vim/plugged/completor.vim/pythonx/completor/api.py", line 28, in get_completions
    return c.get_completions(args['msg']) if c else []

  File "/Users/david/.vim/plugged/completor.vim/pythonx/completor/__init__.py", line 141, in get_completions
    return self.parse(base)

  File "/Users/david/.vim/plugged/completor.vim/pythonx/completers/common/omni.py", line 61, in parse
    return omnifunc(0, to_bytes(base, get_encoding())[codepoint:])

  File "/Users/david/.vim/plugged/completor.vim/pythonx/completor/patch.py", line 30, in inner
    return _bytes(ret)

  File "/Users/david/.vim/plugged/completor.vim/pythonx/completor/patch.py", line 11, in _bytes
    data[i] = _bytes(e)

  File "/Users/david/.vim/plugged/completor.vim/pythonx/completor/patch.py", line 13, in _bytes
Error detected while processing function <SNR>90_complete[7]..completor#do_complete[2]..completor#trigger[6]..completor#utils#get_completions[1]..provider#python3#Call:
line   18:
    for k, v

Whithout python3 everything works fine but if completions include non-ascii charachters it also throws encoding error with python2.

So there is two issues:

  • The above error when using python 3
  • Encoding error when using python 2

vimR :version returns:

NVIM 0.2.0-dev
Build type: Release
Compilation:
  /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc
  -Wconversion
  -U_FORTIFY_SOURCE
  -D_FORTIFY_SOURCE=1
  -O2
  -DNDEBUG
  -DDISABLE_LOG
  -Wall
  -Wextra
  -pedantic
  -Wno-unused-parameter
  -Wstrict-prototypes
  -std=gnu99
  -Wvla
  -fstack-protector-strong
  -fdiagnostics-color=auto
  -DINCLUDE_GENERATED_DECLARATIONS
  -DHAVE_CONFIG_H
  -I/Users/hat/.jenkins/workspace/vimr_build/neovim/build/config
  -I/Users/hat/.jenkins/workspace/vimr_build/neovim/src
  -I/Users/hat/.jenkins/workspace/vimr_build/neovim/.deps/usr/include
  -I/Users/hat/.jenkins/workspace/vimr_build/neovim/.deps/usr/include
  -I/Users/hat/.jenkins/workspace/vimr_build/neovim/.deps/usr/include
  -I/Users/hat/.jenkins/workspace/vimr_build/neovim/.deps/usr/include
  -I/usr/local/opt/gettext/include
  -I/usr/include
  -I/Users/hat/.jenkins/workspace/vimr_build/neovim/build/src/nvim/auto
  -I/Users/hat/.jenkins/workspace/vimr_build/neovim/build/include
Compiled by [email protected]

Optional features included (+) or not (-): +acl   +iconv    +jemalloc -tui      
For differences from Vim, see :help vim-differences

   system vimrc file: "$VIM/sysinit.vim"
   fall-back for $VIM: "/usr/local/share/nvim"

Toggling completor On/Off

What is the proper way to toggle this plugin On/Off completely? I have been trying to get through your code but couldn't grasp it.

My use case is that I find autocompletion distracting 90% of the time and super useful 10% of the time. I am using completor only for Python with Jedi and don't need file or buffer completion.

Now for some reason completor doesn't seem to work when I set autocomplete on Tab as per README - which would be a solution. It works on Tab with buffers but with Jedi only when I have auto trigger set to 1.

let g:completor_auto_trigger = 1

Constant autocompletion is an overkill for me. I have been trying to move this option to ftplugin/python.vim but that has obvious side-effects of re-enabling completor in other buffers as well.

So I have created small function using completor#disable() and completor#enable()

let g:completor_toggle = 1
function! ToggleAutocomplete()
    if g:completor_toggle == 1
        let g:completor_toggle = 0
        call completor#disable()
    else
        let g:completor_auto_toggle = 1
        call completor#enable()
    endif
endfunction

it seems to work but completor automagically re-enables itself after few keystrokes. I do not understand why and how.

Set python path to active virtualenv

Is it possible to do something like

let g:completor_python_binary = `which python`

to ensure completor and jedi use the currently active virtualenv for completion?

[Sorry, I realize this is possibly a very simple vim question rather than a subtle completor question!]

Preliminary work on typescript/tsserver

I've done some work throwing together a typescript module for completor. I didn't want to submit a pull request because I didn't write unit-tests for it, and I'm not sure if what I did is the best way (or even a good way) to do it.

TSServer requires a file to be "opened" before doing completions on it, i.e. send the open command to TSServer with the filename. I don't know if completor has facilities for this in place, and I don't know enough vimscript to try that route, so I threw it in the request function. That means the completions don't start until the second request.

TSServer also does much more than completions, but is painfully under-documented. I had enough after getting this working.

So feel free to use this as a starting point.

https://gist.github.com/sloat/6ef3a0cc582dc00208e8dde6cfc1d785

Cursor jumps upward if escaping insert mode before buffer is populated.

The general issue appears to be if I type something and hit escape prior to the autocompletion buffer appearing, that my cursor jumps upwards. I have set g:completor_auto_trigger to 1.

I can replicate this specifically with the below example in python.

If I have a module imported, and I type the module name, it tries to populate an autocompletion buffer with recommendations. Then when I type a period, it tries to populate an autocompletion buffer with recommendations from the module. But if I type the period before the first buffer appears, and then escape before the second buffer appears, then my cursor jumps up a seemingly arbitrary amount. I've been able to narrow this down to this plugin (all other plugins are disabled). This example triggers it for me:

import math

mat  # Finish typing 'math.' then hit esc

If you complete typing the word math. and escape before the autocompletion buffer pops up, your cursor should go up one line.

In some of my files my cursor will jump up ~20 lines with 100% reproducibility.

rust integration issues

i setup completor and it work perfectly in everything except rust, when i try using rust with it i get an error
"Error detected while processing function 66_complete[7]..completor#do_complete[5]..completor#daemon#process[21]..267:
line 2:
E900: invalid job id"

i did all that the installation guide said, ie point it to my racer binary and install racer. racer works by itself in the command line ie typing in racer complete std::io:B and then getting a lot of output.

encode error with cpp

When I use completor.vim, I got an error like this:

"main.cpp" 87L, 1927C
Error detected while processing function <SNR>109_complete[4]..completor#utils#get_completer:
line    1:
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/Users/svtter/.vim/plugged/completor.vim/pythonx/completor/api.py", line 14, in wrapper
    return func(vim.bindeval('a:'))
  File "/Users/svtter/.vim/plugged/completor.vim/pythonx/completor/api.py", line 22, in get_completer
    return [c.format_cmd(), c.filetype, c.daemon, c.sync] if c else []
  File "/Users/svtter/.vim/plugged/completor.vim/pythonx/completers/cpp.py", line 44, in format_cmd
    '-I{}'.format(self.current_directory),
UnicodeEncodeError: 'ascii' codec can't encode characters in position 31-35: ordinal not in range(128)
line    2:
Traceback (most recent call last):
  File "<string>", line 1, in <module>
NameError: name 'res' is not defined
E858: Eval did not return a valid python object
E471: Argument required

and here's my source file:
https://gist.github.com/Svtter/e5b338e448a0c843547d9e3dfb8dd81f
wx20170405-111330 2x

Error in command line window

To reproduce it open the command line window (:<c-f>) and start typing a command.
When the autocomplete suggestions are found it opens a popup (this is fine) but when the popup closes it produces this error:

Error detected while processing CompleteDone Auto commands for "*":
E11: Invalid in command-line window; <CR> executes, CTRL-C quits:  pclose | endif

This is very annoying because it steals the focus away from the text we're trying to type.

New completer: buffers

I'd love to have a competer (or an option to the buffer completer) such that completions can come from all vim buffers.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.