mirror of
https://github.com/sheerun/vim-polyglot.git
synced 2025-11-08 11:33:52 -05:00
Compare commits
12 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7ec499c19f | ||
|
|
33b86476b6 | ||
|
|
4f36a63813 | ||
|
|
d6479bbf0b | ||
|
|
d53d2189b9 | ||
|
|
a6a6aeab76 | ||
|
|
444e7f184d | ||
|
|
4c028b37bf | ||
|
|
9ff714cb6c | ||
|
|
e2bbed8acc | ||
|
|
6b4da27538 | ||
|
|
c284af58fa |
2
Makefile
2
Makefile
@@ -7,4 +7,4 @@ test:
|
||||
@ scripts/test
|
||||
|
||||
dev:
|
||||
@ echo "packages.yaml\nheuristics.yaml\nscripts/test\nscripts/build\ntests/extensions.vim" | DEV=1 entr bash -c 'make && make test'
|
||||
@ echo "polyglot.vim\npackages.yaml\nheuristics.yaml\nscripts/test\nscripts/build\ntests/extensions.vim" | DEV=1 entr bash -c 'make && make test'
|
||||
|
||||
19
README.md
19
README.md
@@ -1,13 +1,13 @@
|
||||

|
||||
|
||||
 []()
|
||||
 []()
