Skip to content

Commit

Permalink
feat(syntax): support short segment syntax, fix #40
Browse files Browse the repository at this point in the history
  • Loading branch information
chemzqm committed Sep 10, 2018
1 parent d9628fd commit 15b1dd9
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
4 changes: 2 additions & 2 deletions after/indent/javascript.vim
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ function! GetJsxIndent()
" <div> | <div>
" </div> | </div>
" ##); | );
if preline =~# '\v(\s?|\k?)\($'
if preline =~# '\v(\s?|\k?)\($' || preline =~# '\v^\s*\<\>'
return indent(v:lnum - 1) + s:sw()
endif

Expand All @@ -123,7 +123,7 @@ function! GetJsxIndent()
endif

" />
if preline =~# '\v^\s*\/?\>$'
if preline =~# '\v^\s*\/?\>$' || currline =~# '\v^\s*\<\/\>'
"let ind = currline =~# '\v^\s*\<\/' ? ind : ind + s:sw()
let ind = ind + s:sw()
" }> or }}\> or }}>
Expand Down
6 changes: 3 additions & 3 deletions after/syntax/javascript.vim
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ endif
" <tag id="sample">
" s~~~~~~~~~~~~~~~e
syntax region jsxTag
\ matchgroup=jsxTag start=+<[^ }/!?<>"'=:]\@=+
\ matchgroup=jsxTag start=+<[^ }/!?<"'=:]\@=+
\ matchgroup=jsxTag end=+\/\?>+
\ contained
\ contains=jsxTagName,jsxAttrib,jsxEqual,jsxString,jsxEscapeJsAttributes

" </tag>
" ~~~~~~
syntax match jsxEndTag
\ +</[^ /!?<>"']\+>+
\ +</[^ /!?<>"']*>+
\ contained
\ contains=jsxEndString

Expand All @@ -47,7 +47,7 @@ syntax match jsxSelfClosingTag +<[^ /!?<>"'=:]\+\%(\%(=>\|[>]\@!\_.\)\)\{-}\/>+
" <tag></tag>
" s~~~~~~~~~~~e
syntax region jsxRegion
\ start=+\%(<\|\w\)\@<!<\z([^ /!?<>"'=:]\+\)+
\ start=+\%(<\|\w\)\@<!<\z([^ /!?<>"'=:]*\)+
\ skip=+<!--\_.\{-}-->+
\ end=+</\z1\_s\{-}>+
\ end=+/>+
Expand Down
11 changes: 7 additions & 4 deletions react.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class TodoApp extends React.Component {
super(props);
this.handleChange = this.handleChange.bind(this);
this.handleSubmit = this.handleSubmit.bind(this);
this.state = {items: [], text: ''};
this.state = { items: [], text: '' };
}

render() {
Expand All @@ -27,7 +27,7 @@ class TodoApp extends React.Component {
}

handleChange(e) {
this.setState({text: e.target.value});
this.setState({ text: e.target.value });
}

handleSubmit(e) {
Expand Down Expand Up @@ -61,11 +61,11 @@ class MarkdownEditor extends React.Component {
constructor(props) {
super(props);
this.handleChange = this.handleChange.bind(this);
this.state = {value: 'Type some *markdown* here!'};
this.state = { value: 'Type some *markdown* here!' };
}

handleChange() {
this.setState({value: this.refs.textarea.value});
this.setState({ value: this.refs.textarea.value });
}

getRawMarkup() {
Expand All @@ -82,6 +82,9 @@ class MarkdownEditor extends React.Component {
ref="textarea"
defaultValue={this.state.value} />
<h3>Output</h3>
<>
<div></div>
</>
<div
className="content"
dangerouslySetInnerHTML={this.getRawMarkup()}
Expand Down

0 comments on commit 15b1dd9

Please sign in to comment.