roxma / nvim-completion-manager

:warning: PLEASE USE https://github.com/ncm2/ncm2 INSTEAD
MIT License
917 stars 49 forks source link

Request for mutt aliases integration #97

Closed tricktux closed 7 years ago

tricktux commented 7 years ago

I would like to humbly request for integration with vim-mutt-aliases-plugin.

Thanks for an excellent plugin.

roxma commented 7 years ago

Here's a way to do this, add the following code into your vimrc, you'll also need a snippet engine (ultisnips/snipmate/neosnippet).

The alias name may not match the prefix of the alias pattern (e.g. foo and My Foo <foo@bar.com>), items will be filtered out by NCM. This is why I convert it into snippet.

" ncm's filtering is based on word, so it's better to convert results of
" muttaliases#CompleteMuttAliases into snippet expension
func! g:MuttOmniWrap(findstart, base)
     let ret = muttaliases#CompleteMuttAliases(a:findstart, a:base)
     if type(ret) == type([])
         let i=0
         while i<len(ret)
             let ret[i]['snippet'] = ret[i]['word']
             let ret[i]['word'] = ret[i]['abbr']
             let i+=1
         endwhile
     endif
     return ret
endfunc

au User CmSetup call cm#register_source({'name' : 'mutt',
            \ 'priority': 9, 
            \ 'cm_refresh_length': -1,
            \ 'cm_refresh_patterns': ['^\w+:\s+'],
            \ 'cm_refresh': {'omnifunc': 'g:MuttOmniWrap'},
            \ })
tricktux commented 7 years ago

Awesome!! Thanks!! :100: :+1:

I'll do a screen cast and put it in the screen shots issues once I figure out how to blur screen :stuck_out_tongue:

tricktux commented 7 years ago

This would be a great sample to try to implement #64 ....Just saying :stuck_out_tongue_closed_eyes: