mirror of
https://github.com/mattn/emmet-vim.git
synced 2026-02-21 16:08:27 +08:00
Compare commits
2 Commits
master
...
45b6f23506
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
45b6f23506 | ||
|
|
90fa3f7936 |
@@ -371,21 +371,17 @@ endfunction
|
|||||||
|
|
||||||
function! emmet#getFileType(...) abort
|
function! emmet#getFileType(...) abort
|
||||||
let flg = get(a:000, 0, 0)
|
let flg = get(a:000, 0, 0)
|
||||||
|
|
||||||
if has_key(s:emmet_settings, &filetype)
|
if has_key(s:emmet_settings, &filetype)
|
||||||
let type = &filetype
|
let type = &filetype
|
||||||
if emmet#getResource(type, 'ignore_embeded_filetype', 0)
|
if emmet#getResource(type, 'ignore_embeded_filetype', 0)
|
||||||
return type
|
return type
|
||||||
endif
|
endif
|
||||||
endif
|
|
||||||
|
|
||||||
if get(g:, 'loaded_nvim_treesitter', 0)
|
|
||||||
let type = luaeval('require"emmet_utils".get_node_at_cursor()')
|
|
||||||
else
|
|
||||||
let pos = emmet#util#getcurpos()
|
|
||||||
let type = synIDattr(synID(max([pos[1], 1]), max([pos[2], 1]), 1), 'name')
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
let pos = emmet#util#getcurpos()
|
||||||
|
let type = synIDattr(synID(max([pos[1], 1]), max([pos[2], 1]), 1), 'name')
|
||||||
|
|
||||||
" ignore htmlTagName as it seems to occur too often
|
" ignore htmlTagName as it seems to occur too often
|
||||||
if type == 'htmlTagName'
|
if type == 'htmlTagName'
|
||||||
let type = ''
|
let type = ''
|
||||||
@@ -430,7 +426,7 @@ function! emmet#getFileType(...) abort
|
|||||||
endfor
|
endfor
|
||||||
endif
|
endif
|
||||||
|
|
||||||
return empty(type) ? 'html' : type
|
return len(type) == 0 ? 'html' : type
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! emmet#getDollarExprs(expand) abort
|
function! emmet#getDollarExprs(expand) abort
|
||||||
@@ -1759,6 +1755,7 @@ let s:emmet_settings = {
|
|||||||
\ ."<html lang=\"${lang}\">\n"
|
\ ."<html lang=\"${lang}\">\n"
|
||||||
\ ."<head>\n"
|
\ ."<head>\n"
|
||||||
\ ."\t<meta charset=\"${charset}\">\n"
|
\ ."\t<meta charset=\"${charset}\">\n"
|
||||||
|
\ ."\t<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n"
|
||||||
\ ."\t<title></title>\n"
|
\ ."\t<title></title>\n"
|
||||||
\ ."</head>\n"
|
\ ."</head>\n"
|
||||||
\ ."<body>\n\t${child}|\n</body>\n"
|
\ ."<body>\n\t${child}|\n</body>\n"
|
||||||
|
|||||||
@@ -1,25 +0,0 @@
|
|||||||
local M = {}
|
|
||||||
|
|
||||||
M.get_node_at_cursor = function()
|
|
||||||
local ts_utils = require("nvim-treesitter.ts_utils")
|
|
||||||
local node = ts_utils.get_node_at_cursor()
|
|
||||||
if not node then
|
|
||||||
return nil
|
|
||||||
end
|
|
||||||
|
|
||||||
while node do
|
|
||||||
local node_type = node:type()
|
|
||||||
|
|
||||||
if node_type == "element" then
|
|
||||||
return "html"
|
|
||||||
elseif node_type == "stylesheet" then
|
|
||||||
return "css"
|
|
||||||
end
|
|
||||||
|
|
||||||
node = node:parent()
|
|
||||||
end
|
|
||||||
|
|
||||||
return ""
|
|
||||||
end
|
|
||||||
|
|
||||||
return M
|
|
||||||
Reference in New Issue
Block a user