summaryrefslogtreecommitdiffstats
path: root/ftplugin
diff options
context:
space:
mode:
authorAdam Stankiewicz <sheerun@sher.pl>2020-09-24 10:50:19 +0200
committerAdam Stankiewicz <sheerun@sher.pl>2020-09-24 10:50:19 +0200
commite2bbed8acc1f1cf498a0085cf771cf9bf40fb709 (patch)
tree001f4955c399ac71b34fa38f2a3bd63526df50d6 /ftplugin
parent6b4da2753814cc61cd842c589d829f03cd7ca98d (diff)
downloadvim-polyglot-e2bbed8acc1f1cf498a0085cf771cf9bf40fb709.tar.gz
vim-polyglot-e2bbed8acc1f1cf498a0085cf771cf9bf40fb709.zip
Fix django highlighting, fixes #553
Diffstat (limited to 'ftplugin')
-rw-r--r--ftplugin/aspvbs.vim64
-rw-r--r--ftplugin/handlebars.vim127
-rw-r--r--ftplugin/htmldjango.vim17
-rw-r--r--ftplugin/mustache.vim124
4 files changed, 209 insertions, 123 deletions
diff --git a/ftplugin/aspvbs.vim b/ftplugin/aspvbs.vim
new file mode 100644
index 00000000..c2afec5a
--- /dev/null
+++ b/ftplugin/aspvbs.vim
@@ -0,0 +1,64 @@
+if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'aspvbs') == -1
+
+" Vim filetype plugin file
+" Language: aspvbs
+" Maintainer: Dan Sharp <dwsharp at users dot sourceforge dot net>
+" Last Changed: 20 Jan 2009
+" URL: http://dwsharp.users.sourceforge.net/vim/ftplugin
+
+if exists("b:did_ftplugin") | finish | endif
+
+" Make sure the continuation lines below do not cause problems in
+" compatibility mode.
+let s:save_cpo = &cpo
+set cpo-=C
+
+" Define some defaults in case the included ftplugins don't set them.
+let s:undo_ftplugin = ""
+let s:browsefilter = "HTML Files (*.html, *.htm)\t*.htm*\n" .
+ \ "All Files (*.*)\t*.*\n"
+let s:match_words = ""
+
+runtime! ftplugin/html.vim ftplugin/html_*.vim ftplugin/html/*.vim
+let b:did_ftplugin = 1
+
+" Override our defaults if these were set by an included ftplugin.
+if exists("b:undo_ftplugin")
+ let s:undo_ftplugin = b:undo_ftplugin
+endif
+if exists("b:browsefilter")
+ let s:browsefilter = b:browsefilter
+endif
+if exists("b:match_words")
+ let s:match_words = b:match_words
+endif
+
+" ASP: Active Server Pages (with Visual Basic Script)
+" thanks to Gontran BAERTS
+if exists("loaded_matchit")
+ let s:notend = '\%(\<end\s\+\)\@<!'
+ let b:match_ignorecase = 1
+ let b:match_words =
+ \ s:notend . '\<if\>\%(.\{-}then\s\+\w\)\@!:\<elseif\>:^\s*\<else\>:\<end\s\+\<if\>,' .
+ \ s:notend . '\<select\s\+case\>:\<case\>:\<case\s\+else\>:\<end\s\+select\>,' .
+ \ '^\s*\<sub\>:\<end\s\+sub\>,' .
+ \ '^\s*\<function\>:\<end\s\+function\>,' .
+ \ '\<class\>:\<end\s\+class\>,' .
+ \ '^\s*\<do\>:\<loop\>,' .
+ \ '^\s*\<for\>:\<next\>,' .
+ \ '\<while\>:\<wend\>,' .
+ \ s:match_words
+endif
+
+" Change the :browse e filter to primarily show ASP-related files.
+if has("gui_win32")
+ let b:browsefilter="ASP Files (*.asp)\t*.asp\n" . s:browsefilter
+endif
+
+let b:undo_ftplugin = "unlet! b:match_words b:match_ignorecase b:browsefilter | " . s:undo_ftplugin
+
+" Restore the saved compatibility options.
+let &cpo = s:save_cpo
+unlet s:save_cpo
+
+endif
diff --git a/ftplugin/handlebars.vim b/ftplugin/handlebars.vim
new file mode 100644
index 00000000..649984aa
--- /dev/null
+++ b/ftplugin/handlebars.vim
@@ -0,0 +1,127 @@
+if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'handlebars') == -1
+
+if exists('b:loaded_mustache_handlebars')
+ finish
+endif
+let b:loaded_mustache_handlebars = 1
+
+let s:cpo_save = &cpo
+set cpo&vim
+
+" Matchit support for Mustache & Handlebars
+" extending HTML matchit groups
+if exists("loaded_matchit") && exists("b:match_words")
+ let b:match_words = b:match_words
+ \ . ',{:},[:],(:),'
+ \ . '\%({{\)\@<=#\s*\%(if\|unless\)\s*.\{-}}}'
+ \ . ':'
+ \ . '\%({{\)\@<=\s*else\s*}}'
+ \ . ':'
+ \ . '\%({{\)\@<=/\s*\%(if\|unless\)\s*}},'
+ \ . '\%({{\)\@<=[#^]\s*\([-0-9a-zA-Z_?!/.]\+\).\{-}}}'
+ \ . ':'
+ \ . '\%({{\)\@<=/\s*\1\s*}}'
+endif
+
+" Set template for comment
+setlocal commentstring={{!--\ %s\ --}}
+
+if exists("g:mustache_abbreviations")
+ inoremap <buffer> {{{ {{{}}}<left><left><left>
+ inoremap <buffer> {{ {{}}<left><left>
+ inoremap <buffer> {{! {{!}}<left><left>
+ inoremap <buffer> {{< {{<}}<left><left>
+ inoremap <buffer> {{> {{>}}<left><left>
+ inoremap <buffer> {{# {{#}}<cr>{{/}}<up><left><left>
+ inoremap <buffer> {{if {{#if }}<cr>{{/if}}<up><left>
+ inoremap <buffer> {{ife {{#if }}<cr>{{else}}<cr>{{/if}}<up><up><left>
+endif
+
+
+" Section movement
+" Adapted from vim-ruby - many thanks to the maintainers of that plugin
+
+function! s:sectionmovement(pattern,flags,mode,count)
+ norm! m'
+ if a:mode ==# 'v'
+ norm! gv
+ endif
+ let i = 0
+ while i < a:count
+ let i = i + 1
+ " saving current position
+ let line = line('.')
+ let col = col('.')
+ let pos = search(a:pattern,'W'.a:flags)
+ " if there's no more matches, return to last position
+ if pos == 0
+ call cursor(line,col)
+ return
+ endif
+ endwhile
+endfunction
+
+nnoremap <silent> <buffer> [[ :<C-U>call <SID>sectionmovement('{{','b','n',v:count1)<CR>
+nnoremap <silent> <buffer> ]] :<C-U>call <SID>sectionmovement('{{','' ,'n',v:count1)<CR>
+xnoremap <silent> <buffer> [[ :<C-U>call <SID>sectionmovement('{{','b','v',v:count1)<CR>
+xnoremap <silent> <buffer> ]] :<C-U>call <SID>sectionmovement('{{','' ,'v',v:count1)<CR>
+
+
+" Operator pending mappings
+
+" Operators are available by default. Set `let g:mustache_operators = 0` in
+" your .vimrc to disable them.
+if ! exists("g:mustache_operators")
+ let g:mustache_operators = 1
+endif
+
+if exists("g:mustache_operators") && g:mustache_operators
+ onoremap <silent> <buffer> ie :<C-U>call <SID>wrap_inside()<CR>
+ onoremap <silent> <buffer> ae :<C-U>call <SID>wrap_around()<CR>
+ xnoremap <silent> <buffer> ie :<C-U>call <SID>wrap_inside()<CR>
+ xnoremap <silent> <buffer> ae :<C-U>call <SID>wrap_around()<CR>
+endif
+
+function! s:wrap_around()
+ " If the cursor is at the end of the tag element, move back
+ " so that the end tag can be detected.
+ while getline('.')[col('.')-1] ==# '}'
+ execute 'norm h'
+ endwhile
+
+ " Moves to the end of the closing tag
+ let pos = search('}}','We')
+ if pos != 0
+ if getline('.')[col('.')] ==# '}'
+ " Ending tag contains 3 closing brackets '}}}',
+ " move to the last bracket.
+ execute 'norm l'
+ endif
+
+ " select the whole tag
+ execute 'norm v%'
+ endif
+endfunction
+
+function! s:wrap_inside()
+ " If the cursor is at the end of the tag element, move back
+ " so that the end tag can be detected.
+ while getline('.')[col('.')-1] ==# '}'
+ execute 'norm h'
+ endwhile
+
+ " Moves to the end of the closing tag
+ let pos = search('}}','W')
+ if pos != 0
+ " select only inside the tag
+ execute 'norm v%loho'
+ endif
+endfunction
+
+
+let &cpo = s:cpo_save
+unlet s:cpo_save
+
+" vim: nofoldenable
+
+endif
diff --git a/ftplugin/htmldjango.vim b/ftplugin/htmldjango.vim
new file mode 100644
index 00000000..55489c0f
--- /dev/null
+++ b/ftplugin/htmldjango.vim
@@ -0,0 +1,17 @@
+if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'htmldjango') == -1
+
+" Vim filetype plugin file
+" Language: Django HTML template
+" Maintainer: Dave Hodder <dmh@dmh.org.uk>
+" Last Change: 2007 Jan 25
+
+" Only use this filetype plugin when no other was loaded.
+if exists("b:did_ftplugin")
+ finish
+endif
+
+" Use HTML and Django template ftplugins.
+runtime! ftplugin/html.vim
+runtime! ftplugin/django.vim
+
+endif
diff --git a/ftplugin/mustache.vim b/ftplugin/mustache.vim
index 649984aa..7ca19b76 100644
--- a/ftplugin/mustache.vim
+++ b/ftplugin/mustache.vim
@@ -1,127 +1,5 @@
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'handlebars') == -1
-if exists('b:loaded_mustache_handlebars')
- finish
-endif
-let b:loaded_mustache_handlebars = 1
-
-let s:cpo_save = &cpo
-set cpo&vim
-
-" Matchit support for Mustache & Handlebars
-" extending HTML matchit groups
-if exists("loaded_matchit") && exists("b:match_words")
- let b:match_words = b:match_words
- \ . ',{:},[:],(:),'
- \ . '\%({{\)\@<=#\s*\%(if\|unless\)\s*.\{-}}}'
- \ . ':'
- \ . '\%({{\)\@<=\s*else\s*}}'
- \ . ':'
- \ . '\%({{\)\@<=/\s*\%(if\|unless\)\s*}},'
- \ . '\%({{\)\@<=[#^]\s*\([-0-9a-zA-Z_?!/.]\+\).\{-}}}'
- \ . ':'
- \ . '\%({{\)\@<=/\s*\1\s*}}'
-endif
-
-" Set template for comment
-setlocal commentstring={{!--\ %s\ --}}
-
-if exists("g:mustache_abbreviations")
- inoremap <buffer> {{{ {{{}}}<left><left><left>
- inoremap <buffer> {{ {{}}<left><left>
- inoremap <buffer> {{! {{!}}<left><left>
- inoremap <buffer> {{< {{<}}<left><left>
- inoremap <buffer> {{> {{>}}<left><left>
- inoremap <buffer> {{# {{#}}<cr>{{/}}<up><left><left>
- inoremap <buffer> {{if {{#if }}<cr>{{/if}}<up><left>
- inoremap <buffer> {{ife {{#if }}<cr>{{else}}<cr>{{/if}}<up><up><left>
-endif
-
-
-" Section movement
-" Adapted from vim-ruby - many thanks to the maintainers of that plugin
-
-function! s:sectionmovement(pattern,flags,mode,count)
- norm! m'
- if a:mode ==# 'v'
- norm! gv
- endif
- let i = 0
- while i < a:count
- let i = i + 1
- " saving current position
- let line = line('.')
- let col = col('.')
- let pos = search(a:pattern,'W'.a:flags)
- " if there's no more matches, return to last position
- if pos == 0
- call cursor(line,col)
- return
- endif
- endwhile
-endfunction
-
-nnoremap <silent> <buffer> [[ :<C-U>call <SID>sectionmovement('{{','b','n',v:count1)<CR>
-nnoremap <silent> <buffer> ]] :<C-U>call <SID>sectionmovement('{{','' ,'n',v:count1)<CR>
-xnoremap <silent> <buffer> [[ :<C-U>call <SID>sectionmovement('{{','b','v',v:count1)<CR>
-xnoremap <silent> <buffer> ]] :<C-U>call <SID>sectionmovement('{{','' ,'v',v:count1)<CR>
-
-
-" Operator pending mappings
-
-" Operators are available by default. Set `let g:mustache_operators = 0` in
-" your .vimrc to disable them.
-if ! exists("g:mustache_operators")
- let g:mustache_operators = 1
-endif
-
-if exists("g:mustache_operators") && g:mustache_operators
- onoremap <silent> <buffer> ie :<C-U>call <SID>wrap_inside()<CR>
- onoremap <silent> <buffer> ae :<C-U>call <SID>wrap_around()<CR>
- xnoremap <silent> <buffer> ie :<C-U>call <SID>wrap_inside()<CR>
- xnoremap <silent> <buffer> ae :<C-U>call <SID>wrap_around()<CR>
-endif
-
-function! s:wrap_around()
- " If the cursor is at the end of the tag element, move back
- " so that the end tag can be detected.
- while getline('.')[col('.')-1] ==# '}'
- execute 'norm h'
- endwhile
-
- " Moves to the end of the closing tag
- let pos = search('}}','We')
- if pos != 0
- if getline('.')[col('.')] ==# '}'
- " Ending tag contains 3 closing brackets '}}}',
- " move to the last bracket.
- execute 'norm l'
- endif
-
- " select the whole tag
- execute 'norm v%'
- endif
-endfunction
-
-function! s:wrap_inside()
- " If the cursor is at the end of the tag element, move back
- " so that the end tag can be detected.
- while getline('.')[col('.')-1] ==# '}'
- execute 'norm h'
- endwhile
-
- " Moves to the end of the closing tag
- let pos = search('}}','W')
- if pos != 0
- " select only inside the tag
- execute 'norm v%loho'
- endif
-endfunction
-
-
-let &cpo = s:cpo_save
-unlet s:cpo_save
-
-" vim: nofoldenable
+runtime! ftplugin/handlebars*.vim ftplugin/handlebars/*.vim
endif