Skip to content

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

Notifications You must be signed in to change notification settings

jsit/vim-customcpt

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 

Repository files navigation

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:

Options

By itself, this plugin does nothing. Only by setting a couple dictionaries in your .vimrc will <C-X><C-U> 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 plugin. Thanks Aaron! 👋

Thanks also to Steve Losh’s Learn Vimscript the Hard Way and the Stack Exchange community.


Related: CompleteHelper

About

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

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published