Last active
August 29, 2015 14:10
-
-
Save mhartington/07c529ed839e5265263f to your computer and use it in GitHub Desktop.
Emmet.vim function
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" Remapping <C-y>, just doesn't cut it. | |
" This is a bit better and works for | |
" angular directives or web components | |
function! s:expand_html_tab() | |
" try to determine if we're within quotes or tags. | |
" if so, assume we're in an emmet fill area. | |
let line = getline('.') | |
if col('.') < len(line) | |
let line = matchstr(line, '[">][^<"]*\%'.col('.').'c[^>"]*[<"]') | |
if len(line) >= 2 | |
return "\<C-y>n" | |
endif | |
endif | |
" go to next item in a popup menu. | |
" this will insert a snippet if it's selected in the menu | |
" due to neosnippets being the first check. | |
if pumvisible() | |
return "\<C-n>" | |
endif | |
" expand anything emmet thinks is expandable. | |
" I'm not sure anything happens below this block. | |
if emmet#isExpandable() | |
return "\<C-y>," | |
endif | |
" return a regular tab character | |
return "\<tab>" | |
endfunction | |
autocmd FileType html imap <buffer><expr><tab> <sid>expand_html_tab() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment