forked from VimPlug/emmet-vim
Merge pull request #433 from jpsouzasilva/prioritize-syntax
Prioritizes syntax at the current cursor position for determining the file type
This commit is contained in:
@@ -376,10 +376,23 @@ endfunction
|
||||
|
||||
function! emmet#getFileType(...) abort
|
||||
let flg = get(a:000, 0, 0)
|
||||
let type = ''
|
||||
|
||||
|
||||
if has_key(s:emmet_settings, &filetype)
|
||||
let type = &filetype
|
||||
return &filetype
|
||||
endif
|
||||
|
||||
let pos = emmet#util#getcurpos()
|
||||
let type = synIDattr(synID(pos[1], pos[2], 1), 'name')
|
||||
if type =~? '^css'
|
||||
let type = 'css'
|
||||
elseif type =~? '^html'
|
||||
let type = 'html'
|
||||
elseif type =~? '^jsx'
|
||||
let type = 'jsx'
|
||||
elseif type =~? '^js\w' || type =~? '^javascript'
|
||||
let type = 'javascript'
|
||||
elseif type =~? '^xml'
|
||||
let type = 'xml'
|
||||
else
|
||||
let types = split(&filetype, '\.')
|
||||
for part in types
|
||||
@@ -399,24 +412,8 @@ function! emmet#getFileType(...) abort
|
||||
endif
|
||||
endfor
|
||||
endif
|
||||
if type ==# 'html'
|
||||
let pos = emmet#util#getcurpos()
|
||||
let type = synIDattr(synID(pos[1], pos[2], 1), 'name')
|
||||
if type =~# '^css\w'
|
||||
let type = 'css'
|
||||
endif
|
||||
if type =~# '^html\w'
|
||||
let type = 'html'
|
||||
endif
|
||||
if type =~# '^javaScript'
|
||||
let type = 'javascript'
|
||||
endif
|
||||
if len(type) ==# 0 && type =~# '^xml'
|
||||
let type = 'xml'
|
||||
endif
|
||||
endif
|
||||
if len(type) ==# 0 | let type = 'html' | endif
|
||||
return type
|
||||
|
||||
return len(type) == 0 ? 'html' : type
|
||||
endfunction
|
||||
|
||||
function! emmet#getDollarExprs(expand) abort
|
||||
|
||||
Reference in New Issue
Block a user