From 1fe780000bb76319d40377360d050631cf526076 Mon Sep 17 00:00:00 2001 From: Yasuhiro Matsumoto Date: Sat, 29 Oct 2016 20:33:05 +0900 Subject: [PATCH] Self closing tag Close #346 --- autoload/emmet.vim | 2 +- autoload/emmet/lang/html.vim | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/autoload/emmet.vim b/autoload/emmet.vim index 5939e68..9d04265 100644 --- a/autoload/emmet.vim +++ b/autoload/emmet.vim @@ -177,7 +177,7 @@ function! emmet#mergeConfig(lhs, rhs) abort endfunction function! emmet#newNode() abort - return { 'name': '', 'attr': {}, 'child': [], 'snippet': '', 'basevalue': 0, 'basedirect': 1, 'multiplier': 1, 'parent': {}, 'value': '', 'pos': 0, 'important': 0, 'attrs_order': ['id', 'class'], 'block': 0 } + return { 'name': '', 'attr': {}, 'child': [], 'snippet': '', 'basevalue': 0, 'basedirect': 1, 'multiplier': 1, 'parent': {}, 'value': '', 'pos': 0, 'important': 0, 'attrs_order': ['id', 'class'], 'block': 0, 'empty': 0 } endfunction function! s:itemno(itemno, current) abort diff --git a/autoload/emmet/lang/html.vim b/autoload/emmet/lang/html.vim index 4ecb584..39ba91e 100644 --- a/autoload/emmet/lang/html.vim +++ b/autoload/emmet/lang/html.vim @@ -401,6 +401,10 @@ function! emmet#lang#html#parseIntoTree(abbr, type) abort endfor endif let abbr = abbr[stridx(abbr, match) + len(match):] + if abbr == '/' + let g:hoge = 1 + let current.empty = 1 + endif if g:emmet_debug > 1 echomsg 'str='.str @@ -562,7 +566,9 @@ function! emmet#lang#html#toString(settings, current, type, inline, filters, ite if len(comment) > 0 && ct ==# 'both' let str = '\n" . str endif - if stridx(','.settings.html.empty_elements.',', ','.current_name.',') != -1 + if current.empty + let str .= ' />' + elseif stridx(','.settings.html.empty_elements.',', ','.current_name.',') != -1 let str .= settings.html.empty_element_suffix else let str .= '>'