Raimondi / delimitMate

Vim plugin, provides insert mode auto-completion for quotes, parens, brackets, etc.
http://www.vim.org/scripts/script.php?script_id=2754
1.98k stars 117 forks source link

Error when opening filetypes executing command "DelimitMateSwitch" #186

Closed bluehavana closed 9 years ago

bluehavana commented 10 years ago
".vim/ftplugin/lua/mylua.vim" 
".vim/ftplugin/lua/mylua.vim" 23L, 525C
Error detected while processing function <SNR>32_DelimitMateSwitch..<SNR>32_Unmap..<SNR>32_g..delimitMate#Get..<SNR>33_g:
line    8:
E716: Key not present in Dictionary: 3.right_delims
E716: Key not present in Dictionary: 3.left_delims
E716: Key not present in Dictionary: 3.quotes_list
E716: Key not present in Dictionary: 3.apostrophes_list
Error detected while processing function <SNR>32_DelimitMateSwitch..<SNR>32_Unmap:
line    1:
E745: Using a List as a Number
E15: Invalid expression: s:g('right_delims') + s:g('left_delims') + s:g('quotes_list') + s:g('apostrophes_list') + ['<BS>', '<C-h>', '<S-BS>', '<Del>', '<CR>', '<Space>', '<S-Tab>', '<Esc>'] + ['<Up>', '<Down>', '<Left>', '<Right>', '<LeftMouse>', '<RightMouse>'] + ['<C-Left>', '<C-Right>'] + ['<Home>', '<End>', '<PageUp>', '<PageDown>', '<S-Down>', '<S-Up>', '<C-G>g']
line   11:
E121: Undefined variable: imaps
E15: Invalid expression: imaps
delimitMate has been enabled.

Sorry, was trying really hard to track this down, I can't reproduce it myself except the error only happens when the DelimitMateSwitch command is called from a filetype autocmd (in my case, an ftplugin file).

example from a .vimrc autocmd FileType vim DelimitMateSwitch

When the command is typed in command mode, the functionality is as expected.

Using this with delimitMate_offByDefault to only load on certain programming filetypes.

Also, maybe DelimitMateSwitch could take an argument to specify enable/disable/on/off for cases like this where the command might somehow be executed twice or some such nonsense. It wouldn't break the API if the command without an argument stayed the same. I've no direct experience with vimscript (other than vimrc), otherwise there would be a pull request for this second functionality. The echo via script is also annoying since it blanks the screen upon startup. I think I'm using this command wrong :/

DelimitMateTest belo... can't use redir on this?

Raimondi commented 9 years ago

I couldn't reproduce this, but I might have fixed it. Please, reopen the issue if you still have the problem and give a minimal setup where the problem occurs, so I can try to reproduce it.