|
||||
|
||||
A collection of language packs for Vim.
|
||||
|
||||
> One to rule them all, one to find them, one to bring them all and in the darkness bind them.
|
||||
|
||||
- It **won't affect your startup time**, as scripts are loaded only on demand\*.
|
||||
- It **installs and updates 120+ times faster** than the <!--Package Count-->200<!--/Package Count--> packages it consists of.
|
||||
- It **installs and updates 120+ times faster** than the <!--Package Count-->201<!--/Package Count--> packages it consists of.
|
||||
- It is more secure because scripts loaded for all extensions are generated by vim-polyglot (ftdetect).
|
||||
- Solid syntax and indentation support (other features skipped). Only the best language packs.
|
||||
- All unnecessary files are ignored (like enormous documentation from php support).
|
||||
@@ -62,7 +62,7 @@ If you need full functionality of any plugin, please use it directly with your p
|
||||
- [ansible](https://github.com/pearofducks/ansible-vim)
|
||||
- [ant](https://github.com/vim/vim/tree/master/runtime)
|
||||
- [apache](https://github.com/vim/vim/tree/master/runtime)
|
||||
- [apiblueprint](https://github.com/sheerun/apiblueprint.vim)
|
||||
- [apiblueprint](https://github.com/kylef/apiblueprint.vim)
|
||||
- [applescript](https://github.com/mityu/vim-applescript)
|
||||
- [aptconf](https://github.com/vim/vim/tree/master/runtime)
|
||||
- [arch](https://github.com/vim/vim/tree/master/runtime)
|
||||
@@ -115,6 +115,7 @@ If you need full functionality of any plugin, please use it directly with your p
|
||||
- [fsharp](https://github.com/ionide/Ionide-vim)
|
||||
- [gdscript](https://github.com/calviken/vim-gdscript3)
|
||||
- [git](https://github.com/tpope/vim-git)
|
||||
- [gitignore](https://github.com/fszymanski/fzf-gitignore)
|
||||
- [glsl](https://github.com/tikhomirov/vim-glsl)
|
||||
- [gmpl](https://github.com/maelvalais/gmpl.vim)
|
||||
- [gnuplot](https://github.com/vim-scripts/gnuplot-syntax-highlighting)
|
||||
@@ -123,8 +124,8 @@ If you need full functionality of any plugin, please use it directly with your p
|
||||
- [graphql](https://github.com/jparise/vim-graphql)
|
||||
- [groovy](https://github.com/vim/vim/tree/master/runtime)
|
||||
- [grub](https://github.com/vim/vim/tree/master/runtime)
|
||||
- [haml](https://github.com/sheerun/vim-haml)
|
||||
- [handlebars](https://github.com/sheerun/vim-mustache-handlebars)
|
||||
- [haml](https://github.com/tpope/vim-haml)
|
||||
- [handlebars](https://github.com/mustache/vim-mustache-handlebars)
|
||||
- [haproxy](https://github.com/CH-DanReif/haproxy.vim)
|
||||
- [haskell](https://github.com/neovimhaskell/haskell-vim)
|
||||
- [haxe](https://github.com/yaymukund/vim-haxe)
|
||||
@@ -133,6 +134,7 @@ If you need full functionality of any plugin, please use it directly with your p
|
||||
- [help](https://github.com/neovim/neovim/tree/master/runtime)
|
||||
- [hive](https://github.com/zebradil/hive.vim)
|
||||
- [html5](https://github.com/othree/html5.vim)
|
||||
- [htmldjango](https://github.com/vim/vim/tree/master/runtime)
|
||||
- [i3](https://github.com/mboughaba/i3config.vim)
|
||||
- [icalendar](https://github.com/chutzpah/icalendar.vim)
|
||||
- [idris2](https://github.com/edwinb/idris2-vim)
|
||||
@@ -141,7 +143,6 @@ If you need full functionality of any plugin, please use it directly with your p
|
||||
- [javascript-sql](https://github.com/statico/vim-javascript-sql)
|
||||
- [javascript](https://github.com/pangloss/vim-javascript)
|
||||
- [jenkins](https://github.com/martinda/Jenkinsfile-vim-syntax)
|
||||
- [jinja](https://github.com/lepture/vim-jinja)
|
||||
- [jq](https://github.com/vito-c/jq.vim)
|
||||
- [json5](https://github.com/GutenYe/json5.vim)
|
||||
- [json](https://github.com/elzr/vim-json)
|
||||
@@ -239,7 +240,7 @@ If you need full functionality of any plugin, please use it directly with your p
|
||||
- [xml](https://github.com/amadeus/vim-xml)
|
||||
- [xsl](https://github.com/vim-scripts/XSLT-syntax)
|
||||
- [yaml](https://github.com/vim/vim/tree/df44a27b53586fccfc6a3aedc89061fdd9a515ff/runtime)
|
||||
- [yard](https://github.com/sheerun/vim-yardoc)
|
||||
- [yard](https://github.com/noprompt/vim-yardoc)
|
||||
- [zephir](https://github.com/xwsoul/vim-zephir)
|
||||
- [zig](https://github.com/ziglang/zig.vim)
|
||||
- [zinit](https://github.com/zinit-zsh/zplugin-vim-syntax)
|
||||
@@ -263,13 +264,13 @@ The list of available languages to disable is shown above.
|
||||
|
||||
*Please declare this variable before polyglot is loaded (at the top of .vimrc)*
|
||||
|
||||
If you wish to use filetype detection by Vim Polyglot but you'd like to use your own syntax-highlighting plugin, you can append `.plugin` to disabled entry, like so:
|
||||
If you wish to use filetype detection by Vim Polyglot but you'd like to use your own syntax-highlighting plugin, you can append `.plugin` to disabled entry, like below. Disabling Vim Polyglot filetype plugin won't disable native Vim filetype plugin.
|
||||
|
||||
```vim
|
||||
let g:polyglot_disabled = ['markdown.plugin']
|
||||
```
|
||||
|
||||
Please note that disabling a language won't make in your vim startup any faster / slower (only for specific this specific filetype). All plugins are lazily loaded only when they are really needed.
|
||||
Please note that disabling a language won't make in your vim startup any faster / slower (only for specific this specific filetype). All plugins are lazily loaded only when they are really needed.
|
||||
|
||||
Vim Polyglot tries to automatically detect indentation settings (just like vim-sleuth). If this feature is not working for you for some reason, please file an issue and disable it temporarily with:
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@ syn match yardNote "@note" contained
|
||||
syn match yardOption "@option" contained
|
||||
syn match yardOverload "@overload" contained
|
||||
syn match yardParam "@param" contained
|
||||
syn match yardParamName /@param \h\+/hs=s+7 contained contains=yardParam
|
||||
syn match yardPrivate "@private" contained
|
||||
syn match yardRaise "@raise" contained
|
||||
syn match yardReturn "@return" contained
|
||||
@@ -32,7 +33,7 @@ syn match yardVersion "@version" contained
|
||||
syn match yardYield "@yield" contained
|
||||
syn match yardYieldParam "@yieldparam" contained
|
||||
syn match yardYieldReturn "@yieldreturn" contained
|
||||
syn cluster yardTags contains=yardGenericTag,yardAbstract,yardApi,yardAttr,yardAttrReader,yardAttrWriter,yardAuthor,yardDeprecated,yardExample,yardNote,yardOption,yardOverload,yardParam,yardPrivate,yardRaise,yardReturn,yardSee,yardSince,yardTodo,yardVersion,yardYield,yardYieldParam,yardYieldReturn
|
||||
syn cluster yardTags contains=yardGenericTag,yardAbstract,yardApi,yardAttr,yardAttrReader,yardAttrWriter,yardAuthor,yardDeprecated,yardExample,yardNote,yardOption,yardOverload,yardParam,yardParamName,yardPrivate,yardRaise,yardReturn,yardSee,yardSince,yardTodo,yardVersion,yardYield,yardYieldParam,yardYieldReturn
|
||||
|
||||
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
" Directives
|
||||
@@ -81,7 +82,7 @@ syn cluster rubyNotTop add=@yardTags,@yardDirectives,@yardTypes,@yardLists,@yard
|
||||
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
hi def link yardComment rubyComment
|
||||
" Tags
|
||||
hi def link yardGenericTag rubyKeyword
|
||||
hi def link yardGenericTag rubyTodo
|
||||
hi def link yardAbstract yardGenericTag
|
||||
hi def link yardApi yardGenericTag
|
||||
hi def link yardAttr yardGenericTag
|
||||
@@ -101,11 +102,11 @@ hi def link yardSee yardGenericTag
|
||||
hi def link yardSince yardGenericTag
|
||||
hi def link yardTodo yardGenericTag
|
||||
hi def link yardVersion yardGenericTag
|
||||
hi def link yield yardGenericTag
|
||||
hi def link yieldparam yardGenericTag
|
||||
hi def link yieldreturn yardGenericTag
|
||||
hi def link yardYield yardGenericTag
|
||||
hi def link yardYieldParam yardGenericTag
|
||||
hi def link yardYieldReturn yardGenericTag
|
||||
" Directives
|
||||
hi def link yardGenericDirective rubyKeyword
|
||||
hi def link yardGenericDirective rubyTodo
|
||||
hi def link yardAttribute yardGenericDirective
|
||||
hi def link yardEndGroup yardGenericDirective
|
||||
hi def link yardGroup yardGenericDirective
|
||||
|
||||
@@ -276,12 +276,14 @@ function! elixir#indent#handle_inside_block(context)
|
||||
" hack - handle do: better
|
||||
let block_info = searchpairpos(start_pattern, '', end_pattern, 'bnW', "line('.') == " . line('.') . " || elixir#indent#searchpair_back_skip() || getline(line('.')) =~ 'do:'", max([0, a:context.lnum - g:elixir_indent_max_lookbehind]))
|
||||
let block_start_lnum = block_info[0]
|
||||
call s:debug("block_start_lnum=" . block_start_lnum)
|
||||
let block_start_col = block_info[1]
|
||||
if block_start_lnum != 0 || block_start_col != 0
|
||||
let block_text = getline(block_start_lnum)
|
||||
let block_start_char = block_text[block_start_col - 1]
|
||||
call s:debug("block_start_char=" . block_start_char)
|
||||
|
||||
let never_match = '\(a\)\@=b'
|
||||
let never_match = ''
|
||||
let config = {
|
||||
\'f': {'aligned_clauses': s:keyword('end'), 'pattern_match_clauses': never_match},
|
||||
\'c': {'aligned_clauses': s:keyword('end'), 'pattern_match_clauses': never_match},
|
||||
@@ -293,17 +295,25 @@ function! elixir#indent#handle_inside_block(context)
|
||||
\'(': {'aligned_clauses': ')', 'pattern_match_clauses': never_match}
|
||||
\}
|
||||
|
||||
" if `with` clause...
|
||||
if block_start_char == 'w'
|
||||
call s:debug("testing s:handle_with")
|
||||
return s:handle_with(block_start_lnum, block_start_col, a:context)
|
||||
else
|
||||
let block_config = config[block_start_char]
|
||||
" if aligned clause (closing tag/`else` clause/etc...) then indent this
|
||||
" at the same level as the block open tag (e.g. `if`/`case`/etc...)
|
||||
if s:starts_with(a:context, block_config.aligned_clauses)
|
||||
call s:debug("clause")
|
||||
return indent(block_start_lnum)
|
||||
else
|
||||
let clause_lnum = searchpair(block_config.pattern_match_clauses, '', '*', 'bnW', "line('.') == " . line('.') . " || elixir#indent#searchpair_back_skip()", block_start_lnum)
|
||||
let relative_lnum = max([clause_lnum, block_start_lnum])
|
||||
if block_config.pattern_match_clauses == never_match
|
||||
let relative_lnum = block_start_lnum
|
||||
else
|
||||
let clause_lnum = searchpair(block_config.pattern_match_clauses, '', '*', 'bnW', "line('.') == " . line('.') . " || elixir#indent#searchpair_back_skip()", block_start_lnum)
|
||||
call s:debug("clause_lum=" . clause_lnum)
|
||||
let relative_lnum = max([clause_lnum, block_start_lnum])
|
||||
end
|
||||
call s:debug("pattern matching relative to lnum " . relative_lnum)
|
||||
return s:do_handle_pattern_match_block(relative_lnum, a:context)
|
||||
endif
|
||||
|
||||
41
autoload/fzf_gitignore.vim
Normal file
41
autoload/fzf_gitignore.vim
Normal file
@@ -0,0 +1,41 @@
|
||||
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'gitignore') == -1
|
||||
|
||||
scriptencoding utf-8
|
||||
|
||||
" Copyright (c) 2017-2020 Filip Szymański. All rights reserved.
|
||||
" Use of this source code is governed by an MIT license that can be
|
||||
" found in the LICENSE file.
|
||||
|
||||
function! s:template_sink(templates) abort
|
||||
try
|
||||
let l:lines = _fzf_gitignore_create(a:templates)
|
||||
catch /^Vim(\(let\|return\)):/
|
||||
return
|
||||
endtry
|
||||
|
||||
new
|
||||
setlocal filetype=gitignore
|
||||
|
||||
call setline(1, l:lines)
|
||||
|
||||
$-2,$delete _
|
||||
normal! gg
|
||||
endfunction
|
||||
|
||||
function! fzf_gitignore#run() abort
|
||||
try
|
||||
let l:opts = {
|
||||
\ 'source': _fzf_gitignore_get_all_templates(),
|
||||
\ 'sink*': function('s:template_sink'),
|
||||
\ 'options': '-m --prompt="Template> " --header="gitignore.io"'
|
||||
\ }
|
||||
catch /^Vim(\(let\|return\)):/
|
||||
return
|
||||
endtry
|
||||
|
||||
call fzf#run(fzf#wrap(l:opts))
|
||||
endfunction
|
||||
|
||||
" vim: ts=2 et sw=2
|
||||
|
||||
endif
|
||||
@@ -1,16 +1,63 @@
|
||||
" Please do not edit this file directly, instead modify polyglot.vim or scripts/build
|
||||
|
||||
" Line continuation is used here, remove 'C' from 'cpoptions'
|
||||
let s:cpo_save = &cpo
|
||||
set cpo&vim
|
||||
|
||||
func! polyglot#Shebang()
|
||||
" Try to detect filetype from shebang
|
||||
let ft = polyglot#ShebangFiletype()
|
||||
if ft != ""
|
||||
let &ft = ft
|
||||
return 1
|
||||
if getline(1) =~# "^#!"
|
||||
let ft = polyglot#ShebangFiletype()
|
||||
if ft != ""
|
||||
let &ft = ft
|
||||
endif
|
||||
endif
|
||||
|
||||
return 0
|
||||
if &ft == ""
|
||||
runtime! scripts.vim
|
||||
endif
|
||||
|
||||
return &ft != ""
|
||||
endfunc
|
||||
|
||||
let s:r_hashbang = '^#!\s*\(\S\+\)\s*\(.*\)\s*'
|
||||
let s:r_envflag = '%(\S\+=\S\+\|-[iS]\|--ignore-environment\|--split-string\)'
|
||||
let s:r_env = '^\%(\' . s:r_envflag . '\s\+\)*\(\S\+\)'
|
||||
|
||||
func! polyglot#ShebangFiletype()
|
||||
let l:line1 = getline(1)
|
||||
|
||||
if l:line1 !~# "^#!"
|
||||
return
|
||||
endif
|
||||
|
||||
let l:pathrest = matchlist(l:line1, s:r_hashbang)
|
||||
|
||||
if len(l:pathrest) == 0
|
||||
return
|
||||
endif
|
||||
|
||||
let [_, l:path, l:rest; __] = l:pathrest
|
||||
|
||||
let l:script = split(l:path, "/")[-1]
|
||||
|
||||
if l:script == "env"
|
||||
let l:argspath = matchlist(l:rest, s:r_env)
|
||||
if len(l:argspath) == 0
|
||||
return
|
||||
endif
|
||||
|
||||
let l:script = l:argspath[1]
|
||||
endif
|
||||
|
||||
if has_key(s:interpreters, l:script)
|
||||
return s:interpreters[l:script]
|
||||
endif
|
||||
|
||||
for interpreter in keys(s:interpreters)
|
||||
if l:script =~# '^' . interpreter
|
||||
return s:interpreters[interpreter]
|
||||
endif
|
||||
endfor
|
||||
endfunc
|
||||
|
||||
let s:interpreters = {
|
||||
@@ -83,48 +130,7 @@ let s:interpreters = {
|
||||
\ 'z3': 'smt2',
|
||||
\ 'deno': 'typescript',
|
||||
\ 'ts-node': 'typescript',
|
||||
\ }
|
||||
|
||||
let s:r_hashbang = '^#!\s*\(\S\+\)\s*\(.*\)\s*'
|
||||
let s:r_envflag = '%(\S\+=\S\+\|-[iS]\|--ignore-environment\|--split-string\)'
|
||||
let s:r_env = '^\%(\' . s:r_envflag . '\s\+\)*\(\S\+\)'
|
||||
|
||||
func! polyglot#ShebangFiletype()
|
||||
let l:line1 = getline(1)
|
||||
|
||||
if l:line1 !~# "^#!"
|
||||
return
|
||||
endif
|
||||
|
||||
let l:pathrest = matchlist(l:line1, s:r_hashbang)
|
||||
|
||||
if len(l:pathrest) == 0
|
||||
return
|
||||
endif
|
||||
|
||||
let [_, l:path, l:rest; __] = l:pathrest
|
||||
|
||||
let l:script = split(l:path, "/")[-1]
|
||||
|
||||
if l:script == "env"
|
||||
let l:argspath = matchlist(l:rest, s:r_env)
|
||||
if len(l:argspath) == 0
|
||||
return
|
||||
endif
|
||||
|
||||
let l:script = l:argspath[1]
|
||||
endif
|
||||
|
||||
if has_key(s:interpreters, l:script)
|
||||
return s:interpreters[l:script]
|
||||
endif
|
||||
|
||||
for interpreter in keys(s:interpreters)
|
||||
if l:script =~# '^' . interpreter
|
||||
return s:interpreters[interpreter]
|
||||
endif
|
||||
endfor
|
||||
endfunc
|
||||
\ }
|
||||
|
||||
func! polyglot#DetectInpFiletype()
|
||||
let line = getline(nextnonblank(1))
|
||||
@@ -372,13 +378,328 @@ func! polyglot#DetectHtmlFiletype()
|
||||
endif
|
||||
for lnum in range(1, min([line("$"), 50]))
|
||||
let line = getline(lnum)
|
||||
if line =~# '{{.*}}\|{%-\=\s*\(end.*\|extends\|block\|macro\|set\|if\|for\|include\|trans\)\(\<\|\>\)'
|
||||
set ft=jinja.html | return
|
||||
if line =~# '{{.*}}\|{%-\=\s*\(end.*\|extends\|block\|macro\|set\|if\|for\|include\|trans\)\(\<\|\>\)\|{#\s\+'
|
||||
set ft=htmldjango | return
|
||||
endif
|
||||
if line =~# '\(\<\|\>\)DTD\s\+XHTML\s'
|
||||
set ft=xhtml | return
|
||||
endif
|
||||
endfor
|
||||
set ft=html | return
|
||||
set ft=html | au! BufWritePost <buffer> ++once call polyglot#DetectHtmlFiletype()
|
||||
return
|
||||
endfunc
|
||||
|
||||
|
||||
" Restore 'cpoptions'
|
||||
let &cpo = s:cpo_save
|
||||
unlet s:cpo_save
|
||||
|
||||
""" ftdetect/polyglot.vim
|
||||
|
||||
" don't spam the user when Vim is started in Vi compatibility mode
|
||||
let s:cpo_save = &cpo
|
||||
set cpo&vim
|
||||
|
||||
" Disable all native vim ftdetect
|
||||
if exists('g:polyglot_test')
|
||||
autocmd!
|
||||
endif
|
||||
|
||||
func! s:Observe(fn)
|
||||
let b:polyglot_observe = a:fn
|
||||
augroup polyglot-observer
|
||||
au! CursorHold,CursorHoldI,BufWritePost <buffer>
|
||||
\ execute('if polyglot#' . b:polyglot_observe . '() | au! polyglot-observer | endif')
|
||||
augroup END
|
||||
endfunc
|
||||
|
||||
let s:disabled_packages = {}
|
||||
let s:new_polyglot_disabled = []
|
||||
|
||||
if exists('g:polyglot_disabled')
|
||||
for pkg in g:polyglot_disabled
|
||||
let base = split(pkg, '\.')
|
||||
if len(base) > 0
|
||||
let s:disabled_packages[pkg] = 1
|
||||
call add(s:new_polyglot_disabled, base[0])
|
||||
endif
|
||||
endfor
|
||||
else
|
||||
let g:polyglot_disabled_not_set = 1
|
||||
endif
|
||||
|
||||
function! s:SetDefault(name, value)
|
||||
if !exists(a:name)
|
||||
let {a:name} = a:value
|
||||
endif
|
||||
endfunction
|
||||
|
||||
call s:SetDefault('g:markdown_enable_spell_checking', 0)
|
||||
call s:SetDefault('g:markdown_enable_input_abbreviations', 0)
|
||||
call s:SetDefault('g:markdown_enable_mappings', 0)
|
||||
|
||||
" Enable jsx syntax by default
|
||||
call s:SetDefault('g:jsx_ext_required', 0)
|
||||
|
||||
" Needed for sql highlighting
|
||||
call s:SetDefault('g:javascript_sql_dialect', 'sql')
|
||||
|
||||
" Make csv loading faster
|
||||
call s:SetDefault('g:csv_start', 1)
|
||||
call s:SetDefault('g:csv_end', 2)
|
||||
|
||||
" Disable json concealing by default
|
||||
call s:SetDefault('g:vim_json_syntax_conceal', 0)
|
||||
|
||||
call s:SetDefault('g:filetype_euphoria', 'elixir')
|
||||
|
||||
if !exists('g:python_highlight_all')
|
||||
call s:SetDefault('g:python_highlight_builtins', 1)
|
||||
call s:SetDefault('g:python_highlight_builtin_objs', 1)
|
||||
call s:SetDefault('g:python_highlight_builtin_types', 1)
|
||||
call s:SetDefault('g:python_highlight_builtin_funcs', 1)
|
||||
call s:SetDefault('g:python_highlight_builtin_funcs_kwarg', 1)
|
||||
call s:SetDefault('g:python_highlight_exceptions', 1)
|
||||
call s:SetDefault('g:python_highlight_string_formatting', 1)
|
||||
call s:SetDefault('g:python_highlight_string_format', 1)
|
||||
call s:SetDefault('g:python_highlight_string_templates', 1)
|
||||
call s:SetDefault('g:python_highlight_indent_errors', 1)
|
||||
call s:SetDefault('g:python_highlight_space_errors', 1)
|
||||
call s:SetDefault('g:python_highlight_doctests', 1)
|
||||
call s:SetDefault('g:python_highlight_func_calls', 1)
|
||||
call s:SetDefault('g:python_highlight_class_vars', 1)
|
||||
call s:SetDefault('g:python_highlight_operators', 1)
|
||||
call s:SetDefault('g:python_highlight_file_headers_as_comments', 1)
|
||||
call s:SetDefault('g:python_slow_sync', 1)
|
||||
endif
|
||||
|
||||
" We need it because scripts.vim in vim uses "set ft=" which cannot be
|
||||
" overridden with setf (and we can't use set ft= so our scripts.vim work)
|
||||
func! s:Setf(ft)
|
||||
if &filetype !~# '\<'.a:ft.'\>'
|
||||
let &filetype = a:ft
|
||||
endif
|
||||
endfunc
|
||||
|
||||
" Function used for patterns that end in a star: don't set the filetype if the
|
||||
" file name matches ft_ignore_pat.
|
||||
" When using this, the entry should probably be further down below with the
|
||||
" other StarSetf() calls.
|
||||
func! s:StarSetf(ft)
|
||||
if expand("<amatch>") !~ g:ft_ignore_pat && &filetype !~# '\<'.a:ft.'\>'
|
||||
let &filetype = a:ft
|
||||
endif
|
||||
endfunc
|
||||
|
||||
augroup filetypedetect
|
||||
|
||||
" scripts/build inserts here filetype detection autocommands
|
||||
|
||||
au! BufNewFile,BufRead,StdinReadPost * if expand("<afile>") !~ g:ft_ignore_pat |
|
||||
\ call polyglot#Shebang() | endif
|
||||
|
||||
au BufEnter * if &ft == "" && expand("<afile>") !~ g:ft_ignore_pat |
|
||||
\ call s:Observe('Shebang') | endif
|
||||
|
||||
augroup END
|
||||
|
||||
if !has_key(s:disabled_packages, 'autoindent')
|
||||
" Code below re-implements sleuth for vim-polyglot
|
||||
let g:loaded_sleuth = 1
|
||||
let g:loaded_foobar = 1
|
||||
|
||||
" Makes shiftwidth to be synchronized with tabstop by default
|
||||
if &shiftwidth == &tabstop
|
||||
let &shiftwidth = 0
|
||||
endif
|
||||
|
||||
function! s:guess(lines) abort
|
||||
let options = {}
|
||||
let ccomment = 0
|
||||
let podcomment = 0
|
||||
let triplequote = 0
|
||||
let backtick = 0
|
||||
let xmlcomment = 0
|
||||
let heredoc = ''
|
||||
let minindent = 10
|
||||
let spaces_minus_tabs = 0
|
||||
let i = 0
|
||||
|
||||
for line in a:lines
|
||||
let i += 1
|
||||
|
||||
if !len(line) || line =~# '^\W*$'
|
||||
continue
|
||||
endif
|
||||
|
||||
if line =~# '^\s*/\*'
|
||||
let ccomment = 1
|
||||
endif
|
||||
if ccomment
|
||||
if line =~# '\*/'
|
||||
let ccomment = 0
|
||||
endif
|
||||
continue
|
||||
endif
|
||||
|
||||
if line =~# '^=\w'
|
||||
let podcomment = 1
|
||||
endif
|
||||
if podcomment
|
||||
if line =~# '^=\%(end\|cut\)\>'
|
||||
let podcomment = 0
|
||||
endif
|
||||
continue
|
||||
endif
|
||||
|
||||
if triplequote
|
||||
if line =~# '^[^"]*"""[^"]*$'
|
||||
let triplequote = 0
|
||||
endif
|
||||
continue
|
||||
elseif line =~# '^[^"]*"""[^"]*$'
|
||||
let triplequote = 1
|
||||
endif
|
||||
|
||||
if backtick
|
||||
if line =~# '^[^`]*`[^`]*$'
|
||||
let backtick = 0
|
||||
endif
|
||||
continue
|
||||
elseif &filetype ==# 'go' && line =~# '^[^`]*`[^`]*$'
|
||||
let backtick = 1
|
||||
endif
|
||||
|
||||
if line =~# '^\s*<\!--'
|
||||
let xmlcomment = 1
|
||||
endif
|
||||
if xmlcomment
|
||||
if line =~# '-->'
|
||||
let xmlcomment = 0
|
||||
endif
|
||||
continue
|
||||
endif
|
||||
|
||||
" This is correct order because both "<<EOF" and "EOF" matches end
|
||||
if heredoc != ''
|
||||
if line =~# heredoc
|
||||
let heredoc = ''
|
||||
endif
|
||||
continue
|
||||
endif
|
||||
let herematch = matchlist(line, '\C<<\W*\([A-Z]\+\)\s*$')
|
||||
if len(herematch) > 0
|
||||
let heredoc = herematch[1] . '$'
|
||||
endif
|
||||
|
||||
let spaces_minus_tabs += line[0] == "\t" ? 1 : -1
|
||||
|
||||
if line[0] == "\t"
|
||||
setlocal noexpandtab
|
||||
let &l:shiftwidth=&tabstop
|
||||
let b:sleuth_culprit .= ':' . i
|
||||
return 1
|
||||
elseif line[0] == " "
|
||||
let indent = len(matchstr(line, '^ *'))
|
||||
if (indent % 2 == 0 || indent % 3 == 0) && indent < minindent
|
||||
let minindent = indent
|
||||
endif
|
||||
endif
|
||||
endfor
|
||||
|
||||
if minindent < 10
|
||||
setlocal expandtab
|
||||
let &l:shiftwidth=minindent
|
||||
let b:sleuth_culprit .= ':' . i
|
||||
return 1
|
||||
endif
|
||||
|
||||
return 0
|
||||
endfunction
|
||||
|
||||
function! s:detect_indent() abort
|
||||
if &buftype ==# 'help'
|
||||
return
|
||||
endif
|
||||
|
||||
let b:sleuth_culprit = expand("<afile>:p")
|
||||
if s:guess(getline(1, 32))
|
||||
return
|
||||
endif
|
||||
let pattern = sleuth#GlobForFiletype(&filetype)
|
||||
if len(pattern) == 0
|
||||
return
|
||||
endif
|
||||
let pattern = '{' . pattern . ',.git,.svn,.hg}'
|
||||
let dir = expand('%:p:h')
|
||||
let level = 3
|
||||
while isdirectory(dir) && dir !=# fnamemodify(dir, ':h') && level > 0
|
||||
" Ignore files from homedir and root
|
||||
if dir == expand('~') || dir == '/'
|
||||
unlet b:sleuth_culprit
|
||||
return
|
||||
endif
|
||||
for neighbor in glob(dir . '/' . pattern, 0, 1)[0:level]
|
||||
let b:sleuth_culprit = neighbor
|
||||
" Do not consider directories above .git, .svn or .hg
|
||||
if fnamemodify(neighbor, ":h:t")[0] == "."
|
||||
let level = 0
|
||||
continue
|
||||
endif
|
||||
if neighbor !=# expand('%:p') && filereadable(neighbor)
|
||||
if s:guess(readfile(neighbor, '', 32))
|
||||
return
|
||||
endif
|
||||
endif
|
||||
endfor
|
||||
|
||||
let dir = fnamemodify(dir, ':h')
|
||||
let level -= 1
|
||||
endwhile
|
||||
|
||||
unlet b:sleuth_culprit
|
||||
endfunction
|
||||
|
||||
setglobal smarttab
|
||||
|
||||
function! SleuthIndicator() abort
|
||||
let sw = &shiftwidth ? &shiftwidth : &tabstop
|
||||
if &expandtab
|
||||
return 'sw='.sw
|
||||
elseif &tabstop == sw
|
||||
return 'ts='.&tabstop
|
||||
else
|
||||
return 'sw='.sw.',ts='.&tabstop
|
||||
endif
|
||||
endfunction
|
||||
|
||||
augroup polyglot-sleuth
|
||||
au!
|
||||
au FileType * call s:detect_indent()
|
||||
au User Flags call Hoist('buffer', 5, 'SleuthIndicator')
|
||||
augroup END
|
||||
|
||||
command! -bar -bang Sleuth call s:detect_indent()
|
||||
endif
|
||||
|
||||
func! s:verify()
|
||||
if exists("g:polyglot_disabled_not_set")
|
||||
if exists("g:polyglot_disabled")
|
||||
echohl WarningMsg
|
||||
echo "vim-polyglot: g:polyglot_disabled should be defined before loading vim-polyglot"
|
||||
echohl None
|
||||
endif
|
||||
|
||||
unlet g:polyglot_disabled_not_set
|
||||
endif
|
||||
endfunc
|
||||
|
||||
au VimEnter * call s:verify()
|
||||
|
||||
" Save polyglot_disabled without postfixes
|
||||
if exists('g:polyglot_disabled')
|
||||
let g:polyglot_disabled = s:new_polyglot_disabled
|
||||
endif
|
||||
|
||||
" restore Vi compatibility settings
|
||||
let &cpo = s:cpo_save
|
||||
@@ -2,7 +2,7 @@ let s:globs = {
|
||||
\ '8th': '*.8th',
|
||||
\ 'Dockerfile': '*.dockerfile,*.dock,*.Dockerfile,Dockerfile,dockerfile,Dockerfile*',
|
||||
\ 'Jenkinsfile': '*.jenkinsfile,*.Jenkinsfile,Jenkinsfile,Jenkinsfile*',
|
||||
\ 'a2ps': 'a2psrc',
|
||||
\ 'a2ps': 'a2psrc,.a2psrc',
|
||||
\ 'a65': '*.a65',
|
||||
\ 'aap': '*.aap',
|
||||
\ 'abap': '*.abap',
|
||||
@@ -13,15 +13,15 @@ let s:globs = {
|
||||
\ 'ada': '*.adb,*.ads,*.ada,*.adc,*.gpr,*.ada_m',
|
||||
\ 'ahdl': '*.tdf',
|
||||
\ 'aidl': '*.aidl',
|
||||
\ 'alsaconf': '',
|
||||
\ 'alsaconf': '.asoundrc',
|
||||
\ 'aml': '*.aml',
|
||||
\ 'ampl': '*.run',
|
||||
\ 'ant': 'build.xml',
|
||||
\ 'apache': 'access.conf*,apache.conf*,apache2.conf*,httpd.conf*,srm.conf*',
|
||||
\ 'apache': '.htaccess,access.conf*,apache.conf*,apache2.conf*,httpd.conf*,srm.conf*',
|
||||
\ 'apiblueprint': '*.apib',
|
||||
\ 'applescript': '*.applescript,*.scpt',
|
||||
\ 'aptconf': 'apt.conf',
|
||||
\ 'arch': '=tagging-method',
|
||||
\ 'arch': '.arch-inventory,=tagging-method',
|
||||
\ 'arduino': '*.pde,*.ino',
|
||||
\ 'art': '*.art',
|
||||
\ 'asciidoc': '*.asciidoc,*.adoc,*.asc',
|
||||
@@ -38,7 +38,7 @@ let s:globs = {
|
||||
\ 'basic': '*.basic',
|
||||
\ 'blade': '*.blade,*.blade.php',
|
||||
\ 'brewfile': 'Brewfile',
|
||||
\ 'bzl': '*.bzl,BUCK,BUILD,BUILD.bazel,Tiltfile,WORKSPACE',
|
||||
\ 'bzl': '*.bzl,*.bazel,*.BUILD,BUCK,BUILD,BUILD.bazel,Tiltfile,WORKSPACE',
|
||||
\ 'c': '*.c,*.cats,*.h,*.idc,*.qc',
|
||||
\ 'caddyfile': 'Caddyfile',
|
||||
\ 'carp': '*.carp',
|
||||
@@ -58,7 +58,7 @@ let s:globs = {
|
||||
\ 'dd': '*.dd',
|
||||
\ 'ddoc': '*.ddoc',
|
||||
\ 'dhall': '*.dhall',
|
||||
\ 'dosini': '*.wrap,*.ini,*.dof,*.lektorproject,*.prefs,*.pro,*.properties,buildozer.spec,php.ini-*',
|
||||
\ 'dosini': '*.wrap,*.ini,*.dof,*.lektorproject,*.prefs,*.pro,*.properties,buildozer.spec,.editorconfig,.npmrc,php.ini-*',
|
||||
\ 'dsdl': '*.sdl',
|
||||
\ 'dune': 'jbuild,dune,dune-project,dune-workspace',
|
||||
\ 'ecrystal': '*.ecr',
|
||||
@@ -80,9 +80,10 @@ let s:globs = {
|
||||
\ 'fsharp': '*.fs,*.fsi,*.fsx',
|
||||
\ 'gdscript3': '*.gd',
|
||||
\ 'gitcommit': 'COMMIT_EDITMSG,MERGE_MSG,TAG_EDITMSG',
|
||||
\ 'gitconfig': '*.gitconfig',
|
||||
\ 'gitconfig': '*.gitconfig,.gitconfig,.gitmodules',
|
||||
\ 'gitignore': '.gitignore',
|
||||
\ 'gitrebase': 'git-rebase-todo',
|
||||
\ 'gitsendemail': '',
|
||||
\ 'gitsendemail': '.gitsendemail.*',
|
||||
\ 'glsl': '*.glsl,*.fp,*.frag,*.frg,*.fs,*.fsh,*.fshader,*.geo,*.geom,*.glslf,*.glslv,*.gs,*.gshader,*.shader,*.tesc,*.tese,*.vert,*.vrx,*.vsh,*.vshader,*.comp',
|
||||
\ 'gmpl': '*.mod',
|
||||
\ 'gnuplot': '*.gp,*.gnu,*.gnuplot,*.p,*.plot,*.plt,*.gpi',
|
||||
@@ -101,17 +102,19 @@ let s:globs = {
|
||||
\ 'help': '',
|
||||
\ 'hive': '*.q,*.hql,*.ql',
|
||||
\ 'html': '*.html,*.htm,*.html.hl,*.inc,*.st,*.xht,*.xhtml',
|
||||
\ 'html.handlebars': '*.handlebars,*.hbs,*.hdbs,*.hb',
|
||||
\ 'html.mustache': '*.mustache,*.hogan,*.hulk,*.hjs',
|
||||
\ 'html.twig': '*.twig',
|
||||
\ 'i3config': '*.i3.config,*.i3config,i3.config,i3config',
|
||||
\ 'htmldjango': '*.jinja,*.j2,*.jinja2,*.njk',
|
||||
\ 'i3config': '*.i3.config,*.i3config,i3.config,i3config,.i3.config,.i3config',
|
||||
\ 'icalendar': '*.ics',
|
||||
\ 'idris': '*.idr,*.lidr,idris-response',
|
||||
\ 'idris2': '*.idr,*.ipkg,idris-response',
|
||||
\ 'ion': '*.ion',
|
||||
\ 'javascript': '*.js,*._js,*.bones,*.cjs,*.es,*.es6,*.frag,*.gs,*.jake,*.jsb,*.jscad,*.jsfl,*.jsm,*.jss,*.mjs,*.njs,*.pac,*.sjs,*.ssjs,*.xsjs,*.xsjslib,Jakefile',
|
||||
\ 'javascriptreact': '*.jsx',
|
||||
\ 'jinja.html': '*.jinja,*.j2,*.jinja2',
|
||||
\ 'jq': '*.jq',
|
||||
\ 'json': '*.json,*.avsc,*.geojson,*.gltf,*.har,*.ice,*.JSON-tmLanguage,*.jsonl,*.mcmeta,*.tfstate,*.tfstate.backup,*.topojson,*.webapp,*.webmanifest,*.yy,*.yyp,*.jsonp,*.template,composer.lock,mcmod.info,Pipfile.lock',
|
||||
\ 'jq': '*.jq,.jqrc,.jqrc*',
|
||||
\ 'json': '*.json,*.avsc,*.geojson,*.gltf,*.har,*.ice,*.JSON-tmLanguage,*.jsonl,*.mcmeta,*.tfstate,*.tfstate.backup,*.topojson,*.webapp,*.webmanifest,*.yy,*.yyp,*.jsonp,*.template,.arcconfig,.htmlhintrc,.tern-config,.tern-project,.watchmanconfig,composer.lock,mcmod.info,Pipfile.lock',
|
||||
\ 'json5': '*.json5',
|
||||
\ 'jsonnet': '*.jsonnet,*.libsonnet',
|
||||
\ 'jst': '*.ejs,*.ect,*.jst',
|
||||
@@ -125,7 +128,7 @@ let s:globs = {
|
||||
\ 'livescript': '*.ls,*._ls,Slakefile',
|
||||
\ 'llvm': '*.ll',
|
||||
\ 'log': '*.log,*.LOG,*_log,*_LOG',
|
||||
\ 'lua': '*.lua,*.fcgi,*.nse,*.p8,*.pd_lua,*.rbxs,*.rockspec,*.wlua',
|
||||
\ 'lua': '*.lua,*.fcgi,*.nse,*.p8,*.pd_lua,*.rbxs,*.rockspec,*.wlua,.luacheckrc',
|
||||
\ 'm4': '*.m4,*.at',
|
||||
\ 'mako': '*.mako,*.mao',
|
||||
\ 'markdown': '*.md,*.markdown,*.mdown,*.mdwn,*.mkd,*.mkdn,*.mkdown,*.ronn,*.workbook,contents.lr',
|
||||
@@ -135,13 +138,12 @@ let s:globs = {
|
||||
\ 'mma': '*.mathematica,*.cdf,*.m,*.ma,*.mt,*.nb,*.nbp,*.wl,*.wlt,*.wls,*.mma',
|
||||
\ 'moon': '*.moon',
|
||||
\ 'murphi': '*.m',
|
||||
\ 'mustache': '*.handlebars,*.hbs,*.hulk,*.hjs,*.mustache,*.njk,*.hogan,*.hdbs,*.hb',
|
||||
\ 'nginx': '*.nginx,*.nginxconf,*.vhost,nginx.conf,nginx*.conf,*nginx.conf',
|
||||
\ 'nim': '*.nim,*.nim.cfg,*.nimble,*.nimrod,*.nims,nim.cfg',
|
||||
\ 'nix': '*.nix',
|
||||
\ 'oasis': '_oasis',
|
||||
\ 'objc': '*.m,*.h',
|
||||
\ 'ocaml': '*.ml,*.eliom,*.eliomi,*.ml4,*.mli,*.mll,*.mly,*.mlt,*.mlp,*.mlip,*.mli.cppo,*.ml.cppo',
|
||||
\ 'ocaml': '*.ml,*.eliom,*.eliomi,*.ml4,*.mli,*.mll,*.mly,*.mlt,*.mlp,*.mlip,*.mli.cppo,*.ml.cppo,.ocamlinit',
|
||||
\ 'ocamlbuild_tags': '_tags',
|
||||
\ 'ocpbuild': '*.ocp',
|
||||
\ 'ocpbuildroot': '*.root',
|
||||
@@ -151,7 +153,7 @@ let s:globs = {
|
||||
\ 'opam': '*.opam,*.opam.template,opam',
|
||||
\ 'opencl': '*.cl,*.opencl',
|
||||
\ 'perl': '*.pl,*.al,*.cgi,*.fcgi,*.perl,*.ph,*.plx,*.pm,*.psgi,*.t,Makefile.PL,Rexfile,ack,cpanfile',
|
||||
\ 'php': '*.php,*.aw,*.ctp,*.fcgi,*.inc,*.php3,*.php4,*.php5,*.phps,*.phpt,Phakefile',
|
||||
\ 'php': '*.php,*.aw,*.ctp,*.fcgi,*.inc,*.php3,*.php4,*.php5,*.phps,*.phpt,.php,.php_cs,.php_cs.dist,Phakefile',
|
||||
\ 'plantuml': '*.puml,*.iuml,*.plantuml,*.uml,*.pu',
|
||||
\ 'pod': '*.pod',
|
||||
\ 'pony': '*.pony',
|
||||
@@ -162,10 +164,10 @@ let s:globs = {
|
||||
\ 'pug': '*.jade,*.pug',
|
||||
\ 'puppet': '*.pp,Modulefile',
|
||||
\ 'purescript': '*.purs',
|
||||
\ 'python': '*.py,*.cgi,*.fcgi,*.gyp,*.gypi,*.lmi,*.py3,*.pyde,*.pyi,*.pyp,*.pyt,*.pyw,*.rpy,*.smk,*.spec,*.tac,*.wsgi,*.xpy,DEPS,SConscript,SConstruct,Snakefile,wscript',
|
||||
\ 'python': '*.py,*.cgi,*.fcgi,*.gyp,*.gypi,*.lmi,*.py3,*.pyde,*.pyi,*.pyp,*.pyt,*.pyw,*.rpy,*.smk,*.spec,*.tac,*.wsgi,*.xpy,.gclient,DEPS,SConscript,SConstruct,Snakefile,wscript',
|
||||
\ 'qmake': '*.pro,*.pri',
|
||||
\ 'qml': '*.qml,*.qbs',
|
||||
\ 'r': '*.r,*.rsx,*.s,*.S,expr-dist',
|
||||
\ 'r': '*.r,*.rsx,*.s,*.S,.Rprofile,expr-dist',
|
||||
\ 'racket': '*.rkt,*.rktd,*.rktl,*.scrbl',
|
||||
\ 'ragel': '*.rl',
|
||||
\ 'raku': '*.6pl,*.6pm,*.nqp,*.p6,*.p6l,*.p6m,*.pl,*.pl6,*.pm,*.pm6,*.t,*.rakudoc,*.rakutest,*.raku,*.rakumod,*.pod6,*.t6',
|
||||
@@ -175,13 +177,13 @@ let s:globs = {
|
||||
\ 'requirements': '*.pip,*requirements.{txt,in},*require.{txt,in},constraints.{txt,in}',
|
||||
\ 'rhelp': '*.rd',
|
||||
\ 'rst': '*.rst,*.rest,*.rest.txt,*.rst.txt',
|
||||
\ 'ruby': '*.rb,*.builder,*.eye,*.fcgi,*.gemspec,*.god,*.jbuilder,*.mspec,*.pluginspec,*.podspec,*.rabl,*.rake,*.rbi,*.rbuild,*.rbw,*.rbx,*.ru,*.ruby,*.spec,*.thor,*.watchr,*.rxml,*.rjs,*.rant,*.axlsx,*.cap,*.opal,Appraisals,Berksfile,Buildfile,Capfile,Dangerfile,Deliverfile,Fastfile,Gemfile,Gemfile.lock,Guardfile,Jarfile,Mavenfile,Podfile,Puppetfile,Rakefile,Snapfile,Thorfile,Vagrantfile,buildfile,Rantfile,Cheffile,KitchenSink,Routefile,vagrantfile,[Rr]akefile*,*_spec.rb',
|
||||
\ 'ruby': '*.rb,*.builder,*.eye,*.fcgi,*.gemspec,*.god,*.jbuilder,*.mspec,*.pluginspec,*.podspec,*.rabl,*.rake,*.rbi,*.rbuild,*.rbw,*.rbx,*.ru,*.ruby,*.spec,*.thor,*.watchr,*.rxml,*.rjs,*.rant,*.axlsx,*.cap,*.opal,.irbrc,.pryrc,.simplecov,Appraisals,Berksfile,Buildfile,Capfile,Dangerfile,Deliverfile,Fastfile,Gemfile,Gemfile.lock,Guardfile,Jarfile,Mavenfile,Podfile,Puppetfile,Rakefile,Snapfile,Thorfile,Vagrantfile,buildfile,Rantfile,.autotest,Cheffile,KitchenSink,Routefile,.Guardfile,.Brewfile,vagrantfile,[Rr]akefile*,*_spec.rb',
|
||||
\ 'rust': '*.rs,*.rs.in',
|
||||
\ 'sbt.scala': '*.sbt',
|
||||
\ 'scala': '*.scala,*.kojo,*.sc',
|
||||
\ 'scss': '*.scss',
|
||||
\ 'sexplib': '*.sexp',
|
||||
\ 'sh': '*.sh,*.bash,*.bats,*.cgi,*.command,*.env,*.fcgi,*.ksh,*.sh.in,*.tmux,*.tool,9fs,PKGBUILD,bash_aliases,bash_logout,bash_profile,bashrc,cshrc,gradlew,login,man,profile',
|
||||
\ 'sh': '*.sh,*.bash,*.bats,*.cgi,*.command,*.env,*.fcgi,*.ksh,*.sh.in,*.tmux,*.tool,.bash_aliases,.bash_history,.bash_logout,.bash_profile,.bashrc,.cshrc,.env,.env.example,.flaskenv,.login,.profile,9fs,PKGBUILD,bash_aliases,bash_logout,bash_profile,bashrc,cshrc,gradlew,login,man,profile',
|
||||
\ 'slim': '*.slim',
|
||||
\ 'slime': '*.slime',
|
||||
\ 'smt2': '*.smt2,*.smt',
|
||||
@@ -198,7 +200,7 @@ let s:globs = {
|
||||
\ 'terraform': '*.hcl,*.nomad,*.tf,*.tfvars,*.workflow',
|
||||
\ 'textile': '*.textile',
|
||||
\ 'thrift': '*.thrift',
|
||||
\ 'tmux': '',
|
||||
\ 'tmux': '.tmux.conf',
|
||||
\ 'toml': '*.toml,Cargo.lock,Gopkg.lock,poetry.lock,Pipfile',
|
||||
\ 'tptp': '*.p,*.tptp,*.ax',
|
||||
\ 'trasys': '*.inp',
|
||||
@@ -216,17 +218,17 @@ let s:globs = {
|
||||
\ 'vmasm': '*.mar',
|
||||
\ 'vue': '*.vue,*.wpy',
|
||||
\ 'xdc': '*.xdc',
|
||||
\ 'xml': '*.xml,*.adml,*.admx,*.ant,*.axml,*.builds,*.ccproj,*.ccxml,*.clixml,*.cproject,*.cscfg,*.csdef,*.csl,*.csproj,*.ct,*.depproj,*.dita,*.ditamap,*.ditaval,*.dll.config,*.dotsettings,*.filters,*.fsproj,*.fxml,*.glade,*.gml,*.gmx,*.grxml,*.gst,*.iml,*.ivy,*.jelly,*.jsproj,*.kml,*.launch,*.mdpolicy,*.mjml,*.mm,*.mod,*.mxml,*.natvis,*.ncl,*.ndproj,*.nproj,*.nuspec,*.odd,*.osm,*.pkgproj,*.pluginspec,*.proj,*.props,*.ps1xml,*.psc1,*.pt,*.rdf,*.resx,*.rss,*.sch,*.scxml,*.sfproj,*.shproj,*.srdf,*.storyboard,*.sublime-snippet,*.targets,*.tml,*.ui,*.urdf,*.ux,*.vbproj,*.vcxproj,*.vsixmanifest,*.vssettings,*.vstemplate,*.vxml,*.wixproj,*.workflow,*.wsdl,*.wsf,*.wxi,*.wxl,*.wxs,*.x3d,*.xacro,*.xaml,*.xib,*.xlf,*.xliff,*.xmi,*.xml.dist,*.xproj,*.xsd,*.xspec,*.xul,*.zcml,*.cdxml,App.config,NuGet.config,Settings.StyleCop,Web.Debug.config,Web.Release.config,Web.config,packages.config',
|
||||
\ 'xml': '*.xml,*.adml,*.admx,*.ant,*.axml,*.builds,*.ccproj,*.ccxml,*.clixml,*.cproject,*.cscfg,*.csdef,*.csl,*.csproj,*.ct,*.depproj,*.dita,*.ditamap,*.ditaval,*.dll.config,*.dotsettings,*.filters,*.fsproj,*.fxml,*.glade,*.gml,*.gmx,*.grxml,*.gst,*.iml,*.ivy,*.jelly,*.jsproj,*.kml,*.launch,*.mdpolicy,*.mjml,*.mm,*.mod,*.mxml,*.natvis,*.ncl,*.ndproj,*.nproj,*.nuspec,*.odd,*.osm,*.pkgproj,*.pluginspec,*.proj,*.props,*.ps1xml,*.psc1,*.pt,*.rdf,*.resx,*.rss,*.sch,*.scxml,*.sfproj,*.shproj,*.srdf,*.storyboard,*.sublime-snippet,*.targets,*.tml,*.ui,*.urdf,*.ux,*.vbproj,*.vcxproj,*.vsixmanifest,*.vssettings,*.vstemplate,*.vxml,*.wixproj,*.workflow,*.wsdl,*.wsf,*.wxi,*.wxl,*.wxs,*.x3d,*.xacro,*.xaml,*.xib,*.xlf,*.xliff,*.xmi,*.xml.dist,*.xproj,*.xsd,*.xspec,*.xul,*.zcml,*.cdxml,*.tpm,*.csproj.user,*.wpl,.classpath,.cproject,.project,App.config,NuGet.config,Settings.StyleCop,Web.Debug.config,Web.Release.config,Web.config,packages.config',
|
||||
\ 'xml.twig': '*.xml.twig',
|
||||
\ 'xs': '*.xs',
|
||||
\ 'xsl': '*.xslt,*.xsl',
|
||||
\ 'yaml': '*.yml,*.mir,*.reek,*.rviz,*.sublime-syntax,*.syntax,*.yaml,*.yaml-tmlanguage,*.yaml.sed,*.yml.mysql,glide.lock,yarn.lock,fish_history,fish_read_history',
|
||||
\ 'yaml': '*.yml,*.mir,*.reek,*.rviz,*.sublime-syntax,*.syntax,*.yaml,*.yaml-tmlanguage,*.yaml.sed,*.yml.mysql,.clang-format,.clang-tidy,.gemrc,glide.lock,yarn.lock,fish_history,fish_read_history',
|
||||
\ 'yaml.ansible': 'playbook.y{a,}ml,site.y{a,}ml,main.y{a,}ml,local.y{a,}ml,requirements.y{a,}ml,tasks.*.y{a,}ml,roles.*.y{a,}ml,handlers.*.y{a,}ml',
|
||||
\ 'yaml.docker-compose': 'docker-compose*.yaml,docker-compose*.yml',
|
||||
\ 'zephir': '*.zep',
|
||||
\ 'zig': '*.zig,*.zir',
|
||||
\ 'zir': '*.zir',
|
||||
\ 'zsh': '*.zsh',
|
||||
\ 'zsh': '*.zsh,.zshrc,.zshenv,.zlogin,.zprofile,.zlogout',
|
||||
\}
|
||||
|
||||
func! sleuth#GlobForFiletype(type)
|
||||
|
||||
85
doc/fzf_gitignore.txt
Normal file
85
doc/fzf_gitignore.txt
Normal file
@@ -0,0 +1,85 @@
|
||||
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'gitignore') == -1
|
||||
|
||||
*fzf_gitignore.txt* Create useful .gitignore files for your project
|
||||
|
||||
Author: Filip Szymański <fszymanski.pl@gmail.com>
|
||||
|
||||
==============================================================================
|
||||
CONTENTS *fzf-gitignore-contents*
|
||||
|
||||
1. Introduction |fzf-gitignore-introduction|
|
||||
2. Configuration |fzf-gitignore-configuration|
|
||||
3. Commands |fzf-gitignore-commands|
|
||||
4. Mappings |fzf-gitignore-mappings|
|
||||
5. License |fzf-gitignore-license|
|
||||
6. Bugs |fzf-gitignore-bugs|
|
||||
7. Contributing |fzf-gitignore-contributing|
|
||||
|
||||
==============================================================================
|
||||
INTRODUCTION *fzf-gitignore-introduction*
|
||||
|
||||
fzf[1] interface for creating .gitignore files using the gitignore.io[2] API.
|
||||
|
||||
Note: This plugin was inspired by helm-gitignore[3].
|
||||
|
||||
==============================================================================
|
||||
CONFIGURATION *fzf-gitignore-configuration*
|
||||
|
||||
*g:fzf_gitignore_no_maps*
|
||||
Set this option to disable all key mappings.
|
||||
>
|
||||
let g:fzf_gitignore_no_maps = 1
|
||||
<
|
||||
Default: Not defined (number)
|
||||
|
||||
*g:fzf_gitignore_map*
|
||||
Set this option to change the |<Plug>(fzf-gitignore)| key mapping.
|
||||
>
|
||||
let g:fzf_gitignore_map = '<Leader>i'
|
||||
<
|
||||
Default: '<Leader>gi' (string)
|
||||
|
||||
==============================================================================
|
||||
COMMANDS *fzf-gitignore-commands*
|
||||
|
||||
*:FzfGitignore*
|
||||
Create .gitignore file.
|
||||
|
||||
==============================================================================
|
||||
MAPPINGS *fzf-gitignore-mappings*
|
||||
|
||||
-----------------------------------+----------------------------------------
|
||||
Mapping | Description ~
|
||||
-----------------------------------+----------------------------------------
|
||||
<Plug>(fzf-gitignore) | Create .gitignore file
|
||||
-----------------------------------+----------------------------------------
|
||||
|
||||
==============================================================================
|
||||
LICENSE *fzf-gitignore-license*
|
||||
|
||||
MIT
|
||||
|
||||
==============================================================================
|
||||
BUGS *fzf-gitignore-bugs*
|
||||
|
||||
If you find a bug please create an issue on GitHub.
|
||||
|
||||
https://github.com/fszymanski/fzf-gitignore/issues
|
||||
|
||||
==============================================================================
|
||||
CONTRIBUTING *fzf-gitignore-contributing*
|
||||
|
||||
Think you can make this plugin better? Awesome. Fork it on GitHub and create
|
||||
a pull request.
|
||||
|
||||
https://github.com/fszymanski/fzf-gitignore
|
||||
|
||||
==============================================================================
|
||||
|
||||
[1] https://github.com/junegunn/fzf
|
||||
[2] https://www.gitignore.io/
|
||||
[3] https://github.com/jupl/helm-gitignore
|
||||
|
||||
vim: tw=78 ts=8 ft=help norl
|
||||
|
||||
endif
|
||||
@@ -1,3 +1,5 @@
|
||||
" Please do not edit this file directly, instead modify polyglot.vim or scripts/build
|
||||
|
||||
" don't spam the user when Vim is started in Vi compatibility mode
|
||||
let s:cpo_save = &cpo
|
||||
set cpo&vim
|
||||
@@ -7,6 +9,14 @@ if exists('g:polyglot_test')
|
||||
autocmd!
|
||||
endif
|
||||
|
||||
func! s:Observe(fn)
|
||||
let b:polyglot_observe = a:fn
|
||||
augroup polyglot-observer
|
||||
au! CursorHold,CursorHoldI,BufWritePost <buffer>
|
||||
\ execute('if polyglot#' . b:polyglot_observe . '() | au! polyglot-observer | endif')
|
||||
augroup END
|
||||
endfunc
|
||||
|
||||
let s:disabled_packages = {}
|
||||
let s:new_polyglot_disabled = []
|
||||
|
||||
@@ -87,9 +97,6 @@ endfunc
|
||||
|
||||
augroup filetypedetect
|
||||
|
||||
au! filetypedetect BufRead,BufNewFile,StdinReadPost *
|
||||
|
||||
" filetypes
|
||||
|
||||
if !has_key(s:disabled_packages, '8th')
|
||||
au! BufRead,BufNewFile *.8th
|
||||
@@ -156,7 +163,7 @@ if !has_key(s:disabled_packages, 'ampl')
|
||||
endif
|
||||
|
||||
if !has_key(s:disabled_packages, 'xml')
|
||||
au! BufRead,BufNewFile *.csproj,*.ui,*.wsdl,*.wsf,*.xlf,*.xliff,*.xmi,*.xsd,*.xul
|
||||
au! BufRead,BufNewFile *.csproj,*.ui,*.wsdl,*.wsf,*.xlf,*.xliff,*.xmi,*.xsd,*.xul,*.tpm,*.csproj.user,*.wpl
|
||||
endif
|
||||
|
||||
if !has_key(s:disabled_packages, 'ant')
|
||||
@@ -488,7 +495,7 @@ if !has_key(s:disabled_packages, 'dosini')
|
||||
endif
|
||||
|
||||
if !has_key(s:disabled_packages, 'bzl')
|
||||
au! BufRead,BufNewFile *.bzl,BUILD,WORKSPACE
|
||||
au! BufRead,BufNewFile *.bzl,*.bazel,*.BUILD,BUILD,WORKSPACE
|
||||
endif
|
||||
|
||||
if !has_key(s:disabled_packages, 'tads')
|
||||
@@ -591,6 +598,7 @@ if !has_key(s:disabled_packages, 'xml')
|
||||
au BufNewFile,BufRead *.csdef set ft=xml
|
||||
au BufNewFile,BufRead *.csl set ft=xml
|
||||
au BufNewFile,BufRead *.csproj set ft=xml
|
||||
au BufNewFile,BufRead *.csproj.user set ft=xml
|
||||
au BufNewFile,BufRead *.ct set ft=xml
|
||||
au BufNewFile,BufRead *.depproj set ft=xml
|
||||
au BufNewFile,BufRead *.dita set ft=xml
|
||||
@@ -643,6 +651,7 @@ if !has_key(s:disabled_packages, 'xml')
|
||||
au BufNewFile,BufRead *.sublime-snippet set ft=xml
|
||||
au BufNewFile,BufRead *.targets set ft=xml
|
||||
au BufNewFile,BufRead *.tml set ft=xml
|
||||
au BufNewFile,BufRead *.tpm set ft=xml
|
||||
au BufNewFile,BufRead *.ui set ft=xml
|
||||
au BufNewFile,BufRead *.urdf set ft=xml
|
||||
au BufNewFile,BufRead *.ux set ft=xml
|
||||
@@ -654,6 +663,7 @@ if !has_key(s:disabled_packages, 'xml')
|
||||
au BufNewFile,BufRead *.vxml set ft=xml
|
||||
au BufNewFile,BufRead *.wixproj set ft=xml
|
||||
au BufNewFile,BufRead *.workflow set ft=xml
|
||||
au BufNewFile,BufRead *.wpl set ft=xml
|
||||
au BufNewFile,BufRead *.wsdl set ft=xml
|
||||
au BufNewFile,BufRead *.wsf set ft=xml
|
||||
au BufNewFile,BufRead *.wxi set ft=xml
|
||||
@@ -1099,15 +1109,14 @@ if !has_key(s:disabled_packages, 'haml')
|
||||
endif
|
||||
|
||||
if !has_key(s:disabled_packages, 'handlebars')
|
||||
au BufNewFile,BufRead *.handlebars set ft=mustache
|
||||
au BufNewFile,BufRead *.hb set ft=mustache
|
||||
au BufNewFile,BufRead *.hbs set ft=mustache
|
||||
au BufNewFile,BufRead *.hdbs set ft=mustache
|
||||
au BufNewFile,BufRead *.hjs set ft=mustache
|
||||
au BufNewFile,BufRead *.hogan set ft=mustache
|
||||
au BufNewFile,BufRead *.hulk set ft=mustache
|
||||
au BufNewFile,BufRead *.mustache set ft=mustache
|
||||
au BufNewFile,BufRead *.njk set ft=mustache
|
||||
au BufNewFile,BufRead *.hjs set ft=html.mustache
|
||||
au BufNewFile,BufRead *.hogan set ft=html.mustache
|
||||
au BufNewFile,BufRead *.hulk set ft=html.mustache
|
||||
au BufNewFile,BufRead *.mustache set ft=html.mustache
|
||||
au BufNewFile,BufRead *.handlebars set ft=html.handlebars
|
||||
au BufNewFile,BufRead *.hb set ft=html.handlebars
|
||||
au BufNewFile,BufRead *.hbs set ft=html.handlebars
|
||||
au BufNewFile,BufRead *.hdbs set ft=html.handlebars
|
||||
endif
|
||||
|
||||
if !has_key(s:disabled_packages, 'haskell')
|
||||
@@ -1184,10 +1193,11 @@ if !has_key(s:disabled_packages, 'jenkins')
|
||||
au BufNewFile,BufRead Jenkinsfile* call s:StarSetf('Jenkinsfile')
|
||||
endif
|
||||
|
||||
if !has_key(s:disabled_packages, 'jinja')
|
||||
au BufNewFile,BufRead *.j2 set ft=jinja.html
|
||||
au BufNewFile,BufRead *.jinja set ft=jinja.html
|
||||
au BufNewFile,BufRead *.jinja2 set ft=jinja.html
|
||||
if !has_key(s:disabled_packages, 'htmldjango')
|
||||
au BufNewFile,BufRead *.j2 set ft=htmldjango
|
||||
au BufNewFile,BufRead *.jinja set ft=htmldjango
|
||||
au BufNewFile,BufRead *.jinja2 set ft=htmldjango
|
||||
au BufNewFile,BufRead *.njk set ft=htmldjango
|
||||
endif
|
||||
|
||||
if !has_key(s:disabled_packages, 'jq')
|
||||
@@ -1992,6 +2002,8 @@ if !has_key(s:disabled_packages, 'odin')
|
||||
endif
|
||||
|
||||
if !has_key(s:disabled_packages, 'bzl')
|
||||
au BufNewFile,BufRead *.BUILD set ft=bzl
|
||||
au BufNewFile,BufRead *.bazel set ft=bzl
|
||||
au BufNewFile,BufRead *.bzl set ft=bzl
|
||||
au BufNewFile,BufRead BUCK set ft=bzl
|
||||
au BufNewFile,BufRead BUILD set ft=bzl
|
||||
@@ -2011,21 +2023,19 @@ if !has_key(s:disabled_packages, 'tads')
|
||||
au! BufNewFile,BufRead *.t call polyglot#DetectTFiletype()
|
||||
endif
|
||||
|
||||
if !has_key(s:disabled_packages, 'gitignore')
|
||||
au BufNewFile,BufRead *.git/info/exclude set ft=gitignore
|
||||
au BufNewFile,BufRead */.config/git/ignore set ft=gitignore
|
||||
au BufNewFile,BufRead {.,}gitignore set ft=gitignore
|
||||
endif
|
||||
|
||||
" end filetypes
|
||||
|
||||
func! s:PolyglotFallback()
|
||||
if expand("<afile>") !~ g:ft_ignore_pat
|
||||
if getline(1) =~# "^#!"
|
||||
call polyglot#Shebang()
|
||||
endif
|
||||
if &filetype == ''
|
||||
runtime! scripts.vim
|
||||
endif
|
||||
endif
|
||||
endfunc
|
||||
|
||||
au BufNewFile,BufRead,StdinReadPost * call s:PolyglotFallback()
|
||||
au! BufNewFile,BufRead,StdinReadPost * if expand("<afile>") !~ g:ft_ignore_pat |
|
||||
\ call polyglot#Shebang() | endif
|
||||
|
||||
au BufEnter * if &ft == "" && expand("<afile>") !~ g:ft_ignore_pat |
|
||||
\ call s:Observe('Shebang') | endif
|
||||
|
||||
augroup END
|
||||
|
||||
@@ -2122,7 +2132,7 @@ if !has_key(s:disabled_packages, 'autoindent')
|
||||
|
||||
if line[0] == "\t"
|
||||
setlocal noexpandtab
|
||||
let &shiftwidth=&tabstop
|
||||
let &l:shiftwidth=&tabstop
|
||||
let b:sleuth_culprit .= ':' . i
|
||||
return 1
|
||||
elseif line[0] == " "
|
||||
@@ -2135,7 +2145,7 @@ if !has_key(s:disabled_packages, 'autoindent')
|
||||
|
||||
if minindent < 10
|
||||
setlocal expandtab
|
||||
let &shiftwidth=minindent
|
||||
let &l:shiftwidth=minindent
|
||||
let b:sleuth_culprit .= ':' . i
|
||||
return 1
|
||||
endif
|
||||
@@ -2222,22 +2232,10 @@ endfunc
|
||||
|
||||
au VimEnter * call s:verify()
|
||||
|
||||
func! s:observe_filetype()
|
||||
augroup polyglot-observer
|
||||
au! CursorHold,CursorHoldI <buffer>
|
||||
\ if polyglot#Shebang() | au! polyglot-observer CursorHold,CursorHoldI | endif
|
||||
augroup END
|
||||
endfunc
|
||||
|
||||
au BufEnter * if &ft == "" && expand("<afile>") !~ g:ft_ignore_pat
|
||||
\ | call s:observe_filetype() | endif
|
||||
|
||||
|
||||
" Save polyglot_disabled without postfixes
|
||||
if exists('g:polyglot_disabled')
|
||||
let g:polyglot_disabled = s:new_polyglot_disabled
|
||||
endif
|
||||
|
||||
" restore Vi compatibility settings
|
||||
let &cpo = s:cpo_save
|
||||
unlet s:cpo_save
|
||||
let &cpo = s:cpo_save
|
||||
64
ftplugin/aspvbs.vim
Normal file
64
ftplugin/aspvbs.vim
Normal file
@@ -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
|
||||
20
ftplugin/gitignore.vim
Normal file
20
ftplugin/gitignore.vim
Normal file
@@ -0,0 +1,20 @@
|
||||
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'gitignore') == -1
|
||||
|
||||
scriptencoding utf-8
|
||||
|
||||
" Copyright (c) 2017-2020 Filip Szymański. All rights reserved.
|
||||
" Use of this source code is governed by an MIT license that can be
|
||||
" found in the LICENSE file.
|
||||
|
||||
if exists('b:did_ftplugin')
|
||||
finish
|
||||
endif
|
||||
let b:did_ftplugin = 1
|
||||
|
||||
setlocal commentstring=#\ %s
|
||||
|
||||
let b:undo_ftplugin = 'setlocal commentstring<'
|
||||
|
||||
" vim: ts=2 et sw=2
|
||||
|
||||
endif
|
||||
127
ftplugin/handlebars.vim
Normal file
127
ftplugin/handlebars.vim
Normal file
@@ -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
|
||||
17
ftplugin/htmldjango.vim
Normal file
17
ftplugin/htmldjango.vim
Normal file
@@ -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
|
||||
@@ -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
|
||||
|
||||
@@ -181,7 +181,10 @@ rules:
|
||||
pattern: '^(%|<[%&].*>)'
|
||||
filetype: mason
|
||||
- lines: 50
|
||||
pattern: '{{.*}}|{%-?\s*(end.*|extends|block|macro|set|if|for|include|trans)\b'
|
||||
filetype: jinja.html
|
||||
rules:
|
||||
- pattern: '{{.*}}|{%-?\s*(end.*|extends|block|macro|set|if|for|include|trans)\b|{#\s+'
|
||||
filetype: htmldjango
|
||||
- pattern: '\bDTD\s+XHTML\s'
|
||||
filetype: xhtml
|
||||
- filetype: html
|
||||
|
||||
fallback: true
|
||||
|
||||
129
indent/handlebars.vim
Normal file
129
indent/handlebars.vim
Normal file
@@ -0,0 +1,129 @@
|
||||
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'handlebars') == -1
|
||||
|
||||
" Mustache & Handlebars syntax
|
||||
" Language: Mustache, Handlebars
|
||||
" Maintainer: Juvenn Woo <machese@gmail.com>
|
||||
" Screenshot: http://imgur.com/6F408
|
||||
" Version: 3
|
||||
" Last Change: 26 Nov 2018
|
||||
" Remarks: based on eruby indent plugin by tpope
|
||||
" References:
|
||||
" [Mustache](http://github.com/defunkt/mustache)
|
||||
" [Handlebars](https://github.com/wycats/handlebars.js)
|
||||
" [ctemplate](http://code.google.com/p/google-ctemplate/)
|
||||
" [ctemplate doc](http://google-ctemplate.googlecode.com/svn/trunk/doc/howto.html)
|
||||
" [et](http://www.ivan.fomichev.name/2008/05/erlang-template-engine-prototype.html)
|
||||
|
||||
if exists("b:did_indent_hbs")
|
||||
finish
|
||||
endif
|
||||
|
||||
unlet! b:did_indent
|
||||
setlocal indentexpr=
|
||||
|
||||
runtime! indent/html.vim
|
||||
unlet! b:did_indent
|
||||
|
||||
" Force HTML indent to not keep state.
|
||||
let b:html_indent_usestate = 0
|
||||
|
||||
if &l:indentexpr == ''
|
||||
if &l:cindent
|
||||
let &l:indentexpr = 'cindent(v:lnum)'
|
||||
else
|
||||
let &l:indentexpr = 'indent(prevnonblank(v:lnum-1))'
|
||||
endif
|
||||
endif
|
||||
let b:handlebars_subtype_indentexpr = &l:indentexpr
|
||||
|
||||
let b:did_indent = 1
|
||||
let b:did_indent_hbs = 1
|
||||
|
||||
setlocal indentexpr=GetHandlebarsIndent()
|
||||
setlocal indentkeys=o,O,*<Return>,<>>,{,},0),0],o,O,!^F,=end,=else,=elsif,=rescue,=ensure,=when
|
||||
|
||||
" Only define the function once.
|
||||
if exists("*GetHandlebarsIndent")
|
||||
finish
|
||||
endif
|
||||
|
||||
function! GetHandlebarsIndent(...)
|
||||
" The value of a single shift-width
|
||||
if exists('*shiftwidth')
|
||||
let sw = shiftwidth()
|
||||
else
|
||||
let sw = &sw
|
||||
endif
|
||||
|
||||
if a:0 && a:1 == '.'
|
||||
let v:lnum = line('.')
|
||||
elseif a:0 && a:1 =~ '^\d'
|
||||
let v:lnum = a:1
|
||||
endif
|
||||
let vcol = col('.')
|
||||
call cursor(v:lnum,1)
|
||||
call cursor(v:lnum,vcol)
|
||||
exe "let ind = ".b:handlebars_subtype_indentexpr
|
||||
|
||||
" Workaround for Andy Wokula's HTML indent. This should be removed after
|
||||
" some time, since the newest version is fixed in a different way.
|
||||
if b:handlebars_subtype_indentexpr =~# '^HtmlIndent('
|
||||
\ && exists('b:indent')
|
||||
\ && type(b:indent) == type({})
|
||||
\ && has_key(b:indent, 'lnum')
|
||||
" Force HTML indent to not keep state
|
||||
let b:indent.lnum = -1
|
||||
endif
|
||||
let lnum = prevnonblank(v:lnum-1)
|
||||
let prevLine = getline(lnum)
|
||||
let currentLine = getline(v:lnum)
|
||||
|
||||
" all indent rules only apply if the block opening/closing
|
||||
" tag is on a separate line
|
||||
|
||||
" indent after block {{#block
|
||||
if prevLine =~# '\v\s*\{\{[#^].*\s*'
|
||||
let ind = ind + sw
|
||||
endif
|
||||
" but not if the block ends on the same line
|
||||
if prevLine =~# '\v\s*\{\{\#(.+)(\s+|\}\}).*\{\{\/\1'
|
||||
let ind = ind - sw
|
||||
endif
|
||||
" unindent after block close {{/block}}
|
||||
if currentLine =~# '\v^\s*\{\{\/\S*\}\}\s*'
|
||||
let ind = ind - sw
|
||||
endif
|
||||
" indent after component block {{a-component
|
||||
if prevLine =~# '\v\s*\{\{\w'
|
||||
let ind = ind + sw
|
||||
endif
|
||||
" but not if the component block ends on the same line
|
||||
if prevLine =~# '\v\s*\{\{\w(.+)\}\}'
|
||||
let ind = ind - sw
|
||||
endif
|
||||
" unindent }} lines, and following lines if not inside a block expression
|
||||
let savedPos = getpos('.')
|
||||
if currentLine =~# '\v^\s*\}\}\s*$' || (currentLine !~# '\v^\s*\{\{\/' && prevLine =~# '\v^\s*[^\{\} \t]+\}\}\s*$')
|
||||
let closingLnum = search('}}\s*$', 'Wbc', lnum)
|
||||
let [openingLnum, col] = searchpairpos('{{', '', '}}', 'Wb')
|
||||
if openingLnum > 0 && closingLnum > 0
|
||||
if strpart(getline(openingLnum), col - 1, 3) !~ '{{[#^]'
|
||||
let ind = ind - sw
|
||||
endif
|
||||
else
|
||||
call setpos('.', savedPos)
|
||||
endif
|
||||
endif
|
||||
" unindent {{else}}
|
||||
if currentLine =~# '\v^\s*\{\{else.*\}\}\s*$'
|
||||
let ind = ind - sw
|
||||
endif
|
||||
" indent again after {{else}}
|
||||
if prevLine =~# '\v^\s*\{\{else.*\}\}\s*$'
|
||||
let ind = ind + sw
|
||||
endif
|
||||
|
||||
return ind
|
||||
endfunction
|
||||
|
||||
endif
|
||||
16
indent/htmldjango.vim
Normal file
16
indent/htmldjango.vim
Normal file
@@ -0,0 +1,16 @@
|
||||
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'htmldjango') == -1
|
||||
|
||||
" Vim indent file
|
||||
" Language: Django HTML template
|
||||
" Maintainer: Dave Hodder <dmh@dmh.org.uk>
|
||||
" Last Change: 2007 Jan 25
|
||||
|
||||
" Only load this indent file when no other was loaded.
|
||||
if exists("b:did_indent")
|
||||
finish
|
||||
endif
|
||||
|
||||
" Use HTML formatting rules.
|
||||
runtime! indent/html.vim
|
||||
|
||||
endif
|
||||
@@ -1,84 +0,0 @@
|
||||
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'jinja') == -1
|
||||
|
||||
" Vim indent file
|
||||
" Language: Jinja HTML template
|
||||
" Maintainer: Evan Hammer <evan@evanhammer.com>
|
||||
" Last Change: 2013 Jan 26
|
||||
|
||||
" Only load this indent file when no other was loaded.
|
||||
if exists("b:did_indent")
|
||||
finish
|
||||
endif
|
||||
|
||||
" Use HTML formatting rules.
|
||||
setl indentkeys=o,O,<Return>,<>>,!^F
|
||||
runtime! indent/html.vim +setl nosmartindent
|
||||
let b:did_indent = 1
|
||||
|
||||
" Indent within the jinja tags
|
||||
" Made by Steve Losh <steve@stevelosh.com>
|
||||
if &l:indentexpr == ''
|
||||
if &l:cindent
|
||||
let &l:indentexpr = 'cindent(v:lnum)'
|
||||
else
|
||||
let &l:indentexpr = 'indent(prevnonblank(v:lnum-1))'
|
||||
endif
|
||||
endif
|
||||
let b:html_indentexpr = &l:indentexpr
|
||||
|
||||
let b:did_indent = 1
|
||||
|
||||
setlocal indentexpr=GetDjangoIndent()
|
||||
setlocal indentkeys=o,O,*<Return>,{,},o,O,!^F,<>>
|
||||
|
||||
" Only define the function once.
|
||||
if exists("*GetDjangoIndent")
|
||||
finish
|
||||
endif
|
||||
|
||||
function! GetDjangoIndent(...)
|
||||
if a:0 && a:1 == '.'
|
||||
let v:lnum = line('.')
|
||||
elseif a:0 && a:1 =~ '^\d'
|
||||
let v:lnum = a:1
|
||||
endif
|
||||
let vcol = col('.')
|
||||
|
||||
call cursor(v:lnum,vcol)
|
||||
|
||||
exe "let ind = ".b:html_indentexpr
|
||||
|
||||
let lnum = prevnonblank(v:lnum-1)
|
||||
let pnb = getline(lnum)
|
||||
let cur = getline(v:lnum)
|
||||
|
||||
let tagstart = '.*' . '{%\s*'
|
||||
let tagend = '.*%}' . '.*'
|
||||
|
||||
let blocktags = '\(block\|for\|if\|with\|autoescape\|comment\|filter\|spaceless\)'
|
||||
let midtags = '\(empty\|else\|elif\)'
|
||||
|
||||
let pnb_blockstart = pnb =~# tagstart . blocktags . tagend
|
||||
let pnb_blockend = pnb =~# tagstart . 'end' . blocktags . tagend
|
||||
let pnb_blockmid = pnb =~# tagstart . midtags . tagend
|
||||
|
||||
let cur_blockstart = cur =~# tagstart . blocktags . tagend
|
||||
let cur_blockend = cur =~# tagstart . 'end' . blocktags . tagend
|
||||
let cur_blockmid = cur =~# tagstart . midtags . tagend
|
||||
|
||||
if pnb_blockstart && !pnb_blockend
|
||||
let ind = ind + &sw
|
||||
elseif pnb_blockmid && !pnb_blockend
|
||||
let ind = ind + &sw
|
||||
endif
|
||||
|
||||
if cur_blockend && !cur_blockstart
|
||||
let ind = ind - &sw
|
||||
elseif cur_blockmid
|
||||
let ind = ind - &sw
|
||||
endif
|
||||
|
||||
return ind
|
||||
endfunction
|
||||
|
||||
endif
|
||||
@@ -1,129 +1,5 @@
|
||||
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'handlebars') == -1
|
||||
|
||||
" Mustache & Handlebars syntax
|
||||
" Language: Mustache, Handlebars
|
||||
" Maintainer: Juvenn Woo <machese@gmail.com>
|
||||
" Screenshot: http://imgur.com/6F408
|
||||
" Version: 3
|
||||
" Last Change: 26 Nov 2018
|
||||
" Remarks: based on eruby indent plugin by tpope
|
||||
" References:
|
||||
" [Mustache](http://github.com/defunkt/mustache)
|
||||
" [Handlebars](https://github.com/wycats/handlebars.js)
|
||||
" [ctemplate](http://code.google.com/p/google-ctemplate/)
|
||||
" [ctemplate doc](http://google-ctemplate.googlecode.com/svn/trunk/doc/howto.html)
|
||||
" [et](http://www.ivan.fomichev.name/2008/05/erlang-template-engine-prototype.html)
|
||||
|
||||
if exists("b:did_indent_hbs")
|
||||
finish
|
||||
endif
|
||||
|
||||
unlet! b:did_indent
|
||||
setlocal indentexpr=
|
||||
|
||||
runtime! indent/html.vim
|
||||
unlet! b:did_indent
|
||||
|
||||
" Force HTML indent to not keep state.
|
||||
let b:html_indent_usestate = 0
|
||||
|
||||
if &l:indentexpr == ''
|
||||
if &l:cindent
|
||||
let &l:indentexpr = 'cindent(v:lnum)'
|
||||
else
|
||||
let &l:indentexpr = 'indent(prevnonblank(v:lnum-1))'
|
||||
endif
|
||||
endif
|
||||
let b:handlebars_subtype_indentexpr = &l:indentexpr
|
||||
|
||||
let b:did_indent = 1
|
||||
let b:did_indent_hbs = 1
|
||||
|
||||
setlocal indentexpr=GetHandlebarsIndent()
|
||||
setlocal indentkeys=o,O,*<Return>,<>>,{,},0),0],o,O,!^F,=end,=else,=elsif,=rescue,=ensure,=when
|
||||
|
||||
" Only define the function once.
|
||||
if exists("*GetHandlebarsIndent")
|
||||
finish
|
||||
endif
|
||||
|
||||
function! GetHandlebarsIndent(...)
|
||||
" The value of a single shift-width
|
||||
if exists('*shiftwidth')
|
||||
let sw = shiftwidth()
|
||||
else
|
||||
let sw = &sw
|
||||
endif
|
||||
|
||||
if a:0 && a:1 == '.'
|
||||
let v:lnum = line('.')
|
||||
elseif a:0 && a:1 =~ '^\d'
|
||||
let v:lnum = a:1
|
||||
endif
|
||||
let vcol = col('.')
|
||||
call cursor(v:lnum,1)
|
||||
call cursor(v:lnum,vcol)
|
||||
exe "let ind = ".b:handlebars_subtype_indentexpr
|
||||
|
||||
" Workaround for Andy Wokula's HTML indent. This should be removed after
|
||||
" some time, since the newest version is fixed in a different way.
|
||||
if b:handlebars_subtype_indentexpr =~# '^HtmlIndent('
|
||||
\ && exists('b:indent')
|
||||
\ && type(b:indent) == type({})
|
||||
\ && has_key(b:indent, 'lnum')
|
||||
" Force HTML indent to not keep state
|
||||
let b:indent.lnum = -1
|
||||
endif
|
||||
let lnum = prevnonblank(v:lnum-1)
|
||||
let prevLine = getline(lnum)
|
||||
let currentLine = getline(v:lnum)
|
||||
|
||||
" all indent rules only apply if the block opening/closing
|
||||
" tag is on a separate line
|
||||
|
||||
" indent after block {{#block
|
||||
if prevLine =~# '\v\s*\{\{[#^].*\s*'
|
||||
let ind = ind + sw
|
||||
endif
|
||||
" but not if the block ends on the same line
|
||||
if prevLine =~# '\v\s*\{\{\#(.+)(\s+|\}\}).*\{\{\/\1'
|
||||
let ind = ind - sw
|
||||
endif
|
||||
" unindent after block close {{/block}}
|
||||
if currentLine =~# '\v^\s*\{\{\/\S*\}\}\s*'
|
||||
let ind = ind - sw
|
||||
endif
|
||||
" indent after component block {{a-component
|
||||
if prevLine =~# '\v\s*\{\{\w'
|
||||
let ind = ind + sw
|
||||
endif
|
||||
" but not if the component block ends on the same line
|
||||
if prevLine =~# '\v\s*\{\{\w(.+)\}\}'
|
||||
let ind = ind - sw
|
||||
endif
|
||||
" unindent }} lines, and following lines if not inside a block expression
|
||||
let savedPos = getpos('.')
|
||||
if currentLine =~# '\v^\s*\}\}\s*$' || (currentLine !~# '\v^\s*\{\{\/' && prevLine =~# '\v^\s*[^\{\} \t]+\}\}\s*$')
|
||||
let closingLnum = search('}}\s*$', 'Wbc', lnum)
|
||||
let [openingLnum, col] = searchpairpos('{{', '', '}}', 'Wb')
|
||||
if openingLnum > 0 && closingLnum > 0
|
||||
if strpart(getline(openingLnum), col - 1, 3) !~ '{{[#^]'
|
||||
let ind = ind - sw
|
||||
endif
|
||||
else
|
||||
call setpos('.', savedPos)
|
||||
endif
|
||||
endif
|
||||
" unindent {{else}}
|
||||
if currentLine =~# '\v^\s*\{\{else.*\}\}\s*$'
|
||||
let ind = ind - sw
|
||||
endif
|
||||
" indent again after {{else}}
|
||||
if prevLine =~# '\v^\s*\{\{else.*\}\}\s*$'
|
||||
let ind = ind + sw
|
||||
endif
|
||||
|
||||
return ind
|
||||
endfunction
|
||||
runtime! indent/handlebars.vim
|
||||
|
||||
endif
|
||||
|
||||
@@ -169,7 +169,7 @@ filetypes:
|
||||
- '*/etc/httpd/conf.d/*.conf*'
|
||||
---
|
||||
name: apiblueprint
|
||||
remote: sheerun/apiblueprint.vim
|
||||
remote: kylef/apiblueprint.vim
|
||||
filetypes:
|
||||
- name: apiblueprint
|
||||
linguist: API Blueprint
|
||||
@@ -440,9 +440,6 @@ remote: tpope/vim-cucumber
|
||||
filetypes:
|
||||
- name: cucumber
|
||||
linguist: Gherkin
|
||||
extra_extensions:
|
||||
# https://github.com/search?q=extension%3Astory+when&type=Code
|
||||
- story
|
||||
---
|
||||
name: cue
|
||||
remote: mgrabovsky/vim-cuesheet
|
||||
@@ -720,7 +717,8 @@ filetypes:
|
||||
- '*/etc/grub.conf'
|
||||
---
|
||||
name: haml
|
||||
remote: sheerun/vim-haml
|
||||
remote: tpope/vim-haml
|
||||
glob: '**/haml.vim'
|
||||
filetypes:
|
||||
- name: haml
|
||||
linguist: Haml
|
||||
@@ -729,16 +727,17 @@ filetypes:
|
||||
- hamlbars
|
||||
---
|
||||
name: handlebars
|
||||
remote: sheerun/vim-mustache-handlebars
|
||||
remote: mustache/vim-mustache-handlebars
|
||||
filetypes:
|
||||
- name: mustache
|
||||
linguist: Handlebars
|
||||
- name: html.mustache
|
||||
linguist: Mustache
|
||||
extra_extensions:
|
||||
- hogan
|
||||
- hulk
|
||||
- hjs
|
||||
- mustache
|
||||
- njk
|
||||
- hogan
|
||||
- name: html.handlebars
|
||||
linguist: Handlebars
|
||||
extra_extensions:
|
||||
- hdbs
|
||||
- hb
|
||||
---
|
||||
@@ -770,8 +769,6 @@ remote: b4b4r07/vim-hcl
|
||||
filetypes:
|
||||
- name: hcl
|
||||
linguist: HCL
|
||||
extra_extensions:
|
||||
- nomad
|
||||
extra_filenames:
|
||||
- Appfile
|
||||
ignored_extensions:
|
||||
@@ -873,15 +870,14 @@ filetypes:
|
||||
- Jenkinsfile
|
||||
- Jenkinsfile*
|
||||
---
|
||||
name: jinja
|
||||
remote: lepture/vim-jinja
|
||||
name: htmldjango
|
||||
remote: vim/vim:runtime
|
||||
globs:
|
||||
- '**/django.vim'
|
||||
- '**/htmldjango.vim'
|
||||
filetypes:
|
||||
- name: jinja.html
|
||||
- name: htmldjango
|
||||
linguist: HTML+Django
|
||||
extra_extensions:
|
||||
- j2
|
||||
ignored_extensions:
|
||||
- njk
|
||||
ignore_warnings:
|
||||
# handled by mustache plugin
|
||||
- mustache
|
||||
@@ -1437,7 +1433,9 @@ filetypes:
|
||||
- '*_spec.rb'
|
||||
---
|
||||
name: yard
|
||||
remote: sheerun/vim-yardoc
|
||||
remote: noprompt/vim-yardoc
|
||||
patches:
|
||||
- 'https://github.com/sheerun/vim-yardoc/commit/173924ec12a66e26a886e80431b92cc9bda578d4.patch'
|
||||
# just adds to ruby
|
||||
filetypes: []
|
||||
---
|
||||
@@ -1727,6 +1725,9 @@ filetypes:
|
||||
linguist: XML
|
||||
extra_extensions:
|
||||
- cdxml
|
||||
- tpm
|
||||
- csproj.user
|
||||
- wpl
|
||||
ignored_extensions:
|
||||
- ts
|
||||
- tsx
|
||||
@@ -1863,6 +1864,9 @@ glob: '**/bzl.vim'
|
||||
filetypes:
|
||||
- name: bzl
|
||||
linguist: Starlark
|
||||
extra_extensions:
|
||||
- bazel
|
||||
- BUILD
|
||||
---
|
||||
name: prolog
|
||||
remote: vim/vim:runtime
|
||||
@@ -1878,3 +1882,12 @@ filetypes:
|
||||
- name: tads
|
||||
extensions:
|
||||
- t
|
||||
---
|
||||
name: gitignore
|
||||
remote: fszymanski/fzf-gitignore
|
||||
filetypes:
|
||||
- name: gitignore
|
||||
filenames:
|
||||
- '.gitignore'
|
||||
- '*/.config/git/ignore'
|
||||
- '*.git/info/exclude'
|
||||
|
||||
379
polyglot.vim
Normal file
379
polyglot.vim
Normal file
@@ -0,0 +1,379 @@
|
||||
""" autoload/polyglot.vim
|
||||
|
||||
" Line continuation is used here, remove 'C' from 'cpoptions'
|
||||
let s:cpo_save = &cpo
|
||||
set cpo&vim
|
||||
|
||||
func! polyglot#Shebang()
|
||||
if getline(1) =~# "^#!"
|
||||
let ft = polyglot#ShebangFiletype()
|
||||
if ft != ""
|
||||
let &ft = ft
|
||||
endif
|
||||
endif
|
||||
|
||||
if &ft == ""
|
||||
runtime! scripts.vim
|
||||
endif
|
||||
|
||||
return &ft != ""
|
||||
endfunc
|
||||
|
||||
let s:r_hashbang = '^#!\s*\(\S\+\)\s*\(.*\)\s*'
|
||||
let s:r_envflag = '%(\S\+=\S\+\|-[iS]\|--ignore-environment\|--split-string\)'
|
||||
let s:r_env = '^\%(\' . s:r_envflag . '\s\+\)*\(\S\+\)'
|
||||
|
||||
func! polyglot#ShebangFiletype()
|
||||
let l:line1 = getline(1)
|
||||
|
||||
if l:line1 !~# "^#!"
|
||||
return
|
||||
endif
|
||||
|
||||
let l:pathrest = matchlist(l:line1, s:r_hashbang)
|
||||
|
||||
if len(l:pathrest) == 0
|
||||
return
|
||||
endif
|
||||
|
||||
let [_, l:path, l:rest; __] = l:pathrest
|
||||
|
||||
let l:script = split(l:path, "/")[-1]
|
||||
|
||||
if l:script == "env"
|
||||
let l:argspath = matchlist(l:rest, s:r_env)
|
||||
if len(l:argspath) == 0
|
||||
return
|
||||
endif
|
||||
|
||||
let l:script = l:argspath[1]
|
||||
endif
|
||||
|
||||
if has_key(s:interpreters, l:script)
|
||||
return s:interpreters[l:script]
|
||||
endif
|
||||
|
||||
for interpreter in keys(s:interpreters)
|
||||
if l:script =~# '^' . interpreter
|
||||
return s:interpreters[interpreter]
|
||||
endif
|
||||
endfor
|
||||
endfunc
|
||||
|
||||
" scripts/build generates heuristics functions here
|
||||
|
||||
" Restore 'cpoptions'
|
||||
let &cpo = s:cpo_save
|
||||
unlet s:cpo_save
|
||||
|
||||
""" ftdetect/polyglot.vim
|
||||
|
||||
" don't spam the user when Vim is started in Vi compatibility mode
|
||||
let s:cpo_save = &cpo
|
||||
set cpo&vim
|
||||
|
||||
" Disable all native vim ftdetect
|
||||
if exists('g:polyglot_test')
|
||||
autocmd!
|
||||
endif
|
||||
|
||||
func! s:Observe(fn)
|
||||
let b:polyglot_observe = a:fn
|
||||
augroup polyglot-observer
|
||||
au! CursorHold,CursorHoldI,BufWritePost <buffer>
|
||||
\ execute('if polyglot#' . b:polyglot_observe . '() | au! polyglot-observer | endif')
|
||||
augroup END
|
||||
endfunc
|
||||
|
||||
let s:disabled_packages = {}
|
||||
let s:new_polyglot_disabled = []
|
||||
|
||||
if exists('g:polyglot_disabled')
|
||||
for pkg in g:polyglot_disabled
|
||||
let base = split(pkg, '\.')
|
||||
if len(base) > 0
|
||||
let s:disabled_packages[pkg] = 1
|
||||
call add(s:new_polyglot_disabled, base[0])
|
||||
endif
|
||||
endfor
|
||||
else
|
||||
let g:polyglot_disabled_not_set = 1
|
||||
endif
|
||||
|
||||
function! s:SetDefault(name, value)
|
||||
if !exists(a:name)
|
||||
let {a:name} = a:value
|
||||
endif
|
||||
endfunction
|
||||
|
||||
call s:SetDefault('g:markdown_enable_spell_checking', 0)
|
||||
call s:SetDefault('g:markdown_enable_input_abbreviations', 0)
|
||||
call s:SetDefault('g:markdown_enable_mappings', 0)
|
||||
|
||||
" Enable jsx syntax by default
|
||||
call s:SetDefault('g:jsx_ext_required', 0)
|
||||
|
||||
" Needed for sql highlighting
|
||||
call s:SetDefault('g:javascript_sql_dialect', 'sql')
|
||||
|
||||
" Make csv loading faster
|
||||
call s:SetDefault('g:csv_start', 1)
|
||||
call s:SetDefault('g:csv_end', 2)
|
||||
|
||||
" Disable json concealing by default
|
||||
call s:SetDefault('g:vim_json_syntax_conceal', 0)
|
||||
|
||||
call s:SetDefault('g:filetype_euphoria', 'elixir')
|
||||
|
||||
if !exists('g:python_highlight_all')
|
||||
call s:SetDefault('g:python_highlight_builtins', 1)
|
||||
call s:SetDefault('g:python_highlight_builtin_objs', 1)
|
||||
call s:SetDefault('g:python_highlight_builtin_types', 1)
|
||||
call s:SetDefault('g:python_highlight_builtin_funcs', 1)
|
||||
call s:SetDefault('g:python_highlight_builtin_funcs_kwarg', 1)
|
||||
call s:SetDefault('g:python_highlight_exceptions', 1)
|
||||
call s:SetDefault('g:python_highlight_string_formatting', 1)
|
||||
call s:SetDefault('g:python_highlight_string_format', 1)
|
||||
call s:SetDefault('g:python_highlight_string_templates', 1)
|
||||
call s:SetDefault('g:python_highlight_indent_errors', 1)
|
||||
call s:SetDefault('g:python_highlight_space_errors', 1)
|
||||
call s:SetDefault('g:python_highlight_doctests', 1)
|
||||
call s:SetDefault('g:python_highlight_func_calls', 1)
|
||||
call s:SetDefault('g:python_highlight_class_vars', 1)
|
||||
call s:SetDefault('g:python_highlight_operators', 1)
|
||||
call s:SetDefault('g:python_highlight_file_headers_as_comments', 1)
|
||||
call s:SetDefault('g:python_slow_sync', 1)
|
||||
endif
|
||||
|
||||
" We need it because scripts.vim in vim uses "set ft=" which cannot be
|
||||
" overridden with setf (and we can't use set ft= so our scripts.vim work)
|
||||
func! s:Setf(ft)
|
||||
if &filetype !~# '\<'.a:ft.'\>'
|
||||
let &filetype = a:ft
|
||||
endif
|
||||
endfunc
|
||||
|
||||
" Function used for patterns that end in a star: don't set the filetype if the
|
||||
" file name matches ft_ignore_pat.
|
||||
" When using this, the entry should probably be further down below with the
|
||||
" other StarSetf() calls.
|
||||
func! s:StarSetf(ft)
|
||||
if expand("<amatch>") !~ g:ft_ignore_pat && &filetype !~# '\<'.a:ft.'\>'
|
||||
let &filetype = a:ft
|
||||
endif
|
||||
endfunc
|
||||
|
||||
augroup filetypedetect
|
||||
|
||||
" scripts/build inserts here filetype detection autocommands
|
||||
|
||||
au! BufNewFile,BufRead,StdinReadPost * if expand("<afile>") !~ g:ft_ignore_pat |
|
||||
\ call polyglot#Shebang() | endif
|
||||
|
||||
au BufEnter * if &ft == "" && expand("<afile>") !~ g:ft_ignore_pat |
|
||||
\ call s:Observe('Shebang') | endif
|
||||
|
||||
augroup END
|
||||
|
||||
if !has_key(s:disabled_packages, 'autoindent')
|
||||
" Code below re-implements sleuth for vim-polyglot
|
||||
let g:loaded_sleuth = 1
|
||||
let g:loaded_foobar = 1
|
||||
|
||||
" Makes shiftwidth to be synchronized with tabstop by default
|
||||
if &shiftwidth == &tabstop
|
||||
let &shiftwidth = 0
|
||||
endif
|
||||
|
||||
function! s:guess(lines) abort
|
||||
let options = {}
|
||||
let ccomment = 0
|
||||
let podcomment = 0
|
||||
let triplequote = 0
|
||||
let backtick = 0
|
||||
let xmlcomment = 0
|
||||
let heredoc = ''
|
||||
let minindent = 10
|
||||
let spaces_minus_tabs = 0
|
||||
let i = 0
|
||||
|
||||
for line in a:lines
|
||||
let i += 1
|
||||
|
||||
if !len(line) || line =~# '^\W*$'
|
||||
continue
|
||||
endif
|
||||
|
||||
if line =~# '^\s*/\*'
|
||||
let ccomment = 1
|
||||
endif
|
||||
if ccomment
|
||||
if line =~# '\*/'
|
||||
let ccomment = 0
|
||||
endif
|
||||
continue
|
||||
endif
|
||||
|
||||
if line =~# '^=\w'
|
||||
let podcomment = 1
|
||||
endif
|
||||
if podcomment
|
||||
if line =~# '^=\%(end\|cut\)\>'
|
||||
let podcomment = 0
|
||||
endif
|
||||
continue
|
||||
endif
|
||||
|
||||
if triplequote
|
||||
if line =~# '^[^"]*"""[^"]*$'
|
||||
let triplequote = 0
|
||||
endif
|
||||
continue
|
||||
elseif line =~# '^[^"]*"""[^"]*$'
|
||||
let triplequote = 1
|
||||
endif
|
||||
|
||||
if backtick
|
||||
if line =~# '^[^`]*`[^`]*$'
|
||||
let backtick = 0
|
||||
endif
|
||||
continue
|
||||
elseif &filetype ==# 'go' && line =~# '^[^`]*`[^`]*$'
|
||||
let backtick = 1
|
||||
endif
|
||||
|
||||
if line =~# '^\s*<\!--'
|
||||
let xmlcomment = 1
|
||||
endif
|
||||
if xmlcomment
|
||||
if line =~# '-->'
|
||||
let xmlcomment = 0
|
||||
endif
|
||||
continue
|
||||
endif
|
||||
|
||||
" This is correct order because both "<<EOF" and "EOF" matches end
|
||||
if heredoc != ''
|
||||
if line =~# heredoc
|
||||
let heredoc = ''
|
||||
endif
|
||||
continue
|
||||
endif
|
||||
let herematch = matchlist(line, '\C<<\W*\([A-Z]\+\)\s*$')
|
||||
if len(herematch) > 0
|
||||
let heredoc = herematch[1] . '$'
|
||||
endif
|
||||
|
||||
let spaces_minus_tabs += line[0] == "\t" ? 1 : -1
|
||||
|
||||
if line[0] == "\t"
|
||||
setlocal noexpandtab
|
||||
let &l:shiftwidth=&tabstop
|
||||
let b:sleuth_culprit .= ':' . i
|
||||
return 1
|
||||
elseif line[0] == " "
|
||||
let indent = len(matchstr(line, '^ *'))
|
||||
if (indent % 2 == 0 || indent % 3 == 0) && indent < minindent
|
||||
let minindent = indent
|
||||
endif
|
||||
endif
|
||||
endfor
|
||||
|
||||
if minindent < 10
|
||||
setlocal expandtab
|
||||
let &l:shiftwidth=minindent
|
||||
let b:sleuth_culprit .= ':' . i
|
||||
return 1
|
||||
endif
|
||||
|
||||
return 0
|
||||
endfunction
|
||||
|
||||
function! s:detect_indent() abort
|
||||
if &buftype ==# 'help'
|
||||
return
|
||||
endif
|
||||
|
||||
let b:sleuth_culprit = expand("<afile>:p")
|
||||
if s:guess(getline(1, 32))
|
||||
return
|
||||
endif
|
||||
let pattern = sleuth#GlobForFiletype(&filetype)
|
||||
if len(pattern) == 0
|
||||
return
|
||||
endif
|
||||
let pattern = '{' . pattern . ',.git,.svn,.hg}'
|
||||
let dir = expand('%:p:h')
|
||||
let level = 3
|
||||
while isdirectory(dir) && dir !=# fnamemodify(dir, ':h') && level > 0
|
||||
" Ignore files from homedir and root
|
||||
if dir == expand('~') || dir == '/'
|
||||
unlet b:sleuth_culprit
|
||||
return
|
||||
endif
|
||||
for neighbor in glob(dir . '/' . pattern, 0, 1)[0:level]
|
||||
let b:sleuth_culprit = neighbor
|
||||
" Do not consider directories above .git, .svn or .hg
|
||||
if fnamemodify(neighbor, ":h:t")[0] == "."
|
||||
let level = 0
|
||||
continue
|
||||
endif
|
||||
if neighbor !=# expand('%:p') && filereadable(neighbor)
|
||||
if s:guess(readfile(neighbor, '', 32))
|
||||
return
|
||||
endif
|
||||
endif
|
||||
endfor
|
||||
|
||||
let dir = fnamemodify(dir, ':h')
|
||||
let level -= 1
|
||||
endwhile
|
||||
|
||||
unlet b:sleuth_culprit
|
||||
endfunction
|
||||
|
||||
setglobal smarttab
|
||||
|
||||
function! SleuthIndicator() abort
|
||||
let sw = &shiftwidth ? &shiftwidth : &tabstop
|
||||
if &expandtab
|
||||
return 'sw='.sw
|
||||
elseif &tabstop == sw
|
||||
return 'ts='.&tabstop
|
||||
else
|
||||
return 'sw='.sw.',ts='.&tabstop
|
||||
endif
|
||||
endfunction
|
||||
|
||||
augroup polyglot-sleuth
|
||||
au!
|
||||
au FileType * call s:detect_indent()
|
||||
au User Flags call Hoist('buffer', 5, 'SleuthIndicator')
|
||||
augroup END
|
||||
|
||||
command! -bar -bang Sleuth call s:detect_indent()
|
||||
endif
|
||||
|
||||
func! s:verify()
|
||||
if exists("g:polyglot_disabled_not_set")
|
||||
if exists("g:polyglot_disabled")
|
||||
echohl WarningMsg
|
||||
echo "vim-polyglot: g:polyglot_disabled should be defined before loading vim-polyglot"
|
||||
echohl None
|
||||
endif
|
||||
|
||||
unlet g:polyglot_disabled_not_set
|
||||
endif
|
||||
endfunc
|
||||
|
||||
au VimEnter * call s:verify()
|
||||
|
||||
" Save polyglot_disabled without postfixes
|
||||
if exists('g:polyglot_disabled')
|
||||
let g:polyglot_disabled = s:new_polyglot_disabled
|
||||
endif
|
||||
|
||||
" restore Vi compatibility settings
|
||||
let &cpo = s:cpo_save
|
||||
|
||||
""" end
|
||||
126
scripts/build
126
scripts/build
@@ -12,6 +12,11 @@ Dir.chdir(File.dirname(__dir__))
|
||||
|
||||
BASE_URL = 'https://raw.githubusercontent.com/github/linguist/master'
|
||||
|
||||
def read_section(name)
|
||||
"\" Please do not edit this file directly, instead modify polyglot.vim or scripts/build\n\n" +
|
||||
File.read('polyglot.vim').match(/""" #{Regexp.escape(name)}\n*(.*)\n(?=\n""")/m)[1]
|
||||
end
|
||||
|
||||
def camelize(str)
|
||||
str.split(/[-_\.]/).map { |a| a.capitalize }.join("")
|
||||
end
|
||||
@@ -317,10 +322,20 @@ def rule_to_code(rule)
|
||||
EOS
|
||||
end
|
||||
|
||||
if (rule.keys - ["filetype", "override", "set", "extensions"]).size > 0
|
||||
raise "Unknown rule: #{JSON.generate(rule)}"
|
||||
if rule.has_key?("filetype")
|
||||
if rule.has_key?("fallback")
|
||||
return <<~EOS
|
||||
set ft=#{rule["filetype"]} | au! BufWritePost <buffer> ++once call polyglot#Detect#{camelize(rule["extensions"].first)}Filetype()
|
||||
return
|
||||
EOS
|
||||
end
|
||||
|
||||
return <<~EOS
|
||||
set ft=#{rule["filetype"]} | return
|
||||
#{indent(rule_to_code(except(rule, "filetype")), 0)}
|
||||
EOS
|
||||
end
|
||||
|
||||
|
||||
if rule.has_key?("override")
|
||||
variable = "g:filetype_#{rule["extensions"].first}"
|
||||
return <<~EOS
|
||||
@@ -330,18 +345,10 @@ def rule_to_code(rule)
|
||||
EOS
|
||||
end
|
||||
|
||||
if rule.has_key?("filetype")
|
||||
return "set ft=#{rule["filetype"]} | return"
|
||||
if (rule.keys - ["extensions"]).size > 0
|
||||
raise "Unknown rule: #{JSON.generate(rule)}"
|
||||
end
|
||||
|
||||
if rule.has_key?("filetype")
|
||||
return "set ft=#{rule["filetype"]} | return"
|
||||
end
|
||||
|
||||
if rule.has_key?("extensions")
|
||||
return ""
|
||||
end
|
||||
|
||||
|
||||
return ""
|
||||
end
|
||||
|
||||
@@ -371,13 +378,15 @@ def extract(packages)
|
||||
if repo == "vim/vim" && (["glob", "globs"] & package.keys).size == 0
|
||||
raise "Package from vim/vim should define glob or globs: #{package["name"]}"
|
||||
end
|
||||
glob = package.fetch("glob", package.fetch('globs', '**/*.{vim,ctags,vital,txt}'))
|
||||
Dir.glob("#{subdir}/#{glob}", base: subtree).each do |p|
|
||||
next unless File.file?("#{subtree}/#{p}")
|
||||
if p.include?("samba")
|
||||
raise package["name"]
|
||||
globs = [package.fetch("glob", package.fetch('globs', '**/*.{vim,ctags,vital,txt}'))].flatten
|
||||
globs.each do |glob|
|
||||
Dir.glob("#{subdir}/#{glob}", base: subtree).each do |p|
|
||||
next unless File.file?("#{subtree}/#{p}")
|
||||
if p.include?("samba")
|
||||
raise package["name"]
|
||||
end
|
||||
copy_file(package, "#{subtree}/#{p}", p)
|
||||
end
|
||||
copy_file(package, "#{subtree}/#{p}", p)
|
||||
end
|
||||
elsif File.exist?(subpath)
|
||||
copy_file(package, subpath, subdir)
|
||||
@@ -548,25 +557,14 @@ def generate_ftdetect(packages, heuristics)
|
||||
puts "Missing filename for #{name}: #{e}"
|
||||
end
|
||||
|
||||
ftdetect = File.read('ftdetect/polyglot.vim')
|
||||
File.write('ftdetect/polyglot.vim', ftdetect.gsub(/(?<=" filetypes\n).*(?=\n" end filetypes)/m, output))
|
||||
ftdetect = read_section('ftdetect/polyglot.vim')
|
||||
|
||||
File.write(
|
||||
'ftdetect/polyglot.vim',
|
||||
ftdetect.gsub('" scripts/build inserts here filetype detection autocommands') { output }
|
||||
)
|
||||
|
||||
output = <<~EOS
|
||||
" Line continuation is used here, remove 'C' from 'cpoptions'
|
||||
let s:cpo_save = &cpo
|
||||
set cpo&vim
|
||||
|
||||
func! polyglot#Shebang()
|
||||
" Try to detect filetype from shebang
|
||||
let ft = polyglot#ShebangFiletype()
|
||||
if ft != ""
|
||||
let &ft = ft
|
||||
return 1
|
||||
endif
|
||||
|
||||
return 0
|
||||
endfunc
|
||||
|
||||
let s:interpreters = {
|
||||
EOS
|
||||
|
||||
@@ -579,47 +577,6 @@ def generate_ftdetect(packages, heuristics)
|
||||
output << <<~EOS
|
||||
\\ }
|
||||
|
||||
let s:r_hashbang = '^#!\\s*\\(\\S\\+\\)\\s*\\(.*\\)\\s*'
|
||||
let s:r_envflag = '%(\\S\\+=\\S\\+\\|-[iS]\\|--ignore-environment\\|--split-string\\)'
|
||||
let s:r_env = '^\\%(\\' . s:r_envflag . '\\s\\+\\)*\\(\\S\\+\\)'
|
||||
|
||||
func! polyglot#ShebangFiletype()
|
||||
let l:line1 = getline(1)
|
||||
|
||||
if l:line1 !~# "^#!"
|
||||
return
|
||||
endif
|
||||
|
||||
let l:pathrest = matchlist(l:line1, s:r_hashbang)
|
||||
|
||||
if len(l:pathrest) == 0
|
||||
return
|
||||
endif
|
||||
|
||||
let [_, l:path, l:rest; __] = l:pathrest
|
||||
|
||||
let l:script = split(l:path, "/")[-1]
|
||||
|
||||
if l:script == "env"
|
||||
let l:argspath = matchlist(l:rest, s:r_env)
|
||||
if len(l:argspath) == 0
|
||||
return
|
||||
endif
|
||||
|
||||
let l:script = l:argspath[1]
|
||||
endif
|
||||
|
||||
if has_key(s:interpreters, l:script)
|
||||
return s:interpreters[l:script]
|
||||
endif
|
||||
|
||||
for interpreter in keys(s:interpreters)
|
||||
if l:script =~# '^' . interpreter
|
||||
return s:interpreters[interpreter]
|
||||
endif
|
||||
endfor
|
||||
endfunc
|
||||
|
||||
EOS
|
||||
|
||||
for heuristic in heuristics
|
||||
@@ -631,13 +588,10 @@ def generate_ftdetect(packages, heuristics)
|
||||
EOS
|
||||
end
|
||||
|
||||
output << <<~EOS
|
||||
" Restore 'cpoptions'
|
||||
let &cpo = s:cpo_save
|
||||
unlet s:cpo_save
|
||||
EOS
|
||||
autoload_script = read_section('autoload/polyglot.vim')
|
||||
autoload_script["\" scripts/build generates heuristics functions here\n"] = output
|
||||
|
||||
File.write('autoload/polyglot.vim', output)
|
||||
File.write('autoload/polyglot.vim', autoload_script)
|
||||
end
|
||||
|
||||
def generate_tests(packages)
|
||||
@@ -736,8 +690,6 @@ def detect_filetypes(glob)
|
||||
end
|
||||
|
||||
def generate_plugins(packages)
|
||||
FileUtils.mkdir_p('autoload/polyglot')
|
||||
|
||||
output = "let s:globs = {\n"
|
||||
|
||||
patterns = Hash.new { |h, k| h[k] = [] }
|
||||
@@ -745,7 +697,7 @@ def generate_plugins(packages)
|
||||
for package in packages
|
||||
for filetype in package["filetypes"]
|
||||
extensions = (filetype["extensions"] || []).map { |e| "*.#{e}" }
|
||||
files = (filetype["filenames"] || []).reject { |e| e.match(/\*\*|\//) || e[0] == "." }
|
||||
files = (filetype["filenames"] || []).reject { |e| e.match(/\*\*|\//) }
|
||||
patterns[filetype["name"]].concat(extensions)
|
||||
patterns[filetype["name"]].concat(files)
|
||||
end
|
||||
|
||||
29
syntax/aspperl.vim
Normal file
29
syntax/aspperl.vim
Normal file
@@ -0,0 +1,29 @@
|
||||
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'aspperl') == -1
|
||||
|
||||
" Vim syntax file
|
||||
" Language: Active State's PerlScript (ASP)
|
||||
" Maintainer: Aaron Hope <edh@brioforge.com>
|
||||
" URL: http://nim.dhs.org/~edh/aspperl.vim
|
||||
" Last Change: 2001 May 09
|
||||
|
||||
" quit when a syntax file was already loaded
|
||||
if exists("b:current_syntax")
|
||||
finish
|
||||
endif
|
||||
|
||||
if !exists("main_syntax")
|
||||
let main_syntax = 'perlscript'
|
||||
endif
|
||||
|
||||
runtime! syntax/html.vim
|
||||
unlet b:current_syntax
|
||||
syn include @AspPerlScript syntax/perl.vim
|
||||
|
||||
syn cluster htmlPreproc add=AspPerlScriptInsideHtmlTags
|
||||
|
||||
syn region AspPerlScriptInsideHtmlTags keepend matchgroup=Delimiter start=+<%=\=+ skip=+".*%>.*"+ end=+%>+ contains=@AspPerlScript
|
||||
syn region AspPerlScriptInsideHtmlTags keepend matchgroup=Delimiter start=+<script\s\+language="\=perlscript"\=[^>]*>+ end=+</script>+ contains=@AspPerlScript
|
||||
|
||||
let b:current_syntax = "aspperl"
|
||||
|
||||
endif
|
||||
186
syntax/aspvbs.vim
Normal file
186
syntax/aspvbs.vim
Normal file
@@ -0,0 +1,186 @@
|
||||
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'aspvbs') == -1
|
||||
|
||||
" Vim syntax file
|
||||
" Language: Microsoft VBScript Web Content (ASP)
|
||||
" Maintainer: Devin Weaver <ktohg@tritarget.com> (non-functional)
|
||||
" URL: http://tritarget.com/pub/vim/syntax/aspvbs.vim (broken)
|
||||
" Last Change: 2006 Jun 19
|
||||
" by Dan Casey
|
||||
" Version: $Revision: 1.3 $
|
||||
" Thanks to Jay-Jay <vim@jay-jay.net> for a syntax sync hack, hungarian
|
||||
" notation, and extra highlighting.
|
||||
" Thanks to patrick dehne <patrick@steidle.net> for the folding code.
|
||||
" Thanks to Dean Hall <hall@apt7.com> for testing the use of classes in
|
||||
" VBScripts which I've been too scared to do.
|
||||
|
||||
" quit when a syntax file was already loaded
|
||||
if exists("b:current_syntax")
|
||||
finish
|
||||
endif
|
||||
|
||||
if !exists("main_syntax")
|
||||
let main_syntax = 'aspvbs'
|
||||
endif
|
||||
|
||||
runtime! syntax/html.vim
|
||||
unlet b:current_syntax
|
||||
|
||||
syn cluster htmlPreProc add=AspVBScriptInsideHtmlTags
|
||||
|
||||
|
||||
" Colored variable names, if written in hungarian notation
|
||||
hi def AspVBSVariableSimple term=standout ctermfg=3 guifg=#99ee99
|
||||
hi def AspVBSVariableComplex term=standout ctermfg=3 guifg=#ee9900
|
||||
syn match AspVBSVariableSimple contained "\<\(bln\|byt\|dtm\=\|dbl\|int\|str\)\u\w*"
|
||||
syn match AspVBSVariableComplex contained "\<\(arr\|ary\|obj\)\u\w*"
|
||||
|
||||
|
||||
" Functions and methods that are in VB but will cause errors in an ASP page
|
||||
" This is helpfull if your porting VB code to ASP
|
||||
" I removed (Count, Item) because these are common variable names in AspVBScript
|
||||
syn keyword AspVBSError contained Val Str CVar CVDate DoEvents GoSub Return GoTo
|
||||
syn keyword AspVBSError contained Stop LinkExecute Add Type LinkPoke
|
||||
syn keyword AspVBSError contained LinkRequest LinkSend Declare Optional Sleep
|
||||
syn keyword AspVBSError contained ParamArray Static Erl TypeOf Like LSet RSet Mid StrConv
|
||||
" It may seem that most of these can fit into a keyword clause but keyword takes
|
||||
" priority over all so I can't get the multi-word matches
|
||||
syn match AspVBSError contained "\<Def[a-zA-Z0-9_]\+\>"
|
||||
syn match AspVBSError contained "^\s*Open\s\+"
|
||||
syn match AspVBSError contained "Debug\.[a-zA-Z0-9_]*"
|
||||
syn match AspVBSError contained "^\s*[a-zA-Z0-9_]\+:"
|
||||
syn match AspVBSError contained "[a-zA-Z0-9_]\+![a-zA-Z0-9_]\+"
|
||||
syn match AspVBSError contained "^\s*#.*$"
|
||||
syn match AspVBSError contained "\<As\s\+[a-zA-Z0-9_]*"
|
||||
syn match AspVBSError contained "\<End\>\|\<Exit\>"
|
||||
syn match AspVBSError contained "\<On\s\+Error\>\|\<On\>\|\<Error\>\|\<Resume\s\+Next\>\|\<Resume\>"
|
||||
syn match AspVBSError contained "\<Option\s\+\(Base\|Compare\|Private\s\+Module\)\>"
|
||||
" This one I want 'cause I always seem to mis-spell it.
|
||||
syn match AspVBSError contained "Respon\?ce\.\S*"
|
||||
syn match AspVBSError contained "Respose\.\S*"
|
||||
" When I looked up the VBScript syntax it mentioned that Property Get/Set/Let
|
||||
" statements are illegal, however, I have recived reports that they do work.
|
||||
" So I commented it out for now.
|
||||
" syn match AspVBSError contained "\<Property\s\+\(Get\|Let\|Set\)\>"
|
||||
|
||||
" AspVBScript Reserved Words.
|
||||
syn match AspVBSStatement contained "\<On\s\+Error\s\+\(Resume\s\+Next\|goto\s\+0\)\>\|\<Next\>"
|
||||
syn match AspVBSStatement contained "\<End\s\+\(If\|For\|Select\|Class\|Function\|Sub\|With\|Property\)\>"
|
||||
syn match AspVBSStatement contained "\<Exit\s\+\(Do\|For\|Sub\|Function\)\>"
|
||||
syn match AspVBSStatement contained "\<Exit\s\+\(Do\|For\|Sub\|Function\|Property\)\>"
|
||||
syn match AspVBSStatement contained "\<Option\s\+Explicit\>"
|
||||
syn match AspVBSStatement contained "\<For\s\+Each\>\|\<For\>"
|
||||
syn match AspVBSStatement contained "\<Set\>"
|
||||
syn keyword AspVBSStatement contained Call Class Const Default Dim Do Loop Erase And
|
||||
syn keyword AspVBSStatement contained Function If Then Else ElseIf Or
|
||||
syn keyword AspVBSStatement contained Private Public Randomize ReDim
|
||||
syn keyword AspVBSStatement contained Select Case Sub While With Wend Not
|
||||
|
||||
" AspVBScript Functions
|
||||
syn keyword AspVBSFunction contained Abs Array Asc Atn CBool CByte CCur CDate CDbl
|
||||
syn keyword AspVBSFunction contained Chr CInt CLng Cos CreateObject CSng CStr Date
|
||||
syn keyword AspVBSFunction contained DateAdd DateDiff DatePart DateSerial DateValue
|
||||
syn keyword AspVBSFunction contained Date Day Exp Filter Fix FormatCurrency
|
||||
syn keyword AspVBSFunction contained FormatDateTime FormatNumber FormatPercent
|
||||
syn keyword AspVBSFunction contained GetObject Hex Hour InputBox InStr InStrRev Int
|
||||
syn keyword AspVBSFunction contained IsArray IsDate IsEmpty IsNull IsNumeric
|
||||
syn keyword AspVBSFunction contained IsObject Join LBound LCase Left Len LoadPicture
|
||||
syn keyword AspVBSFunction contained Log LTrim Mid Minute Month MonthName MsgBox Now
|
||||
syn keyword AspVBSFunction contained Oct Replace RGB Right Rnd Round RTrim
|
||||
syn keyword AspVBSFunction contained ScriptEngine ScriptEngineBuildVersion
|
||||
syn keyword AspVBSFunction contained ScriptEngineMajorVersion
|
||||
syn keyword AspVBSFunction contained ScriptEngineMinorVersion Second Sgn Sin Space
|
||||
syn keyword AspVBSFunction contained Split Sqr StrComp StrReverse String Tan Time Timer
|
||||
syn keyword AspVBSFunction contained TimeSerial TimeValue Trim TypeName UBound UCase
|
||||
syn keyword AspVBSFunction contained VarType Weekday WeekdayName Year
|
||||
|
||||
" AspVBScript Methods
|
||||
syn keyword AspVBSMethods contained Add AddFolders BuildPath Clear Close Copy
|
||||
syn keyword AspVBSMethods contained CopyFile CopyFolder CreateFolder CreateTextFile
|
||||
syn keyword AspVBSMethods contained Delete DeleteFile DeleteFolder DriveExists
|
||||
syn keyword AspVBSMethods contained Exists FileExists FolderExists
|
||||
syn keyword AspVBSMethods contained GetAbsolutePathName GetBaseName GetDrive
|
||||
syn keyword AspVBSMethods contained GetDriveName GetExtensionName GetFile
|
||||
syn keyword AspVBSMethods contained GetFileName GetFolder GetParentFolderName
|
||||
syn keyword AspVBSMethods contained GetSpecialFolder GetTempName Items Keys Move
|
||||
syn keyword AspVBSMethods contained MoveFile MoveFolder OpenAsTextStream
|
||||
syn keyword AspVBSMethods contained OpenTextFile Raise Read ReadAll ReadLine Remove
|
||||
syn keyword AspVBSMethods contained RemoveAll Skip SkipLine Write WriteBlankLines
|
||||
syn keyword AspVBSMethods contained WriteLine
|
||||
syn match AspVBSMethods contained "Response\.\w*"
|
||||
" Colorize boolean constants:
|
||||
syn keyword AspVBSMethods contained true false
|
||||
|
||||
" AspVBScript Number Contstants
|
||||
" Integer number, or floating point number without a dot.
|
||||
syn match AspVBSNumber contained "\<\d\+\>"
|
||||
" Floating point number, with dot
|
||||
syn match AspVBSNumber contained "\<\d\+\.\d*\>"
|
||||
" Floating point number, starting with a dot
|
||||
syn match AspVBSNumber contained "\.\d\+\>"
|
||||
|
||||
" String and Character Contstants
|
||||
" removed (skip=+\\\\\|\\"+) because VB doesn't have backslash escaping in
|
||||
" strings (or does it?)
|
||||
syn region AspVBSString contained start=+"+ end=+"+ keepend
|
||||
|
||||
" AspVBScript Comments
|
||||
syn region AspVBSComment contained start="^REM\s\|\sREM\s" end="$" contains=AspVBSTodo keepend
|
||||
syn region AspVBSComment contained start="^'\|\s'" end="$" contains=AspVBSTodo keepend
|
||||
" misc. Commenting Stuff
|
||||
syn keyword AspVBSTodo contained TODO FIXME
|
||||
|
||||
" Cosmetic syntax errors commanly found in VB but not in AspVBScript
|
||||
" AspVBScript doesn't use line numbers
|
||||
syn region AspVBSError contained start="^\d" end="\s" keepend
|
||||
" AspVBScript also doesn't have type defining variables
|
||||
syn match AspVBSError contained "[a-zA-Z0-9_][\$&!#]"ms=s+1
|
||||
" Since 'a%' is a VB variable with a type and in AspVBScript you can have 'a%>'
|
||||
" I have to make a special case so 'a%>' won't show as an error.
|
||||
syn match AspVBSError contained "[a-zA-Z0-9_]%\($\|[^>]\)"ms=s+1
|
||||
|
||||
" Top Cluster
|
||||
syn cluster AspVBScriptTop contains=AspVBSStatement,AspVBSFunction,AspVBSMethods,AspVBSNumber,AspVBSString,AspVBSComment,AspVBSError,AspVBSVariableSimple,AspVBSVariableComplex
|
||||
|
||||
" Folding
|
||||
syn region AspVBSFold start="^\s*\(class\)\s\+.*$" end="^\s*end\s\+\(class\)\>.*$" fold contained transparent keepend
|
||||
syn region AspVBSFold start="^\s*\(private\|public\)\=\(\s\+default\)\=\s\+\(sub\|function\)\s\+.*$" end="^\s*end\s\+\(function\|sub\)\>.*$" fold contained transparent keepend
|
||||
|
||||
" Define AspVBScript delimeters
|
||||
" <%= func("string_with_%>_in_it") %> This is illegal in ASP syntax.
|
||||
syn region AspVBScriptInsideHtmlTags keepend matchgroup=Delimiter start=+<%=\=+ end=+%>+ contains=@AspVBScriptTop, AspVBSFold
|
||||
syn region AspVBScriptInsideHtmlTags keepend matchgroup=Delimiter start=+<script\s\+language="\=vbscript"\=[^>]*\s\+runatserver[^>]*>+ end=+</script>+ contains=@AspVBScriptTop
|
||||
|
||||
|
||||
" Synchronization
|
||||
" syn sync match AspVBSSyncGroup grouphere AspVBScriptInsideHtmlTags "<%"
|
||||
" This is a kludge so the HTML will sync properly
|
||||
syn sync match htmlHighlight grouphere htmlTag "%>"
|
||||
|
||||
|
||||
|
||||
" Define the default highlighting.
|
||||
" Only when an item doesn't have highlighting yet
|
||||
|
||||
"hi def link AspVBScript Special
|
||||
hi def link AspVBSLineNumber Comment
|
||||
hi def link AspVBSNumber Number
|
||||
hi def link AspVBSError Error
|
||||
hi def link AspVBSStatement Statement
|
||||
hi def link AspVBSString String
|
||||
hi def link AspVBSComment Comment
|
||||
hi def link AspVBSTodo Todo
|
||||
hi def link AspVBSFunction Identifier
|
||||
hi def link AspVBSMethods PreProc
|
||||
hi def link AspVBSEvents Special
|
||||
hi def link AspVBSTypeSpecifier Type
|
||||
|
||||
|
||||
let b:current_syntax = "aspvbs"
|
||||
|
||||
if main_syntax == 'aspvbs'
|
||||
unlet main_syntax
|
||||
endif
|
||||
|
||||
" vim: ts=8:sw=2:sts=0:noet
|
||||
|
||||
endif
|
||||
@@ -56,6 +56,7 @@ syntax cluster typescriptPrimaryType contains=
|
||||
\ typescriptTupleType,
|
||||
\ typescriptTypeQuery,
|
||||
\ typescriptStringLiteralType,
|
||||
\ typescriptTemplateLiteralType,
|
||||
\ typescriptReadonlyArrayKeyword,
|
||||
\ typescriptAssertType
|
||||
|
||||
@@ -64,6 +65,17 @@ syntax region typescriptStringLiteralType contained
|
||||
\ nextgroup=typescriptUnion
|
||||
\ skipwhite skipempty
|
||||
|
||||
syntax region typescriptTemplateLiteralType contained
|
||||
\ start=/`/ skip=/\\\\\|\\`\|\n/ end=/`\|$/
|
||||
\ contains=typescriptTemplateSubstitutionType
|
||||
\ nextgroup=typescriptTypeOperator
|
||||
\ skipwhite skipempty
|
||||
|
||||
syntax region typescriptTemplateSubstitutionType matchgroup=typescriptTemplateSB
|
||||
\ start=/\${/ end=/}/
|
||||
\ contains=@typescriptType
|
||||
\ contained
|
||||
|
||||
syntax region typescriptParenthesizedType matchgroup=typescriptParens
|
||||
\ start=/(/ end=/)/
|
||||
\ contains=@typescriptType
|
||||
@@ -103,10 +115,12 @@ syntax region typescriptTupleType matchgroup=typescriptBraces
|
||||
\ contained skipwhite
|
||||
|
||||
syntax cluster typescriptTypeOperator
|
||||
\ contains=typescriptUnion,typescriptTypeBracket
|
||||
\ contains=typescriptUnion,typescriptTypeBracket,typescriptConstraint,typescriptConditionalType
|
||||
|
||||
syntax match typescriptUnion /|\|&/ contained nextgroup=@typescriptPrimaryType skipwhite skipempty
|
||||
|
||||
syntax match typescriptConditionalType /?\|:/ contained nextgroup=@typescriptPrimaryType skipwhite skipempty
|
||||
|
||||
syntax cluster typescriptFunctionType contains=typescriptGenericFunc,typescriptFuncType
|
||||
syntax region typescriptGenericFunc matchgroup=typescriptTypeBrackets
|
||||
\ start=/</ end=/>/
|
||||
|
||||
@@ -71,6 +71,7 @@ if exists("did_typescript_hilink")
|
||||
HiLink typescriptString String
|
||||
HiLink typescriptSpecial Special
|
||||
HiLink typescriptStringLiteralType String
|
||||
HiLink typescriptTemplateLiteralType String
|
||||
HiLink typescriptStringMember String
|
||||
HiLink typescriptTemplate String
|
||||
HiLink typescriptEventString String
|
||||
|
||||
87
syntax/django.vim
Normal file
87
syntax/django.vim
Normal file
@@ -0,0 +1,87 @@
|
||||
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'htmldjango') == -1
|
||||
|
||||
" Vim syntax file
|
||||
" Language: Django template
|
||||
" Maintainer: Dave Hodder <dmh@dmh.org.uk>
|
||||
" Last Change: 2014 Jul 13
|
||||
|
||||
" quit when a syntax file was already loaded
|
||||
if exists("b:current_syntax")
|
||||
finish
|
||||
endif
|
||||
|
||||
syntax case match
|
||||
|
||||
" Mark illegal characters
|
||||
syn match djangoError "%}\|}}\|#}"
|
||||
|
||||
" Django template built-in tags and parameters
|
||||
" 'comment' doesn't appear here because it gets special treatment
|
||||
syn keyword djangoStatement contained autoescape csrf_token empty
|
||||
" FIXME ==, !=, <, >, <=, and >= should be djangoStatements:
|
||||
" syn keyword djangoStatement contained == != < > <= >=
|
||||
syn keyword djangoStatement contained and as block endblock by cycle debug else elif
|
||||
syn keyword djangoStatement contained extends filter endfilter firstof for
|
||||
syn keyword djangoStatement contained endfor if endif ifchanged endifchanged
|
||||
syn keyword djangoStatement contained ifequal endifequal ifnotequal
|
||||
syn keyword djangoStatement contained endifnotequal in include load not now or
|
||||
syn keyword djangoStatement contained parsed regroup reversed spaceless
|
||||
syn keyword djangoStatement contained endspaceless ssi templatetag openblock
|
||||
syn keyword djangoStatement contained closeblock openvariable closevariable
|
||||
syn keyword djangoStatement contained openbrace closebrace opencomment
|
||||
syn keyword djangoStatement contained closecomment widthratio url with endwith
|
||||
syn keyword djangoStatement contained get_current_language trans noop blocktrans
|
||||
syn keyword djangoStatement contained endblocktrans get_available_languages
|
||||
syn keyword djangoStatement contained get_current_language_bidi plural
|
||||
|
||||
" Django templete built-in filters
|
||||
syn keyword djangoFilter contained add addslashes capfirst center cut date
|
||||
syn keyword djangoFilter contained default default_if_none dictsort
|
||||
syn keyword djangoFilter contained dictsortreversed divisibleby escape escapejs
|
||||
syn keyword djangoFilter contained filesizeformat first fix_ampersands
|
||||
syn keyword djangoFilter contained floatformat get_digit join last length length_is
|
||||
syn keyword djangoFilter contained linebreaks linebreaksbr linenumbers ljust
|
||||
syn keyword djangoFilter contained lower make_list phone2numeric pluralize
|
||||
syn keyword djangoFilter contained pprint random removetags rjust slice slugify
|
||||
syn keyword djangoFilter contained safe safeseq stringformat striptags
|
||||
syn keyword djangoFilter contained time timesince timeuntil title truncatechars
|
||||
syn keyword djangoFilter contained truncatewords truncatewords_html unordered_list upper urlencode
|
||||
syn keyword djangoFilter contained urlize urlizetrunc wordcount wordwrap yesno
|
||||
|
||||
" Keywords to highlight within comments
|
||||
syn keyword djangoTodo contained TODO FIXME XXX
|
||||
|
||||
" Django template constants (always surrounded by double quotes)
|
||||
syn region djangoArgument contained start=/"/ skip=/\\"/ end=/"/
|
||||
|
||||
" Mark illegal characters within tag and variables blocks
|
||||
syn match djangoTagError contained "#}\|{{\|[^%]}}\|[&#]"
|
||||
syn match djangoVarError contained "#}\|{%\|%}\|[<>!&#%]"
|
||||
|
||||
" Django template tag and variable blocks
|
||||
syn region djangoTagBlock start="{%" end="%}" contains=djangoStatement,djangoFilter,djangoArgument,djangoTagError display
|
||||
syn region djangoVarBlock start="{{" end="}}" contains=djangoFilter,djangoArgument,djangoVarError display
|
||||
|
||||
" Django template 'comment' tag and comment block
|
||||
syn region djangoComment start="{%\s*comment\(\s\+.\{-}\)\?%}" end="{%\s*endcomment\s*%}" contains=djangoTodo
|
||||
syn region djangoComBlock start="{#" end="#}" contains=djangoTodo
|
||||
|
||||
" Define the default highlighting.
|
||||
" Only when an item doesn't have highlighting yet
|
||||
|
||||
hi def link djangoTagBlock PreProc
|
||||
hi def link djangoVarBlock PreProc
|
||||
hi def link djangoStatement Statement
|
||||
hi def link djangoFilter Identifier
|
||||
hi def link djangoArgument Constant
|
||||
hi def link djangoTagError Error
|
||||
hi def link djangoVarError Error
|
||||
hi def link djangoError Error
|
||||
hi def link djangoComment Comment
|
||||
hi def link djangoComBlock Comment
|
||||
hi def link djangoTodo Todo
|
||||
|
||||
|
||||
let b:current_syntax = "django"
|
||||
|
||||
endif
|
||||
@@ -20,10 +20,6 @@ syn keyword elixirTodo FIXME NOTE TODO OPTIMIZE XXX HACK contained
|
||||
|
||||
syn match elixirId '\<[_a-zA-Z]\w*[!?]\?\>' contains=elixirUnusedVariable
|
||||
|
||||
syn match elixirFunctionCall '\<[a-z_]\w*[!?]\?\(\s*\.\?\s*(\|\s\+[a-zA-Z0-9@:\'\"\[]\)\@='
|
||||
syn match elixirFunctionCall '\(:\w\+\s*\.\s*\|[A-Z]\w*\s*\.\s*\)\@<=[a-z_]\w*[!?]\?'
|
||||
syn match elixirFunctionCall '\(>\s+\)\<[a-z_]\w*[!?]\?'
|
||||
|
||||
syn match elixirKeyword '\(\.\)\@<!\<\(for\|case\|when\|with\|cond\|if\|unless\|try\|receive\|after\|raise\|rescue\|catch\|else\|quote\|unquote\|super\|unquote_splicing\)\>:\@!'
|
||||
|
||||
syn keyword elixirInclude import require alias use
|
||||
@@ -48,7 +44,7 @@ syn match elixirOperator '\~>\|\~>>\|<\~\|<<\~\|<\~>'
|
||||
|
||||
syn match elixirAlias '\([a-z]\)\@<![A-Z]\w*\%(\.[A-Z]\w*\)*'
|
||||
|
||||
syn match elixirAtom '\(:\)\@<!:\%([a-zA-Z_]\w*\%([?!]\|=[>=]\@!\)\?\|<>\|===\?\|>=\?\|<=\?\)'
|
||||
syn match elixirAtom '\(:\)\@<!:\%([a-zA-Z_*]\w*\%([?!]\|=[>=]\@!\)\?\|<>\|===\?\|>=\?\|<=\?\)'
|
||||
syn match elixirAtom '\(:\)\@<!:\%(<=>\|&&\?\|%\(()\|\[\]\|{}\)\|++\?\|--\?\|||\?\|!\|//\|[%&`/|]\)'
|
||||
syn match elixirAtom "\%([a-zA-Z_]\w*[?!]\?\):\(:\)\@!"
|
||||
|
||||
|
||||
33
syntax/gitignore.vim
Normal file
33
syntax/gitignore.vim
Normal file
@@ -0,0 +1,33 @@
|
||||
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'gitignore') == -1
|
||||
|
||||
scriptencoding utf-8
|
||||
|
||||
" Copyright (c) 2017-2020 Filip Szymański. All rights reserved.
|
||||
" Use of this source code is governed by an MIT license that can be
|
||||
" found in the LICENSE file.
|
||||
|
||||
if exists('b:current_syntax')
|
||||
finish
|
||||
endif
|
||||
|
||||
" https://git-scm.com/docs/gitignore#_pattern_format
|
||||
syntax keyword gitignoreTodo TODO FIXME XXX NOTE SEE contained
|
||||
syntax match gitignoreComment '^#.*' contains=gitignoreTodo
|
||||
syntax match gitignoreComment '\s#.*'ms=s+1 contains=gitignoreTodo
|
||||
syntax match gitignoreNegation '^!'
|
||||
syntax match gitignoreSeparator '/'
|
||||
syntax match gitignoreWildcard '\(\\\)\@<![*?]'
|
||||
syntax region gitignoreSet start='\[' skip='\\\]' end='\]'
|
||||
|
||||
highlight default link gitignoreTodo Todo
|
||||
highlight default link gitignoreComment Comment
|
||||
highlight default link gitignoreNegation Exception
|
||||
highlight default link gitignoreSeparator Constant
|
||||
highlight default link gitignoreWildcard Special
|
||||
highlight default link gitignoreSet Character
|
||||
|
||||
let b:current_syntax = 'gitignore'
|
||||
|
||||
" vim: ts=2 et sw=2
|
||||
|
||||
endif
|
||||
110
syntax/handlebars.vim
Normal file
110
syntax/handlebars.vim
Normal file
@@ -0,0 +1,110 @@
|
||||
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'handlebars') == -1
|
||||
|
||||
" Mustache & Handlebars syntax
|
||||
" Language: Mustache, Handlebars
|
||||
" Maintainer: Juvenn Woo <machese@gmail.com>
|
||||
" Screenshot: http://imgur.com/6F408
|
||||
" Version: 6
|
||||
" Last Change: Jul 16 2019
|
||||
" Remark:
|
||||
" It lexically hilights embedded mustaches (exclusively) in html file.
|
||||
" While it was written for Ruby-based Mustache template system, it should
|
||||
" work for Google's C-based *ctemplate* as well as Erlang-based *et*. All
|
||||
" of them are, AFAIK, based on the idea of ctemplate.
|
||||
" References:
|
||||
" [Mustache](http://github.com/defunkt/mustache)
|
||||
" [Handlebars](https://github.com/wycats/handlebars.js)
|
||||
" [ctemplate](http://code.google.com/p/google-ctemplate/)
|
||||
" [ctemplate doc](http://google-ctemplate.googlecode.com/svn/trunk/doc/howto.html)
|
||||
" [et](http://www.ivan.fomichev.name/2008/05/erlang-template-engine-prototype.html)
|
||||
" TODO: Feedback is welcomed.
|
||||
|
||||
|
||||
" Read the HTML syntax to start with
|
||||
if version < 600
|
||||
so <sfile>:p:h/html.vim
|
||||
else
|
||||
runtime! syntax/html.vim
|
||||
unlet b:current_syntax
|
||||
endif
|
||||
|
||||
if version < 600
|
||||
syntax clear
|
||||
elseif exists("b:current_syntax")
|
||||
finish
|
||||
endif
|
||||
|
||||
" Standard HiLink will not work with included syntax files
|
||||
if version < 508
|
||||
command! -nargs=+ HtmlHiLink hi link <args>
|
||||
else
|
||||
command! -nargs=+ HtmlHiLink hi def link <args>
|
||||
endif
|
||||
|
||||
syntax match mustacheError '}}}\?'
|
||||
syntax match mustacheInsideError '{{[{$#<>=!\/]\?'
|
||||
|
||||
" Ember angle bracket syntax syntax starts with a capital letter:
|
||||
" https://github.com/emberjs/rfcs/blob/master/text/0311-angle-bracket-invocation.md
|
||||
syntax case match
|
||||
syntax region mustacheAngleComponent start=/<\/\?[[:upper:]]/ end=/>/ keepend containedin=TOP,@htmlMustacheContainer
|
||||
syntax case ignore
|
||||
syntax match mustacheAngleBrackets '</\?\|/\?>' contained containedin=mustacheAngleComponent
|
||||
syntax match mustacheAngleComponentName '</[[:alnum:]]\+'hs=s+2 contained containedin=mustacheAngleBrackets
|
||||
syntax match mustacheAngleComponentName '<[[:alnum:]]\+'hs=s+1 contained containedin=mustacheAngleBrackets
|
||||
|
||||
syntax region mustacheHbsComponent start=/{{[^!][$#^/]\?/ end=/}}}\?/ keepend containedin=TOP,@htmlMustacheContainer
|
||||
|
||||
syntax cluster mustacheInside add=mustacheHbsComponent,mustacheAngleComponent
|
||||
|
||||
syntax match mustacheOperators '=\|\.\|/^>' contained containedin=@mustacheInside,mustacheParam
|
||||
syntax region mustacheHtmlValue start=/={{[^!][$#^/]\?/rs=s+1,hs=s+1 end=/}}/ oneline keepend contained containedin=htmlTag contains=@mustacheInside
|
||||
syntax region mustachePartial start=/{{[<>]/lc=2 end=/}}/me=e-2 contained containedin=@mustacheInside,@htmlMustacheContainer
|
||||
syntax region mustacheMarkerSet start=/{{=/lc=2 end=/=}}/me=e-2 contained containedin=@mustacheInside,@htmlMustacheContainer
|
||||
syntax match mustacheHandlebars '{{\|}}' contained containedin=@mustacheInside
|
||||
syntax match mustacheUnescape '{{{\|}}}' contained containedin=@mustacheInside
|
||||
syntax match mustacheConditionals '\([/#]\?\<\(if\|unless\)\|\<else\)\>' contained containedin=@mustacheInside
|
||||
syntax match mustacheHelpers '[/#]\?\<\(with\|link\-to\|each\(\-in\)\?\|let\)\>' contained containedin=@mustacheInside
|
||||
syntax match mustacheHelpers 'else \(if\|unless\|with\|link\-to\|each\(\-in\)\?\)' contained containedin=@mustacheInside
|
||||
syntax match mustacheParam /[a-z@_-]\+=/he=e-1 contained containedin=@mustacheInside
|
||||
syntax region mustacheComment start=/{{!/rs=s+2 skip=/{{.\{-}}}/ end=/}}/re=e-2 contains=Todo contained containedin=TOP,@mustacheInside,@htmlMustacheContainer
|
||||
syntax region mustacheBlockComment start=/{{!--/rs=s+2 skip=/{{.\{-}}}/ end=/--}}/re=e-2 contains=Todo contained extend containedin=TOP,@mustacheInside,@htmlMustacheContainer
|
||||
syntax region mustacheQString start=/'/ skip=/\\'/ end=/'/ contained containedin=@mustacheInside
|
||||
syntax region mustacheDQString start=/"/ skip=/\\"/ end=/"/ contained containedin=@mustacheInside
|
||||
|
||||
" Clustering
|
||||
syntax cluster htmlMustacheContainer add=htmlHead,htmlTitle,htmlString,htmlH1,htmlH2,htmlH3,htmlH4,htmlH5,htmlH6,htmlLink,htmlBold,htmlUnderline,htmlItalic,htmlValue
|
||||
|
||||
|
||||
" Hilighting
|
||||
" mustacheInside hilighted as Number, which is rarely used in html
|
||||
" you might like change it to Function or Identifier
|
||||
HtmlHiLink mustacheVariable Number
|
||||
HtmlHiLink mustacheVariableUnescape Number
|
||||
HtmlHiLink mustachePartial Number
|
||||
HtmlHiLink mustacheMarkerSet Number
|
||||
HtmlHiLink mustacheParam htmlArg
|
||||
HtmlHiLink mustacheAngleComponentName htmlTag
|
||||
|
||||
HtmlHiLink mustacheComment Comment
|
||||
HtmlHiLink mustacheBlockComment Comment
|
||||
HtmlHiLink mustacheError Error
|
||||
HtmlHiLink mustacheInsideError Error
|
||||
|
||||
HtmlHiLink mustacheHandlebars Special
|
||||
HtmlHiLink mustacheAngleBrackets htmlTagName
|
||||
HtmlHiLink mustacheUnescape Identifier
|
||||
HtmlHiLink mustacheOperators Operator
|
||||
HtmlHiLink mustacheConditionals Conditional
|
||||
HtmlHiLink mustacheHelpers Repeat
|
||||
HtmlHiLink mustacheQString String
|
||||
HtmlHiLink mustacheDQString String
|
||||
|
||||
syn region mustacheScriptTemplate start=+<script [^>]*type *=[^>]*text/\(mustache\|x-handlebars-template\)[^>]*>+
|
||||
\ end=+</script>+me=s-1 keepend
|
||||
\ contains=mustacheInside,@htmlMustacheContainer,htmlTag,htmlEndTag,htmlTagName,htmlSpecialChar
|
||||
|
||||
let b:current_syntax = "handlebars"
|
||||
delcommand HtmlHiLink
|
||||
|
||||
endif
|
||||
@@ -1,196 +0,0 @@
|
||||
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'html5') == -1
|
||||
|
||||
" Vim syntax file
|
||||
" Language: HTML (version 5.1)
|
||||
" SVG (SVG 1.1 Second Edition)
|
||||
" MathML (MathML 3.0 Second Edition)
|
||||
" Last Change: 2017 Mar 07
|
||||
" License: Public domain
|
||||
" (but let me know if you like :) )
|
||||
"
|
||||
" Note: This file just add new tags from HTML 5
|
||||
" and don't replace default html.vim syntax file
|
||||
"
|
||||
" Maintainer: Kao, Wei-Ko(othree) ( othree AT gmail DOT com )
|
||||
" Changes: update to Draft 2016 Jan 13
|
||||
" add microdata Attributes
|
||||
" Maintainer: Rodrigo Machado <rcmachado@gmail.com>
|
||||
" URL: http://rm.blog.br/vim/syntax/html.vim
|
||||
" Modified: htdebeer <H.T.de.Beer@gmail.com>
|
||||
" Changes: add common SVG elements and attributes for inline SVG
|
||||
|
||||
" Patch 7.4.1142
|
||||
if has("patch-7.4-1142")
|
||||
if has("win32")
|
||||
syn iskeyword @,48-57,_,128-167,224-235,-
|
||||
else
|
||||
syn iskeyword @,48-57,_,192-255,-
|
||||
endif
|
||||
endif
|
||||
|
||||
" HTML 5 tags
|
||||
syn keyword htmlTagName contained article aside audio canvas command
|
||||
syn keyword htmlTagName contained datalist details dialog embed figcaption figure footer
|
||||
syn keyword htmlTagName contained header hgroup keygen main mark meter menu menuitem nav output
|
||||
syn keyword htmlTagName contained progress ruby rt rp rb rtc section source summary time track video data
|
||||
syn keyword htmlTagName contained template content shadow slot
|
||||
syn keyword htmlTagName contained wbr bdi
|
||||
syn keyword htmlTagName contained picture
|
||||
|
||||
" SVG tags
|
||||
" http://www.w3.org/TR/SVG/
|
||||
" as found in http://www.w3.org/TR/SVG/eltindex.html
|
||||
syn keyword htmlTagName contained svg
|
||||
syn keyword htmlTagName contained altGlyph altGlyphDef altGlyphItem
|
||||
syn keyword htmlTagName contained animate animateColor animateMotion animateTransform
|
||||
syn keyword htmlTagName contained circle ellipse rect line polyline polygon image path
|
||||
syn keyword htmlTagName contained clipPath color-profile cursor
|
||||
syn keyword htmlTagName contained defs desc g symbol view use switch foreignObject
|
||||
syn keyword htmlTagName contained filter feBlend feColorMatrix feComponentTransfer feComposite feConvolveMatrix feDiffuseLighting feDisplacementMap feDistantLight feFlood feFuncA feFuncB feFuncG feFuncR feGaussianBlur feImage feMerge feMergeNode feMorphology feOffset fePointLight feSpecularLighting feSpotLight feTile feTurbulence
|
||||
syn keyword htmlTagName contained font font-face font-face-format font-face-name font-face-src font-face-uri
|
||||
syn keyword htmlTagName contained glyph glyphRef hkern
|
||||
syn keyword htmlTagName contained linearGradient marker mask pattern radialGradient set stop
|
||||
syn keyword htmlTagName contained missing-glyph mpath
|
||||
syn keyword htmlTagName contained text textPath tref tspan vkern
|
||||
syn keyword htmlTagName contained metadata title
|
||||
|
||||
" MathML tags
|
||||
" https://www.w3.org/TR/MathML3/appendixi.html#index.elem
|
||||
syn keyword htmlTagName contained abs and annotation annotation-xml apply approx arccos arccosh arccot arccoth
|
||||
syn keyword htmlTagName contained arccsc arccsch arcsec arcsech arcsin arcsinh arctan arctanh arg bind
|
||||
syn keyword htmlTagName contained bvar card cartesianproduct cbytes ceiling cerror ci cn codomain complexes
|
||||
syn keyword htmlTagName contained compose condition conjugate cos cosh cot coth cs csc csch
|
||||
syn keyword htmlTagName contained csymbol curl declare degree determinant diff divergence divide domain domainofapplication
|
||||
syn keyword htmlTagName contained emptyset eq equivalent eulergamma exists exp exponentiale factorial factorof false
|
||||
syn keyword htmlTagName contained floor fn forall gcd geq grad gt ident image imaginary
|
||||
syn keyword htmlTagName contained imaginaryi implies in infinity int integers intersect interval inverse lambda
|
||||
syn keyword htmlTagName contained laplacian lcm leq limit list ln log logbase lowlimit lt
|
||||
syn keyword htmlTagName contained maction maligngroup malignmark math matrix matrixrow max mean median menclose
|
||||
syn keyword htmlTagName contained merror mfenced mfrac mglyph mi mi" min minus mlabeledtr mlongdiv
|
||||
syn keyword htmlTagName contained mmultiscripts mn mo mode moment momentabout mover mpadded mphantom mprescripts
|
||||
syn keyword htmlTagName contained mroot mrow ms mscarries mscarry msgroup msline mspace msqrt msrow
|
||||
syn keyword htmlTagName contained mstack mstyle msub msubsup msup mtable mtd mtext mtr munder
|
||||
syn keyword htmlTagName contained munderover naturalnumbers neq none not notanumber notin notprsubset notsubset or
|
||||
syn keyword htmlTagName contained otherwise outerproduct partialdiff pi piece piecewise plus power primes product
|
||||
syn keyword htmlTagName contained prsubset quotient rationals real reals reln rem root scalarproduct sdev
|
||||
syn keyword htmlTagName contained sec sech selector semantics sep set setdiff share sin sinh
|
||||
syn keyword htmlTagName contained span subset sum tan tanh tendsto times transpose true union
|
||||
syn keyword htmlTagName contained uplimit variance vector vectorproduct xor
|
||||
|
||||
" Custom Element
|
||||
syn match htmlTagName contained "\<[a-z][-.0-9_a-z]*-[-.0-9_a-z]*\>"
|
||||
syn match htmlTagName contained "[.0-9_a-z]\@<=-[-.0-9_a-z]*\>"
|
||||
|
||||
" HTML 5 arguments
|
||||
" Core Attributes
|
||||
syn keyword htmlArg contained accesskey class contenteditable contextmenu dir
|
||||
syn keyword htmlArg contained draggable hidden id is lang spellcheck style tabindex title translate
|
||||
" Event-handler Attributes
|
||||
syn keyword htmlArg contained onabort onblur oncanplay oncanplaythrough onchange
|
||||
syn keyword htmlArg contained onclick oncontextmenu ondblclick ondrag ondragend ondragenter ondragleave ondragover
|
||||
syn keyword htmlArg contained ondragstart ondrop ondurationchange onemptied onended onerror onfocus onformchange
|
||||
syn keyword htmlArg contained onforminput oninput oninvalid onkeydown onkeypress onkeyup onload onloadeddata
|
||||
syn keyword htmlArg contained onloadedmetadata onloadstart onmousedown onmousemove onmouseout onmouseover onmouseup
|
||||
syn keyword htmlArg contained onmousewheel onpause onplay onplaying onprogress onratechange onreadystatechange
|
||||
syn keyword htmlArg contained onscroll onseeked onseeking onselect onshow onstalled onsubmit onsuspend ontimeupdate
|
||||
syn keyword htmlArg contained onvolumechange onwaiting
|
||||
" XML Attributes
|
||||
syn keyword htmlArg contained xml:lang xml:space xml:base xmlns
|
||||
" new features
|
||||
" <body>
|
||||
syn keyword htmlArg contained onafterprint onbeforeprint onbeforeunload onblur onerror onfocus onhashchange onload
|
||||
syn keyword htmlArg contained onmessage onoffline ononline onpopstate onredo onresize onstorage onundo onunload
|
||||
" <video>, <audio>, <source>, <track>
|
||||
syn keyword htmlArg contained autoplay preload controls loop poster media kind charset srclang track playsinline
|
||||
" <form>, <input>, <button>
|
||||
syn keyword htmlArg contained form autocomplete autofocus list min max step
|
||||
syn keyword htmlArg contained formaction autofocus formenctype formmethod formtarget formnovalidate
|
||||
syn keyword htmlArg contained required placeholder pattern
|
||||
" <command>, <details>, <time>
|
||||
syn keyword htmlArg contained label icon open datetime-local pubdate
|
||||
" <script>
|
||||
syn keyword htmlArg contained async
|
||||
" <content>
|
||||
syn keyword htmlArg contained select
|
||||
" <iframe>
|
||||
syn keyword htmlArg contained seamless srcdoc sandbox allowfullscreen allowusermedia allowpaymentrequest allowpresentation
|
||||
" <picture>
|
||||
syn keyword htmlArg contained srcset sizes
|
||||
" <a>
|
||||
syn keyword htmlArg contained download media
|
||||
" <script>, <style>
|
||||
syn keyword htmlArg contained nonce
|
||||
" <area>, <a>, <img>, <iframe>, <link>
|
||||
syn keyword htmlArg contained referrerpolicy
|
||||
" https://w3c.github.io/webappsec-subresource-integrity/#the-integrity-attribute
|
||||
syn keyword htmlArg contained integrity crossorigin
|
||||
" <link>
|
||||
syn keyword htmlArg contained prefetch
|
||||
" syn keyword htmlArg contained preload
|
||||
" <img>
|
||||
syn keyword htmlArg contained decoding
|
||||
" https://w3c.github.io/selection-api/#extensions-to-globaleventhandlers
|
||||
syn keyword htmlArg contained onselectstart onselectionchange
|
||||
" https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/loading
|
||||
syn keyword htmlArg contained loading
|
||||
|
||||
" Custom Data Attributes
|
||||
" http://w3c.github.io/html/single-page.html#embedding-custom-non-visible-data-with-the-data-attributes
|
||||
syn match htmlArg "\<data[-.0-9_a-z]*-[-.0-9_a-z]*\>" contained
|
||||
|
||||
" Vendor Extension Attributes
|
||||
" http://w3c.github.io/html/single-page.html#conformance-requirements-extensibility
|
||||
syn match htmlArg "\<x[-.0-9_a-z]*-[-.0-9_a-z]*\>" contained
|
||||
|
||||
" Microdata
|
||||
" http://dev.w3.org/html5/md/
|
||||
syn keyword htmlArg contained itemid itemscope itemtype itemprop itemref
|
||||
|
||||
" SVG
|
||||
" http://www.w3.org/TR/SVG/
|
||||
" Some common attributes from http://www.w3.org/TR/SVG/attindex.html
|
||||
syn keyword htmlArg contained accent-height accumulate additive alphabetic amplitude arabic-form ascent attributeName attributeType azimuth
|
||||
syn keyword htmlArg contained baseFrequency baseProfile bbox begin bias by
|
||||
syn keyword htmlArg contained calcMode cap-height class clipPathUnits contentScriptType contentStyleType cx cy
|
||||
syn keyword htmlArg contained d descent diffuseConstant divisor dur dx dy
|
||||
syn keyword htmlArg contained edgeMode elevation end exponent externalResourcesRequired
|
||||
syn keyword htmlArg contained fill filterRes filterUnits font-family font-size font-stretch font-style font-variant font-weight format format from fx fy
|
||||
syn keyword htmlArg contained g1 g2 glyph-name glyphRef gradientTransform gradientUnits
|
||||
syn keyword htmlArg contained hanging height horiz-adv-x horiz-origin-x horiz-origin-y
|
||||
syn keyword htmlArg contained id ideographic in in2 intercept
|
||||
syn keyword htmlArg contained k k1 k2 k3 k4 kernelMatrix kernelUnitLength keyPoints keySplines keyTimes
|
||||
syn keyword htmlArg contained lang lengthAdjust limitingConeAngle local
|
||||
syn keyword htmlArg contained markerHeight markerUnits markerWidth maskContentUnits maskUnits mathematical max media method min mode name
|
||||
syn keyword htmlArg contained numOctaves
|
||||
syn keyword htmlArg contained offset onabort onactivate onbegin onclick onend onerror onfocusin onfocusout onload onmousedown onmousemove onmouseout onmouseover onmouseup onrepeat onresize onscroll onunload onzoom operator order orient orientation origin overline-position overline-thickness
|
||||
syn keyword htmlArg contained panose-1 path pathLength patternContentUnits patternTransform patternUnits points pointsAtX pointsAtY pointsAtZ preserveAlpha preserveAspectRatio primitiveUnits
|
||||
syn keyword htmlArg contained r radius refX refY rendering-intent repeatCount repeatDur requiredExtensions requiredFeatures restart result rotate rx ry
|
||||
syn keyword htmlArg contained scale seed slope spacing specularConstant specularExponent spreadMethod startOffset stdDeviation stemh stemv stitchTiles strikethrough-position strikethrough-thickness string surfaceScale systemLanguage
|
||||
syn keyword htmlArg contained tableValues target targetX targetY textLength title to transform type
|
||||
syn keyword htmlArg contained u1 u2 underline-position underline-thickness unicode unicode-range units-per-em
|
||||
syn keyword htmlArg contained v-alphabetic v-hanging v-ideographic v-mathematical values version vert-adv-y vert-origin-x vert-origin-y viewBox viewTarget
|
||||
syn keyword htmlArg contained width widths
|
||||
syn keyword htmlArg contained x x-height x1 x2 xChannelSelector xlink:actuate xlink:actuate xlink:arcrole xlink:href xlink:role xlink:show xlink:title xlink:type xml:base xml:lang xml:space
|
||||
syn keyword htmlArg contained y y1 y2 yChannelSelector
|
||||
syn keyword htmlArg contained z zoomAndPan
|
||||
syn keyword htmlArg contained alignment-baseline baseline-shift clip-path clip-rule clip color-interpolation-filters color-interpolation color-profile color-rendering color cursor direction display dominant-baseline enable-background fill-opacity fill-rule fill filter flood-color flood-opacity font-family font-size-adjust font-size font-stretch font-style font-variant font-weight glyph-orientation-horizontal glyph-orientation-vertical image-rendering kerning letter-spacing lighting-color marker-end marker-mid marker-start mask opacity overflow pointer-events shape-rendering stop-color stop-opacity stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width stroke text-anchor text-decoration text-rendering unicode-bidi visibility word-spacing writing-mode
|
||||
|
||||
" MathML attributes
|
||||
" https://www.w3.org/TR/MathML3/chapter2.html#interf.toplevel.atts
|
||||
syn keyword htmlArg contained accent accentunder actiontype align alignmentscope altimg altimg-height altimg-valign altimg-width alttext
|
||||
syn keyword htmlArg contained annotation-xml background base baseline bevelled cd cdgroup charalign charspacing close
|
||||
syn keyword htmlArg contained closure color columnalign columnalignment columnlines columnspacing columnspan columnwidth crossout decimalpoint
|
||||
syn keyword htmlArg contained definitionURL denomalign depth display displaystyle edge encoding equalcolumns equalrows fence
|
||||
syn keyword htmlArg contained fontfamily fontsize fontstyle fontweight form frame framespacing groupalign height indentalign
|
||||
syn keyword htmlArg contained indentalignfirst indentalignlast indentshift indentshiftfirst indentshiftlast indenttarget index infixlinebreakstyle integer largeop
|
||||
syn keyword htmlArg contained leftoverhang length linebreak linebreakmultchar linebreakstyle lineleading linethickness location longdivstyle lquote
|
||||
syn keyword htmlArg contained lspace ltr macros math mathbackground mathcolor mathsize mathvariant maxsize maxwidth
|
||||
syn keyword htmlArg contained mediummathspace menclose minlabelspacing minsize mode movablelimits msgroup mslinethickness name nargs
|
||||
syn keyword htmlArg contained newline notation numalign number occurrence open order other overflow position
|
||||
syn keyword htmlArg contained rightoverhang role rowalign rowlines rowspacing rowspan rquote rspace schemaLocation scope
|
||||
syn keyword htmlArg contained scriptlevel scriptminsize scriptsize scriptsizemultiplier selection separator separators shift side stackalign
|
||||
syn keyword htmlArg contained stretchy subscriptshift superscriptshift symmetric thickmathspace thinmathspace type valign verythickmathspace verythinmathspace
|
||||
syn keyword htmlArg contained veryverythickmathspace veryverythinmathspace voffset width xref
|
||||
|
||||
|
||||
endif
|
||||
@@ -1,94 +0,0 @@
|
||||
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'jinja') == -1
|
||||
|
||||
" Vim syntax file
|
||||
" Language: HTML (version 5)
|
||||
" Maintainer: Rodrigo Machado <rcmachado@gmail.com>
|
||||
" URL: http://rm.blog.br/vim/syntax/html.vim
|
||||
" Last Change: 2009 Aug 19
|
||||
" License: Public domain
|
||||
" (but let me know if you like :) )
|
||||
"
|
||||
" Note: This file just adds the new tags from HTML 5
|
||||
" and don't replace default html.vim syntax file
|
||||
"
|
||||
" Modified: othree <othree@gmail.com>
|
||||
" Changes: update to Draft 28 August 2010
|
||||
" add complete new attributes
|
||||
" add wai-aria attributes
|
||||
" add microdata attributes
|
||||
" add rdfa attributes
|
||||
|
||||
|
||||
syn keyword htmlTagName contained script
|
||||
" HTML 5 tags
|
||||
syn keyword htmlTagName contained article aside audio canvas command
|
||||
syn keyword htmlTagName contained datalist details dialog embed figcaption figure footer
|
||||
syn keyword htmlTagName contained header hgroup keygen mark meter menu nav output
|
||||
syn keyword htmlTagName contained progress time ruby rt rp section source summary time track video wbr
|
||||
|
||||
" HTML 5 arguments
|
||||
" Core Attributes
|
||||
syn keyword htmlArg contained accesskey class contenteditable contextmenu dir
|
||||
syn keyword htmlArg contained draggable hidden id lang spellcheck style tabindex title
|
||||
" Event-handler Attributes
|
||||
syn keyword htmlArg contained onabort onblur oncanplay oncanplaythrough onchange
|
||||
syn keyword htmlArg contained onclick oncontextmenu ondblclick ondrag ondragend ondragenter ondragleave ondragover
|
||||
syn keyword htmlArg contained ondragstart ondrop ondurationchange onemptied onended onerror onfocus onformchange
|
||||
syn keyword htmlArg contained onforminput oninput oninvalid onkeydown onkeypress onkeyup onload onloadeddata
|
||||
syn keyword htmlArg contained onloadedmetadata onloadstart onmousedown onmousemove onmouseout onmouseover onmouseup
|
||||
syn keyword htmlArg contained onmousewheel onpause onplay onplaying onprogress onratechange onreadystatechange
|
||||
syn keyword htmlArg contained onscroll onseeked onseeking onselect onshow onstalled onsubmit onsuspend ontimeupdate
|
||||
syn keyword htmlArg contained onvolumechange onwaiting
|
||||
" XML Attributes
|
||||
syn keyword htmlArg contained xml:lang xml:space xml:base
|
||||
" new features
|
||||
" <body>
|
||||
syn keyword htmlArg contained onafterprint onbeforeprint onbeforeunload onblur onerror onfocus onhashchange onload
|
||||
syn keyword htmlArg contained onmessage onoffline ononline onpopstate onredo onresize onstorage onundo onunload
|
||||
" <video>, <audio>, <source>, <track>
|
||||
syn keyword htmlArg contained autoplay preload controls loop poster media kind charset srclang track
|
||||
" <form>, <input>, <button>
|
||||
syn keyword htmlArg contained form autocomplete autofocus list min max step
|
||||
syn keyword htmlArg contained formaction autofocus formenctype formmethod formtarget formnovalidate
|
||||
" <command>, <details>, <time>
|
||||
syn keyword htmlArg contained label icon open datetime pubdate
|
||||
|
||||
" Custom Data Attributes
|
||||
" http://dev.w3.org/html5/spec/Overview.html#custom-data-attribute
|
||||
syn match htmlArg "\<\(data(\-[a-z]\+)\+\)=" contained
|
||||
|
||||
" Microdata
|
||||
" http://dev.w3.org/html5/md/
|
||||
syn keyword htmlArg contained item itemid itemscope itemtype itemprop
|
||||
|
||||
" RDFa
|
||||
" http://www.w3.org/TR/rdfa-syntax/#a_xhtmlrdfa_dtd
|
||||
syn keyword htmlArg contained about typeof property resource content datatype rel rev
|
||||
|
||||
" WAI-ARIA States and Properties
|
||||
" http://www.w3.org/TR/wai-aria/states_and_properties
|
||||
syn keyword htmlArg contained role
|
||||
" Global States and Properties
|
||||
syn match htmlArg contained "\<aria-\(atomic\|busy\|controls\|describedby\)\>"
|
||||
syn match htmlArg contained "\<aria-\(disabled\|dropeffect\|flowto\|grabbed\)\>"
|
||||
syn match htmlArg contained "\<aria-\(haspopup\|hidden\|invalid\|label\)\>"
|
||||
syn match htmlArg contained "\<aria-\(labelledby\|live\|owns\|relevant\)\>"
|
||||
|
||||
" Widget Attributes
|
||||
syn match htmlArg contained "\<aria-\(autocomplete\|checked\|disabled\|expanded\)\>"
|
||||
syn match htmlArg contained "\<aria-\(haspopup\|hidden\|invalid\|label\)\>"
|
||||
syn match htmlArg contained "\<aria-\(level\|multiline\|multiselectable\|orientation\)\>"
|
||||
syn match htmlArg contained "\<aria-\(pressed\|readonly\|required\|selected\)\>"
|
||||
syn match htmlArg contained "\<aria-\(sort\|valuemax\|valuemin\|valuenow\|valuetext\|\)\>"
|
||||
|
||||
" Live Region Attributes
|
||||
syn match htmlArg contained "\<aria-\(atomic\|busy\|live\|relevant\|\)\>"
|
||||
|
||||
" Drag-and-Drop attributes
|
||||
syn match htmlArg contained "\<aria-\(dropeffect\|grabbed\)\>"
|
||||
|
||||
" Relationship Attributes
|
||||
syn match htmlArg contained "\<aria-\(activedescendant\|controls\|describedby\|flowto\|\)\>"
|
||||
syn match htmlArg contained "\<aria-\(labelledby\|owns\|posinset\|setsize\|\)\>"
|
||||
|
||||
endif
|
||||
199
syntax/html.vim
199
syntax/html.vim
@@ -1,3 +1,196 @@
|
||||
" Polyglot metafile
|
||||
source <sfile>:h/html-1.vim
|
||||
source <sfile>:h/html-2.vim
|
||||
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'html5') == -1
|
||||
|
||||
" Vim syntax file
|
||||
" Language: HTML (version 5.1)
|
||||
" SVG (SVG 1.1 Second Edition)
|
||||
" MathML (MathML 3.0 Second Edition)
|
||||
" Last Change: 2017 Mar 07
|
||||
" License: Public domain
|
||||
" (but let me know if you like :) )
|
||||
"
|
||||
" Note: This file just add new tags from HTML 5
|
||||
" and don't replace default html.vim syntax file
|
||||
"
|
||||
" Maintainer: Kao, Wei-Ko(othree) ( othree AT gmail DOT com )
|
||||
" Changes: update to Draft 2016 Jan 13
|
||||
" add microdata Attributes
|
||||
" Maintainer: Rodrigo Machado <rcmachado@gmail.com>
|
||||
" URL: http://rm.blog.br/vim/syntax/html.vim
|
||||
" Modified: htdebeer <H.T.de.Beer@gmail.com>
|
||||
" Changes: add common SVG elements and attributes for inline SVG
|
||||
|
||||
" Patch 7.4.1142
|
||||
if has("patch-7.4-1142")
|
||||
if has("win32")
|
||||
syn iskeyword @,48-57,_,128-167,224-235,-
|
||||
else
|
||||
syn iskeyword @,48-57,_,192-255,-
|
||||
endif
|
||||
endif
|
||||
|
||||
" HTML 5 tags
|
||||
syn keyword htmlTagName contained article aside audio canvas command
|
||||
syn keyword htmlTagName contained datalist details dialog embed figcaption figure footer
|
||||
syn keyword htmlTagName contained header hgroup keygen main mark meter menu menuitem nav output
|
||||
syn keyword htmlTagName contained progress ruby rt rp rb rtc section source summary time track video data
|
||||
syn keyword htmlTagName contained template content shadow slot
|
||||
syn keyword htmlTagName contained wbr bdi
|
||||
syn keyword htmlTagName contained picture
|
||||
|
||||
" SVG tags
|
||||
" http://www.w3.org/TR/SVG/
|
||||
" as found in http://www.w3.org/TR/SVG/eltindex.html
|
||||
syn keyword htmlTagName contained svg
|
||||
syn keyword htmlTagName contained altGlyph altGlyphDef altGlyphItem
|
||||
syn keyword htmlTagName contained animate animateColor animateMotion animateTransform
|
||||
syn keyword htmlTagName contained circle ellipse rect line polyline polygon image path
|
||||
syn keyword htmlTagName contained clipPath color-profile cursor
|
||||
syn keyword htmlTagName contained defs desc g symbol view use switch foreignObject
|
||||
syn keyword htmlTagName contained filter feBlend feColorMatrix feComponentTransfer feComposite feConvolveMatrix feDiffuseLighting feDisplacementMap feDistantLight feFlood feFuncA feFuncB feFuncG feFuncR feGaussianBlur feImage feMerge feMergeNode feMorphology feOffset fePointLight feSpecularLighting feSpotLight feTile feTurbulence
|
||||
syn keyword htmlTagName contained font font-face font-face-format font-face-name font-face-src font-face-uri
|
||||
syn keyword htmlTagName contained glyph glyphRef hkern
|
||||
syn keyword htmlTagName contained linearGradient marker mask pattern radialGradient set stop
|
||||
syn keyword htmlTagName contained missing-glyph mpath
|
||||
syn keyword htmlTagName contained text textPath tref tspan vkern
|
||||
syn keyword htmlTagName contained metadata title
|
||||
|
||||
" MathML tags
|
||||
" https://www.w3.org/TR/MathML3/appendixi.html#index.elem
|
||||
syn keyword htmlTagName contained abs and annotation annotation-xml apply approx arccos arccosh arccot arccoth
|
||||
syn keyword htmlTagName contained arccsc arccsch arcsec arcsech arcsin arcsinh arctan arctanh arg bind
|
||||
syn keyword htmlTagName contained bvar card cartesianproduct cbytes ceiling cerror ci cn codomain complexes
|
||||
syn keyword htmlTagName contained compose condition conjugate cos cosh cot coth cs csc csch
|
||||
syn keyword htmlTagName contained csymbol curl declare degree determinant diff divergence divide domain domainofapplication
|
||||
syn keyword htmlTagName contained emptyset eq equivalent eulergamma exists exp exponentiale factorial factorof false
|
||||
syn keyword htmlTagName contained floor fn forall gcd geq grad gt ident image imaginary
|
||||
syn keyword htmlTagName contained imaginaryi implies in infinity int integers intersect interval inverse lambda
|
||||
syn keyword htmlTagName contained laplacian lcm leq limit list ln log logbase lowlimit lt
|
||||
syn keyword htmlTagName contained maction maligngroup malignmark math matrix matrixrow max mean median menclose
|
||||
syn keyword htmlTagName contained merror mfenced mfrac mglyph mi mi" min minus mlabeledtr mlongdiv
|
||||
syn keyword htmlTagName contained mmultiscripts mn mo mode moment momentabout mover mpadded mphantom mprescripts
|
||||
syn keyword htmlTagName contained mroot mrow ms mscarries mscarry msgroup msline mspace msqrt msrow
|
||||
syn keyword htmlTagName contained mstack mstyle msub msubsup msup mtable mtd mtext mtr munder
|
||||
syn keyword htmlTagName contained munderover naturalnumbers neq none not notanumber notin notprsubset notsubset or
|
||||
syn keyword htmlTagName contained otherwise outerproduct partialdiff pi piece piecewise plus power primes product
|
||||
syn keyword htmlTagName contained prsubset quotient rationals real reals reln rem root scalarproduct sdev
|
||||
syn keyword htmlTagName contained sec sech selector semantics sep set setdiff share sin sinh
|
||||
syn keyword htmlTagName contained span subset sum tan tanh tendsto times transpose true union
|
||||
syn keyword htmlTagName contained uplimit variance vector vectorproduct xor
|
||||
|
||||
" Custom Element
|
||||
syn match htmlTagName contained "\<[a-z][-.0-9_a-z]*-[-.0-9_a-z]*\>"
|
||||
syn match htmlTagName contained "[.0-9_a-z]\@<=-[-.0-9_a-z]*\>"
|
||||
|
||||
" HTML 5 arguments
|
||||
" Core Attributes
|
||||
syn keyword htmlArg contained accesskey class contenteditable contextmenu dir
|
||||
syn keyword htmlArg contained draggable hidden id is lang spellcheck style tabindex title translate
|
||||
" Event-handler Attributes
|
||||
syn keyword htmlArg contained onabort onblur oncanplay oncanplaythrough onchange
|
||||
syn keyword htmlArg contained onclick oncontextmenu ondblclick ondrag ondragend ondragenter ondragleave ondragover
|
||||
syn keyword htmlArg contained ondragstart ondrop ondurationchange onemptied onended onerror onfocus onformchange
|
||||
syn keyword htmlArg contained onforminput oninput oninvalid onkeydown onkeypress onkeyup onload onloadeddata
|
||||
syn keyword htmlArg contained onloadedmetadata onloadstart onmousedown onmousemove onmouseout onmouseover onmouseup
|
||||
syn keyword htmlArg contained onmousewheel onpause onplay onplaying onprogress onratechange onreadystatechange
|
||||
syn keyword htmlArg contained onscroll onseeked onseeking onselect onshow onstalled onsubmit onsuspend ontimeupdate
|
||||
syn keyword htmlArg contained onvolumechange onwaiting
|
||||
" XML Attributes
|
||||
syn keyword htmlArg contained xml:lang xml:space xml:base xmlns
|
||||
" new features
|
||||
" <body>
|
||||
syn keyword htmlArg contained onafterprint onbeforeprint onbeforeunload onblur onerror onfocus onhashchange onload
|
||||
syn keyword htmlArg contained onmessage onoffline ononline onpopstate onredo onresize onstorage onundo onunload
|
||||
" <video>, <audio>, <source>, <track>
|
||||
syn keyword htmlArg contained autoplay preload controls loop poster media kind charset srclang track playsinline
|
||||
" <form>, <input>, <button>
|
||||
syn keyword htmlArg contained form autocomplete autofocus list min max step
|
||||
syn keyword htmlArg contained formaction autofocus formenctype formmethod formtarget formnovalidate
|
||||
syn keyword htmlArg contained required placeholder pattern
|
||||
" <command>, <details>, <time>
|
||||
syn keyword htmlArg contained label icon open datetime-local pubdate
|
||||
" <script>
|
||||
syn keyword htmlArg contained async
|
||||
" <content>
|
||||
syn keyword htmlArg contained select
|
||||
" <iframe>
|
||||
syn keyword htmlArg contained seamless srcdoc sandbox allowfullscreen allowusermedia allowpaymentrequest allowpresentation
|
||||
" <picture>
|
||||
syn keyword htmlArg contained srcset sizes
|
||||
" <a>
|
||||
syn keyword htmlArg contained download media
|
||||
" <script>, <style>
|
||||
syn keyword htmlArg contained nonce
|
||||
" <area>, <a>, <img>, <iframe>, <link>
|
||||
syn keyword htmlArg contained referrerpolicy
|
||||
" https://w3c.github.io/webappsec-subresource-integrity/#the-integrity-attribute
|
||||
syn keyword htmlArg contained integrity crossorigin
|
||||
" <link>
|
||||
syn keyword htmlArg contained prefetch
|
||||
" syn keyword htmlArg contained preload
|
||||
" <img>
|
||||
syn keyword htmlArg contained decoding
|
||||
" https://w3c.github.io/selection-api/#extensions-to-globaleventhandlers
|
||||
syn keyword htmlArg contained onselectstart onselectionchange
|
||||
" https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/loading
|
||||
syn keyword htmlArg contained loading
|
||||
|
||||
" Custom Data Attributes
|
||||
" http://w3c.github.io/html/single-page.html#embedding-custom-non-visible-data-with-the-data-attributes
|
||||
syn match htmlArg "\<data[-.0-9_a-z]*-[-.0-9_a-z]*\>" contained
|
||||
|
||||
" Vendor Extension Attributes
|
||||
" http://w3c.github.io/html/single-page.html#conformance-requirements-extensibility
|
||||
syn match htmlArg "\<x[-.0-9_a-z]*-[-.0-9_a-z]*\>" contained
|
||||
|
||||
" Microdata
|
||||
" http://dev.w3.org/html5/md/
|
||||
syn keyword htmlArg contained itemid itemscope itemtype itemprop itemref
|
||||
|
||||
" SVG
|
||||
" http://www.w3.org/TR/SVG/
|
||||
" Some common attributes from http://www.w3.org/TR/SVG/attindex.html
|
||||
syn keyword htmlArg contained accent-height accumulate additive alphabetic amplitude arabic-form ascent attributeName attributeType azimuth
|
||||
syn keyword htmlArg contained baseFrequency baseProfile bbox begin bias by
|
||||
syn keyword htmlArg contained calcMode cap-height class clipPathUnits contentScriptType contentStyleType cx cy
|
||||
syn keyword htmlArg contained d descent diffuseConstant divisor dur dx dy
|
||||
syn keyword htmlArg contained edgeMode elevation end exponent externalResourcesRequired
|
||||
syn keyword htmlArg contained fill filterRes filterUnits font-family font-size font-stretch font-style font-variant font-weight format format from fx fy
|
||||
syn keyword htmlArg contained g1 g2 glyph-name glyphRef gradientTransform gradientUnits
|
||||
syn keyword htmlArg contained hanging height horiz-adv-x horiz-origin-x horiz-origin-y
|
||||
syn keyword htmlArg contained id ideographic in in2 intercept
|
||||
syn keyword htmlArg contained k k1 k2 k3 k4 kernelMatrix kernelUnitLength keyPoints keySplines keyTimes
|
||||
syn keyword htmlArg contained lang lengthAdjust limitingConeAngle local
|
||||
syn keyword htmlArg contained markerHeight markerUnits markerWidth maskContentUnits maskUnits mathematical max media method min mode name
|
||||
syn keyword htmlArg contained numOctaves
|
||||
syn keyword htmlArg contained offset onabort onactivate onbegin onclick onend onerror onfocusin onfocusout onload onmousedown onmousemove onmouseout onmouseover onmouseup onrepeat onresize onscroll onunload onzoom operator order orient orientation origin overline-position overline-thickness
|
||||
syn keyword htmlArg contained panose-1 path pathLength patternContentUnits patternTransform patternUnits points pointsAtX pointsAtY pointsAtZ preserveAlpha preserveAspectRatio primitiveUnits
|
||||
syn keyword htmlArg contained r radius refX refY rendering-intent repeatCount repeatDur requiredExtensions requiredFeatures restart result rotate rx ry
|
||||
syn keyword htmlArg contained scale seed slope spacing specularConstant specularExponent spreadMethod startOffset stdDeviation stemh stemv stitchTiles strikethrough-position strikethrough-thickness string surfaceScale systemLanguage
|
||||
syn keyword htmlArg contained tableValues target targetX targetY textLength title to transform type
|
||||
syn keyword htmlArg contained u1 u2 underline-position underline-thickness unicode unicode-range units-per-em
|
||||
syn keyword htmlArg contained v-alphabetic v-hanging v-ideographic v-mathematical values version vert-adv-y vert-origin-x vert-origin-y viewBox viewTarget
|
||||
syn keyword htmlArg contained width widths
|
||||
syn keyword htmlArg contained x x-height x1 x2 xChannelSelector xlink:actuate xlink:actuate xlink:arcrole xlink:href xlink:role xlink:show xlink:title xlink:type xml:base xml:lang xml:space
|
||||
syn keyword htmlArg contained y y1 y2 yChannelSelector
|
||||
syn keyword htmlArg contained z zoomAndPan
|
||||
syn keyword htmlArg contained alignment-baseline baseline-shift clip-path clip-rule clip color-interpolation-filters color-interpolation color-profile color-rendering color cursor direction display dominant-baseline enable-background fill-opacity fill-rule fill filter flood-color flood-opacity font-family font-size-adjust font-size font-stretch font-style font-variant font-weight glyph-orientation-horizontal glyph-orientation-vertical image-rendering kerning letter-spacing lighting-color marker-end marker-mid marker-start mask opacity overflow pointer-events shape-rendering stop-color stop-opacity stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width stroke text-anchor text-decoration text-rendering unicode-bidi visibility word-spacing writing-mode
|
||||
|
||||
" MathML attributes
|
||||
" https://www.w3.org/TR/MathML3/chapter2.html#interf.toplevel.atts
|
||||
syn keyword htmlArg contained accent accentunder actiontype align alignmentscope altimg altimg-height altimg-valign altimg-width alttext
|
||||
syn keyword htmlArg contained annotation-xml background base baseline bevelled cd cdgroup charalign charspacing close
|
||||
syn keyword htmlArg contained closure color columnalign columnalignment columnlines columnspacing columnspan columnwidth crossout decimalpoint
|
||||
syn keyword htmlArg contained definitionURL denomalign depth display displaystyle edge encoding equalcolumns equalrows fence
|
||||
syn keyword htmlArg contained fontfamily fontsize fontstyle fontweight form frame framespacing groupalign height indentalign
|
||||
syn keyword htmlArg contained indentalignfirst indentalignlast indentshift indentshiftfirst indentshiftlast indenttarget index infixlinebreakstyle integer largeop
|
||||
syn keyword htmlArg contained leftoverhang length linebreak linebreakmultchar linebreakstyle lineleading linethickness location longdivstyle lquote
|
||||
syn keyword htmlArg contained lspace ltr macros math mathbackground mathcolor mathsize mathvariant maxsize maxwidth
|
||||
syn keyword htmlArg contained mediummathspace menclose minlabelspacing minsize mode movablelimits msgroup mslinethickness name nargs
|
||||
syn keyword htmlArg contained newline notation numalign number occurrence open order other overflow position
|
||||
syn keyword htmlArg contained rightoverhang role rowalign rowlines rowspacing rowspan rquote rspace schemaLocation scope
|
||||
syn keyword htmlArg contained scriptlevel scriptminsize scriptsize scriptsizemultiplier selection separator separators shift side stackalign
|
||||
syn keyword htmlArg contained stretchy subscriptshift superscriptshift symmetric thickmathspace thinmathspace type valign verythickmathspace verythinmathspace
|
||||
syn keyword htmlArg contained veryverythickmathspace veryverythinmathspace voffset width xref
|
||||
|
||||
|
||||
endif
|
||||
|
||||
30
syntax/htmldjango.vim
Normal file
30
syntax/htmldjango.vim
Normal file
@@ -0,0 +1,30 @@
|
||||
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'htmldjango') == -1
|
||||
|
||||
" Vim syntax file
|
||||
" Language: Django HTML template
|
||||
" Maintainer: Dave Hodder <dmh@dmh.org.uk>
|
||||
" Last Change: 2014 Jul 13
|
||||
|
||||
" quit when a syntax file was already loaded
|
||||
if exists("b:current_syntax")
|
||||
finish
|
||||
endif
|
||||
|
||||
if !exists("main_syntax")
|
||||
let main_syntax = 'html'
|
||||
endif
|
||||
|
||||
runtime! syntax/django.vim
|
||||
runtime! syntax/html.vim
|
||||
unlet b:current_syntax
|
||||
|
||||
syn cluster djangoBlocks add=djangoTagBlock,djangoVarBlock,djangoComment,djangoComBlock
|
||||
|
||||
syn region djangoTagBlock start="{%" end="%}" contains=djangoStatement,djangoFilter,djangoArgument,djangoTagError display containedin=ALLBUT,@djangoBlocks
|
||||
syn region djangoVarBlock start="{{" end="}}" contains=djangoFilter,djangoArgument,djangoVarError display containedin=ALLBUT,@djangoBlocks
|
||||
syn region djangoComment start="{%\s*comment\(\s\+.\{-}\)\?%}" end="{%\s*endcomment\s*%}" contains=djangoTodo containedin=ALLBUT,@djangoBlocks
|
||||
syn region djangoComBlock start="{#" end="#}" contains=djangoTodo containedin=ALLBUT,@djangoBlocks
|
||||
|
||||
let b:current_syntax = "htmldjango"
|
||||
|
||||
endif
|
||||
@@ -1,90 +0,0 @@
|
||||
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'jinja') == -1
|
||||
|
||||
" jinja syntax file
|
||||
" Language: Jinja HTML template
|
||||
" Maintainer: Hsiaoming Yang <lepture@me.com>
|
||||
" Last Change: Sep 13, 2012
|
||||
|
||||
" only support 6.x+
|
||||
|
||||
if exists("b:current_syntax")
|
||||
finish
|
||||
endif
|
||||
|
||||
if !exists("main_syntax")
|
||||
let main_syntax = 'html'
|
||||
endif
|
||||
|
||||
runtime! syntax/html.vim
|
||||
unlet b:current_syntax
|
||||
|
||||
syntax case match
|
||||
|
||||
" jinja template built-in tags and parameters
|
||||
" 'comment' doesn't appear here because it gets special treatment
|
||||
syn keyword jinjaStatement contained if else elif endif is not
|
||||
syn keyword jinjaStatement contained for in recursive endfor
|
||||
syn keyword jinjaStatement contained raw endraw
|
||||
syn keyword jinjaStatement contained block endblock extends super scoped
|
||||
syn keyword jinjaStatement contained macro endmacro call endcall
|
||||
syn keyword jinjaStatement contained from import as do continue break
|
||||
syn keyword jinjaStatement contained filter endfilter set
|
||||
syn keyword jinjaStatement contained include ignore missing
|
||||
syn keyword jinjaStatement contained with without context endwith
|
||||
syn keyword jinjaStatement contained trans endtrans pluralize
|
||||
syn keyword jinjaStatement contained autoescape endautoescape
|
||||
|
||||
" jinja templete built-in filters
|
||||
syn keyword jinjaFilter contained abs attr batch capitalize center default
|
||||
syn keyword jinjaFilter contained dictsort escape filesizeformat first
|
||||
syn keyword jinjaFilter contained float forceescape format groupby indent
|
||||
syn keyword jinjaFilter contained int join last length list lower pprint
|
||||
syn keyword jinjaFilter contained random replace reverse round safe slice
|
||||
syn keyword jinjaFilter contained sort string striptags sum
|
||||
syn keyword jinjaFilter contained title trim truncate upper urlize
|
||||
syn keyword jinjaFilter contained wordcount wordwrap
|
||||
|
||||
" jinja template built-in tests
|
||||
syn keyword jinjaTest contained callable defined divisibleby escaped
|
||||
syn keyword jinjaTest contained even iterable lower mapping none number
|
||||
syn keyword jinjaTest contained odd sameas sequence string undefined upper
|
||||
|
||||
syn keyword jinjaFunction contained range lipsum dict cycler joiner
|
||||
|
||||
|
||||
" Keywords to highlight within comments
|
||||
syn keyword jinjaTodo contained TODO FIXME XXX
|
||||
|
||||
" jinja template constants (always surrounded by double quotes)
|
||||
syn region jinjaArgument contained start=/"/ skip=/\\"/ end=/"/
|
||||
syn region jinjaArgument contained start=/'/ skip=/\\'/ end=/'/
|
||||
syn keyword jinjaArgument contained true false
|
||||
|
||||
" Mark illegal characters within tag and variables blocks
|
||||
syn match jinjaTagError contained "#}\|{{\|[^%]}}\|[&#]"
|
||||
syn match jinjaVarError contained "#}\|{%\|%}\|[<>!&#%]"
|
||||
syn cluster jinjaBlocks add=jinjaTagBlock,jinjaVarBlock,jinjaComBlock,jinjaComment
|
||||
|
||||
" jinja template tag and variable blocks
|
||||
syn region jinjaTagBlock start="{%" end="%}" contains=jinjaStatement,jinjaFilter,jinjaArgument,jinjaFilter,jinjaTest,jinjaTagError display containedin=ALLBUT,@jinjaBlocks
|
||||
syn region jinjaVarBlock start="{{" end="}}" contains=jinjaFilter,jinjaArgument,jinjaVarError display containedin=ALLBUT,@jinjaBlocks
|
||||
syn region jinjaComBlock start="{#" end="#}" contains=jinjaTodo containedin=ALLBUT,@jinjaBlocks
|
||||
|
||||
|
||||
hi def link jinjaTagBlock PreProc
|
||||
hi def link jinjaVarBlock PreProc
|
||||
hi def link jinjaStatement Statement
|
||||
hi def link jinjaFunction Function
|
||||
hi def link jinjaTest Type
|
||||
hi def link jinjaFilter Identifier
|
||||
hi def link jinjaArgument Constant
|
||||
hi def link jinjaTagError Error
|
||||
hi def link jinjaVarError Error
|
||||
hi def link jinjaError Error
|
||||
hi def link jinjaComment Comment
|
||||
hi def link jinjaComBlock Comment
|
||||
hi def link jinjaTodo Todo
|
||||
|
||||
let b:current_syntax = "jinja"
|
||||
|
||||
endif
|
||||
@@ -1,110 +1,5 @@
|
||||
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'handlebars') == -1
|
||||
|
||||
" Mustache & Handlebars syntax
|
||||
" Language: Mustache, Handlebars
|
||||
" Maintainer: Juvenn Woo <machese@gmail.com>
|
||||
" Screenshot: http://imgur.com/6F408
|
||||
" Version: 6
|
||||
" Last Change: Jul 16 2019
|
||||
" Remark:
|
||||
" It lexically hilights embedded mustaches (exclusively) in html file.
|
||||
" While it was written for Ruby-based Mustache template system, it should
|
||||
" work for Google's C-based *ctemplate* as well as Erlang-based *et*. All
|
||||
" of them are, AFAIK, based on the idea of ctemplate.
|
||||
" References:
|
||||
" [Mustache](http://github.com/defunkt/mustache)
|
||||
" [Handlebars](https://github.com/wycats/handlebars.js)
|
||||
" [ctemplate](http://code.google.com/p/google-ctemplate/)
|
||||
" [ctemplate doc](http://google-ctemplate.googlecode.com/svn/trunk/doc/howto.html)
|
||||
" [et](http://www.ivan.fomichev.name/2008/05/erlang-template-engine-prototype.html)
|
||||
" TODO: Feedback is welcomed.
|
||||
|
||||
|
||||
" Read the HTML syntax to start with
|
||||
if version < 600
|
||||
so <sfile>:p:h/html.vim
|
||||
else
|
||||
runtime! syntax/html.vim
|
||||
unlet b:current_syntax
|
||||
endif
|
||||
|
||||
if version < 600
|
||||
syntax clear
|
||||
elseif exists("b:current_syntax")
|
||||
finish
|
||||
endif
|
||||
|
||||
" Standard HiLink will not work with included syntax files
|
||||
if version < 508
|
||||
command! -nargs=+ HtmlHiLink hi link <args>
|
||||
else
|
||||
command! -nargs=+ HtmlHiLink hi def link <args>
|
||||
endif
|
||||
|
||||
syntax match mustacheError '}}}\?'
|
||||
syntax match mustacheInsideError '{{[{$#<>=!\/]\?'
|
||||
|
||||
" Ember angle bracket syntax syntax starts with a capital letter:
|
||||
" https://github.com/emberjs/rfcs/blob/master/text/0311-angle-bracket-invocation.md
|
||||
syntax case match
|
||||
syntax region mustacheAngleComponent start=/<\/\?[[:upper:]]/ end=/>/ keepend containedin=TOP,@htmlMustacheContainer
|
||||
syntax case ignore
|
||||
syntax match mustacheAngleBrackets '</\?\|/\?>' contained containedin=mustacheAngleComponent
|
||||
syntax match mustacheAngleComponentName '</[[:alnum:]]\+'hs=s+2 contained containedin=mustacheAngleBrackets
|
||||
syntax match mustacheAngleComponentName '<[[:alnum:]]\+'hs=s+1 contained containedin=mustacheAngleBrackets
|
||||
|
||||
syntax region mustacheHbsComponent start=/{{[^!][$#^/]\?/ end=/}}}\?/ keepend containedin=TOP,@htmlMustacheContainer
|
||||
|
||||
syntax cluster mustacheInside add=mustacheHbsComponent,mustacheAngleComponent
|
||||
|
||||
syntax match mustacheOperators '=\|\.\|/^>' contained containedin=@mustacheInside,mustacheParam
|
||||
syntax region mustacheHtmlValue start=/={{[^!][$#^/]\?/rs=s+1,hs=s+1 end=/}}/ oneline keepend contained containedin=htmlTag contains=@mustacheInside
|
||||
syntax region mustachePartial start=/{{[<>]/lc=2 end=/}}/me=e-2 contained containedin=@mustacheInside,@htmlMustacheContainer
|
||||
syntax region mustacheMarkerSet start=/{{=/lc=2 end=/=}}/me=e-2 contained containedin=@mustacheInside,@htmlMustacheContainer
|
||||
syntax match mustacheHandlebars '{{\|}}' contained containedin=@mustacheInside
|
||||
syntax match mustacheUnescape '{{{\|}}}' contained containedin=@mustacheInside
|
||||
syntax match mustacheConditionals '\([/#]\?\<\(if\|unless\)\|\<else\)\>' contained containedin=@mustacheInside
|
||||
syntax match mustacheHelpers '[/#]\?\<\(with\|link\-to\|each\(\-in\)\?\|let\)\>' contained containedin=@mustacheInside
|
||||
syntax match mustacheHelpers 'else \(if\|unless\|with\|link\-to\|each\(\-in\)\?\)' contained containedin=@mustacheInside
|
||||
syntax match mustacheParam /[a-z@_-]\+=/he=e-1 contained containedin=@mustacheInside
|
||||
syntax region mustacheComment start=/{{!/rs=s+2 skip=/{{.\{-}}}/ end=/}}/re=e-2 contains=Todo contained containedin=TOP,@mustacheInside,@htmlMustacheContainer
|
||||
syntax region mustacheBlockComment start=/{{!--/rs=s+2 skip=/{{.\{-}}}/ end=/--}}/re=e-2 contains=Todo contained extend containedin=TOP,@mustacheInside,@htmlMustacheContainer
|
||||
syntax region mustacheQString start=/'/ skip=/\\'/ end=/'/ contained containedin=@mustacheInside
|
||||
syntax region mustacheDQString start=/"/ skip=/\\"/ end=/"/ contained containedin=@mustacheInside
|
||||
|
||||
" Clustering
|
||||
syntax cluster htmlMustacheContainer add=htmlHead,htmlTitle,htmlString,htmlH1,htmlH2,htmlH3,htmlH4,htmlH5,htmlH6,htmlLink,htmlBold,htmlUnderline,htmlItalic,htmlValue
|
||||
|
||||
|
||||
" Hilighting
|
||||
" mustacheInside hilighted as Number, which is rarely used in html
|
||||
" you might like change it to Function or Identifier
|
||||
HtmlHiLink mustacheVariable Number
|
||||
HtmlHiLink mustacheVariableUnescape Number
|
||||
HtmlHiLink mustachePartial Number
|
||||
HtmlHiLink mustacheMarkerSet Number
|
||||
HtmlHiLink mustacheParam htmlArg
|
||||
HtmlHiLink mustacheAngleComponentName htmlTag
|
||||
|
||||
HtmlHiLink mustacheComment Comment
|
||||
HtmlHiLink mustacheBlockComment Comment
|
||||
HtmlHiLink mustacheError Error
|
||||
HtmlHiLink mustacheInsideError Error
|
||||
|
||||
HtmlHiLink mustacheHandlebars Special
|
||||
HtmlHiLink mustacheAngleBrackets htmlTagName
|
||||
HtmlHiLink mustacheUnescape Identifier
|
||||
HtmlHiLink mustacheOperators Operator
|
||||
HtmlHiLink mustacheConditionals Conditional
|
||||
HtmlHiLink mustacheHelpers Repeat
|
||||
HtmlHiLink mustacheQString String
|
||||
HtmlHiLink mustacheDQString String
|
||||
|
||||
syn region mustacheScriptTemplate start=+<script [^>]*type *=[^>]*text/\(mustache\|x-handlebars-template\)[^>]*>+
|
||||
\ end=+</script>+me=s-1 keepend
|
||||
\ contains=mustacheInside,@htmlMustacheContainer,htmlTag,htmlEndTag,htmlTagName,htmlSpecialChar
|
||||
|
||||
let b:current_syntax = "mustache"
|
||||
delcommand HtmlHiLink
|
||||
runtime! syntax/handlebars.vim
|
||||
|
||||
endif
|
||||
|
||||
@@ -201,6 +201,13 @@ call TestExtension("cpp", "foobar.moc", "")
|
||||
call TestExtension("cpp", "foobar.tcc", "")
|
||||
call TestExtension("cpp", "foobar.inl", "")
|
||||
|
||||
" Django
|
||||
|
||||
call TestExtension("htmldjango", "foobar.j2", "")
|
||||
call TestExtension("htmldjango", "foobar.jinja", "")
|
||||
call TestExtension("htmldjango", "foobar.jinja2", "")
|
||||
call TestExtension("htmldjango", "foobar.njk", "")
|
||||
|
||||
" vim-polyglot only
|
||||
call TestExtension("blade", "test.blade.php", "")
|
||||
call TestExtension("yaml.ansible", "playbook.yml", "")
|
||||
@@ -356,6 +363,11 @@ call TestExtension("tt2html", "html.tt2", "<html>")
|
||||
call TestExtension("html", "empty.html", "")
|
||||
call TestExtension("mason", "mason1.html", "% my $planet = 42;")
|
||||
call TestExtension("mason", "mason2.html", "<%filter></%filter>")
|
||||
call TestExtension("jinja.html", "jinja.html", "{{ item.href }}")
|
||||
call TestExtension("jinja.html", "jinja.html", "{% for item in navigation %}{% endfor %}")
|
||||
call TestExtension("jinja.html", "jinja.html", "{% block head %}")
|
||||
call TestExtension("htmldjango", "jinja1.html", "{{ item.href }}")
|
||||
call TestExtension("htmldjango", "jinja2.html", "{% for item in navigation %}{% endfor %}")
|
||||
call TestExtension("htmldjango", "jinja3.html", "{% block head %}")
|
||||
call TestExtension("htmldjango", "jinja4.html", "{# some comment #}")
|
||||
call TestExtension("xhtml", "xhtml.html", "<DTD XHTML ")
|
||||
|
||||
" .gitignore
|
||||
call TestExtension("gitignore", ".gitignore", "")
|
||||
|
||||
@@ -95,7 +95,8 @@ call TestFiletype('graphql')
|
||||
call TestFiletype('groovy')
|
||||
call TestFiletype('grub')
|
||||
call TestFiletype('haml')
|
||||
call TestFiletype('mustache')
|
||||
call TestFiletype('html.mustache')
|
||||
call TestFiletype('html.handlebars')
|
||||
call TestFiletype('haskell')
|
||||
call TestFiletype('haxe')
|
||||
call TestFiletype('hcl')
|
||||
@@ -108,7 +109,7 @@ call TestFiletype('idris2')
|
||||
call TestFiletype('lidris2')
|
||||
call TestFiletype('ion')
|
||||
call TestFiletype('Jenkinsfile')
|
||||
call TestFiletype('jinja.html')
|
||||
call TestFiletype('htmldjango')
|
||||
call TestFiletype('jq')
|
||||
call TestFiletype('json5')
|
||||
call TestFiletype('json')
|
||||
@@ -235,3 +236,4 @@ call TestFiletype('odin')
|
||||
call TestFiletype('bzl')
|
||||
call TestFiletype('prolog')
|
||||
call TestFiletype('tads')
|
||||
call TestFiletype('gitignore')
|
||||
|
||||
Reference in New Issue
Block a user