lervag / wiki.vim

A wiki plugin for Vim
MIT License
660 stars 69 forks source link

Using ncm2 for link completion #163

Closed j-hui closed 3 years ago

j-hui commented 3 years ago

The docs only discuss making ncm2 aware of the syntax subscopes in a wiki, but don't say anything about using ncm2 for completing links.

In case this is of any value to others, the following registers wiki.vim's omnicomplete function as a source for ncm2:

autocmd User WikiBufferInitialized call ncm2#register_source({
            \ 'name': 'wiki',
            \ 'priority': 9,
            \ 'scope': ['wiki'],
            \ 'word_pattern': '\w+',
            \ 'complete_pattern': '\[\[',
            \ 'on_complete': ['ncm2#on_complete#delay', 200,
            \                 'ncm2#on_complete#omni',
            \                 'wiki#complete#omnicomplete'],
            \ })

This allows wiki-style links to be autocompleted (but not markdown-style links). Perhaps this could be added to the documentation? Or should this be put into a separate ncm2-wiki.vim plugin (like many ncm2 plugin sources are)?

(This is also my first time adding a source to ncm2 so any feedback is appreciated.)

lervag commented 3 years ago

In case this is of any value to others, the following registers wiki.vim's omnicomplete function as a source for ncm2: ... This allows wiki-style links to be autocompleted (but not markdown-style links). Perhaps this could be added to the documentation?

Thanks, I'll add it!

Or should this be put into a separate ncm2-wiki.vim plugin (like many ncm2 plugin sources are)?

I won't do that, but if anyone does, then feel free to let me know and I'll update the docs again.

(This is also my first time adding a source to ncm2 so any feedback is appreciated.)

I no longer use ncm2 myself, but it looks good to me.