An open API service indexing awesome lists of open source software.

https://github.com/jsit/vim-customcpt

Easily create custom completion menus using any json or tab-separated file
https://github.com/jsit/vim-customcpt

completion plugin vim

Last synced: about 1 year ago
JSON representation

Easily create custom completion menus using any json or tab-separated file

Awesome Lists containing this project

README

          

# vim-customcpt

Easily create custom completion menus using any dictionary/json file, in the format:

`{ "word(" : { "kind" : "f", "menu" : "menu", "info" : "info" } }`

*Or* a tab-separated values file, like this:

`word kind menu info`

So, for instance, a WordPress function (a full example wordpress.json file is included in this repo):

```
{
"get_bloginfo(" : {
"kind" : "f",
"menu" : "string $show, string $filter | string",
"info" : "Retrieves information about the current site.",
}
}
```

Or, as tab-separated values:

`get_bloginfo( f string $show, string $filter | string Retrieves information about the current site.`

See `:help complete-items` for more info:

```
word the text that will be inserted, mandatory
kind single letter indicating the type of completion
menu extra text for the popup menu, displayed after "word"
or "abbr"
info more information about the item, can be displayed in a
preview window
```

Your custom completion file will show up as a "full" complete menu similar to the omnicomplete menu, like so:

![](http://i.imgur.com/rxbVIdH.png)

## Options

By itself, this plugin does nothing. Only by setting a couple dictionaries in your .vimrc will `` use the completion function generated by your file.

`g:customcpt_funcs` (required): A Dictionary with a function name for a key and a List of files to use for completion with it

```
let g:customcpt_funcs = {
\ "WPComplete" : [
\ $HOME . "/.vim/wordpress.json",
\ ]
\ }
endif
```

`g:customcpt_types` (optional): A Dictionary with a comma-separated list of filetypes as keys and the name of a completion function to use with them

```
let g:customcpt_types = {
\ "php,php.html" : "WPComplete",
\ }
endif
```

Alternatively, you could just do something like this in your .vimrc:

`au FileType php,php.html setlocal completefunc=WPComplete`

## Thanks

This plugin is heavily based on @aaronspring’s [cdo_lazy_vim](https://github.com/aaronspring/cdo_lazy_vim) plugin. Thanks Aaron! 👋

Thanks also to Steve Losh’s [Learn Vimscript the Hard Way](http://learnvimscriptthehardway.stevelosh.com) and the Stack Exchange community.

---

Related: [CompleteHelper](http://www.vim.org/scripts/script.php?script_id=3914)