Shougo / ddc.vim

Dark deno-powered completion framework for Vim/Neovim
MIT License
676 stars 32 forks source link

README.md instructions gives `Undefined variable: around` #117

Closed grhkm21 closed 1 year ago

grhkm21 commented 1 year ago

Problems summary

I am quite new to vim plugins in general, so sorry if I am doing something stupid. I used the README.md settings under "Configuration", and it seems to work, but everytime I start editing a file it gives an error

E121: Undefined variable: around
E116: Invalid arguments for function ddc#custom#patch_filetype

Environment Information

(Sorry if I did these wrong, but I followed this)

Expected

No error. (But the autocomplete part works fine! I can press tab to select them as well)

Provide a minimal init.vim/vimrc without plugin managers (Required!)

I am not sure how to not use plugin managers...

call plug#begin()

Plug 'Shougo/ddc.vim'
Plug 'vim-denops/denops.vim'

Plug 'Shougo/ddc-ui-native'
Plug 'Shougo/ddc-source-around'
Plug 'Shougo/ddc-matcher_head'
Plug 'Shougo/ddc-sorter_rank'

call plug#end()

" Customize global settings

" You must set the default ui.
" Note: native ui
" https://github.com/Shougo/ddc-ui-native
call ddc#custom#patch_global('ui', 'native')

" Use around source.
" https://github.com/Shougo/ddc-source-around
call ddc#custom#patch_global('sources', ['around'])

" Use matcher_head and sorter_rank.
" https://github.com/Shougo/ddc-matcher_head
" https://github.com/Shougo/ddc-sorter_rank
call ddc#custom#patch_global('sourceOptions', #{
      \ _: #{
      \   matchers: ['matcher_head'],
      \   sorters: ['sorter_rank']},
      \ })

" Change source options
call ddc#custom#patch_global('sourceOptions', #{
      \   around: #{ mark: 'A' },
      \ })
call ddc#custom#patch_global('sourceParams', #{
      \   around: #{ maxSize: 500 },
      \ })

" Customize settings on a filetype
call ddc#custom#patch_filetype(['c', 'cpp'], 'sources',
      \ ['around', 'clangd'])
call ddc#custom#patch_filetype(['c', 'cpp'], 'sourceOptions', #{
      \   clangd: #{ mark: 'C' },
      \ })
call ddc#custom#patch_filetype('markdown', 'sourceParams', {
      \   around: #{ maxSize: 100 },
      \ })

" Mappings

" <TAB>: completion.
inoremap <silent><expr> <TAB>
\ pumvisible() ? '<C-n>' :
\ (col('.') <= 1 <Bar><Bar> getline('.')[col('.') - 2] =~# '\s') ?
\ '<TAB>' : ddc#map#manual_complete()

" <S-TAB>: completion back.
inoremap <expr><S-TAB>  pumvisible() ? '<C-p>' : '<C-h>'

" Use ddc.
call ddc#enable()

How to reproduce the problem from neovim/Vim startup (Required!)

  1. Run nvim file
  2. ...

Screenshot (if possible)

Screenshot 2022-12-23 at 20 19 08

https://asciinema.org/a/2uPF3Senm49xUrGHukWwhxXiC

Log messages

:message

Error detected while processing /Users/grhkm/.config/nvim/init.vim:
line   47:
E121: Undefined variable: around
E116: Invalid arguments for function ddc#custom#patch_filetype
E475: Invalid argument:
Shougo commented 1 year ago

One line is wrong. It must be:

call ddc#custom#patch_filetype('markdown', 'sourceParams', #{
      \   around: #{ maxSize: 100 },
      \ })

I am quite new to vim plugins in general, so sorry if I am doing something stupid. I used the README.md settings under "Configuration", and it seems to work, but everytime I start editing a file it gives an error

I have checked the example in the documentation. It is right. So this is your copy-and-paste miss.