6 Commits

Author SHA1 Message Date
Tiago Rinaldi
11f2d05d81 Merge 90fa3f7936 into 6c511a8d7d 2024-10-21 11:06:42 +01:00
mattn
6c511a8d7d Merge pull request #558 from kola-web/master
support treesitter
2024-08-10 11:07:49 +09:00
kola
033476412e Change treesitter judgment method 2024-08-10 09:32:53 +08:00
kola
8f1581550d my_utils.lua -> emmet_utils.lua 2024-08-10 09:29:20 +08:00
kola
c5c5188a0b support treesitter 2024-08-09 18:06:47 +08:00
Tiago Rinaldi
90fa3f7936 Add meta tag for responsiviness
The usual `html:5_` snippet does not have the meta tag with the contents
`name="viewport" content="width=device-width, initial-scale=1"`, which
allows the website to be responsive.
2020-07-17 14:18:26 -03:00
2 changed files with 35 additions and 5 deletions

View File

@@ -371,16 +371,20 @@ 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 endif
let pos = emmet#util#getcurpos() if get(g:, 'loaded_nvim_treesitter', 0)
let type = synIDattr(synID(max([pos[1], 1]), max([pos[2], 1]), 1), 'name') 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 " ignore htmlTagName as it seems to occur too often
if type == 'htmlTagName' if type == 'htmlTagName'
@@ -1755,6 +1759,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"

25
lua/emmet_utils.lua Normal file
View 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