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

Prevent errors inside excluded filetype #210

Closed codebeige closed 9 years ago

codebeige commented 9 years ago

I am using sexp for editing clojure files and therefore wanted to disable delimitMate for this filetype. While adding the ft to g:delimitMate_exluded_ft correctly disabled all functionality, there were errors thrown when hitting enter. (This does not happen immediately when editing a single file, but after switching buffers.) This was due to insert mode mappings still triggering delimitMate#ExpandReturn() whith g:delimitMate_expand_cr being enabled. Obviously some dictionary lookups fail:

Error detected while processing function delimitMate#ExpandReturn..<SNR>53_is_forbidden..    <SNR>53_get:
line    7:
E716: Key not present in Dictionary: 3.excluded_regions_enabled
Error detected while processing function delimitMate#ExpandReturn..<SNR>53_get:
line    7:
E716: Key not present in Dictionary: 3.expand_cr
Error detected while processing function delimitMate#ExpandReturn..<SNR>53_get:
line    7:
E716: Key not present in Dictionary: 3.expand_inside_quotes
Error detected while processing function delimitMate#ExpandReturn..<SNR>53_is_empty_matchpair..<SNR>53_get:
line    7:
E716: Key not present in Dictionary: 3.left_delims
Error detected while processing function delimitMate#ExpandReturn..<SNR>53_is_empty_matchpair:
line    3:
E714: List required

I felt like it would be better to not execute the full command for disabled filetypes anyway, so I added a guard clause that will immediately return for excluded filetypes.

codebeige commented 9 years ago

Any chance this might be merged? Does the job for me.

Raimondi commented 9 years ago

Thanks!

codebeige commented 9 years ago

Cool. Thank you for merging. :-)