roxma / nvim-completion-manager

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

Abbrev matcher throws `Undefined variable: s:startcol` #157

Closed stellarhoof closed 6 years ago

stellarhoof commented 6 years ago

Only nvim-completion-manager installed. Minimal vimrc with:

    call plug#begin(g:plugdir)
    Plug 'https://github.com/roxma/nvim-completion-manager'
        let g:cm_matcher = {'module': 'cm_matchers.abbrev_matcher', 'case': 'smartcase'}
        " When the <Enter> key is pressed while the popup menu is visible, it
        " only hides the menu. Use this mapping to hide the menu and also start
        " a new line.
        inoremap <expr> <CR> (pumvisible() ? "\<c-y>\<cr>" : "\<CR>")
        " When using CTRL-C to leave insert mode, it does not trigger
        " InsertLeave. You should use CTRL-[, or map the CTRL-C to <ESC>.
        inoremap <C-c> <ESC>
        " Use <TAB> to select the popup menu.
        inoremap <expr> <Tab> pumvisible() ? "\<C-n>" : "\<Tab>"
        inoremap <expr> <S-Tab> pumvisible() ? "\<C-p>" : "\<S-Tab>"
   call plug#end()

Steps to reproduce: Open any file (filetype doesn't matter), enter insert mode and type <C-X><C-U>.

roxma commented 6 years ago

There is a side effect by default when you're not using the default prefix matcher.

:help g:cm_completekeys and read #8

stellarhoof commented 6 years ago

Well yes, I read the documentation beforehand. It sets g:cm_completekeys to use completefunc, which according to #8 reduces flickering. However I don't see how that explains why s:startcol ends up being undefined in Vimscript. Relevant code in autoload/cm.vim:337

func! cm#_completefunc(findstart,base)
    if a:findstart
        return s:startcol-1
    endif
    return {'refresh': 'always', 'words': s:matches }
endfunc

I can also provide the logs but I didn't see anything strange in them.

roxma commented 6 years ago

If <c-x><c-u> is used for auto completion, manually typing <c-x><c-u> is never considered as a use case. I don't think this is a valid issue.

If you need to trigger completion manually, you need <Plug>(cm_force_refresh)

stellarhoof commented 6 years ago

For posterity: The issue was that the_silver_searcher wasn't installed, therefore ag wasn't being found. The logs were helpful in this respect. Because of this, the popup menu wasn't being triggered, forcing me to manually trigger <C-X><C-U>, which produced the error above. #8 does mention that ag needs to be in $PATH, however from a usability point, this should be in the documentation. Would you like me to submit a pull request to add this to the documentation?

roxma commented 6 years ago

Would you like me to submit a pull request to add this to the documentation?

PR is welcome