From f0f49cf0fa8bbcb7f84e3ffe699a934142498b14 Mon Sep 17 00:00:00 2001 From: Adam Stankiewicz Date: Thu, 28 May 2020 11:12:25 +0200 Subject: Add support for ics, closes #492 --- README.md | 5 ++- build | 1 + compiler/haml.vim | 32 ++++++++++++++ ftdetect/polyglot.vim | 4 ++ ftplugin/haml.vim | 75 +++++++++++++++++++++++++++++++++ indent/haml.vim | 78 ++++++++++++++++++++++++++++++++++ syntax/haml.vim | 113 ++++++++++++++++++++++++++++++++++++++++++++++++++ syntax/icalendar.vim | 59 ++++++++++++++++++++++++++ 8 files changed, 365 insertions(+), 2 deletions(-) create mode 100644 compiler/haml.vim create mode 100644 ftplugin/haml.vim create mode 100644 indent/haml.vim create mode 100644 syntax/haml.vim create mode 100644 syntax/icalendar.vim diff --git a/README.md b/README.md index 90842396..a35cb742 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,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 149 packages it consists of. +- It **installs and updates 120+ times faster** than the 150 packages it consists of. - Solid syntax and indentation support (other features skipped). Only the best language packs. - All unnecessary files are ignored (like enormous documentation from php support). - No support for esoteric languages, only most popular ones (modern too, like `slim`). @@ -89,7 +89,7 @@ If you need full functionality of any plugin, please use it directly with your p - [go](https://github.com/fatih/vim-go) (syntax, compiler, indent) - [gradle](https://github.com/tfnico/vim-gradle) (compiler) - [graphql](https://github.com/jparise/vim-graphql) (syntax, indent, autoload, ftplugin, after) -- [haml](https://github.com/sheerun/vim-haml) () +- [haml](https://github.com/sheerun/vim-haml) (syntax, indent, compiler, ftplugin) - [handlebars](https://github.com/mustache/vim-mustache-handlebars) (syntax, indent, ftplugin) - [haproxy](https://github.com/CH-DanReif/haproxy.vim) (syntax) - [haskell](https://github.com/neovimhaskell/haskell-vim) (syntax, indent, ftplugin) @@ -99,6 +99,7 @@ If you need full functionality of any plugin, please use it directly with your p - [hive](https://github.com/zebradil/hive.vim) (syntax, ftplugin) - [html5](https://github.com/othree/html5.vim) (syntax, indent, autoload, ftplugin) - [i3](https://github.com/mboughaba/i3config.vim) (syntax, ftplugin) +- [icalenadr](https://github.com/chutzpah/icalendar.vim) (syntax) - [idris](https://github.com/idris-hackers/idris-vim) (syntax, indent, ftplugin) - [ion](https://github.com/vmchale/ion-vim) (syntax, ftplugin) - [javascript](https://github.com/pangloss/vim-javascript) (syntax, indent, compiler, ftplugin, extras) diff --git a/build b/build index 3d87a71a..436885b2 100755 --- a/build +++ b/build @@ -191,6 +191,7 @@ PACKS=" hive:zebradil/hive.vim html5:othree/html5.vim i3:mboughaba/i3config.vim + icalenadr:chutzpah/icalendar.vim idris:idris-hackers/idris-vim ion:vmchale/ion-vim javascript:pangloss/vim-javascript:_JAVASCRIPT diff --git a/compiler/haml.vim b/compiler/haml.vim new file mode 100644 index 00000000..e942631f --- /dev/null +++ b/compiler/haml.vim @@ -0,0 +1,32 @@ +if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'haml') == -1 + +" Vim compiler file +" Compiler: Haml +" Maintainer: Tim Pope +" Last Change: 2016 Aug 29 + +if exists("current_compiler") + finish +endif +let current_compiler = "haml" + +if exists(":CompilerSet") != 2 " older Vim always used :setlocal + command -nargs=* CompilerSet setlocal +endif + +let s:cpo_save = &cpo +set cpo-=C + +CompilerSet makeprg=haml + +CompilerSet errorformat= + \Haml\ %trror\ on\ line\ %l:\ %m, + \Syntax\ %trror\ on\ line\ %l:\ %m, + \%-G%.%# + +let &cpo = s:cpo_save +unlet s:cpo_save + +" vim:set sw=2 sts=2: + +endif diff --git a/ftdetect/polyglot.vim b/ftdetect/polyglot.vim index b22d1ee0..229905ba 100644 --- a/ftdetect/polyglot.vim +++ b/ftdetect/polyglot.vim @@ -276,6 +276,10 @@ if index(g:polyglot_disabled, 'i3') == -1 au BufNewFile,BufRead .i3.config,i3.config,*.i3config,*.i3.config set ft=i3config endif +if index(g:polyglot_disabled, 'icalendar') == -1 + au BufNewFile,BufRead *.ics set ft=icalendar +endif + if index(g:polyglot_disabled, 'idris') == -1 au BufNewFile,BufRead *.idr set ft=idris au BufNewFile,BufRead idris-response set ft=idris diff --git a/ftplugin/haml.vim b/ftplugin/haml.vim new file mode 100644 index 00000000..ca5655ec --- /dev/null +++ b/ftplugin/haml.vim @@ -0,0 +1,75 @@ +if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'haml') == -1 + +" Vim filetype plugin +" Language: Haml +" Maintainer: Tim Pope +" Last Change: 2016 Aug 29 + +" Only do this when not done yet for this buffer +if exists("b:did_ftplugin") + finish +endif + +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 = "All Files (*.*)\t*.*\n" +let s:match_words = "" + +runtime! ftplugin/html.vim ftplugin/html_*.vim ftplugin/html/*.vim +unlet! b:did_ftplugin +set matchpairs-=<:> + +" Override our defaults if these were set by an included ftplugin. +if exists("b:undo_ftplugin") + let s:undo_ftplugin = b:undo_ftplugin + unlet b:undo_ftplugin +endif +if exists("b:browsefilter") + let s:browsefilter = b:browsefilter + unlet b:browsefilter +endif +if exists("b:match_words") + let s:match_words = b:match_words + unlet b:match_words +endif + +runtime! ftplugin/ruby.vim ftplugin/ruby_*.vim ftplugin/ruby/*.vim +let b:did_ftplugin = 1 + +let &l:define .= empty(&l:define ? '' : '\|') . '^\s*\%(%\w*\)\=\%(\.[[:alnum:]_-]\+\)*#' + +" Combine the new set of values with those previously included. +if exists("b:undo_ftplugin") + let s:undo_ftplugin = b:undo_ftplugin . " | " . s:undo_ftplugin +endif +if exists ("b:browsefilter") + let s:browsefilter = substitute(b:browsefilter,'\cAll Files (\*\.\*)\t\*\.\*\n','','') . s:browsefilter +endif +if exists("b:match_words") + let s:match_words = b:match_words . ',' . s:match_words +endif + +" Change the browse dialog on Win32 to show mainly Haml-related files +if has("gui_win32") + let b:browsefilter="Haml Files (*.haml)\t*.haml\nSass Files (*.sass)\t*.sass\n" . s:browsefilter +endif + +" Load the combined list of match_words for matchit.vim +if exists("loaded_matchit") + let b:match_words = s:match_words +endif + +setlocal comments= commentstring=-#\ %s + +let b:undo_ftplugin = "setl def< cms< com< " + \ " | unlet! b:browsefilter b:match_words | " . s:undo_ftplugin + +let &cpo = s:save_cpo +unlet s:save_cpo + +" vim:set sw=2: + +endif diff --git a/indent/haml.vim b/indent/haml.vim new file mode 100644 index 00000000..ea6f5d17 --- /dev/null +++ b/indent/haml.vim @@ -0,0 +1,78 @@ +if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'haml') == -1 + +" Vim indent file +" Language: Haml +" Maintainer: Tim Pope +" Last Change: 2017 Jun 13 + +if exists("b:did_indent") + finish +endif +runtime! indent/ruby.vim +unlet! b:did_indent +let b:did_indent = 1 + +setlocal autoindent +setlocal indentexpr=GetHamlIndent() +setlocal indentkeys=o,O,*,},],0),!^F,=end,=else,=elsif,=rescue,=ensure,=when + +" Only define the function once. +if exists("*GetHamlIndent") + finish +endif + +let s:attributes = '\%({.\{-\}}\|\[.\{-\}\]\)' +let s:tag = '\%([%.#][[:alnum:]_-]\+\|'.s:attributes.'\)*[<>]*' + +if !exists('g:haml_self_closing_tags') + let g:haml_self_closing_tags = 'base|link|meta|br|hr|img|input' +endif + +function! GetHamlIndent() + let lnum = prevnonblank(v:lnum-1) + if lnum == 0 + return 0 + endif + let line = substitute(getline(lnum),'\s\+$','','') + let cline = substitute(substitute(getline(v:lnum),'\s\+$','',''),'^\s\+','','') + let lastcol = strlen(line) + let line = substitute(line,'^\s\+','','') + let indent = indent(lnum) + let cindent = indent(v:lnum) + let sw = shiftwidth() + if cline =~# '\v^-\s*%(elsif|else|when)>' + let indent = cindent < indent ? cindent : indent - sw + endif + let increase = indent + sw + if indent == indent(lnum) + let indent = cindent <= indent ? -1 : increase + endif + + let group = synIDattr(synID(lnum,lastcol,1),'name') + + if line =~ '^!!!' + return indent + elseif line =~ '^/\%(\[[^]]*\]\)\=$' + return increase + elseif group == 'hamlFilter' + return increase + elseif line =~ '^'.s:tag.'[&!]\=[=~-]\s*\%(\%(if\|else\|elsif\|unless\|case\|when\|while\|until\|for\|begin\|module\|class\|def\)\>\%(.*\\)\@!\|.*do\%(\s*|[^|]*|\)\=\s*$\)' + return increase + elseif line =~ '^'.s:tag.'[&!]\=[=~-].*,\s*$' + return increase + elseif line == '-#' + return increase + elseif group =~? '\v^(hamlSelfCloser)$' || line =~? '^%\v%('.g:haml_self_closing_tags.')>' + return indent + elseif group =~? '\v^%(hamlTag|hamlAttributesDelimiter|hamlObjectDelimiter|hamlClass|hamlId|htmlTagName|htmlSpecialTagName)$' + return increase + elseif synIDattr(synID(v:lnum,1,1),'name') ==? 'hamlRubyFilter' + return GetRubyIndent() + else + return indent + endif +endfunction + +" vim:set sw=2: + +endif diff --git a/syntax/haml.vim b/syntax/haml.vim new file mode 100644 index 00000000..02f5cf83 --- /dev/null +++ b/syntax/haml.vim @@ -0,0 +1,113 @@ +if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'haml') == -1 + +" Vim syntax file +" Language: Haml +" Maintainer: Tim Pope +" Filenames: *.haml +" Last Change: 2018 Aug 21 + +if exists("b:current_syntax") + finish +endif + +if !exists("main_syntax") + let main_syntax = 'haml' +endif +let b:ruby_no_expensive = 1 + +runtime! syntax/html.vim +unlet! b:current_syntax +silent! syn include @hamlSassTop syntax/sass.vim +unlet! b:current_syntax +syn include @hamlRubyTop syntax/ruby.vim + +syn case match + +syn region rubyCurlyBlock start="{" end="}" contains=@hamlRubyTop contained +syn cluster hamlRubyTop add=rubyCurlyBlock + +syn cluster hamlComponent contains=hamlAttributes,hamlAttributesHash,hamlClassChar,hamlIdChar,hamlObject,hamlDespacer,hamlSelfCloser,hamlRuby,hamlPlainChar,hamlInterpolatable +syn cluster hamlEmbeddedRuby contains=hamlAttributesHash,hamlObject,hamlRuby,hamlRubyFilter +syn cluster hamlTop contains=hamlBegin,hamlPlainFilter,hamlRubyFilter,hamlSassFilter,hamlComment,hamlHtmlComment + +syn match hamlBegin "^\s*\%([<>]\|&[^=~ ]\)\@!" nextgroup=hamlTag,hamlClassChar,hamlIdChar,hamlRuby,hamlPlainChar,hamlInterpolatable + +syn match hamlTag "%\w\+\%(:\w\+\)\=" contained contains=htmlTagName,htmlSpecialTagName nextgroup=@hamlComponent +syn region hamlAttributes matchgroup=hamlAttributesDelimiter start="(" end=")" contained contains=htmlArg,hamlAttributeString,hamlAttributeVariable,htmlEvent,htmlCssDefinition nextgroup=@hamlComponent +syn region hamlAttributesHash matchgroup=hamlAttributesDelimiter start="{" end="}" contained contains=@hamlRubyTop nextgroup=@hamlComponent +syn region hamlObject matchgroup=hamlObjectDelimiter start="\[" end="\]" contained contains=@hamlRubyTop nextgroup=@hamlComponent +syn match hamlDespacer "[<>]" contained nextgroup=hamlDespacer,hamlSelfCloser,hamlRuby,hamlPlainChar,hamlInterpolatable +syn match hamlSelfCloser "/" contained +syn match hamlClassChar "\." contained nextgroup=hamlClass +syn match hamlIdChar "#{\@!" contained nextgroup=hamlId +syn match hamlClass "\%(\w\|-\|\:\)\+" contained nextgroup=@hamlComponent +syn match hamlId "\%(\w\|-\)\+" contained nextgroup=@hamlComponent +syn region hamlDocType start="^\s*!!!" end="$" + +syn region hamlRuby matchgroup=hamlRubyOutputChar start="[!&]\==\|\~" skip=",\s*$" end="$" contained contains=@hamlRubyTop keepend +syn region hamlRuby matchgroup=hamlRubyChar start="-" skip=",\s*$" end="$" contained contains=@hamlRubyTop keepend +syn match hamlPlainChar "\\" contained +syn region hamlInterpolatable matchgroup=hamlInterpolatableChar start="!\===\|!=\@!" end="$" keepend contained contains=hamlInterpolation,hamlInterpolationEscape,@hamlHtmlTop +syn region hamlInterpolatable matchgroup=hamlInterpolatableChar start="&==\|&=\@!" end="$" keepend contained contains=hamlInterpolation,hamlInterpolationEscape +syn region hamlInterpolation matchgroup=hamlInterpolationDelimiter start="#{" end="}" contains=@hamlRubyTop containedin=javascriptStringS,javascriptStringD +syn match hamlInterpolationEscape "\\\@" contained contains=@hamlRubyTop + +syn region hamlAttributeString start=+\%(=\s*\)\@<='+ skip=+\%(\\\\\)*\\'+ end=+'+ contains=hamlInterpolation,hamlInterpolationEscape +syn region hamlAttributeString start=+\%(=\s*\)\@<="+ skip=+\%(\\\\\)*\\"+ end=+"+ contains=hamlInterpolation,hamlInterpolationEscape +syn match hamlAttributeVariable "\%(=\s*\)\@<=\%(@@\=\|\$\)\=\w\+" contained + +syn match hamlHelper "\[^]]*]" contained containedin=hamlHtmlComment + +hi def link hamlSelfCloser Special +hi def link hamlDespacer Special +hi def link hamlClassChar Special +hi def link hamlIdChar Special +hi def link hamlTag Special +hi def link hamlClass Type +hi def link hamlId Identifier +hi def link hamlPlainChar Special +hi def link hamlInterpolatableChar hamlRubyChar +hi def link hamlRubyOutputChar hamlRubyChar +hi def link hamlRubyChar Special +hi def link hamlInterpolationDelimiter Delimiter +hi def link hamlInterpolationEscape Special +hi def link hamlAttributeString String +hi def link hamlAttributeVariable Identifier +hi def link hamlDocType PreProc +hi def link hamlFilter PreProc +hi def link hamlAttributesDelimiter Delimiter +hi def link hamlObjectDelimiter Delimiter +hi def link hamlHelper Function +hi def link hamlHtmlComment hamlComment +hi def link hamlComment Comment +hi def link hamlIEConditional SpecialComment +hi def link hamlError Error + +let b:current_syntax = "haml" + +if main_syntax == "haml" + unlet main_syntax +endif + +" vim:set sw=2: + +endif diff --git a/syntax/icalendar.vim b/syntax/icalendar.vim new file mode 100644 index 00000000..ca8179fe --- /dev/null +++ b/syntax/icalendar.vim @@ -0,0 +1,59 @@ +if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'icalenadr') == -1 + +" Vim syntax file +" Language: icalendar +" Maintainer: Steven N. Severinghaus +" Last Modified: 2006-04-17 +" Version: 0.3 + +" Quit if syntax file is already loaded +if version < 600 + syntax clear +elseif exists("b:current_syntax") + finish +endif + +command! -nargs=+ IcalHiLink hi def link + +syntax case ignore +setlocal iskeyword+=- + +syn match icalObject "^\(BEGIN\|END\)" +syn match icalObjectType ":\(VCALENDAR\|VEVENT\|VTODO\|VJOURNAL\|VFREEBUSY\|VTIMEZONE\|VALARM\)$" +syn match icalObjectType ":\(DAYLIGHT\|STANDARD\)$" +syn match icalProperty "^\(DTSTART\|PRODID\|VERSION\|CALSCALE\|METHOD\)" +syn match icalProperty "^\(DTEND\|DTSTAMP\|ORGANIZER\|UID\|CLASS\|CREATED\)" +syn match icalProperty "^\(LOCATION\|SEQUENCE\|STATUS\|SUMMARY\|COMMENT\)" +syn match icalProperty "^\(TRANSP\|ATTENDEE\|ATTACH\|FREEBUSY\|METHOD\|CONTACT\)" +syn match icalProperty "^\(DURATION\|RRULE\|EXDATE\|EXRULE\|URL\|DESCRIPTION\|ACTION\)" +syn match icalProperty "^\(LAST-MODIFIED\|RECURRENCE-ID\|TRIGGER\|RELATED-TO\|RDATE\)" +syn match icalProperty "^\(TZID\|TZOFFSETFROM\|TZOFFSETTO\|TZNAME\|TZURL\)" +syn match icalProperty "^\(PRIORITY\|DUE\|COMPLETED\|PERCENT-COMPLETE\|CATEGORIES\)" +syn match icalProperty "^\(RESOURCES\|REPEAT\|REQUEST-STATUS\)" +syn match icalCustom /^X-[A-Z-]\+/ +syn match icalDate "\<\d\{8}\>" +syn match icalDate "[0-9]\{8}T[0-9]\{6}Z\=" +syn match icalParameter "[A-Z0-9-]\+=[^;:]\+" +syn keyword icalSetValue CONFIRMED TENTATIVE CANCELLED DELEGATED OPAQUE +syn keyword icalSetValue NEEDS-ACTION ACCEPTED DECLINED IN-PROGRESS +syn keyword icalSetValue PRIVATE PUBLIC PUBLISH GREGORIAN DISPLAY +syn match icalSetValue /:COMPLETED$/ + +" Types: PreProc Keyword Type String Comment Special +IcalHiLink icalProperty PreProc +IcalHiLink icalObject Label +IcalHiLink icalObjectType Type +IcalHiLink icalDate String +IcalHiLink icalParameter Comment +IcalHiLink icalSetValue Special +IcalHiLink icalCustom Error + +delcommand IcalHiLink + +let b:current_syntax = "icalendar" + +"EOF vim: tw=78:ft=vim:ts=8 + + + +endif -- cgit v1.2.3