Add support for CSS in JS annotations like css` and styled.*`

This commit is contained in:
gitusp
2020-10-18 06:55:14 +09:00
parent dc6cb4fd07
commit f8e6431776
6 changed files with 12 additions and 1 deletions

View File

@@ -404,6 +404,8 @@ function! emmet#getFileType(...) abort
let type = 'typescript'
elseif type =~? '^xml'
let type = 'xml'
elseif type == 'styledEmmetAbbreviation'
let type = 'styled'
else
let types = split(&filetype, '\.')
for part in types
@@ -1680,6 +1682,9 @@ let s:emmet_settings = {
\ 'css.drupal': {
\ 'extends': 'css',
\ },
\ 'styled': {
\ 'extends': 'css',
\ },
\ 'html': {
\ 'snippets': {
\ '!': "html:5",

View File

@@ -23,7 +23,7 @@ function! emmet#lang#css#parseIntoTree(abbr, type) abort
" emmet
let tokens = split(abbr, '+\ze[^+)!]')
let block = emmet#util#searchRegion('{', '}')
if abbr !~# '^@' && emmet#getBaseType(type) ==# 'css' && type !=# 'sass' && block[0] ==# [0,0] && block[1] ==# [0,0]
if abbr !~# '^@' && emmet#getBaseType(type) ==# 'css' && type !=# 'sass' && type !=# 'styled' && block[0] ==# [0,0] && block[1] ==# [0,0]
let current = emmet#newNode()
let current.snippet = substitute(abbr, '\s\+$', '', '') . " {\n" . indent . "${cursor}\n}"
let current.name = ''

3
syntax/javascript.vim Normal file
View File

@@ -0,0 +1,3 @@
" Register `styledEmmetAbbreviation` syntax in `styledDefinition` region defined in
" https://github.com/styled-components/vim-styled-components.
syntax match styledEmmetAbbreviation "[a-z0-9#+!%]\+" containedin=styledDefinition contained

View File

@@ -0,0 +1 @@
runtime syntax/javascript.vim

1
syntax/typescript.vim Normal file
View File

@@ -0,0 +1 @@
runtime syntax/javascript.vim

View File

@@ -0,0 +1 @@
runtime syntax/javascript.vim