Prioritizes syntax at the current cursor position for determining the file type

This commit is contained in:
jpsouzasilva
2018-08-25 15:22:18 -03:00
parent 63c98d801b
commit 7843f18e40

View File

@@ -376,8 +376,18 @@ endfunction
function! emmet#getFileType(...) abort
let flg = get(a:000, 0, 0)
let type = ''
let pos = emmet#util#getcurpos()
let type = synIDattr(synID(pos[1], pos[2], 1), 'name')
if type =~# '^css\w'
let type = 'css'
elseif type =~# '^html\w'
let type = 'html'
elseif type =~# '^javaScript'
let type = 'javascript'
elseif len(type) ==# 0 && type =~# '^xml'
let type = 'xml'
else
if has_key(s:emmet_settings, &filetype)
let type = &filetype
else
@@ -399,23 +409,9 @@ 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
endif
return type
endfunction