gabrielelana / vim-markdown

Markdown for Vim: a complete environment to create Markdown files with a syntax highlight that doesn't suck!
MIT License
740 stars 59 forks source link

Snippet completion with <tab>? #69

Open srsudar opened 6 years ago

srsudar commented 6 years ago

I use UltiSnips for snippets in my markdown. By default I use <tab> to complete Snippets. That completion is no longer working with this plugin enabled.

I would have thought that was because <tab> here indents list items, but a few other things are going wonky on me as well--eg my autowrap at 80 is no longer working.

Before trying to track down potential vagaries in my configuration I was hoping to hear if you use snippets successfully, if your <tab> mapping only applies in the context of a bulleted list and otherwise should be unaffected, etc.

Any thoughts you might have would be much appreciated.

This looks great and I would love to get my config back to normal so I can use it without hiccups.

srsudar commented 6 years ago

Aha, :verbose imap <tab> reveals the problem. The insert mode mappings override my existing <tab> trigger, and it looks like they don't pass on the keypress to the next function (no idea if this is possible or desirable in general), eg:

    inoremap <silent> <buffer> <script> <expr> <Tab>
      \ <SID>IsAnEmptyListItem() \|\| <SID>IsAnEmptyQuote() ? '<C-O>:call <SID>Indent(1)<CR>' : '<Tab>'

I can disable this with g:markdown_enable_insert_mappings = 0, but I would love to keep these very useful commands if possible. I don't know enough about vimscript to suggest good options I'm afraid.

tachim commented 5 years ago

Hey @srsudar did you find any good workaround for this?

srsudar commented 5 years ago

Hmm you know I do not remember. Apparently I use my own fork of the repo in my .vimrc, but I don't appear to actually have any diffs there. I think I was trying to get fancy with changing the bullet formatting, but in the end I found it too imperfect so I just turned it all off.

UltiSnips now works for me, I think due to this line in my .vimrc:

let g:markdown_enable_insert_mode_mappings = 0

I can't remember what I lost by enabling that, but I don't miss it.

tachim commented 5 years ago

Thanks. Presumably what you lose is tab/shift-tab for indenting and un-indenting while in insert mode.

unixdigest commented 4 years ago

This is also a problem with both supertab and if you use a custom function like these: https://vim.fandom.com/wiki/Smart_mapping_for_tab_completion

The solution provided by @srsudar solves the issue nicely.