Skip to content

Supporting i18n tag #127

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions indent/vue.vim
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ let s:languages = [
\ { 'name': 'css', 'pairs': ['<style', '</style>'] },
\ { 'name': 'coffee', 'pairs': ['<script lang="coffee"', '</script>'] },
\ { 'name': 'javascript', 'pairs': ['<script', '</script>'] },
\ { 'name': 'json', 'pairs': ['<i18n', '</i18n>'] },
\ ]

for s:language in s:languages
Expand Down
17 changes: 16 additions & 1 deletion syntax/vue.vim
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,21 @@ function! s:register_language(language, tag, ...)
endif
endfunction

function! s:register_custom_tag(tag, language)
if s:syntax_available(a:language)
execute 'syntax include @' . a:language . ' syntax/' . a:language . '.vim'
unlet! b:current_syntax
execute 'syntax region vue_' . a:language
\ 'keepend'
\ 'start=/<' . a:tag . '\>\_[^>]*>/'
\ 'end="</' . a:tag . '>"me=s-1'
\ 'contains=@' . a:language . ',vueSurroundingTag'
\ 'fold'
endif
endfunction

call s:register_custom_tag('i18n', 'json')

if !exists("g:vue_disable_pre_processors") || !g:vue_disable_pre_processors
call s:register_language('less', 'style')
call s:register_language('pug', 'template', s:attr('lang', '\%(pug\|jade\)'))
Expand All @@ -55,7 +70,7 @@ if !exists("g:vue_disable_pre_processors") || !g:vue_disable_pre_processors
call s:register_language('scss', 'style')
endif

syn region vueSurroundingTag contained start=+<\(script\|style\|template\)+ end=+>+ fold contains=htmlTagN,htmlString,htmlArg,htmlValue,htmlTagError,htmlEvent
syn region vueSurroundingTag contained start=+<\(\w\|-\)+ end=+>+ fold contains=htmlTagN,htmlString,htmlArg,htmlValue,htmlTagError,htmlEvent
syn keyword htmlSpecialTagName contained template
syn keyword htmlArg contained scoped ts
syn match htmlArg "[@v:][-:.0-9_a-z]*\>" contained
Expand Down