mirror of
https://github.com/sheerun/vim-polyglot.git
synced 2025-11-08 11:33:52 -05:00
Compare commits
14 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
19a69cf77d | ||
|
|
4f7a4036eb | ||
|
|
0ff5d451b0 | ||
|
|
49840b1893 | ||
|
|
2dc954d6fa | ||
|
|
2369cd5d22 | ||
|
|
46affb6153 | ||
|
|
a4cc3f64f9 | ||
|
|
2fe310256e | ||
|
|
2e1a980632 | ||
|
|
cecfb5dd10 | ||
|
|
a4a9481d37 | ||
|
|
5e5d127eb8 | ||
|
|
002573265a |
2
.github/workflows/test.yml
vendored
2
.github/workflows/test.yml
vendored
@@ -14,7 +14,7 @@ jobs:
|
||||
run: |
|
||||
sudo add-apt-repository ppa:jonathonf/vim -y
|
||||
sudo apt-get update -q
|
||||
sudo apt-get install -y vim
|
||||
sudo apt-get install -y vim expect
|
||||
vim --version
|
||||
- uses: actions/checkout@v2
|
||||
- name: Run Tests
|
||||
|
||||
@@ -7,7 +7,7 @@ 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-->193<!--/Package Count--> packages it consists of.
|
||||
- It **installs and updates 120+ times faster** than the <!--Package Count-->194<!--/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).
|
||||
@@ -118,6 +118,7 @@ If you need full functionality of any plugin, please use it directly with your p
|
||||
- [go](https://github.com/fatih/vim-go)
|
||||
- [gradle](https://github.com/tfnico/vim-gradle)
|
||||
- [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)
|
||||
|
||||
@@ -21,6 +21,7 @@ let s:interpreters = {
|
||||
\ 'escript': 'erlang',
|
||||
\ 'fish': 'fish',
|
||||
\ 'gnuplot': 'gnuplot',
|
||||
\ 'groovy': 'groovy',
|
||||
\ 'runhaskell': 'haskell',
|
||||
\ 'chakra': 'javascript',
|
||||
\ 'd8': 'javascript',
|
||||
|
||||
@@ -44,7 +44,7 @@ let s:globs = {
|
||||
\ 'clojure': '*.clj,*.boot,*.cl2,*.cljc,*.cljs,*.cljs.hl,*.cljscm,*.cljx,*.hic,*.edn,riemann.config,build.boot,profile.boot',
|
||||
\ 'cmake': '*.cmake,*.cmake.in,CMakeLists.txt',
|
||||
\ 'coffee': '*.coffee,*._coffee,*.cake,*.cjsx,*.iced,*.coffeekup,Cakefile',
|
||||
\ 'cpp': '*.cpp,*.c++,*.cc,*.cp,*.cxx,*.h,*.h++,*.hh,*.hpp,*.hxx,*.inc,*.inl,*.ipp,*.tcc,*.tpp,*.moc',
|
||||
\ 'cpp': '*.cpp,*.c++,*.cc,*.cp,*.cxx,*.h,*.h++,*.hh,*.hpp,*.hxx,*.inc,*.inl,*.ipp,*.tcc,*.tpp,*.moc,*.tlh',
|
||||
\ 'cql': '*.cql',
|
||||
\ 'cryptol': '*.cry,*.cyl,*.lcry,*.lcyl',
|
||||
\ 'crystal': '*.cr,Projectfile',
|
||||
@@ -78,18 +78,18 @@ let s:globs = {
|
||||
\ 'forth': '*.fs,*.ft,*.fth',
|
||||
\ 'fsharp': '*.fs,*.fsi,*.fsx',
|
||||
\ 'gdscript3': '*.gd',
|
||||
\ 'gitcommit': '',
|
||||
\ 'gitcommit': 'COMMIT_EDITMSG,MERGE_MSG,TAG_EDITMSG',
|
||||
\ 'gitconfig': '*.gitconfig',
|
||||
\ 'gitrebase': 'git-rebase-todo',
|
||||
\ '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',
|
||||
\ 'gnuplot': '*.gp,*.gnu,*.gnuplot,*.p,*.plot,*.plt,*.gpi',
|
||||
\ 'go': '*.go',
|
||||
\ 'gohtmltmpl': '*.tmpl',
|
||||
\ 'gomod': 'go.mod',
|
||||
\ 'graphql': '*.graphql,*.gql,*.graphqls',
|
||||
\ 'groovy': '*.gradle',
|
||||
\ 'groovy': '*.groovy,*.grt,*.gtpl,*.gvy,*.gradle,Jenkinsfile',
|
||||
\ 'grub': '',
|
||||
\ 'haml': '*.haml,*.haml.deface,*.hamlc,*.hamlbars',
|
||||
\ 'haproxy': '*.cfg,haproxy.cfg,haproxy*.c*',
|
||||
|
||||
@@ -13,6 +13,8 @@ if exists('g:polyglot_disabled')
|
||||
for pkg in g:polyglot_disabled
|
||||
let s:disabled_packages[pkg] = 1
|
||||
endfor
|
||||
else
|
||||
let g:polyglot_disabled_not_set = 1
|
||||
endif
|
||||
|
||||
function! s:SetDefault(name, value)
|
||||
@@ -169,6 +171,10 @@ if !has_key(s:disabled_packages, 'go')
|
||||
au! BufRead,BufNewFile *.go
|
||||
endif
|
||||
|
||||
if !has_key(s:disabled_packages, 'groovy')
|
||||
au! BufRead,BufNewFile *.groovy
|
||||
endif
|
||||
|
||||
if !has_key(s:disabled_packages, 'haml')
|
||||
au! BufRead,BufNewFile *.haml
|
||||
endif
|
||||
@@ -490,11 +496,13 @@ if !has_key(s:disabled_packages, 'c/c++')
|
||||
au BufNewFile,BufRead *.ipp setf cpp
|
||||
au BufNewFile,BufRead *.moc setf cpp
|
||||
au BufNewFile,BufRead *.tcc setf cpp
|
||||
au BufNewFile,BufRead *.tlh setf cpp
|
||||
au BufNewFile,BufRead *.tpp setf cpp
|
||||
au BufNewFile,BufRead *.c setf c
|
||||
au BufNewFile,BufRead *.cats setf c
|
||||
au BufNewFile,BufRead *.idc setf c
|
||||
au BufNewFile,BufRead *.qc setf c
|
||||
au BufNewFile,BufRead *enlightenment/*.cfg setf c
|
||||
au! BufNewFile,BufRead *.h call polyglot#DetectHFiletype()
|
||||
endif
|
||||
|
||||
@@ -681,13 +689,15 @@ endif
|
||||
if !has_key(s:disabled_packages, 'git')
|
||||
au BufNewFile,BufRead *.gitconfig setf gitconfig
|
||||
au BufNewFile,BufRead *.git/config setf gitconfig
|
||||
au BufNewFile,BufRead *.git/modules/**/config setf gitconfig
|
||||
au BufNewFile,BufRead *.git/modules/*/config setf gitconfig
|
||||
au BufNewFile,BufRead */.config/git/config setf gitconfig
|
||||
au BufNewFile,BufRead */git/config setf gitconfig
|
||||
au BufNewFile,BufRead */{.,}gitconfig.d/* call s:StarSetf('gitconfig')
|
||||
au BufNewFile,BufRead {.,}gitconfig setf gitconfig
|
||||
au BufNewFile,BufRead {.,}gitmodules setf gitconfig
|
||||
au BufNewFile,BufRead git-rebase-todo setf gitrebase
|
||||
au BufNewFile,BufRead {.,}gitsendemail.* call s:StarSetf('gitsendemail')
|
||||
au BufNewFile,BufRead *.git/{,modules/**/,worktrees/*/}{COMMIT_EDIT,TAG_EDIT,MERGE_,}MSG setf gitcommit
|
||||
au BufNewFile,BufRead COMMIT_EDITMSG,MERGE_MSG,TAG_EDITMSG setf gitcommit
|
||||
endif
|
||||
|
||||
if !has_key(s:disabled_packages, 'glsl')
|
||||
@@ -722,6 +732,7 @@ if !has_key(s:disabled_packages, 'gnuplot')
|
||||
au BufNewFile,BufRead *.gnu setf gnuplot
|
||||
au BufNewFile,BufRead *.gnuplot setf gnuplot
|
||||
au BufNewFile,BufRead *.gp setf gnuplot
|
||||
au BufNewFile,BufRead *.gpi setf gnuplot
|
||||
au BufNewFile,BufRead *.p setf gnuplot
|
||||
au BufNewFile,BufRead *.plot setf gnuplot
|
||||
au BufNewFile,BufRead *.plt setf gnuplot
|
||||
@@ -739,8 +750,13 @@ if !has_key(s:disabled_packages, 'graphql')
|
||||
au BufNewFile,BufRead *.graphqls setf graphql
|
||||
endif
|
||||
|
||||
if !has_key(s:disabled_packages, 'gradle')
|
||||
if !has_key(s:disabled_packages, 'groovy')
|
||||
au BufNewFile,BufRead *.gradle setf groovy
|
||||
au BufNewFile,BufRead *.groovy setf groovy
|
||||
au BufNewFile,BufRead *.grt setf groovy
|
||||
au BufNewFile,BufRead *.gtpl setf groovy
|
||||
au BufNewFile,BufRead *.gvy setf groovy
|
||||
au BufNewFile,BufRead Jenkinsfile setf groovy
|
||||
endif
|
||||
|
||||
if !has_key(s:disabled_packages, 'haml')
|
||||
@@ -877,6 +893,7 @@ endif
|
||||
if !has_key(s:disabled_packages, 'jq')
|
||||
au BufNewFile,BufRead *.jq setf jq
|
||||
au BufNewFile,BufRead {.,}jqrc setf jq
|
||||
au BufNewFile,BufRead {.,}jqrc* call s:StarSetf('jq')
|
||||
endif
|
||||
|
||||
if !has_key(s:disabled_packages, 'json5')
|
||||
@@ -1758,164 +1775,202 @@ endif
|
||||
" end filetypes
|
||||
|
||||
au BufNewFile,BufRead,StdinReadPost *
|
||||
\ if !did_filetype() && expand("<amatch>") !~ g:ft_ignore_pat
|
||||
\ if !did_filetype() && expand("<afile>") !~ g:ft_ignore_pat
|
||||
\ | call polyglot#Heuristics() | endif
|
||||
|
||||
|
||||
if v:version < 700 || &cp
|
||||
finish
|
||||
endif
|
||||
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
|
||||
|
||||
|
||||
" Code below re-implements sleuth for vim-polyglot
|
||||
let g:loaded_sleuth = 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
|
||||
|
||||
for line in a:lines
|
||||
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
|
||||
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 &shiftwidth=minindent
|
||||
return 1
|
||||
" Makes shiftwidth to be synchronized with tabstop by default
|
||||
if &shiftwidth == &tabstop
|
||||
let &shiftwidth = 0
|
||||
endif
|
||||
|
||||
return 0
|
||||
endfunction
|
||||
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
|
||||
|
||||
function! s:detect_indent() abort
|
||||
if &buftype ==# 'help'
|
||||
return
|
||||
endif
|
||||
for line in a:lines
|
||||
let i += 1
|
||||
|
||||
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 == '/'
|
||||
return
|
||||
endif
|
||||
for neighbor in glob(dir . '/' . pattern, 0, 1)[0:level]
|
||||
" Do not consider directories above .git, .svn or .hg
|
||||
if fnamemodify(neighbor, ":h:t")[0] == "."
|
||||
return
|
||||
if !len(line) || line =~# '^\W*$'
|
||||
continue
|
||||
endif
|
||||
if neighbor !=# expand('%:p') && filereadable(neighbor)
|
||||
if s:guess(readfile(neighbor, '', 32))
|
||||
return
|
||||
|
||||
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 &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
|
||||
|
||||
let dir = fnamemodify(dir, ':h')
|
||||
let level -= 1
|
||||
endwhile
|
||||
endfunction
|
||||
if minindent < 10
|
||||
setlocal expandtab
|
||||
let &shiftwidth=minindent
|
||||
let b:sleuth_culprit .= ':' . i
|
||||
return 1
|
||||
endif
|
||||
|
||||
setglobal smarttab
|
||||
return 0
|
||||
endfunction
|
||||
|
||||
augroup polyglot
|
||||
autocmd!
|
||||
autocmd FileType * call s:detect_indent()
|
||||
augroup END
|
||||
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
|
||||
autocmd!
|
||||
autocmd FileType * call s:detect_indent()
|
||||
autocmd 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 at the top of .vimrc"
|
||||
echohl None
|
||||
endif
|
||||
|
||||
unlet g:polyglot_disabled_not_set
|
||||
endif
|
||||
endfunc
|
||||
|
||||
autocmd VimEnter * call s:verify()
|
||||
|
||||
" restore Vi compatibility settings
|
||||
let &cpo = s:cpo_save
|
||||
|
||||
23
ftplugin/groovy.vim
Normal file
23
ftplugin/groovy.vim
Normal file
@@ -0,0 +1,23 @@
|
||||
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'groovy') == -1
|
||||
|
||||
" Vim filetype plugin file
|
||||
" Language: groovy
|
||||
" Maintainer: Justin M. Keyes <justinkz@gmail.com>
|
||||
" Last Change: 2016 May 22
|
||||
|
||||
if exists('b:did_ftplugin')
|
||||
finish
|
||||
endif
|
||||
let b:did_ftplugin = 1
|
||||
|
||||
let s:cpo_save = &cpo
|
||||
set cpo-=C
|
||||
|
||||
let b:undo_ftplugin = 'setlocal commentstring<'
|
||||
|
||||
setlocal commentstring=//%s
|
||||
|
||||
let &cpo = s:cpo_save
|
||||
unlet s:cpo_save
|
||||
|
||||
endif
|
||||
@@ -19,7 +19,7 @@ setlocal comments=:# commentstring=#\ %s expandtab
|
||||
setlocal formatoptions-=t formatoptions+=croql
|
||||
|
||||
if !exists("g:yaml_recommended_style") || g:yaml_recommended_style != 0
|
||||
let b:undo_ftplugin ..= " sw< sts<"
|
||||
let b:undo_ftplugin .= " sw< sts<"
|
||||
setlocal shiftwidth=2 softtabstop=2
|
||||
endif
|
||||
|
||||
|
||||
@@ -318,16 +318,25 @@ filetypes:
|
||||
linguist: C++
|
||||
extra_extensions:
|
||||
- moc
|
||||
# TLH files are C++ headers generated by Visual C++'s #import from typelibs
|
||||
- tlh
|
||||
ignored_extensions:
|
||||
# conflicts with more popular reason, remove after heuristics work
|
||||
- re
|
||||
# implemented by arduino
|
||||
- ino
|
||||
ignored_warnings:
|
||||
# TODO: fix these
|
||||
- C
|
||||
- H
|
||||
- name: c
|
||||
linguist: C
|
||||
extra_extensions:
|
||||
# Quake C
|
||||
- qc
|
||||
extra_filenames:
|
||||
# Enlightenment configuration file
|
||||
- '*enlightenment/*.cfg'
|
||||
---
|
||||
name: caddyfile
|
||||
remote: isobit/vim-caddyfile
|
||||
@@ -601,16 +610,27 @@ filetypes:
|
||||
extra_filenames:
|
||||
- "*.git/config"
|
||||
- "*/.config/git/config"
|
||||
- "*.git/modules/*/config"
|
||||
- "*/git/config"
|
||||
- "*/{.,}gitconfig.d/*"
|
||||
ignored_warnings:
|
||||
- '/etc/gitconfig'
|
||||
- '$XDG_CONFIG_HOME/git/config'
|
||||
- "*.git/modules/**/config"
|
||||
- '.gitmodules'
|
||||
- "*.git/modules/**/config"
|
||||
- "/etc/gitconfig.d/*"
|
||||
- name: gitrebase
|
||||
filenames:
|
||||
- git-rebase-todo
|
||||
- name: gitsendemail
|
||||
filenames:
|
||||
- ".gitsendemail.*"
|
||||
ignored_warnings:
|
||||
- '.gitsendemail.msg.??????'
|
||||
- name: gitcommit
|
||||
filenames:
|
||||
- 'COMMIT_EDITMSG,MERGE_MSG,TAG_EDITMSG'
|
||||
ignored_warnings:
|
||||
- '*.git/{,modules/**/,worktrees/*/}{COMMIT_EDIT,TAG_EDIT,MERGE_,}MSG'
|
||||
---
|
||||
name: glsl
|
||||
@@ -636,6 +656,9 @@ remote: vim-scripts/gnuplot-syntax-highlighting
|
||||
filetypes:
|
||||
- name: gnuplot
|
||||
linguist: Gnuplot
|
||||
extra_extensions:
|
||||
# Gnuplot scripts
|
||||
- gpi
|
||||
---
|
||||
name: go
|
||||
remote: fatih/vim-go
|
||||
@@ -662,9 +685,18 @@ filetypes:
|
||||
---
|
||||
name: gradle
|
||||
remote: tfnico/vim-gradle
|
||||
after: groovy
|
||||
# Just adds compiler
|
||||
filetypes: []
|
||||
---
|
||||
name: groovy
|
||||
remote: vim/vim:runtime
|
||||
glob: '**/groovy.vim'
|
||||
filetypes:
|
||||
- name: groovy
|
||||
linguist: Gradle
|
||||
linguist: Groovy
|
||||
extra_extensions:
|
||||
- gradle
|
||||
---
|
||||
name: grub
|
||||
remote: vim/vim:runtime
|
||||
@@ -851,7 +883,6 @@ filetypes:
|
||||
linguist: JSONiq
|
||||
extra_filenames:
|
||||
- ".jqrc"
|
||||
ignored_filenames:
|
||||
- ".jqrc*"
|
||||
---
|
||||
name: json5
|
||||
|
||||
@@ -175,7 +175,9 @@ def copy_file(package, src, dest)
|
||||
else
|
||||
output << "if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, '#{name}') == -1\n\n"
|
||||
end
|
||||
IO.copy_stream(input, output)
|
||||
contents = File.read(input)
|
||||
contents.gsub!(' ..= ', ' .= ')
|
||||
output << contents
|
||||
output << "\nendif\n"
|
||||
end
|
||||
end
|
||||
@@ -463,7 +465,7 @@ def generate_ftdetect(packages, heuristics)
|
||||
extensions = filetype["extensions"]
|
||||
filenames = filetype["filenames"]
|
||||
|
||||
expected_extensions = (all_filetypes.has_key?(name) ? all_filetypes.fetch(name)[:extensions] : []).map(&:downcase)
|
||||
expected_extensions = (all_filetypes.has_key?(name) ? all_filetypes.fetch(name)[:extensions] : [])
|
||||
ignored_extensions = expand_all(filetype.fetch("ignored_extensions", []))
|
||||
ignored_warnings = expand_all(filetype.fetch("ignored_warnings", []))
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ function! TestExtension(filetype, filename, content)
|
||||
1delete _
|
||||
filetype detect
|
||||
exec "if &filetype != '" . a:filetype . "' \nthrow &filetype\nendif"
|
||||
exec ":bw!"
|
||||
exec ":q!"
|
||||
catch
|
||||
echo g:message
|
||||
echo "Filename '" . a:filename . "' does not resolve to extension '" . a:filetype . "'"
|
||||
|
||||
454
syntax/groovy.vim
Normal file
454
syntax/groovy.vim
Normal file
@@ -0,0 +1,454 @@
|
||||
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'groovy') == -1
|
||||
|
||||
" Vim syntax file
|
||||
" Language: Groovy
|
||||
" Original Author: Alessio Pace <billy.corgan AT tiscali.it>
|
||||
" Maintainer: Tobias Rapp <yahuxo+vim AT mailbox.org>
|
||||
" Version: 0.1.17
|
||||
" URL: http://www.vim.org/scripts/script.php?script_id=945
|
||||
" Last Change: 2020 May 26
|
||||
|
||||
" THE ORIGINAL AUTHOR'S NOTES:
|
||||
"
|
||||
" This is my very first vim script, I hope to have
|
||||
" done it the right way.
|
||||
"
|
||||
" I must directly or indirectly thank the author of java.vim and ruby.vim:
|
||||
" I copied from them most of the stuff :-)
|
||||
"
|
||||
" Relies on html.vim
|
||||
|
||||
" For version 5.x: Clear all syntax items
|
||||
" For version 6.x: Quit when a syntax file was already loaded
|
||||
"
|
||||
" HOWTO USE IT (INSTALL) when not part of the distribution:
|
||||
"
|
||||
" 1) copy the file in the (global or user's $HOME/.vim/syntax/) syntax folder
|
||||
"
|
||||
" 2) add this line to recognize groovy files by filename extension:
|
||||
"
|
||||
" au BufNewFile,BufRead *.groovy setf groovy
|
||||
" in the global vim filetype.vim file or inside $HOME/.vim/filetype.vim
|
||||
"
|
||||
" 3) add this part to recognize by content groovy script (no extension needed :-)
|
||||
"
|
||||
" if did_filetype()
|
||||
" finish
|
||||
" endif
|
||||
" if getline(1) =~ '^#!.*[/\\]groovy\>'
|
||||
" setf groovy
|
||||
" endif
|
||||
"
|
||||
" in the global scripts.vim file or in $HOME/.vim/scripts.vim
|
||||
"
|
||||
" 4) open/write a .groovy file or a groovy script :-)
|
||||
"
|
||||
" Let me know if you like it or send me patches, so that I can improve it
|
||||
" when I have time
|
||||
|
||||
" quit when a syntax file was already loaded
|
||||
if !exists("main_syntax")
|
||||
if exists("b:current_syntax")
|
||||
finish
|
||||
endif
|
||||
" we define it here so that included files can test for it
|
||||
let main_syntax='groovy'
|
||||
endif
|
||||
|
||||
let s:cpo_save = &cpo
|
||||
set cpo&vim
|
||||
|
||||
" ##########################
|
||||
" Java stuff taken from java.vim
|
||||
" some characters that cannot be in a groovy program (outside a string)
|
||||
" syn match groovyError "[\\@`]"
|
||||
"syn match groovyError "<<<\|\.\.\|=>\|<>\|||=\|&&=\|[^-]->\|\*\/"
|
||||
"syn match groovyOK "\.\.\."
|
||||
|
||||
" keyword definitions
|
||||
syn keyword groovyExternal native package
|
||||
syn match groovyExternal "\<import\>\(\s\+static\>\)\?"
|
||||
syn keyword groovyError goto const
|
||||
syn keyword groovyConditional if else switch
|
||||
syn keyword groovyRepeat while for do
|
||||
syn keyword groovyBoolean true false
|
||||
syn keyword groovyConstant null
|
||||
syn keyword groovyTypedef this super
|
||||
syn keyword groovyOperator new instanceof
|
||||
syn keyword groovyType boolean char byte short int long float double
|
||||
syn keyword groovyType void
|
||||
syn keyword groovyType Integer Double Date Boolean Float String Array Vector List
|
||||
syn keyword groovyStatement return
|
||||
syn keyword groovyStorageClass static synchronized transient volatile final strictfp serializable
|
||||
syn keyword groovyExceptions throw try catch finally
|
||||
syn keyword groovyAssert assert
|
||||
syn keyword groovyMethodDecl synchronized throws
|
||||
syn keyword groovyClassDecl extends implements interface
|
||||
" to differentiate the keyword class from MyClass.class we use a match here
|
||||
syn match groovyTypedef "\.\s*\<class\>"ms=s+1
|
||||
syn keyword groovyClassDecl enum
|
||||
syn match groovyClassDecl "^class\>"
|
||||
syn match groovyClassDecl "[^.]\s*\<class\>"ms=s+1
|
||||
syn keyword groovyBranch break continue nextgroup=groovyUserLabelRef skipwhite
|
||||
syn match groovyUserLabelRef "\k\+" contained
|
||||
syn keyword groovyScopeDecl public protected private abstract
|
||||
|
||||
|
||||
if exists("groovy_highlight_groovy_lang_ids") || exists("groovy_highlight_groovy_lang") || exists("groovy_highlight_all")
|
||||
" groovy.lang.*
|
||||
syn keyword groovyLangClass Closure MetaMethod GroovyObject
|
||||
|
||||
syn match groovyJavaLangClass "\<System\>"
|
||||
syn keyword groovyJavaLangClass Cloneable Comparable Runnable Serializable Boolean Byte Class Object
|
||||
syn keyword groovyJavaLangClass Character CharSequence ClassLoader Compiler
|
||||
" syn keyword groovyJavaLangClass Integer Double Float Long
|
||||
syn keyword groovyJavaLangClass InheritableThreadLocal Math Number Object Package Process
|
||||
syn keyword groovyJavaLangClass Runtime RuntimePermission InheritableThreadLocal
|
||||
syn keyword groovyJavaLangClass SecurityManager Short StrictMath StackTraceElement
|
||||
syn keyword groovyJavaLangClass StringBuffer Thread ThreadGroup
|
||||
syn keyword groovyJavaLangClass ThreadLocal Throwable Void ArithmeticException
|
||||
syn keyword groovyJavaLangClass ArrayIndexOutOfBoundsException AssertionError
|
||||
syn keyword groovyJavaLangClass ArrayStoreException ClassCastException
|
||||
syn keyword groovyJavaLangClass ClassNotFoundException
|
||||
syn keyword groovyJavaLangClass CloneNotSupportedException Exception
|
||||
syn keyword groovyJavaLangClass IllegalAccessException
|
||||
syn keyword groovyJavaLangClass IllegalArgumentException
|
||||
syn keyword groovyJavaLangClass IllegalMonitorStateException
|
||||
syn keyword groovyJavaLangClass IllegalStateException
|
||||
syn keyword groovyJavaLangClass IllegalThreadStateException
|
||||
syn keyword groovyJavaLangClass IndexOutOfBoundsException
|
||||
syn keyword groovyJavaLangClass InstantiationException InterruptedException
|
||||
syn keyword groovyJavaLangClass NegativeArraySizeException NoSuchFieldException
|
||||
syn keyword groovyJavaLangClass NoSuchMethodException NullPointerException
|
||||
syn keyword groovyJavaLangClass NumberFormatException RuntimeException
|
||||
syn keyword groovyJavaLangClass SecurityException StringIndexOutOfBoundsException
|
||||
syn keyword groovyJavaLangClass UnsupportedOperationException
|
||||
syn keyword groovyJavaLangClass AbstractMethodError ClassCircularityError
|
||||
syn keyword groovyJavaLangClass ClassFormatError Error ExceptionInInitializerError
|
||||
syn keyword groovyJavaLangClass IllegalAccessError InstantiationError
|
||||
syn keyword groovyJavaLangClass IncompatibleClassChangeError InternalError
|
||||
syn keyword groovyJavaLangClass LinkageError NoClassDefFoundError
|
||||
syn keyword groovyJavaLangClass NoSuchFieldError NoSuchMethodError
|
||||
syn keyword groovyJavaLangClass OutOfMemoryError StackOverflowError
|
||||
syn keyword groovyJavaLangClass ThreadDeath UnknownError UnsatisfiedLinkError
|
||||
syn keyword groovyJavaLangClass UnsupportedClassVersionError VerifyError
|
||||
syn keyword groovyJavaLangClass VirtualMachineError
|
||||
|
||||
syn keyword groovyJavaLangObject clone equals finalize getClass hashCode
|
||||
syn keyword groovyJavaLangObject notify notifyAll toString wait
|
||||
|
||||
hi def link groovyLangClass groovyConstant
|
||||
hi def link groovyJavaLangClass groovyExternal
|
||||
hi def link groovyJavaLangObject groovyConstant
|
||||
syn cluster groovyTop add=groovyJavaLangObject,groovyJavaLangClass,groovyLangClass
|
||||
syn cluster groovyClasses add=groovyJavaLangClass,groovyLangClass
|
||||
endif
|
||||
|
||||
|
||||
" Groovy stuff
|
||||
syn match groovyOperator "\.\."
|
||||
syn match groovyOperator "<\{2,3}"
|
||||
syn match groovyOperator ">\{2,3}"
|
||||
syn match groovyOperator "->"
|
||||
syn match groovyLineComment '^\%1l#!.*' " Shebang line
|
||||
syn match groovyExceptions "\<Exception\>\|\<[A-Z]\{1,}[a-zA-Z0-9]*Exception\>"
|
||||
|
||||
" Groovy JDK stuff
|
||||
syn keyword groovyJDKBuiltin as def in
|
||||
syn keyword groovyJDKOperOverl div minus plus abs round power multiply
|
||||
syn keyword groovyJDKMethods each call inject sort print println
|
||||
syn keyword groovyJDKMethods getAt putAt size push pop toList getText writeLine eachLine readLines
|
||||
syn keyword groovyJDKMethods withReader withStream withWriter withPrintWriter write read leftShift
|
||||
syn keyword groovyJDKMethods withWriterAppend readBytes splitEachLine
|
||||
syn keyword groovyJDKMethods newInputStream newOutputStream newPrintWriter newReader newWriter
|
||||
syn keyword groovyJDKMethods compareTo next previous isCase
|
||||
syn keyword groovyJDKMethods times step toInteger upto any collect dump every find findAll grep
|
||||
syn keyword groovyJDKMethods inspect invokeMethods join
|
||||
syn keyword groovyJDKMethods getErr getIn getOut waitForOrKill
|
||||
syn keyword groovyJDKMethods count tokenize asList flatten immutable intersect reverse reverseEach
|
||||
syn keyword groovyJDKMethods subMap append asWritable eachByte eachLine eachFile
|
||||
syn cluster groovyTop add=groovyJDKBuiltin,groovyJDKOperOverl,groovyJDKMethods
|
||||
|
||||
" no useful I think, so I comment it..
|
||||
"if filereadable(expand("<sfile>:p:h")."/groovyid.vim")
|
||||
" source <sfile>:p:h/groovyid.vim
|
||||
"endif
|
||||
|
||||
if exists("groovy_space_errors")
|
||||
if !exists("groovy_no_trail_space_error")
|
||||
syn match groovySpaceError "\s\+$"
|
||||
endif
|
||||
if !exists("groovy_no_tab_space_error")
|
||||
syn match groovySpaceError " \+\t"me=e-1
|
||||
endif
|
||||
endif
|
||||
|
||||
" it is a better case construct than java.vim to match groovy syntax
|
||||
syn region groovyLabelRegion transparent matchgroup=groovyLabel start="\<case\>" matchgroup=NONE end=":\|$" contains=groovyNumber,groovyString,groovyLangClass,groovyJavaLangClass
|
||||
syn match groovyUserLabel "^\s*[_$a-zA-Z][_$a-zA-Z0-9_]*\s*:"he=e-1 contains=groovyLabel
|
||||
syn keyword groovyLabel default
|
||||
|
||||
if !exists("groovy_allow_cpp_keywords")
|
||||
syn keyword groovyError auto delete extern friend inline redeclared
|
||||
syn keyword groovyError register signed sizeof struct template typedef union
|
||||
syn keyword groovyError unsigned operator
|
||||
endif
|
||||
|
||||
" The following cluster contains all groovy groups except the contained ones
|
||||
syn cluster groovyTop add=groovyExternal,groovyError,groovyError,groovyBranch,groovyLabelRegion,groovyLabel,groovyConditional,groovyRepeat,groovyBoolean,groovyConstant,groovyTypedef,groovyOperator,groovyType,groovyType,groovyStatement,groovyStorageClass,groovyAssert,groovyExceptions,groovyMethodDecl,groovyClassDecl,groovyClassDecl,groovyClassDecl,groovyScopeDecl,groovyError,groovyError2,groovyUserLabel,groovyLangObject
|
||||
|
||||
|
||||
" Comments
|
||||
syn keyword groovyTodo contained TODO FIXME XXX
|
||||
if exists("groovy_comment_strings")
|
||||
syn region groovyCommentString contained start=+"+ end=+"+ end=+$+ end=+\*/+me=s-1,he=s-1 contains=groovySpecial,groovyCommentStar,groovySpecialChar,@Spell
|
||||
syn region groovyComment2String contained start=+"+ end=+$\|"+ contains=groovySpecial,groovySpecialChar,@Spell
|
||||
syn match groovyCommentCharacter contained "'\\[^']\{1,6\}'" contains=groovySpecialChar
|
||||
syn match groovyCommentCharacter contained "'\\''" contains=groovySpecialChar
|
||||
syn match groovyCommentCharacter contained "'[^\\]'"
|
||||
syn cluster groovyCommentSpecial add=groovyCommentString,groovyCommentCharacter,groovyNumber
|
||||
syn cluster groovyCommentSpecial2 add=groovyComment2String,groovyCommentCharacter,groovyNumber
|
||||
endif
|
||||
syn region groovyComment start="/\*" end="\*/" contains=@groovyCommentSpecial,groovyTodo,@Spell
|
||||
syn match groovyCommentStar contained "^\s*\*[^/]"me=e-1
|
||||
syn match groovyCommentStar contained "^\s*\*$"
|
||||
syn match groovyLineComment "//.*" contains=@groovyCommentSpecial2,groovyTodo,@Spell
|
||||
hi def link groovyCommentString groovyString
|
||||
hi def link groovyComment2String groovyString
|
||||
hi def link groovyCommentCharacter groovyCharacter
|
||||
|
||||
syn cluster groovyTop add=groovyComment,groovyLineComment
|
||||
|
||||
if !exists("groovy_ignore_groovydoc") && main_syntax != 'jsp'
|
||||
syntax case ignore
|
||||
" syntax coloring for groovydoc comments (HTML)
|
||||
" syntax include @groovyHtml <sfile>:p:h/html.vim
|
||||
syntax include @groovyHtml runtime! syntax/html.vim
|
||||
unlet b:current_syntax
|
||||
syntax spell default " added by Bram
|
||||
syn region groovyDocComment start="/\*\*" end="\*/" keepend contains=groovyCommentTitle,@groovyHtml,groovyDocTags,groovyTodo,@Spell
|
||||
syn region groovyCommentTitle contained matchgroup=groovyDocComment start="/\*\*" matchgroup=groovyCommentTitle keepend end="\.$" end="\.[ \t\r<&]"me=e-1 end="[^{]@"me=s-2,he=s-1 end="\*/"me=s-1,he=s-1 contains=@groovyHtml,groovyCommentStar,groovyTodo,@Spell,groovyDocTags
|
||||
|
||||
syn region groovyDocTags contained start="{@\(link\|linkplain\|inherit[Dd]oc\|doc[rR]oot\|value\)" end="}"
|
||||
syn match groovyDocTags contained "@\(see\|param\|exception\|throws\|since\)\s\+\S\+" contains=groovyDocParam
|
||||
syn match groovyDocParam contained "\s\S\+"
|
||||
syn match groovyDocTags contained "@\(version\|author\|return\|deprecated\|serial\|serialField\|serialData\)\>"
|
||||
syntax case match
|
||||
endif
|
||||
|
||||
" match the special comment /**/
|
||||
syn match groovyComment "/\*\*/"
|
||||
|
||||
" Strings and constants
|
||||
syn match groovySpecialError contained "\\."
|
||||
syn match groovySpecialCharError contained "[^']"
|
||||
syn match groovySpecialChar contained "\\\([4-9]\d\|[0-3]\d\d\|[\"\\'ntbrf]\|u\x\{4\}\|\$\)"
|
||||
syn match groovyRegexChar contained "\\."
|
||||
syn region groovyString start=+"+ end=+"+ end=+$+ contains=groovySpecialChar,groovySpecialError,@Spell,groovyELExpr
|
||||
syn region groovyString start=+'+ end=+'+ end=+$+ contains=groovySpecialChar,groovySpecialError,@Spell
|
||||
syn region groovyString start=+"""+ end=+"""+ contains=groovySpecialChar,groovySpecialError,@Spell,groovyELExpr
|
||||
syn region groovyString start=+'''+ end=+'''+ contains=groovySpecialChar,groovySpecialError,@Spell
|
||||
if exists("groovy_regex_strings")
|
||||
" regex strings interfere with the division operator and thus are disabled
|
||||
" by default
|
||||
syn region groovyString start='/[^/*]' end='/' contains=groovySpecialChar,groovyRegexChar,groovyELExpr
|
||||
endif
|
||||
" syn region groovyELExpr start=+${+ end=+}+ keepend contained
|
||||
syn match groovyELExpr /\${.\{-}}/ contained
|
||||
syn match groovyELExpr /\$[a-zA-Z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u00FF\u0100-\uFFFE_][a-zA-Z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u00FF\u0100-\uFFFE0-9_.]*/ contained
|
||||
hi def link groovyELExpr Identifier
|
||||
|
||||
" TODO: better matching. I am waiting to understand how it really works in groovy
|
||||
" syn region groovyClosureParamsBraces start=+|+ end=+|+ contains=groovyClosureParams
|
||||
" syn match groovyClosureParams "[ a-zA-Z0-9_*]\+" contained
|
||||
" hi def link groovyClosureParams Identifier
|
||||
|
||||
" next line disabled, it can cause a crash for a long line
|
||||
"syn match groovyStringError +"\([^"\\]\|\\.\)*$+
|
||||
|
||||
" disabled: in groovy strings or characters are written the same
|
||||
" syn match groovyCharacter "'[^']*'" contains=groovySpecialChar,groovySpecialCharError
|
||||
" syn match groovyCharacter "'\\''" contains=groovySpecialChar
|
||||
" syn match groovyCharacter "'[^\\]'"
|
||||
syn match groovyNumber "\<\(0[0-7]*\|0[xX]\x\+\|\d\+\)[lL]\=\>"
|
||||
syn match groovyNumber "\(\<\d\+\.\d*\|\.\d\+\)\([eE][-+]\=\d\+\)\=[fFdD]\="
|
||||
syn match groovyNumber "\<\d\+[eE][-+]\=\d\+[fFdD]\=\>"
|
||||
syn match groovyNumber "\<\d\+\([eE][-+]\=\d\+\)\=[fFdD]\>"
|
||||
|
||||
" unicode characters
|
||||
syn match groovySpecial "\\u\d\{4\}"
|
||||
|
||||
syn cluster groovyTop add=groovyString,groovyCharacter,groovyNumber,groovySpecial,groovyStringError
|
||||
|
||||
if exists("groovy_highlight_functions")
|
||||
if groovy_highlight_functions == "indent"
|
||||
syn match groovyFuncDef "^\(\t\| \{8\}\)[_$a-zA-Z][_$a-zA-Z0-9_. \[\]]*([^-+*/()]*)" contains=groovyScopeDecl,groovyType,groovyStorageClass,@groovyClasses
|
||||
syn region groovyFuncDef start=+^\(\t\| \{8\}\)[$_a-zA-Z][$_a-zA-Z0-9_. \[\]]*([^-+*/()]*,\s*+ end=+)+ contains=groovyScopeDecl,groovyType,groovyStorageClass,@groovyClasses
|
||||
syn match groovyFuncDef "^ [$_a-zA-Z][$_a-zA-Z0-9_. \[\]]*([^-+*/()]*)" contains=groovyScopeDecl,groovyType,groovyStorageClass,@groovyClasses
|
||||
syn region groovyFuncDef start=+^ [$_a-zA-Z][$_a-zA-Z0-9_. \[\]]*([^-+*/()]*,\s*+ end=+)+ contains=groovyScopeDecl,groovyType,groovyStorageClass,@groovyClasses
|
||||
else
|
||||
" This line catches method declarations at any indentation>0, but it assumes
|
||||
" two things:
|
||||
" 1. class names are always capitalized (ie: Button)
|
||||
" 2. method names are never capitalized (except constructors, of course)
|
||||
syn region groovyFuncDef start=+^\s\+\(\(public\|protected\|private\|static\|abstract\|final\|native\|synchronized\)\s\+\)*\(\(void\|boolean\|char\|byte\|short\|int\|long\|float\|double\|\([A-Za-z_][A-Za-z0-9_$]*\.\)*[A-Z][A-Za-z0-9_$]*\)\(<[^>]*>\)\=\(\[\]\)*\s\+[a-z][A-Za-z0-9_$]*\|[A-Z][A-Za-z0-9_$]*\)\s*([^0-9]+ end=+)+ contains=groovyScopeDecl,groovyType,groovyStorageClass,groovyComment,groovyLineComment,@groovyClasses
|
||||
endif
|
||||
syn match groovyBraces "[{}]"
|
||||
syn cluster groovyTop add=groovyFuncDef,groovyBraces
|
||||
endif
|
||||
|
||||
if exists("groovy_highlight_debug")
|
||||
|
||||
" Strings and constants
|
||||
syn match groovyDebugSpecial contained "\\\d\d\d\|\\."
|
||||
syn region groovyDebugString contained start=+"+ end=+"+ contains=groovyDebugSpecial
|
||||
syn match groovyDebugStringError +"\([^"\\]\|\\.\)*$+
|
||||
syn match groovyDebugCharacter contained "'[^\\]'"
|
||||
syn match groovyDebugSpecialCharacter contained "'\\.'"
|
||||
syn match groovyDebugSpecialCharacter contained "'\\''"
|
||||
syn match groovyDebugNumber contained "\<\(0[0-7]*\|0[xX]\x\+\|\d\+\)[lL]\=\>"
|
||||
syn match groovyDebugNumber contained "\(\<\d\+\.\d*\|\.\d\+\)\([eE][-+]\=\d\+\)\=[fFdD]\="
|
||||
syn match groovyDebugNumber contained "\<\d\+[eE][-+]\=\d\+[fFdD]\=\>"
|
||||
syn match groovyDebugNumber contained "\<\d\+\([eE][-+]\=\d\+\)\=[fFdD]\>"
|
||||
syn keyword groovyDebugBoolean contained true false
|
||||
syn keyword groovyDebugType contained null this super
|
||||
syn region groovyDebugParen start=+(+ end=+)+ contained contains=groovyDebug.*,groovyDebugParen
|
||||
|
||||
" to make this work you must define the highlighting for these groups
|
||||
syn match groovyDebug "\<System\.\(out\|err\)\.print\(ln\)*\s*("me=e-1 contains=groovyDebug.* nextgroup=groovyDebugParen
|
||||
syn match groovyDebug "\<p\s*("me=e-1 contains=groovyDebug.* nextgroup=groovyDebugParen
|
||||
syn match groovyDebug "[A-Za-z][a-zA-Z0-9_]*\.printStackTrace\s*("me=e-1 contains=groovyDebug.* nextgroup=groovyDebugParen
|
||||
syn match groovyDebug "\<trace[SL]\=\s*("me=e-1 contains=groovyDebug.* nextgroup=groovyDebugParen
|
||||
|
||||
syn cluster groovyTop add=groovyDebug
|
||||
|
||||
hi def link groovyDebug Debug
|
||||
hi def link groovyDebugString DebugString
|
||||
hi def link groovyDebugStringError groovyError
|
||||
hi def link groovyDebugType DebugType
|
||||
hi def link groovyDebugBoolean DebugBoolean
|
||||
hi def link groovyDebugNumber Debug
|
||||
hi def link groovyDebugSpecial DebugSpecial
|
||||
hi def link groovyDebugSpecialCharacter DebugSpecial
|
||||
hi def link groovyDebugCharacter DebugString
|
||||
hi def link groovyDebugParen Debug
|
||||
|
||||
hi def link DebugString String
|
||||
hi def link DebugSpecial Special
|
||||
hi def link DebugBoolean Boolean
|
||||
hi def link DebugType Type
|
||||
endif
|
||||
|
||||
" Match all Exception classes
|
||||
syn match groovyExceptions "\<Exception\>\|\<[A-Z]\{1,}[a-zA-Z0-9]*Exception\>"
|
||||
|
||||
|
||||
if !exists("groovy_minlines")
|
||||
let groovy_minlines = 10
|
||||
endif
|
||||
exec "syn sync ccomment groovyComment minlines=" . groovy_minlines
|
||||
|
||||
|
||||
" ###################
|
||||
" Groovy stuff
|
||||
" syn match groovyOperator "|[ ,a-zA-Z0-9_*]\+|"
|
||||
|
||||
" All groovy valid tokens
|
||||
" syn match groovyTokens ";\|,\|<=>\|<>\|:\|:=\|>\|>=\|=\|==\|<\|<=\|!=\|/\|/=\|\.\.|\.\.\.\|\~=\|\~=="
|
||||
" syn match groovyTokens "\*=\|&\|&=\|\*\|->\|\~\|+\|-\|/\|?\|<<<\|>>>\|<<\|>>"
|
||||
|
||||
" Must put explicit these ones because groovy.vim mark them as errors otherwise
|
||||
" syn match groovyTokens "<=>\|<>\|==\~"
|
||||
"syn cluster groovyTop add=groovyTokens
|
||||
|
||||
" Mark these as operators
|
||||
|
||||
" Hightlight brackets
|
||||
" syn match groovyBraces "[{}]"
|
||||
" syn match groovyBraces "[\[\]]"
|
||||
" syn match groovyBraces "[\|]"
|
||||
|
||||
if exists("groovy_mark_braces_in_parens_as_errors")
|
||||
syn match groovyInParen contained "[{}]"
|
||||
hi def link groovyInParen groovyError
|
||||
syn cluster groovyTop add=groovyInParen
|
||||
endif
|
||||
|
||||
" catch errors caused by wrong parenthesis
|
||||
syn region groovyParenT transparent matchgroup=groovyParen start="(" end=")" contains=@groovyTop,groovyParenT1
|
||||
syn region groovyParenT1 transparent matchgroup=groovyParen1 start="(" end=")" contains=@groovyTop,groovyParenT2 contained
|
||||
syn region groovyParenT2 transparent matchgroup=groovyParen2 start="(" end=")" contains=@groovyTop,groovyParenT contained
|
||||
syn match groovyParenError ")"
|
||||
hi def link groovyParenError groovyError
|
||||
|
||||
" catch errors caused by wrong square parenthesis
|
||||
syn region groovyParenT transparent matchgroup=groovyParen start="\[" end="\]" contains=@groovyTop,groovyParenT1
|
||||
syn region groovyParenT1 transparent matchgroup=groovyParen1 start="\[" end="\]" contains=@groovyTop,groovyParenT2 contained
|
||||
syn region groovyParenT2 transparent matchgroup=groovyParen2 start="\[" end="\]" contains=@groovyTop,groovyParenT contained
|
||||
syn match groovyParenError "\]"
|
||||
|
||||
" ###############################
|
||||
" java.vim default highlighting
|
||||
hi def link groovyFuncDef Function
|
||||
hi def link groovyBraces Function
|
||||
hi def link groovyBranch Conditional
|
||||
hi def link groovyUserLabelRef groovyUserLabel
|
||||
hi def link groovyLabel Label
|
||||
hi def link groovyUserLabel Label
|
||||
hi def link groovyConditional Conditional
|
||||
hi def link groovyRepeat Repeat
|
||||
hi def link groovyExceptions Exception
|
||||
hi def link groovyAssert Statement
|
||||
hi def link groovyStorageClass StorageClass
|
||||
hi def link groovyMethodDecl groovyStorageClass
|
||||
hi def link groovyClassDecl groovyStorageClass
|
||||
hi def link groovyScopeDecl groovyStorageClass
|
||||
hi def link groovyBoolean Boolean
|
||||
hi def link groovySpecial Special
|
||||
hi def link groovySpecialError Error
|
||||
hi def link groovySpecialCharError Error
|
||||
hi def link groovyString String
|
||||
hi def link groovyRegexChar String
|
||||
hi def link groovyCharacter Character
|
||||
hi def link groovySpecialChar SpecialChar
|
||||
hi def link groovyNumber Number
|
||||
hi def link groovyError Error
|
||||
hi def link groovyStringError Error
|
||||
hi def link groovyStatement Statement
|
||||
hi def link groovyOperator Operator
|
||||
hi def link groovyComment Comment
|
||||
hi def link groovyDocComment Comment
|
||||
hi def link groovyLineComment Comment
|
||||
hi def link groovyConstant Constant
|
||||
hi def link groovyTypedef Typedef
|
||||
hi def link groovyTodo Todo
|
||||
|
||||
hi def link groovyCommentTitle SpecialComment
|
||||
hi def link groovyDocTags Special
|
||||
hi def link groovyDocParam Function
|
||||
hi def link groovyCommentStar groovyComment
|
||||
|
||||
hi def link groovyType Type
|
||||
hi def link groovyExternal Include
|
||||
|
||||
hi def link htmlComment Special
|
||||
hi def link htmlCommentPart Special
|
||||
hi def link groovySpaceError Error
|
||||
hi def link groovyJDKBuiltin Special
|
||||
hi def link groovyJDKOperOverl Operator
|
||||
hi def link groovyJDKMethods Function
|
||||
|
||||
|
||||
let b:current_syntax = "groovy"
|
||||
if main_syntax == 'groovy'
|
||||
unlet main_syntax
|
||||
endif
|
||||
|
||||
let b:spell_options="contained"
|
||||
|
||||
let &cpo = s:cpo_save
|
||||
unlet s:cpo_save
|
||||
|
||||
" vim: ts=8
|
||||
|
||||
endif
|
||||
Reference in New Issue
Block a user