From cc63193ce82c1e7b9ee2ad7d0ddd14e8394211ef Mon Sep 17 00:00:00 2001 From: Adam Stankiewicz Date: Mon, 1 Mar 2021 13:44:50 +0100 Subject: Update --- README.md | 4 +- after/syntax/cpp.vim | 2 +- autoload/go/config.vim | 4 + autoload/polyglot/init.vim | 6 +- autoload/polyglot/sleuth.vim | 12 +- autoload/zig/config.vim | 43 ----- autoload/zig/fmt.vim | 177 ++++++------------- autoload/zig/list.vim | 162 ------------------ autoload/zig/util.vim | 394 ------------------------------------------- compiler/puppet-lint.vim | 27 +++ compiler/sml.vim | 32 ++++ compiler/tidy.vim | 17 +- compiler/zig.vim | 32 ++++ compiler/zig_build.vim | 32 ++++ compiler/zig_build_exe.vim | 30 ++++ compiler/zig_test.vim | 30 ++++ extras/filetype.vim | 45 ++++- ftplugin/ada.vim | 69 ++++---- ftplugin/basic.vim | 31 ++++ ftplugin/bzl.vim | 4 +- ftplugin/embeddedpuppet.vim | 79 --------- ftplugin/epuppet.vim | 79 +++++++++ ftplugin/framescript.vim | 6 +- ftplugin/freebasic.vim | 17 ++ ftplugin/hamster.vim | 7 +- ftplugin/lisp.vim | 4 +- ftplugin/octave.vim | 5 + ftplugin/rust.vim | 2 +- ftplugin/sxhkdrc.vim | 10 ++ ftplugin/tidy.vim | 36 ++++ ftplugin/vlang.vim | 31 ++++ ftplugin/zig.vim | 8 +- indent/fortran.vim | 6 +- indent/haskell.vim | 28 +-- indent/html.vim | 8 +- indent/julia.vim | 12 +- indent/puppet.vim | 9 +- indent/ruby.vim | 3 +- syntax/Jenkinsfile.vim | 1 + syntax/basic.vim | 62 ++++--- syntax/basic/literal.vim | 6 +- syntax/basic/type.vim | 3 +- syntax/c.vim | 28 +-- syntax/cabal-1.vim | 2 +- syntax/carp.vim | 10 +- syntax/cpp.vim | 17 +- syntax/crystal.vim | 6 +- syntax/embeddedpuppet.vim | 33 ---- syntax/epuppet.vim | 33 ++++ syntax/groovy.vim | 7 +- syntax/haskell.vim | 19 ++- syntax/html.vim | 25 ++- syntax/julia.vim | 10 +- syntax/kotlin.vim | 28 +-- syntax/lhaskell.vim | 23 ++- syntax/messages.vim | 3 +- syntax/nginx.vim | 1 - syntax/ocaml.vim | 18 +- syntax/pgsql.vim | 38 +++-- syntax/puppet.vim | 6 +- syntax/rst.vim | 7 +- syntax/smt2.vim | 26 +-- syntax/tidy.vim | 195 ++++++++++++++++++--- syntax/zig.vim | 370 ++++++++++++++++++++++++++++++---------- 64 files changed, 1287 insertions(+), 1193 deletions(-) delete mode 100644 autoload/zig/config.vim delete mode 100644 autoload/zig/list.vim delete mode 100644 autoload/zig/util.vim create mode 100644 compiler/puppet-lint.vim create mode 100644 compiler/sml.vim create mode 100644 compiler/zig.vim create mode 100644 compiler/zig_build.vim create mode 100644 compiler/zig_build_exe.vim create mode 100644 compiler/zig_test.vim create mode 100644 ftplugin/basic.vim delete mode 100644 ftplugin/embeddedpuppet.vim create mode 100644 ftplugin/epuppet.vim create mode 100644 ftplugin/freebasic.vim create mode 100644 ftplugin/octave.vim create mode 100644 ftplugin/tidy.vim delete mode 100644 syntax/embeddedpuppet.vim create mode 100644 syntax/epuppet.vim diff --git a/README.md b/README.md index be4ceb04..c2fbd8f0 100644 --- a/README.md +++ b/README.md @@ -126,7 +126,7 @@ On top of all language packs from [vim repository](https://github.com/vim/vim/tr - [log](https://github.com/MTDL9/vim-log-highlighting) (Syntax highlighting for log and LOG files) - [lua](https://github.com/tbastos/vim-lua) (Lua syntax highlighting for lua, fcgi, nse, p8, rbxs, rockspec and wlua files) - [mako](https://github.com/sophacles/vim-bundle-mako) (Mako syntax highlighting for mako and mao files) -- [markdown](https://github.com/plasticboy/vim-markdown) (Markdown syntax highlighting for md, markdown, mdown, mdwn, mkd, mkdn, mkdown, ronn and workbook files) +- [markdown](https://github.com/plasticboy/vim-markdown) (Markdown syntax highlighting for md, markdown, mdown, mdwn, mkd, mkdn, mkdown, ronn, scd and workbook files) - [mathematica](https://github.com/voldikss/vim-mma) (Mathematica syntax highlighting for mathematica, cdf, m, ma, mt and 6 more files) - [mdx](https://github.com/jxnblk/vim-mdx-js) (Syntax highlighting for mdx files) - [meson](https://github.com/mesonbuild/meson/tree/master/data/syntax-highlighting/vim) (Meson syntax highlighting for wrap files) @@ -198,7 +198,7 @@ On top of all language packs from [vim repository](https://github.com/vim/vim/tr - [velocity](https://github.com/lepture/vim-velocity) (Syntax highlighting for vm files) - [vue](https://github.com/posva/vim-vue) (Vue syntax highlighting for vue and wpy files) - [xdc](https://github.com/amal-khailtash/vim-xdc-syntax) (Syntax highlighting for xdc files) -- [xml](https://github.com/amadeus/vim-xml) (XML syntax highlighting for xml, adml, admx, ant, axml and 94 more files) +- [xml](https://github.com/amadeus/vim-xml) (XML syntax highlighting for xml, adml, admx, ant, axml and 95 more files) - [xsl](https://github.com/vim-scripts/XSLT-syntax) (XSLT syntax highlighting for xslt and xsl files) - [yard](https://github.com/noprompt/vim-yardoc) - [zephir](https://github.com/xwsoul/vim-zephir) (Zephir syntax highlighting for zep files) diff --git a/after/syntax/cpp.vim b/after/syntax/cpp.vim index 27e6abdb..c8d98dbb 100644 --- a/after/syntax/cpp.vim +++ b/after/syntax/cpp.vim @@ -120,7 +120,7 @@ if !exists('cpp_no_cpp17') syntax keyword cppSTLnamespace filesystem execution string_view_literals syntax keyword cppSTLtype - \ any is_execution_policy parallel_policy parallel_unsequenced_policy sequenced_policy directory_entry directory_iterator file_status file_time_type path recursive_directory_iterator space_info default_order default_searcher boyer_moore_searcher boyer_moore_horspool_searcher memory_resource monotonic_buffer_resource polymorphic_allocator pool_options synchronized_pool_resource unsynchronized_pool_resource scoped_lock optional shared_mutex basic_string_view string_view u16string_view u32string_view wstring_view bool_constant conjunction disjunction has_unique_object_representations invoke_result is_aggregate is_callable is_invocable is_invocable_r is_nothrow_invocable is_nothrow_invocable_r is_nothrow_swappable is_nothrow_swappable_with is_nowthrow_callable is_swappable is_swappable_with negation node_type insert_return_type in_place_tag monostate variant variant_size variant_alternative + \ any byte is_execution_policy parallel_policy parallel_unsequenced_policy sequenced_policy directory_entry directory_iterator file_status file_time_type path recursive_directory_iterator space_info default_order default_searcher boyer_moore_searcher boyer_moore_horspool_searcher memory_resource monotonic_buffer_resource polymorphic_allocator pool_options synchronized_pool_resource unsynchronized_pool_resource scoped_lock optional shared_mutex basic_string_view string_view u16string_view u32string_view wstring_view bool_constant conjunction disjunction has_unique_object_representations invoke_result is_aggregate is_callable is_invocable is_invocable_r is_nothrow_invocable is_nothrow_invocable_r is_nothrow_swappable is_nothrow_swappable_with is_nowthrow_callable is_swappable is_swappable_with negation node_type insert_return_type in_place_tag monostate variant variant_size variant_alternative syntax keyword cppSTLtypedef \ invoke_result_t default_order_t nullopt_t void_t in_place_t in_place_type_t in_place_index_t variant_alternative_t diff --git a/autoload/go/config.vim b/autoload/go/config.vim index ca89b16f..cafba5f4 100644 --- a/autoload/go/config.vim +++ b/autoload/go/config.vim @@ -215,6 +215,10 @@ function! go#config#DebugWindows() abort endfunction +function! go#config#DebugPreserveLayout() abort + return get(g:, 'go_debug_preserve_layout', 0) +endfunction + function! go#config#DebugAddress() abort return get(g:, 'go_debug_address', '127.0.0.1:8181') endfunction diff --git a/autoload/polyglot/init.vim b/autoload/polyglot/init.vim index 837515ee..d76343f0 100644 --- a/autoload/polyglot/init.vim +++ b/autoload/polyglot/init.vim @@ -2257,7 +2257,7 @@ if !has_key(g:polyglot_is_disabled, 'jq') endif if !has_key(g:polyglot_is_disabled, 'htmldjango') - au BufNewFile,BufRead *.j2,*.jinja,*.jinja2,*.njk setf htmldjango + au BufNewFile,BufRead *.j2,*.jinja,*.jinja2 setf htmldjango endif if !has_key(g:polyglot_is_disabled, 'jenkins') @@ -2473,7 +2473,7 @@ if !has_key(g:polyglot_is_disabled, 'coffee-script') endif if !has_key(g:polyglot_is_disabled, 'markdown') - au BufNewFile,BufRead *.markdown,*.md,*.mdown,*.mdwn,*.mkd,*.mkdn,*.mkdown,*.ronn,*.workbook,contents.lr setf markdown + au BufNewFile,BufRead *.markdown,*.md,*.mdown,*.mdwn,*.mkd,*.mkdn,*.mkdown,*.ronn,*.scd,*.workbook,contents.lr setf markdown endif if !has_key(g:polyglot_is_disabled, 'cmake') @@ -2592,7 +2592,7 @@ if !has_key(g:polyglot_is_disabled, 'ant') endif if !has_key(g:polyglot_is_disabled, 'xml') - au BufNewFile,BufRead *.adml,*.admx,*.ant,*.axml,*.builds,*.ccproj,*.ccxml,*.cdxml,*.clixml,*.cproject,*.cscfg,*.csdef,*.csl,*.csproj,*.csproj.user,*.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,*.psc1,*.pt,*.rdf,*.res,*.resx,*.rss,*.sch,*.scxml,*.sfproj,*.shproj,*.srdf,*.storyboard,*.sublime-snippet,*.targets,*.tml,*.tpm,*.ui,*.urdf,*.ux,*.vbproj,*.vcxproj,*.vsixmanifest,*.vssettings,*.vstemplate,*.vxml,*.wixproj,*.workflow,*.wpl,*.wsdl,*.wsf,*.wxi,*.wxl,*.wxs,*.x3d,*.xacro,*.xaml,*.xib,*.xlf,*.xliff,*.xmi,*.xml,*.xml.dist,*.xproj,*.xsd,*.xspec,*.xul,*.zcml,*/etc/blkid.tab,*/etc/blkid.tab.old,*/etc/xdg/menus/*.menu,*fglrxrc,{.,}classpath,{.,}cproject,{.,}project,App.config,NuGet.config,Settings.StyleCop,Web.Debug.config,Web.Release.config,Web.config,packages.config setf xml + au BufNewFile,BufRead *.adml,*.admx,*.ant,*.axml,*.builds,*.ccproj,*.ccxml,*.cdxml,*.clixml,*.cproject,*.cscfg,*.csdef,*.csl,*.csproj,*.csproj.user,*.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,*.psc1,*.pt,*.rdf,*.res,*.resx,*.rs,*.rss,*.sch,*.scxml,*.sfproj,*.shproj,*.srdf,*.storyboard,*.sublime-snippet,*.targets,*.tml,*.tpm,*.ui,*.urdf,*.ux,*.vbproj,*.vcxproj,*.vsixmanifest,*.vssettings,*.vstemplate,*.vxml,*.wixproj,*.workflow,*.wpl,*.wsdl,*.wsf,*.wxi,*.wxl,*.wxs,*.x3d,*.xacro,*.xaml,*.xib,*.xlf,*.xliff,*.xmi,*.xml,*.xml.dist,*.xproj,*.xsd,*.xspec,*.xul,*.zcml,*/etc/blkid.tab,*/etc/blkid.tab.old,*/etc/xdg/menus/*.menu,*fglrxrc,{.,}classpath,{.,}cproject,{.,}project,App.config,NuGet.config,Settings.StyleCop,Web.Debug.config,Web.Release.config,Web.config,packages.config setf xml endif if !has_key(g:polyglot_is_disabled, 'csv') diff --git a/autoload/polyglot/sleuth.vim b/autoload/polyglot/sleuth.vim index f3df470a..5a7dd312 100644 --- a/autoload/polyglot/sleuth.vim +++ b/autoload/polyglot/sleuth.vim @@ -233,7 +233,7 @@ let s:globs = { \ 'html.handlebars': '*.handlebars,*.hbs,*.hdbs,*.hb', \ 'html.mustache': '*.mustache,*.hogan,*.hulk,*.hjs', \ 'html.twig': '*.twig', - \ 'htmldjango': '*.jinja,*.j2,*.jinja2,*.njk', + \ 'htmldjango': '*.jinja,*.j2,*.jinja2', \ 'htmlm4': '*.html.m4', \ 'httest': '*.htt,*.htb', \ 'i3config': '*.i3.config,*.i3config,i3.config,i3config,.i3.config,.i3config', @@ -263,7 +263,7 @@ let s:globs = { \ 'jovial': '*.jov,*.j73,*.jovial', \ 'jproperties': '*.properties,*.properties_??,*.properties_??_??,*.properties_??_??_*', \ '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', + \ '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,Pipfile.lock,composer.lock,mcmod.info', \ 'json5': '*.json5', \ 'jsonc': '*.cjson,*.jsonc,coc-settings.json,.eslintrc.json,.babelrc,.jshintrc,.jslintrc,.mocharc.json,coffeelint.json,tsconfig.json,jsconfig.json', \ 'jsonnet': '*.jsonnet,*.libsonnet', @@ -321,7 +321,7 @@ let s:globs = { \ 'manconf': 'man.config', \ 'map': '*.map', \ 'maple': '*.mv,*.mpl,*.mws', - \ 'markdown': '*.md,*.markdown,*.mdown,*.mdwn,*.mkd,*.mkdn,*.mkdown,*.ronn,*.workbook,contents.lr', + \ 'markdown': '*.md,*.markdown,*.mdown,*.mdwn,*.mkd,*.mkdn,*.mkdown,*.ronn,*.scd,*.workbook,contents.lr', \ 'markdown.mdx': '*.mdx', \ 'mason': '*.mason,*.mhtml,*.comp', \ 'master': '*.mas,*.master', @@ -436,7 +436,7 @@ let s:globs = { \ 'racket': '*.rkt,*.rktd,*.rktl,*.scrbl', \ 'radiance': '*.rad,*.mat', \ 'ragel': '*.rl', - \ 'raku': '*.6pl,*.6pm,*.nqp,*.p6,*.p6l,*.p6m,*.pl,*.pl6,*.pm,*.pm6,*.t,*.rakudoc,*.rakutest,*.raku,*.rakumod,*.pod6,*.t6', + \ 'raku': '*.6pl,*.6pm,*.nqp,*.p6,*.p6l,*.p6m,*.pl,*.pl6,*.pm,*.pm6,*.raku,*.rakumod,*.t,*.rakudoc,*.rakutest,*.pod6,*.t6', \ 'raml': '*.raml', \ 'ratpoison': '.ratpoisonrc,ratpoisonrc', \ 'razor': '*.cshtml,*.razor', @@ -553,7 +553,7 @@ let s:globs = { \ 'tilde': '*.t.html', \ 'tli': '*.tli', \ 'tmux': '.tmux*.conf', - \ 'toml': '*.toml,Cargo.lock,Gopkg.lock,poetry.lock,Pipfile', + \ 'toml': '*.toml,Cargo.lock,Gopkg.lock,Pipfile,poetry.lock', \ 'tpp': '*.tpp', \ 'tptp': '*.p,*.tptp,*.ax', \ 'trasys': '*.inp', @@ -612,7 +612,7 @@ let s:globs = { \ 'xhtml': '*.xhtml,*.xht', \ 'xinetd': '', \ 'xmath': '*.msc,*.msf', - \ '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,*.psc1,*.pt,*.rdf,*.res,*.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,*fglrxrc', + \ '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,*.psc1,*.pt,*.rdf,*.res,*.resx,*.rs,*.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,*fglrxrc', \ 'xml.twig': '*.xml.twig', \ 'xmodmap': '*Xmodmap,*xmodmap*', \ 'xpm': '*.xpm,*.pm', diff --git a/autoload/zig/config.vim b/autoload/zig/config.vim deleted file mode 100644 index a96595aa..00000000 --- a/autoload/zig/config.vim +++ /dev/null @@ -1,43 +0,0 @@ -if polyglot#init#is_disabled(expand(':p'), 'zig', 'autoload/zig/config.vim') - finish -endif - -function! zig#config#ListTypeCommands() abort - return get(g:, 'zig_list_type_commands', {}) -endfunction - -function! zig#config#ListType() abort - return get(g:, 'zig_list_type', '') -endfunction - -function! zig#config#ListAutoclose() abort - return get(g:, 'zig_list_autoclose', 1) -endfunction - -function! zig#config#ListHeight() abort - return get(g:, "zig_list_height", 0) -endfunction - -function! zig#config#FmtAutosave() abort - return get(g:, "zig_fmt_autosave", 0) -endfunction - -function! zig#config#SetFmtAutosave(value) abort - let g:zig_fmt_autosave = a:value -endfunction - -function! zig#config#FmtCommand() abort - return get(g:, "zig_fmt_command", ['zig', 'fmt', '--color', 'off']) -endfunction - -function! zig#config#FmtFailSilently() abort - return get(g:, "zig_fmt_fail_silently", 0) -endfunction - -function! zig#config#FmtExperimental() abort - return get(g:, "zig_fmt_experimental", 0) -endfunction - -function! zig#config#Debug() abort - return get(g:, 'zig_debug', []) -endfunction diff --git a/autoload/zig/fmt.vim b/autoload/zig/fmt.vim index 2562be39..7b31febd 100644 --- a/autoload/zig/fmt.vim +++ b/autoload/zig/fmt.vim @@ -7,127 +7,70 @@ endif " Copyright 2011 The Go Authors. All rights reserved. " Use of this source code is governed by a BSD-style " license that can be found in the LICENSE file. -" -function! zig#fmt#Format() abort - if zig#config#FmtExperimental() - " Using winsaveview to save/restore cursor state has the problem of - " closing folds on save: - " https://github.com/fatih/vim-go/issues/502 - " One fix is to use mkview instead. Unfortunately, this sometimes causes - " other bad side effects: - " https://github.com/fatih/vim-go/issues/728 - " and still closes all folds if foldlevel>0: - " https://github.com/fatih/vim-go/issues/732 - let l:curw = {} - try - mkview! - catch - let l:curw = winsaveview() - endtry - - " save our undo file to be restored after we are done. This is needed to - " prevent an additional undo jump due to BufWritePre auto command and also - " restore 'redo' history because it's getting being destroyed every - " BufWritePre - let tmpundofile = tempname() - exe 'wundo! ' . tmpundofile - else - " Save cursor position and many other things. - let l:curw = winsaveview() - endif +function! zig#fmt#Format() abort " Save cursor position and many other things. - let l:curw = winsaveview() + let view = winsaveview() - let bin_name = zig#config#FmtCommand() - - " Get current position in file - let current_col = col('.') - let orig_line_count = line('$') - - " Save current buffer first, else fmt will run on the original file and we - " will lose our changes. - silent! execute 'write' expand('%') - - let [l:out, l:err] = zig#fmt#run(bin_name, expand('%')) - - if l:err == 0 - call zig#fmt#update_file(expand('%')) - elseif !zig#config#FmtFailSilently() - let errors = s:parse_errors(expand('%'), out) - call s:show_errors(errors) - endif + let current_buf = bufnr('') - let diff_offset = line('$') - orig_line_count + let bin_path = get(g:, 'zig_bin_path', 'zig') + let stderr_file = tempname() + let cmdline = printf('%s fmt --stdin 2> %s', bin_path, stderr_file) - if zig#config#FmtExperimental() - " restore our undo history - silent! exe 'rundo ' . tmpundofile - call delete(tmpundofile) - - " Restore our cursor/windows positions, folds, etc. - if empty(l:curw) - silent! loadview - else - call winrestview(l:curw) - endif + " The formatted code is output on stdout, the errors go on stderr. + if exists('*systemlist') + silent let out = systemlist(cmdline, current_buf) else - " Restore our cursor/windows positions. - call winrestview(l:curw) + silent let out = split(system(cmdline, current_buf)) + endif + let err = v:shell_error + + if err == 0 + " remove undo point caused via BufWritePre. + try | silent undojoin | catch | endtry + + " Replace the file content with the formatted version. + call deletebufline(current_buf, len(out), line('$')) + call setline(1, out) + + " No errors detected, close the loclist. + call setloclist(0, [], 'r') + lclose + elseif get(g:, 'zig_fmt_parse_errors', 1) + let errors = s:parse_errors(expand('%'), readfile(stderr_file)) + + call setloclist(0, [], 'r', { + \ 'title': 'Errors', + \ 'items': errors, + \ }) + + let max_win_height = get(g:, 'zig_fmt_max_window_height', 5) + " Prevent the loclist from becoming too long. + let win_height = min([max_win_height, len(errors)]) + " Open the loclist, but only if there's at least one error to show. + execute 'lwindow ' . win_height endif - " be smart and jump to the line the new statement was added/removed - call cursor(line('.') + diff_offset, current_col) - - " Syntax highlighting breaks less often. - syntax sync fromstart -endfunction - -" update_file updates the target file with the given formatted source -function! zig#fmt#update_file(target) - " remove undo point caused via BufWritePre - try | silent undojoin | catch | endtry - - " reload buffer to reflect latest changes - silent edit! + call delete(stderr_file) - let l:listtype = zig#list#Type("ZigFmt") + call winrestview(view) - " the title information was introduced with 7.4-2200 - " https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640 - if has('patch-7.4.2200') - " clean up previous list - if l:listtype == "quickfix" - let l:list_title = getqflist({'title': 1}) - else - let l:list_title = getloclist(0, {'title': 1}) - endif - else - " can't check the title, so assume that the list was for go fmt. - let l:list_title = {'title': 'Format'} + if err != 0 + echohl Error | echomsg "zig fmt returned error" | echohl None + return endif - if has_key(l:list_title, "title") && l:list_title['title'] == "Format" - call zig#list#Clean(l:listtype) - endif -endfunction - -" run runs the gofmt/goimport command for the given source file and returns -" the output of the executed command. Target is the real file to be formatted. -function! zig#fmt#run(bin_name, target) - let l:cmd = [] - call extend(cmd, a:bin_name) - call extend(cmd, [a:target]) - return zig#util#Exec(l:cmd) + " Run the syntax highlighter on the updated content and recompute the folds if + " needed. + syntax sync fromstart endfunction " parse_errors parses the given errors and returns a list of parsed errors -function! s:parse_errors(filename, content) abort - let splitted = split(a:content, '\n') - +function! s:parse_errors(filename, lines) abort " list of errors to be put into location list let errors = [] - for line in splitted + for line in a:lines let tokens = matchlist(line, '^\(.\{-}\):\(\d\+\):\(\d\+\)\s*\(.*\)') if !empty(tokens) call add(errors,{ @@ -141,30 +84,4 @@ function! s:parse_errors(filename, content) abort return errors endfunction - -" show_errors opens a location list and shows the given errors. If the given -" errors is empty, it closes the the location list -function! s:show_errors(errors) abort - let l:listtype = zig#list#Type("ZigFmt") - if !empty(a:errors) - call zig#list#Populate(l:listtype, a:errors, 'Format') - echohl Error | echomsg "zig fmt returned error" | echohl None - endif - - " this closes the window if there are no errors or it opens - " it if there is any - call zig#list#Window(l:listtype, len(a:errors)) -endfunction - -function! zig#fmt#ToggleFmtAutoSave() abort - if zig#config#FmtAutosave() - call zig#config#SetFmtAutosave(0) - call zig#util#EchoProgress("auto fmt disabled") - return - end - - call zig#config#SetFmtAutosave(1) - call zig#util#EchoProgress("auto fmt enabled") -endfunction - " vim: sw=2 ts=2 et diff --git a/autoload/zig/list.vim b/autoload/zig/list.vim deleted file mode 100644 index 832ba107..00000000 --- a/autoload/zig/list.vim +++ /dev/null @@ -1,162 +0,0 @@ -if polyglot#init#is_disabled(expand(':p'), 'zig', 'autoload/zig/list.vim') - finish -endif - -" Adapted from fatih/vim-go: autoload/go/list.vim -" -" Copyright 2011 The Go Authors. All rights reserved. -" Use of this source code is governed by a BSD-style -" license that can be found in the LICENSE file. -" - -" Window opens the list with the given height up to 10 lines maximum. -" Otherwise g:zig_loclist_height is used. -" -" If no or zero height is given it closes the window by default. -" To prevent this, set g:zig_list_autoclose = 0 -function! zig#list#Window(listtype, ...) abort - " we don't use lwindow to close the location list as we need also the - " ability to resize the window. So, we are going to use lopen and lclose - " for a better user experience. If the number of errors in a current - " location list increases/decreases, cwindow will not resize when a new - " updated height is passed. lopen in the other hand resizes the screen. - if !a:0 || a:1 == 0 - call zig#list#Close(a:listtype) - return - endif - - let height = zig#config#ListHeight() - if height == 0 - " prevent creating a large location height for a large set of numbers - if a:1 > 10 - let height = 10 - else - let height = a:1 - endif - endif - - if a:listtype == "locationlist" - exe 'lopen ' . height - else - exe 'copen ' . height - endif -endfunction - - -" Get returns the current items from the list -function! zig#list#Get(listtype) abort - if a:listtype == "locationlist" - return getloclist(0) - else - return getqflist() - endif -endfunction - -" Populate populate the list with the given items -function! zig#list#Populate(listtype, items, title) abort - if a:listtype == "locationlist" - call setloclist(0, a:items, 'r') - - " The last argument ({what}) is introduced with 7.4.2200: - " https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640 - if has("patch-7.4.2200") | call setloclist(0, [], 'a', {'title': a:title}) | endif - else - call setqflist(a:items, 'r') - if has("patch-7.4.2200") | call setqflist([], 'a', {'title': a:title}) | endif - endif -endfunction - -" Parse parses the given items based on the specified errorformat and -" populates the list. -function! zig#list#ParseFormat(listtype, errformat, items, title) abort - " backup users errorformat, will be restored once we are finished - let old_errorformat = &errorformat - - " parse and populate the location list - let &errorformat = a:errformat - try - call zig#list#Parse(a:listtype, a:items, a:title) - finally - "restore back - let &errorformat = old_errorformat - endtry -endfunction - -" Parse parses the given items based on the global errorformat and -" populates the list. -function! zig#list#Parse(listtype, items, title) abort - if a:listtype == "locationlist" - lgetexpr a:items - if has("patch-7.4.2200") | call setloclist(0, [], 'a', {'title': a:title}) | endif - else - cgetexpr a:items - if has("patch-7.4.2200") | call setqflist([], 'a', {'title': a:title}) | endif - endif -endfunction - -" JumpToFirst jumps to the first item in the location list -function! zig#list#JumpToFirst(listtype) abort - if a:listtype == "locationlist" - ll 1 - else - cc 1 - endif -endfunction - -" Clean cleans and closes the location list -function! zig#list#Clean(listtype) abort - if a:listtype == "locationlist" - lex [] - else - cex [] - endif - - call zig#list#Close(a:listtype) -endfunction - -" Close closes the location list -function! zig#list#Close(listtype) abort - let autoclose_window = zig#config#ListAutoclose() - if !autoclose_window - return - endif - - if a:listtype == "locationlist" - lclose - else - cclose - endif -endfunction - -function! s:listtype(listtype) abort - let listtype = zig#config#ListType() - if empty(listtype) - return a:listtype - endif - - return listtype -endfunction - -" s:default_list_type_commands is the defaults that will be used for each of -" the supported commands (see documentation for g:zig_list_type_commands). When -" defining a default, quickfix should be used if the command operates on -" multiple files, while locationlist should be used if the command operates on a -" single file or buffer. Keys that begin with an underscore are not supported -" in g:zig_list_type_commands. -let s:default_list_type_commands = { - \ "ZigFmt": "locationlist", - \ } - -function! zig#list#Type(for) abort - let l:listtype = s:listtype(get(s:default_list_type_commands, a:for)) - if l:listtype == "0" - call zig#util#EchoError(printf( - \ "unknown list type command value found ('%s'). Please open a bug report in the zig.vim repo.", - \ a:for)) - let l:listtype = "quickfix" - endif - - return get(zig#config#ListTypeCommands(), a:for, l:listtype) -endfunction - -" vim: sw=2 ts=2 et diff --git a/autoload/zig/util.vim b/autoload/zig/util.vim deleted file mode 100644 index c886fb62..00000000 --- a/autoload/zig/util.vim +++ /dev/null @@ -1,394 +0,0 @@ -if polyglot#init#is_disabled(expand(':p'), 'zig', 'autoload/zig/util.vim') - finish -endif - -" Adapted from vim-go: autoload/go/util.vim -" -" Copyright 2011 The Go Authors. All rights reserved. -" Use of this source code is governed by a BSD-style -" license that can be found in the LICENSE file. -" - -" PathSep returns the appropriate OS specific path separator. -function! zig#util#PathSep() abort - if zig#util#IsWin() - return '\' - endif - return '/' -endfunction - -" PathListSep returns the appropriate OS specific path list separator. -function! zig#util#PathListSep() abort - if zig#util#IsWin() - return ";" - endif - return ":" -endfunction - -" LineEnding returns the correct line ending, based on the current fileformat -function! zig#util#LineEnding() abort - if &fileformat == 'dos' - return "\r\n" - elseif &fileformat == 'mac' - return "\r" - endif - - return "\n" -endfunction - -" Join joins any number of path elements into a single path, adding a -" Separator if necessary and returns the result -function! zig#util#Join(...) abort - return join(a:000, zig#util#PathSep()) -endfunction - -" IsWin returns 1 if current OS is Windows or 0 otherwise -function! zig#util#IsWin() abort - let win = ['win16', 'win32', 'win64', 'win95'] - for w in win - if (has(w)) - return 1 - endif - endfor - - return 0 -endfunction - -" IsMac returns 1 if current OS is macOS or 0 otherwise. -function! zig#util#IsMac() abort - return has('mac') || - \ has('macunix') || - \ has('gui_macvim') || - \ zig#util#Exec(['uname'])[0] =~? '^darwin' -endfunction - - " Checks if using: - " 1) Windows system, - " 2) And has cygpath executable, - " 3) And uses *sh* as 'shell' -function! zig#util#IsUsingCygwinShell() - return zig#util#IsWin() && executable('cygpath') && &shell =~ '.*sh.*' -endfunction - -" Check if Vim jobs API is supported. -" -" The (optional) first paramter can be added to indicate the 'cwd' or 'env' -" parameters will be used, which wasn't added until a later version. -function! zig#util#has_job(...) abort - " cwd and env parameters to job_start was added in this version. - if a:0 > 0 && a:1 is 1 - return has('job') && has("patch-8.0.0902") - endif - - " job was introduced in 7.4.xxx however there are multiple bug fixes and one - " of the latest is 8.0.0087 which is required for a stable async API. - return has('job') && has("patch-8.0.0087") -endfunction - -let s:env_cache = {} - -" env returns the go environment variable for the given key. Where key can be -" GOARCH, GOOS, GOROOT, etc... It caches the result and returns the cached -" version. -function! zig#util#env(key) abort - let l:key = tolower(a:key) - if has_key(s:env_cache, l:key) - return s:env_cache[l:key] - endif - - if executable('go') - let l:var = call('zig#util#'.l:key, []) - if zig#util#ShellError() != 0 - call zig#util#EchoError(printf("'go env %s' failed", toupper(l:key))) - return '' - endif - else - let l:var = eval("$".toupper(a:key)) - endif - - let s:env_cache[l:key] = l:var - return l:var -endfunction - -" Run a shell command. -" -" It will temporary set the shell to /bin/sh for Unix-like systems if possible, -" so that we always use a standard POSIX-compatible Bourne shell (and not e.g. -" csh, fish, etc.) See #988 and #1276. -function! s:system(cmd, ...) abort - " Preserve original shell and shellredir values - let l:shell = &shell - let l:shellredir = &shellredir - - if !zig#util#IsWin() && executable('/bin/sh') - set shell=/bin/sh shellredir=>%s\ 2>&1 - endif - - try - return call('system', [a:cmd] + a:000) - finally - " Restore original values - let &shell = l:shell - let &shellredir = l:shellredir - endtry -endfunction - -" System runs a shell command "str". Every arguments after "str" is passed to -" stdin. -function! zig#util#System(str, ...) abort - return call('s:system', [a:str] + a:000) -endfunction - -" Exec runs a shell command "cmd", which must be a list, one argument per item. -" Every list entry will be automatically shell-escaped -" Every other argument is passed to stdin. -function! zig#util#Exec(cmd, ...) abort - if len(a:cmd) == 0 - call zig#util#EchoError("zig#util#Exec() called with empty a:cmd") - return ['', 1] - endif - - let l:bin = a:cmd[0] - - if !executable(l:bin) - call zig#util#EchoError(printf("could not find binary '%s'", a:cmd[0])) - return ['', 1] - endif - - return call('s:exec', [a:cmd] + a:000) -endfunction - -function! s:exec(cmd, ...) abort - let l:bin = a:cmd[0] - let l:cmd = zig#util#Shelljoin([l:bin] + a:cmd[1:]) - if zig#util#HasDebug('shell-commands') - call zig#util#EchoInfo('shell command: ' . l:cmd) - endif - - let l:out = call('s:system', [l:cmd] + a:000) - return [l:out, zig#util#ShellError()] -endfunction - -function! zig#util#ShellError() abort - return v:shell_error -endfunction - -" StripPath strips the path's last character if it's a path separator. -" example: '/foo/bar/' -> '/foo/bar' -function! zig#util#StripPathSep(path) abort - let last_char = strlen(a:path) - 1 - if a:path[last_char] == zig#util#PathSep() - return strpart(a:path, 0, last_char) - endif - - return a:path -endfunction - -" StripTrailingSlash strips the trailing slash from the given path list. -" example: ['/foo/bar/'] -> ['/foo/bar'] -function! zig#util#StripTrailingSlash(paths) abort - return map(copy(a:paths), 'zig#util#StripPathSep(v:val)') -endfunction - -" Shelljoin returns a shell-safe string representation of arglist. The -" {special} argument of shellescape() may optionally be passed. -function! zig#util#Shelljoin(arglist, ...) abort - try - let ssl_save = &shellslash - set noshellslash - if a:0 - return join(map(copy(a:arglist), 'shellescape(v:val, ' . a:1 . ')'), ' ') - endif - - return join(map(copy(a:arglist), 'shellescape(v:val)'), ' ') - finally - let &shellslash = ssl_save - endtry -endfunction - -fu! zig#util#Shellescape(arg) - try - let ssl_save = &shellslash - set noshellslash - return shellescape(a:arg) - finally - let &shellslash = ssl_save - endtry -endf - -" Shelllist returns a shell-safe representation of the items in the given -" arglist. The {special} argument of shellescape() may optionally be passed. -function! zig#util#Shelllist(arglist, ...) abort - try - let ssl_save = &shellslash - set noshellslash - if a:0 - return map(copy(a:arglist), 'shellescape(v:val, ' . a:1 . ')') - endif - return map(copy(a:arglist), 'shellescape(v:val)') - finally - let &shellslash = ssl_save - endtry -endfunction - -" Returns the byte offset for line and column -function! zig#util#Offset(line, col) abort - if &encoding != 'utf-8' - let sep = zig#util#LineEnding() - let buf = a:line == 1 ? '' : (join(getline(1, a:line-1), sep) . sep) - let buf .= a:col == 1 ? '' : getline('.')[:a:col-2] - return len(iconv(buf, &encoding, 'utf-8')) - endif - return line2byte(a:line) + (a:col-2) -endfunction -" -" Returns the byte offset for the cursor -function! zig#util#OffsetCursor() abort - return zig#util#Offset(line('.'), col('.')) -endfunction - -" Windo is like the built-in :windo, only it returns to the window the command -" was issued from -function! zig#util#Windo(command) abort - let s:currentWindow = winnr() - try - execute "windo " . a:command - finally - execute s:currentWindow. "wincmd w" - unlet s:currentWindow - endtry -endfunction - -" snippetcase converts the given word to given preferred snippet setting type -" case. -function! zig#util#snippetcase(word) abort - let l:snippet_case = zig#config#AddtagsTransform() - if l:snippet_case == "snakecase" - return zig#util#snakecase(a:word) - elseif l:snippet_case == "camelcase" - return zig#util#camelcase(a:word) - else - return a:word " do nothing - endif -endfunction - -" snakecase converts a string to snake case. i.e: FooBar -> foo_bar -" Copied from tpope/vim-abolish -function! zig#util#snakecase(word) abort - let word = substitute(a:word, '::', '/', 'g') - let word = substitute(word, '\(\u\+\)\(\u\l\)', '\1_\2', 'g') - let word = substitute(word, '\(\l\|\d\)\(\u\)', '\1_\2', 'g') - let word = substitute(word, '[.-]', '_', 'g') - let word = tolower(word) - return word -endfunction - -" camelcase converts a string to camel case. e.g. FooBar or foo_bar will become -" fooBar. -" Copied from tpope/vim-abolish. -function! zig#util#camelcase(word) abort - let word = substitute(a:word, '-', '_', 'g') - if word !~# '_' && word =~# '\l' - return substitute(word, '^.', '\l&', '') - else - return substitute(word, '\C\(_\)\=\(.\)', '\=submatch(1)==""?tolower(submatch(2)) : toupper(submatch(2))','g') - endif -endfunction - -" pascalcase converts a string to 'PascalCase'. e.g. fooBar or foo_bar will -" become FooBar. -function! zig#util#pascalcase(word) abort - let word = zig#util#camelcase(a:word) - return toupper(word[0]) . word[1:] -endfunction - -" Echo a message to the screen and highlight it with the group in a:hi. -" -" The message can be a list or string; every line with be :echomsg'd separately. -function! s:echo(msg, hi) - let l:msg = [] - if type(a:msg) != type([]) - let l:msg = split(a:msg, "\n") - else - let l:msg = a:msg - endif - - " Tabs display as ^I or <09>, so manually expand them. - let l:msg = map(l:msg, 'substitute(v:val, "\t", " ", "")') - - exe 'echohl ' . a:hi - for line in l:msg - echom "zig.vim: " . line - endfor - echohl None -endfunction - -function! zig#util#EchoSuccess(msg) - call s:echo(a:msg, 'Function') -endfunction -function! zig#util#EchoError(msg) - call s:echo(a:msg, 'ErrorMsg') -endfunction -function! zig#util#EchoWarning(msg) - call s:echo(a:msg, 'WarningMsg') -endfunction -function! zig#util#EchoProgress(msg) - redraw - call s:echo(a:msg, 'Identifier') -endfunction -function! zig#util#EchoInfo(msg) - call s:echo(a:msg, 'Debug') -endfunction - -" Get all lines in the buffer as a a list. -function! zig#util#GetLines() - let buf = getline(1, '$') - if &encoding != 'utf-8' - let buf = map(buf, 'iconv(v:val, &encoding, "utf-8")') - endif - if &l:fileformat == 'dos' - " XXX: line2byte() depend on 'fileformat' option. - " so if fileformat is 'dos', 'buf' must include '\r'. - let buf = map(buf, 'v:val."\r"') - endif - return buf -endfunction - -" Make a named temporary directory which starts with "prefix". -" -" Unfortunately Vim's tempname() is not portable enough across various systems; -" see: https://github.com/mattn/vim-go/pull/3#discussion_r138084911 -function! zig#util#tempdir(prefix) abort - " See :help tempfile - if zig#util#IsWin() - let l:dirs = [$TMP, $TEMP, 'c:\tmp', 'c:\temp'] - else - let l:dirs = [$TMPDIR, '/tmp', './', $HOME] - endif - - let l:dir = '' - for l:d in dirs - if !empty(l:d) && filewritable(l:d) == 2 - let l:dir = l:d - break - endif - endfor - - if l:dir == '' - call zig#util#EchoError('Unable to find directory to store temporary directory in') - return - endif - - " Not great randomness, but "good enough" for our purpose here. - let l:rnd = sha256(printf('%s%s', localtime(), fnamemodify(bufname(''), ":p"))) - let l:tmp = printf("%s/%s%s", l:dir, a:prefix, l:rnd) - call mkdir(l:tmp, 'p', 0700) - return l:tmp -endfunction - -" Report if the user enabled a debug flag in g:zig_debug. -function! zig#util#HasDebug(flag) - return index(zig#config#Debug(), a:flag) >= 0 -endfunction - -" vim: sw=2 ts=2 et diff --git a/compiler/puppet-lint.vim b/compiler/puppet-lint.vim new file mode 100644 index 00000000..c65eeb19 --- /dev/null +++ b/compiler/puppet-lint.vim @@ -0,0 +1,27 @@ +if polyglot#init#is_disabled(expand(':p'), 'puppet', 'compiler/puppet-lint.vim') + finish +endif + +" Vim compiler file +" Compiler: puppet-lint +" Maintainer: Doug Kearns + +if exists("current_compiler") + finish +endif +let current_compiler = "puppet-lint" + +if exists(":CompilerSet") != 2 " older Vim always used :setlocal + command -nargs=* CompilerSet setlocal +endif + +let s:cpo_save = &cpo +set cpo&vim + +CompilerSet makeprg=puppet-lint\ --with-filename +CompilerSet errorformat=%f\ -\ %tRROR:\ %m\ on\ line\ %l, + \%f\ -\ %tARNING:\ %m\ on\ line\ %l, + \%-G%.%# + +let &cpo = s:cpo_save +unlet s:cpo_save diff --git a/compiler/sml.vim b/compiler/sml.vim new file mode 100644 index 00000000..e9b65a8e --- /dev/null +++ b/compiler/sml.vim @@ -0,0 +1,32 @@ +if polyglot#init#is_disabled(expand(':p'), 'sml', 'compiler/sml.vim') + finish +endif + +" Vim compiler file +" Compiler: SML/NJ Compiler +" Maintainer: Doug Kearns +" Last Change: 2020 Feb 10 + +if exists("current_compiler") + finish +endif +let current_compiler = "sml" + +if exists(":CompilerSet") != 2 " older Vim always used :setlocal + command -nargs=* CompilerSet setlocal +endif + +let s:cpo_save = &cpo +set cpo&vim + +CompilerSet makeprg=sml +CompilerSet errorformat=%f:%l.%c-%\\d%\\+.%\\d%\\+\ %trror:\ %m, + \%f:%l.%c\ %trror:\ %m, + \%trror:\ %m + \%f:%l.%c-%\\d%\\+.%\\d%\\+\ %tarning:\ %m, + \%f:%l.%c\ %tarning:\ %m, + \%tarning:\ %m, + \%-G%.%# + +let &cpo = s:cpo_save +unlet s:cpo_save diff --git a/compiler/tidy.vim b/compiler/tidy.vim index fec701da..6e362455 100644 --- a/compiler/tidy.vim +++ b/compiler/tidy.vim @@ -5,7 +5,7 @@ endif " Vim compiler file " Compiler: HTML Tidy " Maintainer: Doug Kearns -" Last Change: 2016 Apr 21 +" Last Change: 2020 Sep 4 if exists("current_compiler") finish @@ -16,8 +16,15 @@ if exists(":CompilerSet") != 2 " older Vim always used :setlocal command -nargs=* CompilerSet setlocal endif -CompilerSet makeprg=tidy\ -quiet\ -errors\ --gnu-emacs\ yes\ %:S +let s:cpo_save = &cpo +set cpo&vim -" foo.html:8:1: Warning: inserting missing 'foobar' element -" foo.html:9:2: Error: is not recognized! -CompilerSet errorformat=%f:%l:%c:\ %trror:%m,%f:%l:%c:\ %tarning:%m,%-G%.%# +CompilerSet makeprg=tidy\ -quiet\ -errors\ --gnu-emacs\ yes +CompilerSet errorformat=%f:%l:%c:\ %trror:\ %m, + \%f:%l:%c:\ %tarning:\ %m, + \%f:%l:%c:\ %tnfo:\ %m, + \%f:%l:%c:\ %m, + \%-G%.%# + +let &cpo = s:cpo_save +unlet s:cpo_save diff --git a/compiler/zig.vim b/compiler/zig.vim new file mode 100644 index 00000000..caa19563 --- /dev/null +++ b/compiler/zig.vim @@ -0,0 +1,32 @@ +if polyglot#init#is_disabled(expand(':p'), 'zig', 'compiler/zig.vim') + finish +endif + +" Vim compiler file +" Compiler: Zig Compiler +" For bugs, patches and license go to https://github.com/ziglang/zig.vim + +if exists("current_compiler") + finish +endif +let current_compiler = "zig" + +let s:save_cpo = &cpo +set cpo&vim + +if exists(":CompilerSet") != 2 + command -nargs=* CompilerSet setlocal +endif + +" a subcommand must be provided for the this compiler (test, build-exe, etc) +if has('patch-7.4.191') + CompilerSet makeprg=zig\ \$*\ \%:S +else + CompilerSet makeprg=zig\ \$*\ \"%\" +endif + +" TODO: improve errorformat as needed. + +let &cpo = s:save_cpo +unlet s:save_cpo +" vim: tabstop=8 shiftwidth=4 softtabstop=4 expandtab diff --git a/compiler/zig_build.vim b/compiler/zig_build.vim new file mode 100644 index 00000000..65472809 --- /dev/null +++ b/compiler/zig_build.vim @@ -0,0 +1,32 @@ +if polyglot#init#is_disabled(expand(':p'), 'zig', 'compiler/zig_build.vim') + finish +endif + +" Vim compiler file +" Compiler: Zig Compiler (zig build) + +if exists('current_compiler') + finish +endif +runtime compiler/zig.vim +let current_compiler = 'zig_build' + +let s:save_cpo = &cpo +set cpo&vim + + +if exists(':CompilerSet') != 2 + command -nargs=* CompilerSet setlocal +endif + +if exists('g:zig_build_makeprg_params') + execute 'CompilerSet makeprg=zig\ build\ '.escape(g:zig_build_makeprg_params, ' \|"').'\ $*' +else + CompilerSet makeprg=zig\ build\ $* +endif + +" TODO: anything to add to errorformat for zig build specifically? + +let &cpo = s:save_cpo +unlet s:save_cpo +" vim: tabstop=8 shiftwidth=4 softtabstop=4 expandtab diff --git a/compiler/zig_build_exe.vim b/compiler/zig_build_exe.vim new file mode 100644 index 00000000..fb46d208 --- /dev/null +++ b/compiler/zig_build_exe.vim @@ -0,0 +1,30 @@ +if polyglot#init#is_disabled(expand(':p'), 'zig', 'compiler/zig_build_exe.vim') + finish +endif + +" Vim compiler file +" Compiler: Zig Compiler (zig build-exe) + +if exists('current_compiler') + finish +endif +runtime compiler/zig.vim +let current_compiler = 'zig_build_exe' + +let s:save_cpo = &cpo +set cpo&vim + + +if exists(':CompilerSet') != 2 + command -nargs=* CompilerSet setlocal +endif + +if has('patch-7.4.191') + CompilerSet makeprg=zig\ build-exe\ \%:S\ \$* +else + CompilerSet makeprg=zig\ build-exe\ \"%\"\ \$* +endif + +let &cpo = s:save_cpo +unlet s:save_cpo +" vim: tabstop=8 shiftwidth=4 softtabstop=4 expandtab diff --git a/compiler/zig_test.vim b/compiler/zig_test.vim new file mode 100644 index 00000000..2000e946 --- /dev/null +++ b/compiler/zig_test.vim @@ -0,0 +1,30 @@ +if polyglot#init#is_disabled(expand(':p'), 'zig', 'compiler/zig_test.vim') + finish +endif + +" Vim compiler file +" Compiler: Zig Compiler (zig test) + +if exists('current_compiler') + finish +endif +runtime compiler/zig.vim +let current_compiler = 'zig_test' + +let s:save_cpo = &cpo +set cpo&vim + + +if exists(':CompilerSet') != 2 + command -nargs=* CompilerSet setlocal +endif + +if has('patch-7.4.191') + CompilerSet makeprg=zig\ test\ \%:S\ \$* +else + CompilerSet makeprg=zig\ test\ \"%\"\ \$* +endif + +let &cpo = s:save_cpo +unlet s:save_cpo +" vim: tabstop=8 shiftwidth=4 softtabstop=4 expandtab diff --git a/extras/filetype.vim b/extras/filetype.vim index 9e0be36d..e3971843 100644 --- a/extras/filetype.vim +++ b/extras/filetype.vim @@ -1,7 +1,7 @@ " Vim support file to detect file types " " Maintainer: Bram Moolenaar -" Last Change: 2020 Dec 24 +" Last Change: 2021 Jan 21 " Listen very carefully, I will say this only once if exists("did_load_filetypes") @@ -216,6 +216,9 @@ au BufNewFile,BufRead *.bc setf bc " BDF font au BufNewFile,BufRead *.bdf setf bdf +" Beancount +au BufNewFile,BufRead *.beancount setf beancount + " BibTeX bibliography database file au BufNewFile,BufRead *.bib setf bib @@ -589,6 +592,9 @@ au BufNewFile,BufRead *.fan,*.fwt setf fan " Factor au BufNewFile,BufRead *.factor setf factor +" Fennel +autocmd BufRead,BufNewFile *.fnl setf fennel + " Fetchmail RC file au BufNewFile,BufRead .fetchmailrc setf fetchmail @@ -1173,9 +1179,10 @@ au BufNewFile,BufRead *.papp,*.pxml,*.pxsl setf papp " Password file au BufNewFile,BufRead */etc/passwd,*/etc/passwd-,*/etc/passwd.edit,*/etc/shadow,*/etc/shadow-,*/etc/shadow.edit,*/var/backups/passwd.bak,*/var/backups/shadow.bak setf passwd -" Pascal (also *.p) +" Pascal (also *.p, *.pp, *.inc) au BufNewFile,BufRead *.pas setf pascal +" Pascal or Puppet manifest au BufNewFile,BufRead *.pp call polyglot#ft#FTpp() " Delphi or Lazarus program file @@ -1266,7 +1273,7 @@ au BufNewFile,BufRead *.pov setf pov " Povray configuration au BufNewFile,BufRead .povrayrc setf povini -" Povray, PHP or assembly +" Povray, Pascal, PHP or assembly au BufNewFile,BufRead *.inc call polyglot#ft#FTinc() " Printcap and Termcap @@ -1275,13 +1282,19 @@ au BufNewFile,BufRead *printcap au BufNewFile,BufRead *termcap \ let b:ptcap_type = "term" | setf ptcap -" PCCTS / ANTRL -"au BufNewFile,BufRead *.g setf antrl +" PCCTS / ANTLR +"au BufNewFile,BufRead *.g setf antlr au BufNewFile,BufRead *.g setf pccts " PPWizard au BufNewFile,BufRead *.it,*.ih setf ppwiz +" Puppet +au BufNewFile,BufRead Puppetfile setf ruby + +" Embedded Puppet +au BufNewFile,BufRead *.epp setf epuppet + " Obj 3D file format " TODO: is there a way to avoid MS-Windows Object files? au BufNewFile,BufRead *.obj setf obj @@ -1424,8 +1437,8 @@ au BufNewFile,BufRead *.rb,*.rbw setf ruby " RubyGems au BufNewFile,BufRead *.gemspec setf ruby -" Rust -au BufNewFile,BufRead *.rs setf rust +" RBS (Ruby Signature) +au BufNewFile,BufRead *.rbs setf rbs " Rackup au BufNewFile,BufRead *.ru setf ruby @@ -1439,6 +1452,9 @@ au BufNewFile,BufRead *.builder,*.rxml,*.rjs setf ruby " Rantfile and Rakefile is like Ruby au BufNewFile,BufRead [rR]antfile,*.rant,[rR]akefile,*.rake setf ruby +" Rust +au BufNewFile,BufRead *.rs setf rust + " S-lang (or shader language, or SmallLisp) au BufNewFile,BufRead *.sl setf slang @@ -1475,6 +1491,9 @@ au BufNewFile,BufRead *.sdl,*.pr setf sdl " sed au BufNewFile,BufRead *.sed setf sed +" svelte +au BufNewFile,BufRead *.svelte setf svelte + " Sieve (RFC 3028, 5228) au BufNewFile,BufRead *.siv,*.sieve setf sieve @@ -1618,6 +1637,9 @@ au BufNewFile,BufRead *.mib,*.my setf mib au BufNewFile,BufRead *.hog,snort.conf,vision.conf setf hog au BufNewFile,BufRead *.rules call polyglot#ft#FTRules() +" SPARQL queries +au BufNewFile,BufRead *.rq,*.sparql setf sparql + " Spec (Linux RPM) au BufNewFile,BufRead *.spec setf spec @@ -1728,8 +1750,13 @@ au BufNewFile,BufRead *.tli setf tli " Telix Salt au BufNewFile,BufRead *.slt setf tsalt -" Tera Term Language -au BufRead,BufNewFile *.ttl setf teraterm +" Tera Term Language or Turtle +au BufRead,BufNewFile *.ttl + \ if getline(1) =~ '^@\?\(prefix\|base\)' | + \ setf turtle | + \ else | + \ setf teraterm | + \ endif " Terminfo au BufNewFile,BufRead *.ti setf terminfo diff --git a/ftplugin/ada.vim b/ftplugin/ada.vim index d7b34be0..bddd43b6 100644 --- a/ftplugin/ada.vim +++ b/ftplugin/ada.vim @@ -163,40 +163,41 @@ if exists("g:ada_abbrev") endif " Section: Commands, Mapping, Menus {{{1 -" -call ada#Map_Popup ( - \ 'Tag.List', - \ 'l', - \ 'call ada#List_Tag ()') -call ada#Map_Popup ( - \'Tag.Jump', - \'j', - \'call ada#Jump_Tag ()') -call ada#Map_Menu ( - \'Tag.Create File', - \':AdaTagFile', - \'call ada#Create_Tags (''file'')') -call ada#Map_Menu ( - \'Tag.Create Dir', - \':AdaTagDir', - \'call ada#Create_Tags (''dir'')') - -call ada#Map_Menu ( - \'Highlight.Toggle Space Errors', - \ ':AdaSpaces', - \'call ada#Switch_Syntax_Option (''space_errors'')') -call ada#Map_Menu ( - \'Highlight.Toggle Lines Errors', - \ ':AdaLines', - \'call ada#Switch_Syntax_Option (''line_errors'')') -call ada#Map_Menu ( - \'Highlight.Toggle Rainbow Color', - \ ':AdaRainbow', - \'call ada#Switch_Syntax_Option (''rainbow_color'')') -call ada#Map_Menu ( - \'Highlight.Toggle Standard Types', - \ ':AdaTypes', - \'call ada#Switch_Syntax_Option (''standard_types'')') +if !exists(':AdaTagFile') + call ada#Map_Popup ( + \ 'Tag.List', + \ 'l', + \ 'call ada#List_Tag ()') + call ada#Map_Popup ( + \'Tag.Jump', + \'j', + \'call ada#Jump_Tag ()') + call ada#Map_Menu ( + \'Tag.Create File', + \':AdaTagFile', + \'call ada#Create_Tags (''file'')') + call ada#Map_Menu ( + \'Tag.Create Dir', + \':AdaTagDir', + \'call ada#Create_Tags (''dir'')') + + call ada#Map_Menu ( + \'Highlight.Toggle Space Errors', + \ ':AdaSpaces', + \'call ada#Switch_Syntax_Option (''space_errors'')') + call ada#Map_Menu ( + \'Highlight.Toggle Lines Errors', + \ ':AdaLines', + \'call ada#Switch_Syntax_Option (''line_errors'')') + call ada#Map_Menu ( + \'Highlight.Toggle Rainbow Color', + \ ':AdaRainbow', + \'call ada#Switch_Syntax_Option (''rainbow_color'')') + call ada#Map_Menu ( + \'Highlight.Toggle Standard Types', + \ ':AdaTypes', + \'call ada#Switch_Syntax_Option (''standard_types'')') +endif " 1}}} " Reset cpoptions diff --git a/ftplugin/basic.vim b/ftplugin/basic.vim new file mode 100644 index 00000000..016253f6 --- /dev/null +++ b/ftplugin/basic.vim @@ -0,0 +1,31 @@ +if polyglot#init#is_disabled(expand(':p'), 'basic', 'ftplugin/basic.vim') + finish +endif + +" Vim filetype plugin file +" Language: BASIC +" Maintainer: Doug Kearns +" Last Change: 2015 Jan 10 + +if exists("b:did_ftplugin") + finish +endif +let b:did_ftplugin = 1 + +let s:cpo_save = &cpo +set cpo&vim + +setlocal comments=:REM,:' +setlocal commentstring='\ %s +setlocal formatoptions-=t formatoptions+=croql + +if (has("gui_win32") || has("gui_gtk")) && !exists("b:browsefilter") + let b:browsefilter = "BASIC Source Files (*.bas)\t*.bas\n" . + \ "All Files (*.*)\t*.*\n" +endif + +let b:undo_ftplugin = "setl fo< com< cms< sua<" . + \ " | unlet! b:browsefilter" + +let &cpo = s:cpo_save +unlet s:cpo_save diff --git a/ftplugin/bzl.vim b/ftplugin/bzl.vim index b1ece99b..c6add72a 100644 --- a/ftplugin/bzl.vim +++ b/ftplugin/bzl.vim @@ -5,7 +5,7 @@ endif " Vim filetype plugin file " Language: Bazel (http://bazel.io) " Maintainer: David Barnett (https://github.com/google/vim-ft-bzl) -" Last Change: 2015 Aug 11 +" Last Change: 2021 Jan 19 "" " @section Introduction, intro @@ -55,6 +55,8 @@ if get(g:, 'ft_bzl_fold', 0) endif if exists('*BzlFoldText') + let &cpo = s:save_cpo + unlet s:save_cpo finish endif diff --git a/ftplugin/embeddedpuppet.vim b/ftplugin/embeddedpuppet.vim deleted file mode 100644 index 7a2621fb..00000000 --- a/ftplugin/embeddedpuppet.vim +++ /dev/null @@ -1,79 +0,0 @@ -if polyglot#init#is_disabled(expand(':p'), 'puppet', 'ftplugin/embeddedpuppet.vim') - finish -endif - -" Vim filetype plugin -" Language: embedded puppet -" Maintainer: Gabriel Filion -" URL: https://github.com/rodjek/vim-puppet -" Last Change: 2019-09-01 - -" 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/sh.vim -unlet! b:did_ftplugin - -" 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 - -let s:include = &l:include -let s:path = &l:path -let s:suffixesadd = &l:suffixesadd - -runtime! ftplugin/puppet.vim -let b:did_ftplugin = 1 - -" 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 - -if len(s:include) - let &l:include = s:include -endif -let &l:path = s:path . (s:path =~# ',$\|^$' ? '' : ',') . &l:path -let &l:suffixesadd = s:suffixesadd . (s:suffixesadd =~# ',$\|^$' ? '' : ',') . &l:suffixesadd -unlet s:include s:path s:suffixesadd - -" Load the combined list of match_words for matchit.vim -if exists("loaded_matchit") - let b:match_words = s:match_words -endif - -" TODO: comments= -setlocal commentstring=<%#%s%> - -let b:undo_ftplugin = "setl cms< " - \ " | unlet! b:browsefilter b:match_words | " . s:undo_ftplugin - -let &cpo = s:save_cpo -unlet s:save_cpo - diff --git a/ftplugin/epuppet.vim b/ftplugin/epuppet.vim new file mode 100644 index 00000000..482d2af1 --- /dev/null +++ b/ftplugin/epuppet.vim @@ -0,0 +1,79 @@ +if polyglot#init#is_disabled(expand(':p'), 'puppet', 'ftplugin/epuppet.vim') + finish +endif + +" Vim filetype plugin +" Language: embedded puppet +" Maintainer: Gabriel Filion +" URL: https://github.com/rodjek/vim-puppet +" Last Change: 2019-09-01 + +" 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/sh.vim +unlet! b:did_ftplugin + +" 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 + +let s:include = &l:include +let s:path = &l:path +let s:suffixesadd = &l:suffixesadd + +runtime! ftplugin/puppet.vim +let b:did_ftplugin = 1 + +" 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 + +if len(s:include) + let &l:include = s:include +endif +let &l:path = s:path . (s:path =~# ',$\|^$' ? '' : ',') . &l:path +let &l:suffixesadd = s:suffixesadd . (s:suffixesadd =~# ',$\|^$' ? '' : ',') . &l:suffixesadd +unlet s:include s:path s:suffixesadd + +" Load the combined list of match_words for matchit.vim +if exists("loaded_matchit") + let b:match_words = s:match_words +endif + +" TODO: comments= +setlocal commentstring=<%#%s%> + +let b:undo_ftplugin = "setl cms< " + \ " | unlet! b:browsefilter b:match_words | " . s:undo_ftplugin + +let &cpo = s:save_cpo +unlet s:save_cpo + diff --git a/ftplugin/framescript.vim b/ftplugin/framescript.vim index 9ec58b5f..ba858408 100644 --- a/ftplugin/framescript.vim +++ b/ftplugin/framescript.vim @@ -7,14 +7,14 @@ endif " Previous Maintainer: Nikolai Weibull " Latest Revision: 2008-07-19 -let s:cpo_save = &cpo -set cpo&vim - if exists("b:did_ftplugin") finish endif let b:did_ftplugin = 1 +let s:cpo_save = &cpo +set cpo&vim + let b:undo_ftplugin = "setl com< cms< fo< inc< | unlet! b:matchwords" setlocal comments=s1:/*,mb:*,ex:*/,:// commentstring=/*\ %s\ */ diff --git a/ftplugin/freebasic.vim b/ftplugin/freebasic.vim new file mode 100644 index 00000000..d2212481 --- /dev/null +++ b/ftplugin/freebasic.vim @@ -0,0 +1,17 @@ +if polyglot#init#is_disabled(expand(':p'), 'freebasic', 'ftplugin/freebasic.vim') + finish +endif + +" Vim filetype plugin file +" Language: FreeBasic +" Maintainer: Doug Kearns +" Last Change: 2015 Jan 10 + +if exists("b:did_ftplugin") + finish +endif +let b:did_ftplugin = 1 + +runtime! ftplugin/basic.vim + +" vim: ts=8 diff --git a/ftplugin/hamster.vim b/ftplugin/hamster.vim index c72a8657..2eca00f8 100644 --- a/ftplugin/hamster.vim +++ b/ftplugin/hamster.vim @@ -6,7 +6,7 @@ endif " Language: Hamster Script " Version: 2.0.6.0 " Maintainer: David Fishburn -" Last Change: 2017 Mar 18 +" Last Change: 2021 Jan 19 " Only do this when not done yet for this buffer if exists("b:did_ftplugin") @@ -61,6 +61,9 @@ if exists("loaded_matchit") endif setlocal ignorecase + let &cpo = s:cpo_save unlet s:cpo_save -setlocal cpo+=M " makes \%( match \) + +" Disabled, 'cpo' is a global option. +" setlocal cpo+=M " makes \%( match \) diff --git a/ftplugin/lisp.vim b/ftplugin/lisp.vim index 365a26b8..cc86c720 100644 --- a/ftplugin/lisp.vim +++ b/ftplugin/lisp.vim @@ -18,13 +18,11 @@ endif " Don't load another plugin for this buffer let b:did_ftplugin = 1 -setl comments=:; +setl comments=:;;;;,:;;;,:;;,:;,sr:#\|,mb:\|,ex:\|# setl define=^\\s*(def\\k* setl formatoptions-=t setl iskeyword+=+,-,*,/,%,<,=,>,:,$,?,!,@-@,94 setl lisp setl commentstring=;%s -setl comments^=:;;;,:;;,sr:#\|,mb:\|,ex:\|# - let b:undo_ftplugin = "setlocal comments< define< formatoptions< iskeyword< lisp< commentstring<" diff --git a/ftplugin/octave.vim b/ftplugin/octave.vim new file mode 100644 index 00000000..c9408150 --- /dev/null +++ b/ftplugin/octave.vim @@ -0,0 +1,5 @@ +if polyglot#init#is_disabled(expand(':p'), 'octave', 'ftplugin/octave.vim') + finish +endif + +setlocal commentstring=%\ %s diff --git a/ftplugin/rust.vim b/ftplugin/rust.vim index a131a1d1..c13edfbc 100644 --- a/ftplugin/rust.vim +++ b/ftplugin/rust.vim @@ -51,7 +51,7 @@ setlocal smartindent nocindent if get(g:, 'rust_recommended_style', 1) let b:rust_set_style = 1 - setlocal tabstop=8 shiftwidth=4 softtabstop=4 expandtab + setlocal shiftwidth=4 softtabstop=4 expandtab setlocal textwidth=99 endif diff --git a/ftplugin/sxhkdrc.vim b/ftplugin/sxhkdrc.vim index b58baa1f..8b5be981 100644 --- a/ftplugin/sxhkdrc.vim +++ b/ftplugin/sxhkdrc.vim @@ -2,4 +2,14 @@ if polyglot#init#is_disabled(expand(':p'), 'sxhkd', 'ftplugin/sxhkdrc.vim finish endif +if exists("b:did_ftplugin") + finish +endif + setlocal cms=#%s + +if exists('b:undo_ftplugin') + let b:undo_ftplugin .= "|setlocal commentstring<" +else + let b:undo_ftplugin = "setlocal commentstring<" +endif diff --git a/ftplugin/tidy.vim b/ftplugin/tidy.vim new file mode 100644 index 00000000..8f368fa9 --- /dev/null +++ b/ftplugin/tidy.vim @@ -0,0 +1,36 @@ +if polyglot#init#is_disabled(expand(':p'), 'tidy', 'ftplugin/tidy.vim') + finish +endif + +" Vim filetype plugin file +" Language: HMTL Tidy Configuration +" Maintainer: Doug Kearns +" Last Change: 2020 Sep 4 + +if exists("b:did_ftplugin") + finish +endif +let b:did_ftplugin = 1 + +let s:cpo_save = &cpo +set cpo&vim + +setlocal comments=:#,:// +setlocal commentstring=#\ %s +setlocal formatoptions-=t formatoptions+=croql + +if (has("gui_win32") || has("gui_gtk")) && !exists("b:browsefilter") + let b:browsefilter = "HTML Tidy Files (tidyrc, .tidyrc, tidy.conf)\ttidyrc;.tidyrc;tidy.conf\n" . + \ "HTML Files (*.html, *.htm)\t*.html;*.htm\n" . + \ "XHTML Files (*.xhtml, *.xhtm)\t*.xhtml;*.xhtm\n" . + \ "XML Files (*.xml)\t*.xml\n" . + \ "All Files (*.*)\t*.*\n" +endif + +let b:undo_ftplugin = "setl fo< com< cms<" . + \ " | unlet! b:browsefilter" + +let &cpo = s:cpo_save +unlet s:cpo_save + +" vim: nowrap sw=2 sts=2 ts=8 diff --git a/ftplugin/vlang.vim b/ftplugin/vlang.vim index cda16cba..fbc0a711 100644 --- a/ftplugin/vlang.vim +++ b/ftplugin/vlang.vim @@ -2,5 +2,36 @@ if polyglot#init#is_disabled(expand(':p'), 'v', 'ftplugin/vlang.vim') finish endif +if exists("b:did_ftplugin") + finish +endif + setlocal commentstring=//\ %s setlocal makeprg=v\ % + +if exists('b:undo_ftplugin') + let b:undo_ftplugin .= "|setlocal commentstring< makeprg<" +else + let b:undo_ftplugin = "setlocal commentstring< makeprg<" +endif + +function! _VFormatFile() + if exists('g:v_autofmt_bufwritepre') && g:v_autofmt_bufwritepre || exists('b:v_autofmt_bufwritepre') && b:v_autofmt_bufwritepre + let substitution = system("v fmt -", join(getline(1, line('$')), "\n")) + if v:shell_error != 0 + echoerr "While formatting the buffer via vfmt, the following error occurred:" + echoerr printf("ERROR(%d): %s", v:shell_error, substitution) + else + let [_, lnum, colnum, _] = getpos('.') + %delete + call append(0, split(substitution, "\n")) + call cursor(lnum, colnum) + endif + endif +endfunction + +if has('autocmd') + augroup v_fmt + autocmd BufWritePre *.v call _VFormatFile() + augroup END +endif diff --git a/ftplugin/zig.vim b/ftplugin/zig.vim index 3b88372c..cb2f3e84 100644 --- a/ftplugin/zig.vim +++ b/ftplugin/zig.vim @@ -12,6 +12,11 @@ let b:did_ftplugin = 1 let s:cpo_orig = &cpo set cpo&vim +compiler zig_build + +" Match Zig builtin fns +setlocal iskeyword+=@-@ + " Recomended code style, no tabs and 4-space indentation setlocal expandtab setlocal tabstop=8 @@ -21,7 +26,6 @@ setlocal shiftwidth=4 setlocal formatoptions-=t formatoptions+=croql setlocal suffixesadd=.zig,.zir -setlocal makeprg=zig\ build if has('comments') setlocal comments=:///,://!,://,:\\\\ @@ -44,7 +48,7 @@ if exists("*json_decode") && executable('zig') endif let b:undo_ftplugin = - \ 'setl et< ts< sts< sw< fo< sua< mp< com< cms< inex< inc< pa<' + \ 'setl isk< et< ts< sts< sw< fo< sua< mp< com< cms< inex< inc< pa<' let &cpo = s:cpo_orig unlet s:cpo_orig diff --git a/indent/fortran.vim b/indent/fortran.vim index 0f08a996..9a3573ac 100644 --- a/indent/fortran.vim +++ b/indent/fortran.vim @@ -78,11 +78,15 @@ endif if (b:fortran_fixed_source == 1) setlocal indentexpr=FortranGetFixedIndent() if exists("*FortranGetFixedIndent") + let &cpoptions = s:cposet + unlet s:cposet finish endif else setlocal indentexpr=FortranGetFreeIndent() if exists("*FortranGetFreeIndent") + let &cpoptions = s:cposet + unlet s:cposet finish endif endif @@ -217,7 +221,7 @@ function FortranGetFixedIndent() return ind endfunction -let &cpoptions=s:cposet +let &cpoptions = s:cposet unlet s:cposet " vim:sw=2 tw=130 diff --git a/indent/haskell.vim b/indent/haskell.vim index cefa0845..fa906630 100644 --- a/indent/haskell.vim +++ b/indent/haskell.vim @@ -193,13 +193,13 @@ function! GetHaskellIndent() " operator at end of previous line if l:prevline =~ '[!#$%&*+./<>?@\\^|~-]\s*$' - return indent(v:lnum - 1) + &shiftwidth + return indent(v:lnum - 1) + shiftwidth() endif " let foo = " >>>>>>bar if l:prevline =~ '\C\\s\+[^=]\+=\s*$' - return match(l:prevline, '\C\') + g:haskell_indent_let + &shiftwidth + return match(l:prevline, '\C\') + g:haskell_indent_let + shiftwidth() endif " let x = 1 in @@ -247,7 +247,7 @@ function! GetHaskellIndent() " >>foo " if l:prevline =~ '\C\\s*$' - return indent(v:lnum - 1) + get(g:, 'haskell_indent_after_bare_where', &shiftwidth) + return indent(v:lnum - 1) + get(g:, 'haskell_indent_after_bare_where', shiftwidth()) endif " do @@ -256,7 +256,7 @@ function! GetHaskellIndent() " foo = " >>bar if l:prevline =~ '\C\(\\|=\)\s*$' - return indent(v:lnum - 1) + &shiftwidth + return indent(v:lnum - 1) + shiftwidth() endif " do foo @@ -272,7 +272,7 @@ function! GetHaskellIndent() " >>bar -> quux if l:prevline =~ '\C\.\+\\s*$' if get(g:,'haskell_indent_case_alternative', 0) - return indent(v:lnum - 1) + &shiftwidth + return indent(v:lnum - 1) + shiftwidth() else return match(l:prevline, '\C\') + g:haskell_indent_case endif @@ -305,7 +305,7 @@ function! GetHaskellIndent() " newtype Foo = Foo " >>deriving if l:prevline =~ '\C^\s*\<\(newtype\|data\)\>[^{]\+' && l:line =~ '\C^\s*\' - return indent(v:lnum - 1) + &shiftwidth + return indent(v:lnum - 1) + shiftwidth() endif " foo :: Int @@ -318,7 +318,7 @@ function! GetHaskellIndent() if l:line =~ '^\s*[-=]>' return match(l:prevline, '::\s') elseif match(l:prevline, '^\s\+::') > -1 - return match(l:prevline, '::\s') - &shiftwidth + return match(l:prevline, '::\s') - shiftwidth() endif endif @@ -398,13 +398,13 @@ function! GetHaskellIndent() ">>>>>=> Int if l:prevline =~ '^\s*)' && l:line =~ '^\s*=>' let l:s = match(l:prevline, ')') - return l:s - (&shiftwidth + 1) + return l:s - (shiftwidth() + 1) endif " module Foo " >>( bar if l:prevline =~ '\C^\' - return &shiftwidth + return shiftwidth() endif " foo @@ -412,7 +412,7 @@ function! GetHaskellIndent() if l:line =~ '^\s*{' let l:s = indent(v:lnum - 1) if l:s >= 0 - return l:s + &shiftwidth + return l:s + shiftwidth() endif endif @@ -428,7 +428,7 @@ function! GetHaskellIndent() return match(l:prevline, 'in') - g:haskell_indent_in endif - return indent(v:lnum - 1) + get(g:, 'haskell_indent_before_where', &shiftwidth) + return indent(v:lnum - 1) + get(g:, 'haskell_indent_before_where', shiftwidth()) endif " let x = 1 @@ -462,13 +462,13 @@ function! GetHaskellIndent() " >>= if l:line =~ '^\s*=' if l:prevline =~ '\C^\\s\+[^=]\+\s*$' - return match(l:prevline, '\C\') + &shiftwidth + return match(l:prevline, '\C\') + shiftwidth() else let l:s = s:indentGuard(match(l:line, '='), l:prevline) if l:s > 0 return l:s else - return &shiftwidth + return shiftwidth() endif endif endif @@ -493,7 +493,7 @@ function! GetHaskellIndent() " foo " >>:: Int if l:line =~ '^\s*::\s' - return indent(v:lnum - 1) + &shiftwidth + return indent(v:lnum - 1) + shiftwidth() endif " indent closing brace, paren or bracket diff --git a/indent/html.vim b/indent/html.vim index 07c6aa6f..96b32b62 100644 --- a/indent/html.vim +++ b/indent/html.vim @@ -5,7 +5,7 @@ endif " Vim indent script for HTML " Maintainer: Bram Moolenaar " Original Author: Andy Wokula -" Last Change: 2020 Dec 11 +" Last Change: 2021 Jan 26 " Version: 1.0 "{{{ " Description: HTML indent script with cached state for faster indenting on a " range of lines. @@ -945,11 +945,11 @@ func! s:InsideTag(foundHtmlString) let idx = match(text, '<' . s:tagname . '\s\+\zs\w') endif if idx == -1 - " after just "= 0 - call cursor(lnum, idx) - return virtcol('.') + shiftwidth() + call cursor(lnum, idx + 1) + return virtcol('.') - 1 + shiftwidth() * 2 endif endif if idx > 0 diff --git a/indent/julia.vim b/indent/julia.vim index c2a55922..c4c17245 100644 --- a/indent/julia.vim +++ b/indent/julia.vim @@ -261,7 +261,7 @@ function GetJuliaNestingBrackets(lnum, c) if len(brackets_stack) > 0 let first_open_bracket = brackets_stack[0][1] let last_open_bracket = brackets_stack[-1][1] - if brackets_stack[-1][0] == 'par' && IsFunctionArgPar(a:lnum, last_open_bracket) + if brackets_stack[-1][0] == 'par' && IsFunctionArgPar(a:lnum, last_open_bracket+1) let infuncargs = 1 endif endif @@ -295,8 +295,8 @@ function IsFunctionArgPar(lnum, c) if a:c == 0 return 0 endif - let stack = map(synstack(a:lnum, a:c-1), 'synIDattr(v:val, "name")') - return stack[-1] == 'juliaFunctionBlock' + let stack = map(synstack(a:lnum, a:c), 'synIDattr(v:val, "name")') + return len(stack) >= 3 && stack[-3] == 'juliaFunctionDefP' endfunction function JumpToMatch(lnum, last_closed_bracket) @@ -394,13 +394,14 @@ function GetJuliaIndent() let ind = indent(lnum) endif - " Does the current line starts with a closing bracket? Then depending on + " Does the current line start with a closing bracket? Then depending on " the situation we align it with the opening one, or we let the rest of " the code figure it out (the case in which we're closing a function " argument list is special-cased) if JuliaMatch(v:lnum, getline(v:lnum), '[])}]', indent(v:lnum)) == indent(v:lnum) && ind > 0 if !align_brackets && !align_funcargs - let ind = -1 + call JumpToMatch(v:lnum, indent(v:lnum)) + return indent(line(".")) elseif (align_brackets && getline(v:lnum)[indent(v:lnum)] != ')') || align_funcargs return ind - 1 else " must be a ')' and align_brackets==1 and align_funcargs==0 @@ -447,7 +448,6 @@ function GetJuliaIndent() " if the opening line has a colon followed by non-comments, use it as " reference point let cind = JuliaMatch(lnum, prevline, ':', indent(lnum), lim) - " echo "cind=".string(cind) | sleep 1 if cind >= 0 let nonwhiteind = JuliaMatch(lnum, prevline, '\S', cind+1) if nonwhiteind >= 0 diff --git a/indent/puppet.vim b/indent/puppet.vim index cabde843..1067e9e0 100644 --- a/indent/puppet.vim +++ b/indent/puppet.vim @@ -105,11 +105,16 @@ function! GetPuppetIndent(...) let ind = indent(s:PrevNonMultilineString(pnum - 1)) endif - if pline =~ '\({\|\[\|(\|:\)\s*\(#.*\)\?$' + let l:bracketAtEndOfLinePattern = '\({\|\[\|(\|:\)\s*\(#.*\)\?$' + if pline =~ l:bracketAtEndOfLinePattern + let l:i = match(pline, l:bracketAtEndOfLinePattern) + let l:syntaxType = synIDattr(synID(pnum, l:i + 1, 0), 'name') + if l:syntaxType !~# '\(Comment\|String\)$' let ind += &sw + endif elseif pline =~ ';$' && pline !~ '[^:]\+:.*[=+]>.*' let ind -= &sw - elseif pline =~ '^\s*include\s\+.*,$' && pline !~ '[=+]>' + elseif pline =~# '^\s*include\s\+.*,$' && pline !~ '[=+]>' let ind += &sw endif diff --git a/indent/ruby.vim b/indent/ruby.vim index d061edfb..afa72995 100644 --- a/indent/ruby.vim +++ b/indent/ruby.vim @@ -646,8 +646,7 @@ function! s:PreviousNotMSL(msl_info) abort " TODO (2016-10-07) Wrong/unused? How could it be "1"? return indent(info.plnum) - 1 " If previous line is a continuation return its indent. - " TODO: the || s:IsInString() thing worries me a bit. - elseif s:Match(info.plnum, s:non_bracket_continuation_regex) || s:IsInString(info.plnum, strlen(line)) + elseif s:Match(info.plnum, s:non_bracket_continuation_regex) return indent(info.plnum) endif endif diff --git a/syntax/Jenkinsfile.vim b/syntax/Jenkinsfile.vim index 99b8707e..5959fd70 100644 --- a/syntax/Jenkinsfile.vim +++ b/syntax/Jenkinsfile.vim @@ -11,6 +11,7 @@ syn keyword jenkinsfileDirective environment options parameters triggers stage t syn keyword jenkinsfileOption contained buildDiscarder disableConcurrentBuilds overrideIndexTriggers skipDefaultCheckout nextgroup=jenkinsfileOptionParams syn keyword jenkinsfileOption contained skipStagesAfterUnstable checkoutToSubdirectory timeout retry timestamps nextgroup=jenkinsfileOptionParams +syn keyword jenkinsfileOption contained disableResume newContainerPerStage preserveStashes quietPeriod parallelsAlwaysFailFast nextgroup=jenkinsfileOptionParams syn region jenkinsfileOptionParams contained start='(' end=')' transparent contains=@groovyTop syn match jenkinsfileOptionO /[a-zA-Z]\+([^)]*)/ contains=jenkinsfileOption,jenkinsfileOptionParams transparent containedin=groovyParenT1 diff --git a/syntax/basic.vim b/syntax/basic.vim index 1b98eb8d..3502fa14 100644 --- a/syntax/basic.vim +++ b/syntax/basic.vim @@ -3,16 +3,18 @@ if polyglot#init#is_disabled(expand(':p'), 'basic', 'syntax/basic.vim') endif " Vim syntax file -" Language: BASIC -" Maintainer: Allan Kelly -" Last Change: 2011 Dec 25 by Thilo Six +" Language: BASIC +" Maintainer: Doug Kearns +" Previous Maintainer: Allan Kelly +" Contributors: Thilo Six +" Last Change: 2015 Jan 10 " First version based on Micro$soft QBASIC circa 1989, as documented in " 'Learn BASIC Now' by Halvorson&Rygmyr. Microsoft Press 1989. " This syntax file not a complete implementation yet. Send suggestions to the " maintainer. -" quit when a syntax file was already loaded +" Prelude {{{1 if exists("b:current_syntax") finish endif @@ -20,7 +22,7 @@ endif let s:cpo_save = &cpo set cpo&vim -" A bunch of useful BASIC keywords +" Keywords {{{1 syn keyword basicStatement BEEP beep Beep BLOAD bload Bload BSAVE bsave Bsave syn keyword basicStatement CALL call Call ABSOLUTE absolute Absolute syn keyword basicStatement CHAIN chain Chain CHDIR chdir Chdir @@ -120,32 +122,39 @@ syn keyword basicFunction RIGHT$ right$ Right$ RTRIM$ rtrim$ Rtrim$ syn keyword basicFunction SPACE$ space$ Space$ STR$ str$ Str$ syn keyword basicFunction STRING$ string$ String$ TIME$ time$ Time$ syn keyword basicFunction UCASE$ ucase$ Ucase$ VARPTR$ varptr$ Varptr$ -syn keyword basicTodo contained TODO -"integer number, or floating point number without a dot. +" Numbers {{{1 +" Integer number, or floating point number without a dot. syn match basicNumber "\<\d\+\>" -"floating point number, with dot +" Floating point number, with dot syn match basicNumber "\<\d\+\.\d*\>" -"floating point number, starting with a dot +" Floating point number, starting with a dot syn match basicNumber "\.\d\+\>" -" String and Character contstants -syn match basicSpecial contained "\\\d\d\d\|\\." -syn region basicString start=+"+ skip=+\\\\\|\\"+ end=+"+ contains=basicSpecial +" String and Character constants {{{1 +syn match basicSpecial "\\\d\d\d\|\\." contained +syn region basicString start=+"+ skip=+\\\\\|\\"+ end=+"+ contains=basicSpecial -syn region basicComment start="REM" end="$" contains=basicTodo -syn region basicComment start="^[ \t]*'" end="$" contains=basicTodo +" Line numbers {{{1 syn region basicLineNumber start="^\d" end="\s" -syn match basicTypeSpecifier "[a-zA-Z0-9][\$%&!#]"ms=s+1 + +" Data-type suffixes {{{1 +syn match basicTypeSpecifier "[a-zA-Z0-9][$%&!#]"ms=s+1 " Used with OPEN statement syn match basicFilenumber "#\d\+" -"syn sync ccomment basicComment + +" Mathematical operators {{{1 " syn match basicMathsOperator "[<>+\*^/\\=-]" -syn match basicMathsOperator "-\|=\|[:<>+\*^/\\]\|AND\|OR" +syn match basicMathsOperator "-\|=\|[:<>+\*^/\\]\|AND\|OR" -" Define the default highlighting. -" Only when an item doesn't have highlighting yet +" Comments {{{1 +syn keyword basicTodo TODO FIXME XXX NOTE contained +syn region basicComment start="^\s*\zsREM\>" start="\%(:\s*\)\@<=REM\>" end="$" contains=basicTodo +syn region basicComment start="'" end="$" contains=basicTodo +"syn sync ccomment basicComment + +" Default Highlighting {{{1 hi def link basicLabel Label hi def link basicConditional Conditional hi def link basicRepeat Repeat @@ -154,17 +163,18 @@ hi def link basicNumber Number hi def link basicError Error hi def link basicStatement Statement hi def link basicString String -hi def link basicComment Comment -hi def link basicSpecial Special +hi def link basicComment Comment +hi def link basicSpecial Special hi def link basicTodo Todo -hi def link basicFunction Identifier -hi def link basicTypeSpecifier Type -hi def link basicFilenumber basicTypeSpecifier +hi def link basicFunction Identifier +hi def link basicTypeSpecifier Type +hi def link basicFilenumber basicTypeSpecifier "hi basicMathsOperator term=bold cterm=bold gui=bold - +" Postscript {{{1 let b:current_syntax = "basic" let &cpo = s:cpo_save unlet s:cpo_save -" vim: ts=8 + +" vim: nowrap sw=2 sts=2 ts=8 noet fdm=marker: diff --git a/syntax/basic/literal.vim b/syntax/basic/literal.vim index 81bbef96..de71af92 100644 --- a/syntax/basic/literal.vim +++ b/syntax/basic/literal.vim @@ -13,9 +13,11 @@ syntax region typescriptTemplateSubstitution matchgroup=typescriptTemplateSB \ contained -syntax region typescriptString +syntax region typescriptString \ start=+\z(["']\)+ skip=+\\\%(\z1\|$\)+ end=+\z1+ end=+$+ \ contains=typescriptSpecial,@Spell + \ nextgroup=@typescriptSymbols + \ skipwhite skipempty \ extend syntax match typescriptSpecial contained "\v\\%(x\x\x|u%(\x{4}|\{\x{1,6}})|c\u|.)" @@ -42,4 +44,4 @@ syntax match typescriptNumber /\<0[bB][01][01_]*\>/ nextgroup=@typescript syntax match typescriptNumber /\<0[oO][0-7][0-7_]*\>/ nextgroup=@typescriptSymbols skipwhite skipempty syntax match typescriptNumber /\<0[xX][0-9a-fA-F][0-9a-fA-F_]*\>/ nextgroup=@typescriptSymbols skipwhite skipempty syntax match typescriptNumber /\<\%(\d[0-9_]*\%(\.\d[0-9_]*\)\=\|\.\d[0-9_]*\)\%([eE][+-]\=\d[0-9_]*\)\=\>/ - \ nextgroup=typescriptSymbols skipwhite skipempty + \ nextgroup=@typescriptSymbols skipwhite skipempty diff --git a/syntax/basic/type.vim b/syntax/basic/type.vim index 770d3e0d..590dda1a 100644 --- a/syntax/basic/type.vim +++ b/syntax/basic/type.vim @@ -132,7 +132,7 @@ syntax region typescriptGenericFunc matchgroup=typescriptTypeBrackets \ contained skipwhite skipnl syntax region typescriptFuncType matchgroup=typescriptParens - \ start=/(/ end=/)\s*=>/me=e-2 + \ start=/(\(\k\+:\|)\)\@=/ end=/)\s*=>/me=e-2 \ contains=@typescriptParameterList \ nextgroup=typescriptFuncTypeArrow \ contained skipwhite skipnl oneline @@ -142,7 +142,6 @@ syntax match typescriptFuncTypeArrow /=>/ \ containedin=typescriptFuncType \ contained skipwhite skipnl - syntax keyword typescriptConstructorType new \ nextgroup=@typescriptFunctionType \ contained skipwhite skipnl diff --git a/syntax/c.vim b/syntax/c.vim index cb52a22f..a11a95a2 100644 --- a/syntax/c.vim +++ b/syntax/c.vim @@ -5,7 +5,7 @@ endif " Vim syntax file " Language: C " Maintainer: Bram Moolenaar -" Last Change: 2019 Nov 29 +" Last Change: 2021 Jan 11 " Quit when a (custom) syntax file was already loaded if exists("b:current_syntax") @@ -17,6 +17,9 @@ set cpo&vim let s:ft = matchstr(&ft, '^\([^.]\)\+') +" check if this was included from cpp.vim +let s:in_cpp_family = exists("b:filetype_in_cpp_family") + " Optional embedded Autodoc parsing " To enable it add: let g:c_autodoc = 1 " to your .vimrc @@ -59,7 +62,7 @@ if !exists("c_no_cformat") endif " cCppString: same as cString, but ends at end of line -if s:ft ==# "cpp" && !exists("cpp_no_cpp11") && !exists("c_no_cformat") +if s:in_cpp_family && !exists("cpp_no_cpp11") && !exists("c_no_cformat") " ISO C++11 syn region cString start=+\(L\|u\|u8\|U\|R\|LR\|u8R\|uR\|UR\)\="+ skip=+\\\\\|\\"+ end=+"+ contains=cSpecial,cFormat,@Spell extend syn region cCppString start=+\(L\|u\|u8\|U\|R\|LR\|u8R\|uR\|UR\)\="+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"+ end='$' contains=cSpecial,cFormat,@Spell @@ -91,7 +94,7 @@ syn match cSpecialCharacter display "L\='\\\o\{1,3}'" syn match cSpecialCharacter display "'\\x\x\{1,2}'" syn match cSpecialCharacter display "L'\\x\x\+'" -if (s:ft ==# "c" && !exists("c_no_c11")) || (s:ft ==# "cpp" && !exists("cpp_no_cpp11")) +if (s:ft ==# "c" && !exists("c_no_c11")) || (s:in_cpp_family && !exists("cpp_no_cpp11")) " ISO C11 or ISO C++ 11 if exists("c_no_cformat") syn region cString start=+\%(U\|u8\=\)"+ skip=+\\\\\|\\"+ end=+"+ contains=cSpecial,@Spell extend @@ -134,7 +137,7 @@ endif " But avoid matching <::. syn cluster cParenGroup contains=cParenError,cIncluded,cSpecial,cCommentSkip,cCommentString,cComment2String,@cCommentGroup,cCommentStartError,cUserLabel,cBitField,cOctalZero,@cCppOutInGroup,cFormat,cNumber,cFloat,cOctal,cOctalError,cNumbersCom if exists("c_no_curly_error") - if s:ft ==# 'cpp' && !exists("cpp_no_cpp11") + if s:in_cpp_family && !exists("cpp_no_cpp11") syn region cParen transparent start='(' end=')' contains=ALLBUT,@cParenGroup,cCppParen,@cStringGroup,@Spell " cCppParen: same as cParen but ends at end-of-line; used in cDefine syn region cCppParen transparent start='(' skip='\\$' excludenl end=')' end='$' contained contains=ALLBUT,@cParenGroup,cParen,cString,@Spell @@ -148,7 +151,7 @@ if exists("c_no_curly_error") syn match cErrInParen display contained "^[{}]\|^<%\|^%>" endif elseif exists("c_no_bracket_error") - if s:ft ==# 'cpp' && !exists("cpp_no_cpp11") + if s:in_cpp_family && !exists("cpp_no_cpp11") syn region cParen transparent start='(' end=')' contains=ALLBUT,@cParenGroup,cCppParen,@cStringGroup,@Spell " cCppParen: same as cParen but ends at end-of-line; used in cDefine syn region cCppParen transparent start='(' skip='\\$' excludenl end=')' end='$' contained contains=ALLBUT,@cParenGroup,cParen,cString,@Spell @@ -162,7 +165,7 @@ elseif exists("c_no_bracket_error") syn match cErrInParen display contained "[{}]\|<%\|%>" endif else - if s:ft ==# 'cpp' && !exists("cpp_no_cpp11") + if s:in_cpp_family && !exists("cpp_no_cpp11") syn region cParen transparent start='(' end=')' contains=ALLBUT,@cParenGroup,cCppParen,cErrInBracket,cCppBracket,@cStringGroup,@Spell " cCppParen: same as cParen but ends at end-of-line; used in cDefine syn region cCppParen transparent start='(' skip='\\$' excludenl end=')' end='$' contained contains=ALLBUT,@cParenGroup,cErrInBracket,cParen,cBracket,cString,@Spell @@ -276,12 +279,13 @@ if exists("c_gnu") syn keyword cType __label__ __complex__ __volatile__ endif -syn keyword cStructure struct union enum typedef +syn keyword cTypedef typedef +syn keyword cStructure struct union enum syn keyword cStorageClass static register auto volatile extern const if exists("c_gnu") syn keyword cStorageClass inline __attribute__ endif -if !exists("c_no_c99") && s:ft !=# 'cpp' +if !exists("c_no_c99") && !s:in_cpp_family syn keyword cStorageClass inline restrict endif if !exists("c_no_c11") @@ -315,8 +319,7 @@ if !exists("c_no_ansi") || exists("c_ansi_constants") || exists("c_gnu") if exists("c_gnu") syn keyword cConstant __GNUC__ __FUNCTION__ __PRETTY_FUNCTION__ __func__ endif - syn keyword cConstant __LINE__ __FILE__ __DATE__ __TIME__ __STDC__ - syn keyword cConstant __STDC_VERSION__ + syn keyword cConstant __LINE__ __FILE__ __DATE__ __TIME__ __STDC__ __STDC_VERSION__ __STDC_HOSTED__ syn keyword cConstant CHAR_BIT MB_LEN_MAX MB_CUR_MAX syn keyword cConstant UCHAR_MAX UINT_MAX ULONG_MAX USHRT_MAX syn keyword cConstant CHAR_MIN INT_MIN LONG_MIN SHRT_MIN @@ -350,6 +353,8 @@ if !exists("c_no_ansi") || exists("c_ansi_constants") || exists("c_gnu") syn keyword cConstant SIGSTOP SIGTERM SIGTRAP SIGTSTP SIGTTIN SIGTTOU SIGUSR1 SIGUSR2 syn keyword cConstant _IOFBF _IOLBF _IONBF BUFSIZ EOF WEOF FOPEN_MAX FILENAME_MAX L_tmpnam syn keyword cConstant SEEK_CUR SEEK_END SEEK_SET TMP_MAX stderr stdin stdout EXIT_FAILURE EXIT_SUCCESS RAND_MAX + " used in assert.h + syn keyword cConstant NDEBUG " POSIX 2001 syn keyword cConstant SIGBUS SIGPOLL SIGPROF SIGSYS SIGURG SIGVTALRM SIGXCPU SIGXFSZ " non-POSIX signals @@ -422,7 +427,7 @@ endif syn cluster cLabelGroup contains=cUserLabel syn match cUserCont display "^\s*\zs\I\i*\s*:$" contains=@cLabelGroup syn match cUserCont display ";\s*\zs\I\i*\s*:$" contains=@cLabelGroup -if s:ft ==# 'cpp' +if s:in_cpp_family syn match cUserCont display "^\s*\zs\%(class\|struct\|enum\)\@!\I\i*\s*:[^:]"me=e-1 contains=@cLabelGroup syn match cUserCont display ";\s*\zs\%(class\|struct\|enum\)\@!\I\i*\s*:[^:]"me=e-1 contains=@cLabelGroup else @@ -479,6 +484,7 @@ hi def link cSpecialError cError hi def link cCurlyError cError hi def link cOperator Operator hi def link cStructure Structure +hi def link cTypedef Structure hi def link cStorageClass StorageClass hi def link cInclude Include hi def link cPreProc PreProc diff --git a/syntax/cabal-1.vim b/syntax/cabal-1.vim index c473800a..e7a892a3 100644 --- a/syntax/cabal-1.vim +++ b/syntax/cabal-1.vim @@ -25,7 +25,7 @@ syn match cabalDocBulletPoint "^\s\+\*" syn match cabalDocHeadline "^\s\+=.*$" syn match cabalDocCode "^\s\+>.*$" syn match cabalDocNewline "^\s\+\.\s*$" -syn match cabalSection "^\c\(executable\|library\|flag\|source-repository\|test-suite\|benchmark\)" +syn match cabalSection "^\c\(executable\|library\|flag\|source-repository\|test-suite\|benchmark\|common\)" syn match cabalEntry "^\s*[A-Za-z][a-zA-Z\-]*:" contains=cabalIdentifier,cabalColon syn region cabalDescription start="^\s*[dD]escription:" end="^\<" keepend diff --git a/syntax/carp.vim b/syntax/carp.vim index a3f11c66..849c3247 100644 --- a/syntax/carp.vim +++ b/syntax/carp.vim @@ -33,6 +33,7 @@ syn keyword carpSyntax str* println* break doc sig hidden private syn keyword carpSyntax while-do const-assert save-docs defproject syn keyword carpSyntax relative-include not-on-windows load-and-use syn keyword carpSyntax deftest +syn keyword carpSyntax quasiquote unquote unquote-splicing syn match carpSyntax "\vc(a|d){1,4}r" syn keyword carpFunc λ @@ -55,7 +56,7 @@ syn keyword carpFunc string-join free sleep-seconds sleep-micros substitute syn keyword carpFunc neg to-float match matches? find global-match match-str syn keyword carpFunc from-float tan asin atan cosh sinh tanh exp frexp ldexp syn keyword carpFunc log log10 modf pow ceil clamp approx refstr foreach -syn keyword carpFunc => ==> repeat nth replicate range raw aset aset! +syn keyword carpFunc -> --> => ==> repeat nth replicate range raw aset aset! syn keyword carpFunc push-back pop-back sort index-of element-count syn keyword carpFunc apply unsafe-from from just? nothing? ptr from-ptr syn keyword carpFunc map and-then unwrap-or-zero or-else unwrap-or-else @@ -126,6 +127,13 @@ syn match carpComment /;.*$/ contains=@Spell syn region carpQuoted matchgroup=Delimiter start="#['`]"rs=s+2 end=![ \t()\[\]";]!re=e-1,me=e-1 contains=@carpQuotedStuff,@carpQuotedOrNormal syn region carpQuoted matchgroup=Delimiter start="#['`]("rs=s+3 matchgroup=Delimiter end=")"re=e-1 contains=@carpQuotedStuff,@carpQuotedOrNormal +syn region carpUnquote matchgroup=Delimiter start="%"rs=s+1 end=![ \t\[\]()";]!re=e-1,me=e-1 contained contains=@carpNormal +syn region carpUnquote matchgroup=Delimiter start="%@"rs=s+2 end=![ \t\[\]()";]!re=e-1,me=e-1 contained contains=@carpNormal +syn region carpUnquote matchgroup=Delimiter start="%@("rs=s+2 end=")"re=e-1 contained contains=@carpNormal +syn region carpUnquote matchgroup=Delimiter start="%("rs=s+2 end=")"re=e-1 contained contains=@carpNormal + +syn cluster carpQuotedStuff add=carpUnquote + syn cluster carpNormal add=carpQuoted,carpComment syn cluster carpQuotedOrNormal add=carpComment diff --git a/syntax/cpp.vim b/syntax/cpp.vim index 0fd0acc2..a31f3416 100644 --- a/syntax/cpp.vim +++ b/syntax/cpp.vim @@ -6,13 +6,16 @@ endif " Language: C++ " Current Maintainer: vim-jp (https://github.com/vim-jp/vim-cpp) " Previous Maintainer: Ken Shan -" Last Change: 2017 Jun 05 +" Last Change: 2021 Jan 12 " quit when a syntax file was already loaded if exists("b:current_syntax") finish endif +" inform C syntax that the file was included from cpp.vim +let b:filetype_in_cpp_family = 1 + " Read the C syntax to start with runtime! syntax/c.vim unlet b:current_syntax @@ -59,12 +62,6 @@ if !exists("cpp_no_cpp14") syn case match endif -" C++ 17 extensions -if !exists("cpp_no_cpp17") - syn match cppCast "\]?" diff --git a/syntax/crystal.vim b/syntax/crystal.vim index a776e59b..ea862acd 100644 --- a/syntax/crystal.vim +++ b/syntax/crystal.vim @@ -95,8 +95,6 @@ syn match crystalStringEscape "\%(\\M-\\C-\|\\C-\\M-\|\\M-\\c\|\\c\\M-\|\\c\|\\C syn region crystalInterpolation matchgroup=crystalInterpolationDelim start="#{" end="}" contained contains=TOP syn region crystalNoInterpolation start="\\#{" end="}" contained syn match crystalNoInterpolation "\\#{" display contained -syn match crystalNoInterpolation "\\#\%(\$\|@@\=\)\w\+" display contained -syn match crystalNoInterpolation "\\#\$\W" display contained syn match crystalDelimEscape "\\[(<{\[)>}\]]" transparent display contained contains=NONE @@ -261,10 +259,10 @@ syn cluster crystalDeclaration contains=crystalAliasDeclaration,crystalAliasDecl " Note: the following keywords have already been defined: " begin case class def do end for if module unless until while syn match crystalControl "\<\%(break\|next\|rescue\|return\)\>[?!]\@!" -syn match crystalKeyword "\<\%(super\|previous_def\|yield\|of\|with\|uninitialized\|union\)\>[?!]\@!" +syn match crystalKeyword "\<\%(super\|previous_def\|yield\|of\|with\|uninitialized\|union\|out\)\>[?!]\@!" syn match crystalBoolean "\<\%(true\|false\)\>[?!]\@!" syn match crystalPseudoVariable "\<\%(nil\|__DIR__\|__FILE__\|__LINE__\|__END_LINE__\)\>[?!]\@!" " TODO: reorganise -syn match crystalPseudoVariable "\" +syn match crystalPseudoVariable "\[?!]\@!" " Expensive Mode - match 'end' with the appropriate opening keyword for syntax " based folding and special highlighting of module/class/method definitions diff --git a/syntax/embeddedpuppet.vim b/syntax/embeddedpuppet.vim deleted file mode 100644 index dad9e1fb..00000000 --- a/syntax/embeddedpuppet.vim +++ /dev/null @@ -1,33 +0,0 @@ -if polyglot#init#is_disabled(expand(':p'), 'puppet', 'syntax/embeddedpuppet.vim') - finish -endif - -" Vim syntax plugin -" Language: embedded puppet -" Maintainer: Gabriel Filion -" URL: https://github.com/rodjek/vim-puppet -" Last Change: 2019-09-01 - -" quit when a syntax file was already loaded {{{1 -if exists("b:current_syntax") - finish -endif - -runtime! syntax/sh.vim -unlet! b:current_syntax - -syn include @puppetTop syntax/puppet.vim - -syn cluster ePuppetRegions contains=ePuppetBlock,ePuppetExpression,ePuppetComment - -syn region ePuppetBlock matchgroup=ePuppetDelimiter start="<%%\@!-\=" end="[=-]\=%\@" contains=@puppetTop containedin=ALLBUT,@ePuppetRegions keepend -syn region ePuppetExpression matchgroup=ePuppetDelimiter start="<%=\{1,4}" end="[=-]\=%\@" contains=@puppetTop containedin=ALLBUT,@ePuppetRegions keepend -syn region ePuppetComment matchgroup=ePuppetDelimiter start="<%-\=#" end="[=-]\=%\@" contains=puppetTodo,@Spell containedin=ALLBUT,@ePuppetRegions keepend - -" Define the default highlighting. - -hi def link ePuppetDelimiter PreProc -hi def link ePuppetComment Comment - -let b:current_syntax = "embeddedpuppet" - diff --git a/syntax/epuppet.vim b/syntax/epuppet.vim new file mode 100644 index 00000000..61c70d21 --- /dev/null +++ b/syntax/epuppet.vim @@ -0,0 +1,33 @@ +if polyglot#init#is_disabled(expand(':p'), 'puppet', 'syntax/epuppet.vim') + finish +endif + +" Vim syntax plugin +" Language: embedded puppet +" Maintainer: Gabriel Filion +" URL: https://github.com/rodjek/vim-puppet +" Last Change: 2019-09-01 + +" quit when a syntax file was already loaded {{{1 +if exists("b:current_syntax") + finish +endif + +runtime! syntax/sh.vim +unlet! b:current_syntax + +syn include @puppetTop syntax/puppet.vim + +syn cluster ePuppetRegions contains=ePuppetBlock,ePuppetExpression,ePuppetComment + +syn region ePuppetBlock matchgroup=ePuppetDelimiter start="<%%\@!-\=" end="[=-]\=%\@" contains=@puppetTop containedin=ALLBUT,@ePuppetRegions keepend +syn region ePuppetExpression matchgroup=ePuppetDelimiter start="<%=\{1,4}" end="[=-]\=%\@" contains=@puppetTop containedin=ALLBUT,@ePuppetRegions keepend +syn region ePuppetComment matchgroup=ePuppetDelimiter start="<%-\=#" end="[=-]\=%\@" contains=puppetTodo,@Spell containedin=ALLBUT,@ePuppetRegions keepend + +" Define the default highlighting. + +hi def link ePuppetDelimiter PreProc +hi def link ePuppetComment Comment + +let b:current_syntax = "epuppet" + diff --git a/syntax/groovy.vim b/syntax/groovy.vim index fdadca90..87fc89df 100644 --- a/syntax/groovy.vim +++ b/syntax/groovy.vim @@ -6,9 +6,9 @@ endif " Language: Groovy " Original Author: Alessio Pace " Maintainer: Tobias Rapp -" Version: 0.1.17 +" Version: 0.1.18 " URL: http://www.vim.org/scripts/script.php?script_id=945 -" Last Change: 2020 May 26 +" Last Change: 2021 Feb 03 " THE ORIGINAL AUTHOR'S NOTES: " @@ -257,7 +257,8 @@ if exists("groovy_regex_strings") 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 +" Fix: force use of the NFA regexp engine (2), see GitHub issue #7280 +syn match groovyELExpr /\%#=2\$[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 diff --git a/syntax/haskell.vim b/syntax/haskell.vim index 52c33190..efe30323 100644 --- a/syntax/haskell.vim +++ b/syntax/haskell.vim @@ -40,7 +40,12 @@ syn match haskellTypeSig \ haskellParens syn keyword haskellWhere where syn keyword haskellLet let -syn match HaskellDerive "\\(\s\+\<\(anyclass\|instance\|newtype\|stock\)\>\)\?" +syn keyword haskellDeriveKeyword deriving anyclass instance newtype stock via contained +syn match haskellDerive "deriving\(\s\+instance\)\?\(\s\+anyclass\|\s\+newtype\|\s\+stock\|\s\+.\{-}\_s\+via\)\?" + \ contains= + \ haskellDeriveKeyword, + \ haskellParens, + \ haskellType syn keyword haskellDeclKeyword module class instance newtype in syn match haskellDecl "\<\(type\|data\)\>\s\+\(\\)\?" syn keyword haskellDefault default @@ -67,8 +72,8 @@ if get(g:, 'haskell_enable_static_pointers', 0) syn keyword haskellStatic static endif syn keyword haskellConditional if then else -syn match haskellNumber "\<[0-9]\+\>\|\<0[xX][0-9a-fA-F]\+\>\|\<0[oO][0-7]\+\>\|\<0[bB][10]\+\>" -syn match haskellFloat "\<[0-9]\+\.[0-9]\+\([eE][-+]\=[0-9]\+\)\=\>" +syn match haskellNumber "\<[0-9]\+\>\|\<[0-9_]\+\>\|\<0[xX][0-9a-fA-F_]\+\>\|\<0[oO][0-7_]\+\>\|\<0[bB][10_]\+\>" +syn match haskellFloat "\<[0-9]\+\.[0-9_]\+\([eE][-+]\=[0-9_]\+\)\=\>" syn match haskellSeparator "[,;]" syn region haskellParens matchgroup=haskellDelimiter start="(" end=")" contains=TOP,haskellTypeSig,@Spell syn region haskellBrackets matchgroup=haskellDelimiter start="\[" end="]" contains=TOP,haskellTypeSig,@Spell @@ -94,7 +99,7 @@ syn match haskellLineComment "---*\([^-!#$%&\*\+./<=>\?@\\^|~].*\)\?$" syn match haskellBacktick "`[A-Za-z_][A-Za-z0-9_\.']*#\?`" syn region haskellString start=+"+ skip=+\\\\\|\\"+ end=+"+ \ contains=@Spell -syn match haskellIdentifier "[_a-z][a-zA-z0-9_']*" contained +syn match haskellIdentifier "[_a-z][a-zA-Z0-9_']*" contained syn match haskellChar "\<'[^'\\]'\|'\\.'\|'\\u[0-9a-fA-F]\{4}'\>" syn match haskellType "\<[A-Z][a-zA-Z0-9_']*\>" syn region haskellBlockComment start="{-" end="-}" @@ -110,7 +115,7 @@ syn keyword haskellTodo TODO FIXME contained syn match haskellShebang "\%^#!.*$" if !get(g:, 'haskell_disable_TH', 0) syn match haskellQuasiQuoted "." containedin=haskellQuasiQuote contained - syn region haskellQuasiQuote matchgroup=haskellTH start="\[[_a-zA-Z][a-zA-z0-9._']*|" end="|\]" + syn region haskellQuasiQuote matchgroup=haskellTH start="\[[_a-zA-Z][a-zA-Z0-9._']*|" end="|\]" syn region haskellTHBlock matchgroup=haskellTH start="\[\(d\|t\|p\)\?|" end="|]" contains=TOP syn region haskellTHDoubleBlock matchgroup=haskellTH start="\[||" end="||]" contains=TOP endif @@ -165,13 +170,13 @@ highlight def link haskellType Type highlight def link haskellImportKeywords Include if get(g:, 'haskell_classic_highlighting', 0) highlight def link haskellDeclKeyword Keyword - highlight def link HaskellDerive Keyword + highlight def link haskellDeriveKeyword Keyword highlight def link haskellDecl Keyword highlight def link haskellWhere Keyword highlight def link haskellLet Keyword else highlight def link haskellDeclKeyword Structure - highlight def link HaskellDerive Structure + highlight def link haskellDeriveKeyword Structure highlight def link haskellDecl Structure highlight def link haskellWhere Structure highlight def link haskellLet Structure diff --git a/syntax/html.vim b/syntax/html.vim index c823d362..2113f12a 100644 --- a/syntax/html.vim +++ b/syntax/html.vim @@ -4,11 +4,11 @@ endif " Vim syntax file " Language: HTML -" Maintainer: Jorge Maldonado Ventura +" Previous Maintainer: Jorge Maldonado Ventura " Previous Maintainer: Claudio Fleiner " Repository: https://notabug.org/jorgesumle/vim-html-syntax -" Last Change: 2020 Mar 17 -" Included patch from Florian Breisch to add the summary element +" Last Change: 2021 Feb 25 +" Included patch #7900 to fix comments " " Please check :help html.vim for some comments and a description of the options @@ -145,9 +145,21 @@ syn match htmlSpecialChar "&#\=[0-9A-Za-z]\{1,8};" if exists("html_wrong_comments") syn region htmlComment start=+ and are parser errors; browser treats as comments + syn match htmlComment " closes comment + " Idem 8.2.4.52: closing comment by dash-dash-bang (--!>) is error ignored by parser(!); closes comment + syn region htmlCommentPart contained start=+--+ end=+--!\?>+me=e-1 contains=htmlCommentNested,@htmlPreProc,@Spell + " Idem 8.2.4.49: opening nested comment is all right + syn match htmlCommentNested contained ""me=e-3 + syn match htmlCommentNested contained "