mirror of
https://github.com/mattn/emmet-vim.git
synced 2025-12-06 10:44:24 +08:00
Prioritizes syntax at the current cursor position for determining the file type
This commit is contained in:
@@ -376,8 +376,18 @@ endfunction
|
|||||||
|
|
||||||
function! emmet#getFileType(...) abort
|
function! emmet#getFileType(...) abort
|
||||||
let flg = get(a:000, 0, 0)
|
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)
|
if has_key(s:emmet_settings, &filetype)
|
||||||
let type = &filetype
|
let type = &filetype
|
||||||
else
|
else
|
||||||
@@ -399,23 +409,9 @@ function! emmet#getFileType(...) abort
|
|||||||
endif
|
endif
|
||||||
endfor
|
endfor
|
||||||
endif
|
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
|
if len(type) ==# 0 | let type = 'html' | endif
|
||||||
|
endif
|
||||||
|
|
||||||
return type
|
return type
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user