12

GitHub - jayli/vim-easycomplete: 余杭区最好用的 VIM/NVIM 代码自动补全插件

 2 years ago
source link: https://github.com/jayli/vim-easycomplete
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Vim-EasyComplete

中文 | English

A Fast Code Completion Plugin for VIM/NVIM with no redundancy.

Vim-Easycomplete is a minimalism style completion plugin for vim/nvim. In order to provide the best performance and experience. I remove all non-essential requirements and environment dependencies so that it has minimum redundancy. For example, it requires vim script only, and you don't even have to add one line of configuration if you want.

Vim-Easycomplete is easy to install and use. It contains these features:

  • Buffer keywords and dictionary support
  • Directory and file completion support
  • Goto definition support for all languages
  • Full LSP(language-server-protocol) support
  • LSP Server installation with one command
  • Snippet support with ultisnips.

Installation

Easycomplete requires Vim 8.2 and higher version with MacOS/Linux/FreeBSD. For neovim users, 0.4.4 is required (Of course, latest is recommended).

For vim-plug:

Plug 'jayli/vim-easycomplete'

Run :PlugInstall.

For dein.vim

call dein#add('jayli/vim-easycomplete')

Configuration

It use Tab to trigger completion suggestions. You can change this setting by

let g:easycomplete_tab_trigger="<c-space>"

There are four build-in popup menu themes for default styles confliction: dark,light,rider and sharp. (let g:easycomplete_scheme="sharp"). It can be ignored in most cases.

Useage

You can use Tab to trigger the completion suggestions anywhere. Alse use Tab and Shift-Tab to select matched items. Use Ctrl-] for definition jumping, Ctrl-t for jumping back (Same as tags jumping). Or you can use :EasyCompleteGotoDefinition command.

Checking if LSP server is installed via :EasyCompleteCheck. If current LSP Server is not ready, Use :EasyCompleteInstallServer to install.

Typing ./ or ../ to trigger directory completion suggestion.

Dictionary suggestion support via set dictionary=${Your_Dictionary_File} if you need.

Typing :h easycomplete for help.

All commands:

Command Description :EasyCompleteInstallServer Install LSP server for current fileytpe :EasyCompleteGotoDefinition Goto definition position :EasyCompleteCheck Checking LSP server :EasyCompleteProfileStart Start record diagnostics message :EasyCompleteProfileStop Stop record diagnostics message

Language Support

EasyComplete support keywords/dictionary/directory completion by default.

Semantic Completion for Other Languages

Most Language require LSP Server. Install missing LSP Server with :EasyCompleteInstallServer for current filetype (recommended). LSP Server will be installed in ~/.config/vim-easycomplete/servers.

:EasyCompleteInstall

Or you can install a lsp server with specified plugin name (not recommended). Take typescript/javascript for example:

:EasyCompleteInstallServer ts

All supported languages:

Plugin Name Languages Language Server Installer Env requirements directory directory suggestion No Need No None buf keywords & dictionary No Need No None ts JavaScript/TypeScript tsserver Yes node/npm vim Vim vim-language-server Yes node/npm cpp C/C++ ccls Yes ruby/brew css CSS css-languageserver Yes node/npm html HTML html-languageserver Yes node/npm yml YAML yaml-language-server Yes node/npm sh Bash bash-language-server Yes node/npm json JSON json-languageserver Yes node/npm py Python pyls Yes python/pip java Java eclipse-jdt-ls Yes java/jdk go Go gopls Yes go rb Ruby solargraph Yes ruby/bundle lua Lua emmylua-ls Yes java/jdk nim Nim nimlsp Yes nim/nimble grvy Groovy groovy-language-server Yes java/jdk snips Snippets Support ultisnips/vim-snippets No None

More info about semantic completion for each supported language:

Snippet Support

EasyComplete needs ultisnips and vim-snippets for snippets support. This two plugin is compatible with EasyComplete out of the box. Install with vim-plug:

Plug 'SirVer/ultisnips'
Plug 'honza/vim-snippets'

You may meet this error in neovim 0.4.4 with ultisnips:

Error detected while processing /home/xxx/.vim/plugged/ultisnips/autoload/UltiSnips.vim:
line    7:
E319: No "python3" provider found. Run ":checkhealth provider"

Which means python neovim package is missing. Fix it via pip install neovim.

Add custom completion plugin

Take snip as an example (source file) without lsp server.

au User easycomplete_plugin call easycomplete#RegisterSource({
    \ 'name': 'snips',
    \ 'whitelist': ['*'],
    \ 'completor': 'easycomplete#sources#snips#completor',
    \ 'constructor': 'easycomplete#sources#snips#constructor',
    \  })

Another example with lsp server support is easier. source file. By the way, you don't have to writing an omnifunc for Vim's omnicomplete.

Issues

[WIP] If you have bug reports or feature suggestions, please use the issue tracker. In the meantime feel free to read some of my thoughts at https://zhuanlan.zhihu.com/p/366496399.

License


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK