mirror of
https://github.com/mattn/emmet-vim.git
synced 2025-12-06 10:44:24 +08:00
Compare commits
7 Commits
4c7d28ca7d
...
7d19d812a3
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7d19d812a3 | ||
|
|
6c511a8d7d | ||
|
|
033476412e | ||
|
|
8f1581550d | ||
|
|
c5c5188a0b | ||
|
|
a37097cf18 | ||
|
|
a407c0fec7 |
@@ -379,8 +379,12 @@ function! emmet#getFileType(...) abort
|
||||
endif
|
||||
endif
|
||||
|
||||
let pos = emmet#util#getcurpos()
|
||||
let type = synIDattr(synID(max([pos[1], 1]), max([pos[2], 1]), 1), 'name')
|
||||
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
|
||||
|
||||
" ignore htmlTagName as it seems to occur too often
|
||||
if type == 'htmlTagName'
|
||||
@@ -1913,7 +1917,11 @@ let s:emmet_settings = {
|
||||
\ 'cap': 'caption',
|
||||
\ 'colg': 'colgroup',
|
||||
\ 'fst': 'fieldset',
|
||||
\ 'btn:': 'button',
|
||||
\ 'fst:disabled': 'fieldset',
|
||||
\ 'btn': 'button',
|
||||
\ 'btn:d': 'button',
|
||||
\ 'btn:r': 'button',
|
||||
\ 'btn:s': 'button',
|
||||
\ 'optg': 'optgroup',
|
||||
\ 'opt': 'option',
|
||||
\ 'pic': 'picture',
|
||||
@@ -1929,6 +1937,7 @@ let s:emmet_settings = {
|
||||
\ 'sty': 'style',
|
||||
\ 'prog': 'progress',
|
||||
\ 'fset': 'fieldset',
|
||||
\ 'fset:d': 'fieldset',
|
||||
\ 'datag': 'datagrid',
|
||||
\ 'datal': 'datalist',
|
||||
\ 'kg': 'keygen',
|
||||
|
||||
25
lua/emmet_utils.lua
Normal file
25
lua/emmet_utils.lua
Normal file
@@ -0,0 +1,25 @@
|
||||
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