Skip to the content.

vim-imagine

A simple context-based vim completion plugin. It wil try to return the most possible word based on current context. Choosing a word from the menu should be avoided.

Supports

Usage

In INSERT mode, press tab to complete the word. Press c-u to undo the completion.

Install

How it works

It tries these methods in order to find out the completion word.

Literial tab

It will return literial tab if there are blanks or the start of line before the cursor.

Custom snippets

It will return the snippet if the characters before the cursor match the key in the dictionary defined by snippets file.

Extensible fuzzy search

It returns the first match that fuzzy methods find in current file. The order can be changed by g:vim_imagine_fuzzy_chain except the favoured method.

The longest is used if there are more than one matched words.

The fuuzy search will try lines near current line first, then all the lines. See fuzzy_near.

Builtin methods

Custom methods

All methods defined in g:vim_imagine_fuzzy_custom_methods are used in fuzzy completion. See the example.

Emmet

It will return emmet-vim’s result if it’s installed when there is only one character before the cursor or b:vim_imagine_use_emmet is 1.

Supertab

It will return supertab’s result if it’s installed. It’s worth nothing that tab can’t be used to move in popup menu, but up, down, enter still work.

Configuration

Variables

g:vim_imagine_snippets_path

It’s recommended to put it under .vim or vimfiles. It’s a normal vimscript file. The only requirement is that these dictionary variables g:vim_imagine_dict, g:vim_imagine_dict_1, g:vim_imagine_dict_2 are defined as expected. If the path is not readable, the example snippets will be used.

Snippets file format

For dictionary variable g:vim_imagine_dict, g:vim_imagine_dict_1, g:vim_imagine_dict_2, the key is the chars before the cursor, and the value is the snippet string.

Special characters like \r, \t, \e are supported in double quoted string(see :h string). Normal mode commands can be executed after \e.

| can be used to mark cursor location.

g:vim_imagine_fuzzy_chain

g:vim_imagine_fuzzy_near

g:vim_imagine_fuzzy_near_chain

g:vim_imagine_fuzzy_custom_methods

g:vim_imagine_fuzzy_favoured_words

b:vim_imagine_use_emmet

Mappings

INSERT mode

NORMAL mode