Convert Figma logo to code with AI

maralla logocompletor.vim

Async completion framework made ease.

1,312
62
1,312
73

Top Related Projects

A code-completion engine for Vim

24,306

Nodejs extension host for vim & neovim, load extensions like VSCode and host language servers.

3,103

async language server protocol plugin for vim and neovim

Using the jedi autocompletion library for VIM.

Quick Overview

Completor.vim is a fast, asynchronous completion framework for Vim and Neovim. It provides a unified interface for various completion sources, including language servers, buffers, and file systems, offering a seamless and efficient auto-completion experience for developers.

Pros

  • Asynchronous completion, ensuring smooth editing experience
  • Supports multiple completion sources, including language servers (LSP)
  • Easy to extend with custom completion sources
  • Works with both Vim and Neovim

Cons

  • Requires Vim with Python support or Neovim
  • Some users report occasional stability issues
  • Configuration can be complex for advanced setups
  • Limited documentation for certain features

Code Examples

  1. Basic configuration in .vimrc:
Plug 'maralla/completor.vim'
let g:completor_python_binary = '/path/to/python'
let g:completor_node_binary = '/path/to/node'

This code sets up Completor.vim with Vim-Plug and configures paths for Python and Node.js.

  1. Enabling file path completion:
let g:completor_filetype_map = {}
let g:completor_filetype_map.all = ['buffer', 'files']

This example enables buffer and file path completion for all filetypes.

  1. Custom key mapping for manual completion trigger:
inoremap <expr> <Tab> pumvisible() ? "<C-N>" : "<C-R>=completor#do('complete')<CR>"

This mapping allows using the Tab key to trigger completion manually.

Getting Started

To get started with Completor.vim:

  1. Install the plugin using your preferred plugin manager (e.g., Vim-Plug):

    Plug 'maralla/completor.vim'
    
  2. Add basic configuration to your .vimrc:

    let g:completor_python_binary = '/path/to/python'
    let g:completor_node_binary = '/path/to/node'
    
  3. Install any necessary dependencies for your desired completion sources (e.g., language servers).

  4. Restart Vim and enjoy asynchronous completion!

For more advanced configuration and usage, refer to the plugin's documentation.

Competitor Comparisons

A code-completion engine for Vim

Pros of YouCompleteMe

  • More comprehensive language support, including C-family languages, Python, JavaScript, and more
  • Offers semantic completion and advanced features like go-to-definition and refactoring
  • Highly customizable with extensive configuration options

Cons of YouCompleteMe

  • Complex installation process, often requiring compilation
  • Heavier resource usage, which may impact performance on older systems
  • Steeper learning curve due to its many features and configuration options

Code Comparison

YouCompleteMe configuration example:

let g:ycm_auto_trigger = 1
let g:ycm_min_num_of_chars_for_completion = 2
let g:ycm_complete_in_comments = 1

completor.vim configuration example:

let g:completor_auto_trigger = 1
let g:completor_min_chars = 2
let g:completor_complete_in_comments = 1

Key Differences

  • YouCompleteMe offers more advanced features and broader language support, but at the cost of complexity and resource usage
  • completor.vim is lighter and easier to set up, but may lack some advanced features for certain languages
  • YouCompleteMe has a larger community and more frequent updates, while completor.vim is more focused on simplicity and ease of use

Both plugins aim to provide code completion in Vim, but they cater to different user needs and preferences. YouCompleteMe is better suited for users who require advanced features and extensive language support, while completor.vim is ideal for those seeking a lightweight, easy-to-use solution.

24,306

Nodejs extension host for vim & neovim, load extensions like VSCode and host language servers.

Pros of coc.nvim

  • More extensive language server protocol (LSP) support
  • Richer ecosystem with a wide range of extensions
  • Better performance for large projects and complex completions

Cons of coc.nvim

  • Requires Node.js as a dependency
  • Steeper learning curve and more complex configuration
  • Higher memory usage compared to lighter alternatives

Code Comparison

completor.vim:

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

coc.nvim:

let g:coc_global_extensions = ['coc-json', 'coc-tsserver']
inoremap <silent><expr> <TAB> pumvisible() ? "\<C-n>" : <SID>check_back_space() ? "\<TAB>" : coc#refresh()

Both plugins aim to provide code completion for Vim/Neovim, but coc.nvim offers a more comprehensive solution with broader language support and advanced features. completor.vim is lighter and easier to set up but may lack some of the advanced functionality found in coc.nvim.

coc.nvim's extensibility through its plugin ecosystem allows for a more tailored experience, while completor.vim provides a more straightforward, out-of-the-box solution. The choice between the two largely depends on the user's specific needs, project complexity, and willingness to invest time in configuration.

3,103

async language server protocol plugin for vim and neovim

Pros of vim-lsp

  • Supports a wider range of language servers, providing more comprehensive language support
  • More actively maintained with frequent updates and improvements
  • Offers better integration with other Vim plugins and ecosystems

Cons of vim-lsp

  • Requires more configuration and setup compared to completor.vim
  • May have a steeper learning curve for users new to LSP concepts
  • Can be slower in some cases due to its more comprehensive feature set

Code Comparison

vim-lsp configuration example:

if executable('pyls')
    au User lsp_setup call lsp#register_server({
        \ 'name': 'pyls',
        \ 'cmd': {server_info->['pyls']},
        \ 'whitelist': ['python'],
        \ })
endif

completor.vim configuration example:

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

vim-lsp offers more granular control over language server configuration, while completor.vim provides a simpler setup process. vim-lsp is better suited for users who require extensive language support and are comfortable with more complex configurations. completor.vim may be preferable for those seeking a more straightforward, lightweight completion solution with less setup overhead.

Using the jedi autocompletion library for VIM.

Pros of jedi-vim

  • Specialized for Python development with deep language understanding
  • Offers advanced features like goto definitions and docstring display
  • Well-established project with a large user base and active maintenance

Cons of jedi-vim

  • Limited to Python language support only
  • May have slower performance compared to completor.vim's asynchronous completion

Code Comparison

jedi-vim configuration:

let g:jedi#completions_enabled = 1
let g:jedi#use_splits_not_buffers = "right"
let g:jedi#show_call_signatures = "1"

completor.vim configuration:

let g:completor_python_binary = '/path/to/python'
let g:completor_auto_trigger = 1
let g:completor_min_chars = 2

Key Differences

  • Language Support: jedi-vim focuses solely on Python, while completor.vim supports multiple languages
  • Completion Engine: jedi-vim uses Jedi library for intelligent Python completions, completor.vim uses various completion engines
  • Performance: completor.vim offers asynchronous completion, potentially providing better performance in some scenarios
  • Features: jedi-vim provides more Python-specific features like goto definitions and refactoring support

Use Cases

  • Choose jedi-vim for dedicated Python development with advanced language-specific features
  • Opt for completor.vim for multi-language projects or when prioritizing performance in completion

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

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.

Snippets

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

neosnippet: Need to install completor-neosnippet for neosnippet support.

vim-vsnip: Need to install completor-vsnip for vim-vsnip 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'}

To set format options:

let g:completor_filetype_map.rust = {
      \   'ft': 'lsp',
      \   'cmd': 'rust-analyzer',
      \   'options': {
      \     'format': {
      \       'tabSize': 4,
      \       'insertSpaces': v:true
      \     }
      \   }
      \ }