vimカスタムポップアップメニュー

vimカスタムポップアップメニュー

カスタム完成ポップアップメニューを作成する方法。

文字列の一部を入力し、カスタムキーの組み合わせをタップして、特定の文字列グループに対してのみポップアップコンプリート機能を使用できるようにしたいです。

すでにOmniの設定が完了しており、そのリストに追加したくありません。

たとえば、次のリストがあります。
spo
spe
spa

spと入力してCtrl + >を押すと、特定のリストの補完ボックスが表示されます。

ベストアンサー1

  inoremap <F5> <C-R>=ListMonths()<CR>

    func! ListMonths()
      call complete(col('.'), ['January', 'February', 'March',
            \ 'April', 'May', 'June', 'July', 'August', 'September',
            \ 'October', 'November', 'December'])
      return ''
    endfunc

それを発見!彼らが私たちに話したいのは魔法の本に隠された文書です =)

========================私の最終スクリプトは次のとおりです

inoremap <F5> <C-R>=CustomComplete()<CR>

        func! CustomComplete()
                echom 'move to start of last word'
                normal b
                echom 'select word under cursor'
                let b:word = expand('<cword>')
                echom '->'.b:word.'<-'
                echom 'save position'
                let b:position = col('.')
                echom '->'.b:position.'<-'
                normal e
                normal l
                echom 'move to end of word'     

                let b:list = ["spoogle","spangle","frizzle"]
                let b:matches = []


                echom 'begin checking for completion'
                for item in b:list
                echom 'checking '
                echom '->'.item.'<-'      
                        if(match(item,'^'.b:word)==0)
                        echom 'adding to matches'
                        echom '->'.item.'<-'      
                        call add(b:matches,item)
                        endif
                endfor
                call complete(b:position, b:matches)
                return ''
        endfunc

おすすめ記事