From f2ef4cedecf554c0c9f0694f93df1d53a57bf70c Mon Sep 17 00:00:00 2001 From: Adam Stankiewicz Date: Tue, 1 Sep 2020 23:02:36 +0200 Subject: [PATCH 001/299] Fix reason filetype detection, closes #532 --- autoload/polyglot.vim | 10 ++++++++++ ftdetect/polyglot.vim | 12 ++++++------ heuristics.yaml | 8 ++++++++ packages.yaml | 1 + scripts/build | 14 +++++++++++--- scripts/test_extensions.vim | 7 +++++++ scripts/test_filetypes.vim | 2 +- 7 files changed, 44 insertions(+), 10 deletions(-) diff --git a/autoload/polyglot.vim b/autoload/polyglot.vim index 7d5aa8676..3753dc8e4 100644 --- a/autoload/polyglot.vim +++ b/autoload/polyglot.vim @@ -202,6 +202,16 @@ func! polyglot#DetectFsFiletype() setf forth | return endfunc +func! polyglot#DetectReFiletype() + for lnum in range(1, min([line("$"), 50])) + let line = getline(lnum) + if line =~# '^\s*#\%(\%(if\|ifdef\|define\|pragma\)\s\+\w\|\s*include\s\+[<"]\|template\s*<\)' + setf cpp | return + endif + setf reason | return + endfor +endfunc + " Restore 'cpoptions' let &cpo = s:cpo_save unlet s:cpo_save diff --git a/ftdetect/polyglot.vim b/ftdetect/polyglot.vim index 974aa9246..9e86a7ad7 100644 --- a/ftdetect/polyglot.vim +++ b/ftdetect/polyglot.vim @@ -218,6 +218,11 @@ if !has_key(s:disabled_packages, 'awk') au BufNewFile,BufRead *.awk setf awk endif +if !has_key(s:disabled_packages, 'reason') + au BufNewFile,BufRead *.rei setf reason + au! BufNewFile,BufRead *.re call polyglot#DetectReFiletype() +endif + if !has_key(s:disabled_packages, 'c/c++') au BufNewFile,BufRead *.c setf c au BufNewFile,BufRead *.cats setf c @@ -237,9 +242,9 @@ if !has_key(s:disabled_packages, 'c/c++') au BufNewFile,BufRead *.inl setf cpp au BufNewFile,BufRead *.ino setf cpp au BufNewFile,BufRead *.ipp setf cpp - au BufNewFile,BufRead *.re setf cpp au BufNewFile,BufRead *.tcc setf cpp au BufNewFile,BufRead *.tpp setf cpp + au! BufNewFile,BufRead *.re call polyglot#DetectReFiletype() endif if !has_key(s:disabled_packages, 'caddyfile') @@ -1045,11 +1050,6 @@ if !has_key(s:disabled_packages, 'razor') au BufNewFile,BufRead *.razor setf razor endif -if !has_key(s:disabled_packages, 'reason') - au BufNewFile,BufRead *.re setf reason - au BufNewFile,BufRead *.rei setf reason -endif - if !has_key(s:disabled_packages, 'rst') au BufNewFile,BufRead *.rest setf rst au BufNewFile,BufRead *.rest.txt setf rst diff --git a/heuristics.yaml b/heuristics.yaml index 28dff4ce6..97999022b 100644 --- a/heuristics.yaml +++ b/heuristics.yaml @@ -55,3 +55,11 @@ rules: filetype: glsl - override: "g:filetype_fs" - filetype: forth +--- +extensions: [re] +rules: +- lines: 50 + rules: + - pattern: '^\s*#(?:(?:if|ifdef|define|pragma)\s+\w|\s*include\s+[<"]|template\s*<)' + filetype: cpp + - filetype: reason diff --git a/packages.yaml b/packages.yaml index 234891873..d4042c5ef 100644 --- a/packages.yaml +++ b/packages.yaml @@ -1276,6 +1276,7 @@ filetypes: --- name: reason remote: reasonml-editor/vim-reason-plus +after: c/c++ filetypes: - name: reason linguist: Reason diff --git a/scripts/build b/scripts/build index 384c8423e..1fe148e7e 100755 --- a/scripts/build +++ b/scripts/build @@ -202,9 +202,17 @@ def indent(str, amount) end def pattern_to_condition(rule) + if rule.has_key?("or") + return rule["or"].map { |p| pattern_to_condition(p) }.join(" || ") + end + + if rule.has_key?("or") + return rule["and"].map { |p| pattern_to_condition(p) }.join(" && ") + end + operator = (rule["negative"] ? "!" : "=") + "~" + (rule["ignore_case"] ? "?" : "#") - "line #{operator} '#{rule["pattern"]}'" + return "line #{operator} '#{rule["pattern"]}'" end def rules_to_code(rules) @@ -250,10 +258,10 @@ def rule_to_code(rule) return rule["rules"].map { |r| indent(rule_to_code(r), 0) }.join("\n") end - if rule.has_key?("pattern") + if rule.has_key?("pattern") || rule.has_key?("or") || rule.has_key?("and") return <<~EOS if #{pattern_to_condition(rule)} - #{indent(rule_to_code(except(rule, "pattern", "ignore_case", "negative")), 2)} + #{indent(rule_to_code(except(rule, "pattern", "or", "and", "ignore_case", "negative")), 2)} endif EOS end diff --git a/scripts/test_extensions.vim b/scripts/test_extensions.vim index cb52bef8c..dfe2f3a33 100644 --- a/scripts/test_extensions.vim +++ b/scripts/test_extensions.vim @@ -207,3 +207,10 @@ call TestExtension('fsharp', 'fsharp.fs', "let myInt = 5") call TestExtension('glsl', 'glsl.fs', "//#version 120\nvoid main() {}") let g:filetype_fs = 'fizfuz' call TestExtension('fizfuz', 'fizfuz.fs', '') + +" .re extension +call TestExtension('reason', 'empty.re', '') +call TestExtension('cpp', 'cpp.re', '#include "config.h"') +call TestExtension('cpp', 'cpp2.re', '#ifdef HAVE_CONFIG_H') +call TestExtension('cpp', 'cpp3.re', '#define YYCTYPE unsigned char') +call TestExtension('reason', 'react.re', 'ReasonReact.Router.push("");') diff --git a/scripts/test_filetypes.vim b/scripts/test_filetypes.vim index 86e2ff36d..d0bec4ccb 100644 --- a/scripts/test_filetypes.vim +++ b/scripts/test_filetypes.vim @@ -44,6 +44,7 @@ call TestFiletype('atlas') call TestFiletype('autoit') call TestFiletype('ave') call TestFiletype('awk') +call TestFiletype('reason') call TestFiletype('c') call TestFiletype('cpp') call TestFiletype('caddyfile') @@ -175,7 +176,6 @@ call TestFiletype('ragel') call TestFiletype('raku') call TestFiletype('raml') call TestFiletype('razor') -call TestFiletype('reason') call TestFiletype('rst') call TestFiletype('ruby') call TestFiletype('eruby') From 63119f09d1390b61155cc0dc3ff497356d2fc7e5 Mon Sep 17 00:00:00 2001 From: Adam Stankiewicz Date: Tue, 1 Sep 2020 23:38:17 +0200 Subject: [PATCH 002/299] Automatically detect indentation, closes #529 --- README.md | 2 +- autoload/sleuth.vim | 221 ++++++++++++++++++++++++++++++++++++++++++++ plugin/sleuth.vim | 164 ++++++++++++++++++++++++++++++++ scripts/build | 34 +++++++ 4 files changed, 420 insertions(+), 1 deletion(-) create mode 100644 autoload/sleuth.vim create mode 100644 plugin/sleuth.vim diff --git a/README.md b/README.md index 7424431cc..f53acd5f0 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ A collection of language packs for Vim. - It is more secure because scripts loaded for all extensions are generated by vim-polyglot (ftdetect). - Solid syntax and indentation support (other features skipped). Only the best language packs. - All unnecessary files are ignored (like enormous documentation from php support). -- No support for esoteric languages, only most popular ones (modern too, like `slim`). +- Automatically detect indentation (includes performance-optimized version of [vim-sleuth](https://github.com/tpope/vim-sleuth)) - Each build is tested by automated vimrunner script on CI. See `spec` directory. \*To be completely honest, optimized `ftdetect` script takes around `19ms` to load. diff --git a/autoload/sleuth.vim b/autoload/sleuth.vim new file mode 100644 index 000000000..1c9fbefbd --- /dev/null +++ b/autoload/sleuth.vim @@ -0,0 +1,221 @@ +let s:globs = { + \ '8th': '{*.8th,}', + \ 'Dockerfile': '{*.dockerfile,*.dock,*.Dockerfile,Dockerfile,dockerfile,Dockerfile*,}', + \ 'Jenkinsfile': '{*.jenkinsfile,*.Jenkinsfile,Jenkinsfile,Jenkinsfile*,}', + \ 'a2ps': '{a2psrc,.a2psrc,}', + \ 'a65': '{*.a65,}', + \ 'aap': '{*.aap,}', + \ 'abap': '{*.abap,}', + \ 'abaqus': '{*.inp,}', + \ 'abc': '{*.abc,}', + \ 'abel': '{*.abl,}', + \ 'acedb': '{*.wrm,}', + \ 'ada': '{*.adb,*.ads,*.ada,*.gpr,}', + \ 'ahdl': '{*.tdf,}', + \ 'aidl': '{*.aidl,}', + \ 'alsaconf': '{.asoundrc,}', + \ 'aml': '{*.aml,}', + \ 'ampl': '{*.run,}', + \ 'ant': '{build.xml,}', + \ 'apache': '{.htaccess,}', + \ 'apiblueprint': '{*.apib,}', + \ 'applescript': '{*.applescript,*.scpt,}', + \ 'aptconf': '{apt.conf,}', + \ 'arch': '{.arch-inventory,=tagging-method,}', + \ 'arduino': '{*.pde,*.ino,}', + \ 'art': '{*.art,}', + \ 'asciidoc': '{*.asciidoc,*.adoc,*.asc,}', + \ 'asl': '{*.asl,*.dsl,}', + \ 'asn': '{*.asn,*.asn1,}', + \ 'aspperl': '{*.asp,}', + \ 'aspvbs': '{*.asa,*.asp,}', + \ 'atlas': '{*.atl,*.as,}', + \ 'autohotkey': '{*.ahk,*.ahkl,}', + \ 'autoit': '{*.au3,}', + \ 'automake': '{[Mm]akefile.am,GNUmakefile.am,}', + \ 'ave': '{*.ave,}', + \ 'awk': '{*.awk,}', + \ 'blade': '{*.blade,*.blade.php,}', + \ 'brewfile': '{Brewfile,}', + \ 'c': '{*.c,*.cats,*.h,*.idc,}', + \ 'caddyfile': '{Caddyfile,}', + \ 'carp': '{*.carp,}', + \ 'clojure': '{*.clj,*.boot,*.cl2,*.cljc,*.cljs,*.cljs.hl,*.cljscm,*.cljx,*.hic,*.edn,riemann.config,build.boot,profile.boot,}', + \ 'cmake': '{*.cmake,*.cmake.in,CMakeLists.txt,}', + \ 'coffee': '{*.coffee,*._coffee,*.cake,*.cjsx,*.iced,*.coffeekup,Cakefile,}', + \ 'cpp': '{*.cpp,*.c++,*.cc,*.cp,*.cxx,*.h,*.h++,*.hh,*.hpp,*.hxx,*.inc,*.inl,*.ino,*.ipp,*.re,*.tcc,*.tpp,}', + \ 'cql': '{*.cql,}', + \ 'cryptol': '{*.cry,*.cyl,*.lcry,*.lcyl,}', + \ 'crystal': '{*.cr,Projectfile,}', + \ 'csv': '{*.csv,*.tsv,*.tab,}', + \ 'cucumber': '{*.feature,*.story,}', + \ 'cuesheet': '{*.cue,}', + \ 'd': '{*.d,*.di,}', + \ 'dart': '{*.dart,}', + \ 'dcov': '{*.lst,}', + \ 'dd': '{*.dd,}', + \ 'ddoc': '{*.ddoc,}', + \ 'dhall': '{*.dhall,}', + \ 'dosini': '{*.wrap,}', + \ 'dsdl': '{*.sdl,}', + \ 'dune': '{jbuild,dune,dune-project,dune-workspace,}', + \ 'ecrystal': '{*.ecr,}', + \ 'eelixir': '{*.eex,*.leex,}', + \ 'elf': '{*.am,}', + \ 'elixir': '{*.ex,*.exs,mix.lock,}', + \ 'elm': '{*.elm,}', + \ 'embeddedpuppet': '{*.epp,}', + \ 'ember-script': '{*.em,*.emberscript,}', + \ 'emblem': '{*.emblem,*.em,}', + \ 'erlang': '{*.erl,*.app.src,*.es,*.escript,*.hrl,*.xrl,*.yrl,*.app,*.yaws,Emakefile,rebar.config,rebar.config.lock,rebar.lock,}', + \ 'eruby': '{*.erb,*.erb.deface,*.rhtml,}', + \ 'fbs': '{*.fbs,}', + \ 'fennel': '{*.fnl,}', + \ 'ferm': '{*.ferm,ferm.conf,}', + \ 'fish': '{*.fish,}', + \ 'flow': '{*.flow,}', + \ 'forth': '{*.fs,*.ft,*.fth,}', + \ 'fsharp': '{*.fs,*.fsi,*.fsx,}', + \ 'gdscript3': '{*.gd,}', + \ 'gitcommit': '{,}', + \ 'gitconfig': '{*.gitconfig,.gitconfig,.gitmodules,}', + \ 'gitrebase': '{git-rebase-todo,}', + \ 'gitsendemail': '{.gitsendemail.*,}', + \ 'glsl': '{*.glsl,*.fp,*.frag,*.frg,*.fs,*.fsh,*.fshader,*.geo,*.geom,*.glslf,*.glslv,*.gs,*.gshader,*.shader,*.tesc,*.tese,*.vert,*.vrx,*.vsh,*.vshader,*.comp,}', + \ 'gmpl': '{*.mod,}', + \ 'gnuplot': '{*.gp,*.gnu,*.gnuplot,*.p,*.plot,*.plt,}', + \ 'go': '{*.go,}', + \ 'gohtmltmpl': '{*.tmpl,}', + \ 'gomod': '{go.mod,}', + \ 'graphql': '{*.graphql,*.gql,*.graphqls,}', + \ 'groovy': '{*.gradle,}', + \ 'grub': '{,}', + \ 'haml': '{*.haml,*.haml.deface,*.hamlc,*.hamlbars,}', + \ 'haproxy': '{*.cfg,haproxy.cfg,haproxy*.c*,}', + \ 'haskell': '{*.hs,*.hs-boot,*.hsc,*.bpk,*.hsig,}', + \ 'haxe': '{*.hx,*.hxsl,}', + \ 'hcl': '{*.hcl,*.nomad,*.tf,*.tfvars,*.workflow,Appfile,}', + \ 'helm': '{,}', + \ 'help': '{,}', + \ 'hive': '{*.q,*.hql,*.ql,}', + \ 'html': '{*.html,*.htm,*.html.hl,*.inc,*.st,*.xht,*.xhtml,}', + \ 'html.twig': '{*.twig,}', + \ 'i3config': '{*.i3.config,*.i3config,i3.config,i3config,.i3.config,.i3config,}', + \ 'icalendar': '{*.ics,}', + \ 'idris': '{*.idr,*.lidr,idris-response,}', + \ 'ion': '{*.ion,}', + \ 'javascript': '{*.js,*._js,*.bones,*.cjs,*.es,*.es6,*.frag,*.gs,*.jake,*.jsb,*.jscad,*.jsfl,*.jsm,*.jss,*.mjs,*.njs,*.pac,*.sjs,*.ssjs,*.xsjs,*.xsjslib,Jakefile,}', + \ 'javascriptreact': '{*.jsx,}', + \ 'jinja.html': '{*.jinja,*.j2,*.jinja2,*.njk,}', + \ 'jq': '{*.jq,.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,}', + \ 'json5': '{*.json5,}', + \ 'jsonnet': '{*.jsonnet,*.libsonnet,}', + \ 'jst': '{*.ejs,*.ect,*.jst,}', + \ 'julia': '{*.jl,}', + \ 'kotlin': '{*.kt,*.ktm,*.kts,}', + \ 'ledger': '{*.ldg,*.ledger,*.journal,}', + \ 'less': '{*.less,}', + \ 'lilypond': '{*.ly,*.ily,}', + \ 'litcoffee': '{*.litcoffee,*.coffee.md,}', + \ 'livescript': '{*.ls,*._ls,Slakefile,}', + \ 'llvm': '{*.ll,}', + \ 'log': '{*.log,*.LOG,*_log,*_LOG,}', + \ 'lua': '{*.lua,*.fcgi,*.nse,*.p8,*.pd_lua,*.rbxs,*.rockspec,*.wlua,.luacheckrc,}', + \ 'm4': '{*.m4,*.at,}', + \ 'mako': '{*.mako,*.mao,}', + \ 'markdown': '{*.md,*.markdown,*.mdown,*.mdwn,*.mdx,*.mkd,*.mkdn,*.mkdown,*.ronn,*.workbook,contents.lr,}', + \ 'markdown.mdx': '{*.mdx,}', + \ 'meson': '{meson.build,meson_options.txt,}', + \ 'mma': '{*.mathematica,*.cdf,*.m,*.ma,*.mt,*.nb,*.nbp,*.wl,*.wlt,*.wls,}', + \ 'moon': '{*.moon,}', + \ 'murphi': '{*.m,}', + \ 'mustache': '{*.handlebars,*.hbs,*.hulk,*.hjs,*.mustache,*.njk,*.hogan,*.hdbs,*.hb,}', + \ 'nginx': '{*.nginx,*.nginxconf,*.vhost,nginx.conf,nginx*.conf,*nginx.conf,}', + \ 'nim': '{*.nim,*.nim.cfg,*.nimble,*.nimrod,*.nims,nim.cfg,}', + \ 'nix': '{*.nix,}', + \ 'oasis': '{_oasis,}', + \ 'objc': '{*.m,*.h,}', + \ 'ocaml': '{*.ml,*.eliom,*.eliomi,*.ml4,*.mli,*.mll,*.mly,*.mlt,*.mlp,*.mlip,*.mli.cppo,*.ml.cppo,.ocamlinit,}', + \ 'ocamlbuild_tags': '{_tags,}', + \ 'ocpbuild': '{*.ocp,}', + \ 'ocpbuildroot': '{*.root,}', + \ 'octave': '{*.oct,*.m,}', + \ 'omake': '{*.om,OMakefile,OMakeroot,OMakeroot.in,}', + \ 'opam': '{*.opam,*.opam.template,opam,}', + \ 'opencl': '{*.cl,*.opencl,}', + \ 'perl': '{*.pl,*.al,*.cgi,*.fcgi,*.perl,*.ph,*.plx,*.pm,*.psgi,*.t,Makefile.PL,Rexfile,ack,cpanfile,}', + \ 'php': '{*.php,*.aw,*.ctp,*.fcgi,*.inc,*.php3,*.php4,*.php5,*.phps,*.phpt,.php,.php_cs,.php_cs.dist,Phakefile,}', + \ 'plantuml': '{*.puml,*.iuml,*.plantuml,*.uml,*.pu,}', + \ 'pony': '{*.pony,}', + \ 'proto': '{*.proto,}', + \ 'ps1': '{*.ps1,*.psd1,*.psm1,*.pssc,}', + \ 'ps1xml': '{*.ps1xml,}', + \ 'pug': '{*.jade,*.pug,}', + \ 'puppet': '{*.pp,Modulefile,}', + \ 'purescript': '{*.purs,}', + \ 'python': '{*.py,*.cgi,*.fcgi,*.gyp,*.gypi,*.lmi,*.py3,*.pyde,*.pyi,*.pyp,*.pyt,*.pyw,*.rpy,*.smk,*.spec,*.tac,*.wsgi,*.xpy,.gclient,DEPS,SConscript,SConstruct,Snakefile,wscript,}', + \ 'qmake': '{*.pro,*.pri,}', + \ 'qml': '{*.qml,*.qbs,}', + \ 'r': '{*.r,*.rd,*.rsx,*.s,*.S,.Rprofile,expr-dist,}', + \ 'racket': '{*.rkt,*.rktd,*.rktl,*.scrbl,}', + \ 'ragel': '{*.rl,}', + \ 'raku': '{*.6pl,*.6pm,*.nqp,*.p6,*.p6l,*.p6m,*.pl,*.pl6,*.pm,*.pm6,*.t,*.rakudoc,*.rakutest,*.raku,*.rakumod,*.pod6,*.t6,}', + \ 'raml': '{*.raml,}', + \ 'razor': '{*.cshtml,*.razor,}', + \ 'reason': '{*.re,*.rei,}', + \ 'requirements': '{*.pip,*requirements.{txt,in},*require.{txt,in},constraints.{txt,in},}', + \ 'rhelp': '{*.rd,}', + \ 'rst': '{*.rst,*.rest,*.rest.txt,*.rst.txt,}', + \ 'ruby': '{*.rb,*.builder,*.eye,*.fcgi,*.gemspec,*.god,*.jbuilder,*.mspec,*.pluginspec,*.podspec,*.rabl,*.rake,*.rbi,*.rbuild,*.rbw,*.rbx,*.ru,*.ruby,*.spec,*.thor,*.watchr,*.rxml,*.rjs,*.rant,*.axlsx,*.cap,*.opal,.irbrc,.pryrc,.simplecov,Appraisals,Berksfile,Brewfile,Buildfile,Capfile,Dangerfile,Deliverfile,Fastfile,Gemfile,Gemfile.lock,Guardfile,Jarfile,Mavenfile,Podfile,Puppetfile,Rakefile,Snapfile,Thorfile,Vagrantfile,buildfile,Rantfile,.autotest,Cheffile,KitchenSink,Routefile,.Guardfile,.Brewfile,vagrantfile,[Rr]akefile*,*_spec.rb,}', + \ 'rust': '{*.rs,*.rs.in,}', + \ 'sbt.scala': '{*.sbt,}', + \ 'scala': '{*.scala,*.kojo,*.sbt,*.sc,}', + \ 'scss': '{*.scss,}', + \ 'sexplib': '{*.sexp,}', + \ 'sh': '{*.sh,*.bash,*.bats,*.cgi,*.command,*.env,*.fcgi,*.ksh,*.sh.in,*.tmux,*.tool,*.zsh,.bash_aliases,.bash_history,.bash_logout,.bash_profile,.bashrc,.cshrc,.env,.env.example,.flaskenv,.login,.profile,.zlogin,.zlogout,.zprofile,.zshenv,.zshrc,9fs,PKGBUILD,bash_aliases,bash_logout,bash_profile,bashrc,cshrc,gradlew,login,man,profile,zlogin,zlogout,zprofile,zshenv,zshrc,}', + \ 'slim': '{*.slim,}', + \ 'slime': '{*.slime,}', + \ 'smt2': '{*.smt2,*.smt,}', + \ 'solidity': '{*.sol,}', + \ 'sql': '{*.pgsql,*.sql,}', + \ 'stylus': '{*.styl,*.stylus,}', + \ 'svelte': '{*.svelte,}', + \ 'svg': '{*.svg,}', + \ 'swift': '{*.swift,}', + \ 'sxhkdrc': '{*.sxhkdrc,sxhkdrc,}', + \ 'systemd': '{*.automount,*.mount,*.path,*.service,*.socket,*.swap,*.target,*.timer,}', + \ 'tablegen': '{*.td,}', + \ 'terraform': '{*.hcl,*.nomad,*.tf,*.tfvars,*.workflow,}', + \ 'textile': '{*.textile,}', + \ 'thrift': '{*.thrift,}', + \ 'tmux': '{.tmux.conf,}', + \ 'toml': '{*.toml,Cargo.lock,Gopkg.lock,poetry.lock,Pipfile,}', + \ 'tptp': '{*.p,*.tptp,*.ax,}', + \ 'trasys': '{*.inp,}', + \ 'typescript': '{*.ts,}', + \ 'typescriptreact': '{*.tsx,}', + \ 'unison': '{*.u,*.uu,}', + \ 'v': '{*.v,}', + \ 'vala': '{*.vala,*.vapi,*.valadoc,}', + \ 'vbnet': '{*.vb,*.vbhtml,}', + \ 'vcl': '{*.vcl,}', + \ 'velocity': '{*.vm,}', + \ 'vmasm': '{*.mar,}', + \ 'vue': '{*.vue,*.wpy,}', + \ 'xdc': '{*.xdc,}', + \ 'xml': '{*.xml,*.adml,*.admx,*.ant,*.axml,*.builds,*.ccproj,*.ccxml,*.clixml,*.cproject,*.cscfg,*.csdef,*.csl,*.csproj,*.ct,*.depproj,*.dita,*.ditamap,*.ditaval,*.dll.config,*.dotsettings,*.filters,*.fsproj,*.fxml,*.glade,*.gml,*.gmx,*.grxml,*.gst,*.iml,*.ivy,*.jelly,*.jsproj,*.kml,*.launch,*.mdpolicy,*.mjml,*.mm,*.mod,*.mxml,*.natvis,*.ncl,*.ndproj,*.nproj,*.nuspec,*.odd,*.osm,*.pkgproj,*.pluginspec,*.proj,*.props,*.ps1xml,*.psc1,*.pt,*.rdf,*.resx,*.rss,*.sch,*.scxml,*.sfproj,*.shproj,*.srdf,*.storyboard,*.sublime-snippet,*.targets,*.tml,*.ts,*.tsx,*.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,.classpath,.cproject,.project,App.config,NuGet.config,Settings.StyleCop,Web.Debug.config,Web.Release.config,Web.config,packages.config,}', + \ 'xml.twig': '{*.xml.twig,}', + \ 'xsl': '{*.xslt,*.xsl,}', + \ 'yaml': '{*.yml,*.mir,*.reek,*.rviz,*.sublime-syntax,*.syntax,*.yaml,*.yaml-tmlanguage,*.yaml.sed,*.yml.mysql,.clang-format,.clang-tidy,.gemrc,glide.lock,yarn.lock,fish_history,fish_read_history,}', + \ 'yaml.ansible': '{playbook.y{a,}ml,site.y{a,}ml,main.y{a,}ml,local.y{a,}ml,requirements.y{a,}ml,tasks.*.y{a,}ml,roles.*.y{a,}ml,handlers.*.y{a,}ml,}', + \ 'yaml.docker-compose': '{docker-compose*.yaml,docker-compose*.yml,}', + \ 'zephir': '{*.zep,}', + \ 'zig': '{*.zig,*.zir,}', + \ 'zir': '{*.zir,}', + \ 'zsh': '{*.zsh,.zshrc,.zshenv,.zlogin,.zprofile,.zlogout,}', + \} + +func! sleuth#GlobForFiletype(type) + return get(s:globs, a:type, '') +endfunc diff --git a/plugin/sleuth.vim b/plugin/sleuth.vim new file mode 100644 index 000000000..120861730 --- /dev/null +++ b/plugin/sleuth.vim @@ -0,0 +1,164 @@ +" Heuristically set buffer options +" +" Modified version of vim-sleuth: +" - softtab and tabstop reduced from 8 to 2 +" - number of considered lines reduced from 1024 to 64 +" - maximum 6 other files are checked instead of 20 +" - check maximum of files 2 per directory level instead of 8 +" - maximum of 3 directory levels are checked +" - globs are concatenated for performance + +if exists("g:loaded_sleuth") || v:version < 700 || &cp + finish +endif +let g:loaded_sleuth = 1 + +function! s:guess(lines) abort + let options = {} + let heuristics = {'spaces': 0, 'hard': 0, 'soft': 0} + let ccomment = 0 + let podcomment = 0 + let triplequote = 0 + let backtick = 0 + let xmlcomment = 0 + let softtab = repeat(' ', 2) + + for line in a:lines + if !len(line) || line =~# '^\s*$' + continue + endif + + if line =~# '^\s*/\*' + let ccomment = 1 + endif + if ccomment + if line =~# '\*/' + let ccomment = 0 + endif + continue + endif + + if line =~# '^=\w' + let podcomment = 1 + endif + if podcomment + if line =~# '^=\%(end\|cut\)\>' + let podcomment = 0 + endif + continue + endif + + if triplequote + if line =~# '^[^"]*"""[^"]*$' + let triplequote = 0 + endif + continue + elseif line =~# '^[^"]*"""[^"]*$' + let triplequote = 1 + endif + + if backtick + if line =~# '^[^`]*`[^`]*$' + let backtick = 0 + endif + continue + elseif &filetype ==# 'go' && line =~# '^[^`]*`[^`]*$' + let backtick = 1 + endif + + if line =~# '^\s*<\!--' + let xmlcomment = 1 + endif + if xmlcomment + if line =~# '-->' + let xmlcomment = 0 + endif + continue + endif + + if line =~# '^\t' + let heuristics.hard += 1 + elseif line =~# '^' . softtab + let heuristics.soft += 1 + endif + if line =~# '^ ' + let heuristics.spaces += 1 + endif + let indent = len(matchstr(substitute(line, '\t', softtab, 'g'), '^ *')) + if indent > 1 && (indent < 4 || indent % 2 == 0) && + \ get(options, 'shiftwidth', 99) > indent + let options.shiftwidth = indent + endif + endfor + + if heuristics.hard && !heuristics.spaces + return {'expandtab': 0, 'shiftwidth': &tabstop} + elseif heuristics.soft != heuristics.hard + let options.expandtab = heuristics.soft > heuristics.hard + if heuristics.hard + let options.tabstop = 2 + endif + endif + + return options +endfunction + +function! s:apply_if_ready(options) abort + if !has_key(a:options, 'expandtab') || !has_key(a:options, 'shiftwidth') + return 0 + else + for [option, value] in items(a:options) + call setbufvar('', '&'.option, value) + endfor + return 1 + endif +endfunction + +function! s:detect() abort + if &buftype ==# 'help' + return + endif + + let options = s:guess(getline(1, 64)) + if s:apply_if_ready(options) + return + endif + let c = 6 + let pattern = c > 0 ? sleuth#GlobForFiletype(&filetype) : '' + let dir = expand('%:p:h') + let level = 3 + while isdirectory(dir) && dir !=# fnamemodify(dir, ':h') && c > 0 && level > 0 + let level -= 1 + for neighbor in glob(dir.'/'.pattern,0,1)[0:1] + if neighbor !=# expand('%:p') && filereadable(neighbor) + call extend(options, s:guess(readfile(neighbor, '', 32)), 'keep') + let c -= 1 + endif + if s:apply_if_ready(options) + let b:sleuth_culprit = neighbor + return + endif + if c <= 0 + break + endif + endfor + if c <= 0 + break + endif + let dir = fnamemodify(dir, ':h') + endwhile + if has_key(options, 'shiftwidth') + return s:apply_if_ready(extend({'expandtab': 1}, options)) + endif +endfunction + +setglobal smarttab + +if !exists('g:did_indent_on') + filetype indent on +endif + +augroup polyglot + autocmd! + autocmd FileType * call s:detect() +augroup END diff --git a/scripts/build b/scripts/build index 1fe148e7e..2fcbe235a 100755 --- a/scripts/build +++ b/scripts/build @@ -716,6 +716,39 @@ def detect_filetypes }] end +def generate_plugins(packages) + FileUtils.mkdir_p('autoload/polyglot') + + output = "let s:globs = {\n" + + patterns = Hash.new { |h, k| h[k] = [] } + + for package in packages + for filetype in package["filetypes"] + extensions = (filetype["extensions"] || []).map { |e| "*.#{e}" } + files = (filetype["filenames"] || []).reject { |e| e.match(/\*\*|\//) } + patterns[filetype["name"]].concat(extensions) + patterns[filetype["name"]].concat(files) + end + end + + for filetype in patterns.keys.sort + output << " \\ '#{filetype}': '{#{patterns[filetype].uniq.join(",")},}',\n" + end + output << " \\}\n\n" + + + output << <<~EOS + func! sleuth#GlobForFiletype(type) + return get(s:globs, a:type, '') + endfunc + EOS + + + File.write('autoload/sleuth.vim', output) +end + + if __FILE__ == $0 if !ENV["DEV"] FileUtils.rm_rf("tmp") @@ -725,6 +758,7 @@ if __FILE__ == $0 download(packages) extract(packages) generate_ftdetect(packages, heuristics) + generate_plugins(packages) generate_tests(packages) puts(" Bye! Have a wonderful time!") From 7123e974980a76e4db9bf7fff1510cab03b072ae Mon Sep 17 00:00:00 2001 From: Adam Stankiewicz Date: Thu, 3 Sep 2020 05:36:55 +0200 Subject: [PATCH 003/299] Disable native autocommands when appropriate, fixes #533 --- autoload/sleuth.vim | 20 ++-- ftdetect/polyglot.vim | 247 ++++++++++++++++++++++++++++++++++++++---- packages.yaml | 2 + scripts/build | 51 ++++++--- 4 files changed, 274 insertions(+), 46 deletions(-) diff --git a/autoload/sleuth.vim b/autoload/sleuth.vim index 1c9fbefbd..92b531723 100644 --- a/autoload/sleuth.vim +++ b/autoload/sleuth.vim @@ -43,7 +43,7 @@ let s:globs = { \ 'clojure': '{*.clj,*.boot,*.cl2,*.cljc,*.cljs,*.cljs.hl,*.cljscm,*.cljx,*.hic,*.edn,riemann.config,build.boot,profile.boot,}', \ 'cmake': '{*.cmake,*.cmake.in,CMakeLists.txt,}', \ 'coffee': '{*.coffee,*._coffee,*.cake,*.cjsx,*.iced,*.coffeekup,Cakefile,}', - \ 'cpp': '{*.cpp,*.c++,*.cc,*.cp,*.cxx,*.h,*.h++,*.hh,*.hpp,*.hxx,*.inc,*.inl,*.ino,*.ipp,*.re,*.tcc,*.tpp,}', + \ 'cpp': '{*.cpp,*.c++,*.cc,*.cp,*.cxx,*.h,*.h++,*.hh,*.hpp,*.hxx,*.inc,*.inl,*.ipp,*.tcc,*.tpp,}', \ 'cql': '{*.cql,}', \ 'cryptol': '{*.cry,*.cyl,*.lcry,*.lcyl,}', \ 'crystal': '{*.cr,Projectfile,}', @@ -94,7 +94,7 @@ let s:globs = { \ 'haproxy': '{*.cfg,haproxy.cfg,haproxy*.c*,}', \ 'haskell': '{*.hs,*.hs-boot,*.hsc,*.bpk,*.hsig,}', \ 'haxe': '{*.hx,*.hxsl,}', - \ 'hcl': '{*.hcl,*.nomad,*.tf,*.tfvars,*.workflow,Appfile,}', + \ 'hcl': '{*.hcl,*.nomad,*.workflow,Appfile,}', \ 'helm': '{,}', \ 'help': '{,}', \ 'hive': '{*.q,*.hql,*.ql,}', @@ -106,7 +106,7 @@ let s:globs = { \ 'ion': '{*.ion,}', \ 'javascript': '{*.js,*._js,*.bones,*.cjs,*.es,*.es6,*.frag,*.gs,*.jake,*.jsb,*.jscad,*.jsfl,*.jsm,*.jss,*.mjs,*.njs,*.pac,*.sjs,*.ssjs,*.xsjs,*.xsjslib,Jakefile,}', \ 'javascriptreact': '{*.jsx,}', - \ 'jinja.html': '{*.jinja,*.j2,*.jinja2,*.njk,}', + \ 'jinja.html': '{*.jinja,*.j2,*.jinja2,}', \ 'jq': '{*.jq,.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,}', \ 'json5': '{*.json5,}', @@ -124,7 +124,7 @@ let s:globs = { \ 'lua': '{*.lua,*.fcgi,*.nse,*.p8,*.pd_lua,*.rbxs,*.rockspec,*.wlua,.luacheckrc,}', \ 'm4': '{*.m4,*.at,}', \ 'mako': '{*.mako,*.mao,}', - \ 'markdown': '{*.md,*.markdown,*.mdown,*.mdwn,*.mdx,*.mkd,*.mkdn,*.mkdown,*.ronn,*.workbook,contents.lr,}', + \ 'markdown': '{*.md,*.markdown,*.mdown,*.mdwn,*.mkd,*.mkdn,*.mkdown,*.ronn,*.workbook,contents.lr,}', \ 'markdown.mdx': '{*.mdx,}', \ 'meson': '{meson.build,meson_options.txt,}', \ 'mma': '{*.mathematica,*.cdf,*.m,*.ma,*.mt,*.nb,*.nbp,*.wl,*.wlt,*.wls,}', @@ -157,7 +157,7 @@ let s:globs = { \ 'python': '{*.py,*.cgi,*.fcgi,*.gyp,*.gypi,*.lmi,*.py3,*.pyde,*.pyi,*.pyp,*.pyt,*.pyw,*.rpy,*.smk,*.spec,*.tac,*.wsgi,*.xpy,.gclient,DEPS,SConscript,SConstruct,Snakefile,wscript,}', \ 'qmake': '{*.pro,*.pri,}', \ 'qml': '{*.qml,*.qbs,}', - \ 'r': '{*.r,*.rd,*.rsx,*.s,*.S,.Rprofile,expr-dist,}', + \ 'r': '{*.r,*.rsx,*.s,*.S,.Rprofile,expr-dist,}', \ 'racket': '{*.rkt,*.rktd,*.rktl,*.scrbl,}', \ 'ragel': '{*.rl,}', \ 'raku': '{*.6pl,*.6pm,*.nqp,*.p6,*.p6l,*.p6m,*.pl,*.pl6,*.pm,*.pm6,*.t,*.rakudoc,*.rakutest,*.raku,*.rakumod,*.pod6,*.t6,}', @@ -167,18 +167,18 @@ let s:globs = { \ 'requirements': '{*.pip,*requirements.{txt,in},*require.{txt,in},constraints.{txt,in},}', \ 'rhelp': '{*.rd,}', \ 'rst': '{*.rst,*.rest,*.rest.txt,*.rst.txt,}', - \ 'ruby': '{*.rb,*.builder,*.eye,*.fcgi,*.gemspec,*.god,*.jbuilder,*.mspec,*.pluginspec,*.podspec,*.rabl,*.rake,*.rbi,*.rbuild,*.rbw,*.rbx,*.ru,*.ruby,*.spec,*.thor,*.watchr,*.rxml,*.rjs,*.rant,*.axlsx,*.cap,*.opal,.irbrc,.pryrc,.simplecov,Appraisals,Berksfile,Brewfile,Buildfile,Capfile,Dangerfile,Deliverfile,Fastfile,Gemfile,Gemfile.lock,Guardfile,Jarfile,Mavenfile,Podfile,Puppetfile,Rakefile,Snapfile,Thorfile,Vagrantfile,buildfile,Rantfile,.autotest,Cheffile,KitchenSink,Routefile,.Guardfile,.Brewfile,vagrantfile,[Rr]akefile*,*_spec.rb,}', + \ 'ruby': '{*.rb,*.builder,*.eye,*.fcgi,*.gemspec,*.god,*.jbuilder,*.mspec,*.pluginspec,*.podspec,*.rabl,*.rake,*.rbi,*.rbuild,*.rbw,*.rbx,*.ru,*.ruby,*.spec,*.thor,*.watchr,*.rxml,*.rjs,*.rant,*.axlsx,*.cap,*.opal,.irbrc,.pryrc,.simplecov,Appraisals,Berksfile,Buildfile,Capfile,Dangerfile,Deliverfile,Fastfile,Gemfile,Gemfile.lock,Guardfile,Jarfile,Mavenfile,Podfile,Puppetfile,Rakefile,Snapfile,Thorfile,Vagrantfile,buildfile,Rantfile,.autotest,Cheffile,KitchenSink,Routefile,.Guardfile,.Brewfile,vagrantfile,[Rr]akefile*,*_spec.rb,}', \ 'rust': '{*.rs,*.rs.in,}', \ 'sbt.scala': '{*.sbt,}', - \ 'scala': '{*.scala,*.kojo,*.sbt,*.sc,}', + \ 'scala': '{*.scala,*.kojo,*.sc,}', \ 'scss': '{*.scss,}', \ 'sexplib': '{*.sexp,}', - \ 'sh': '{*.sh,*.bash,*.bats,*.cgi,*.command,*.env,*.fcgi,*.ksh,*.sh.in,*.tmux,*.tool,*.zsh,.bash_aliases,.bash_history,.bash_logout,.bash_profile,.bashrc,.cshrc,.env,.env.example,.flaskenv,.login,.profile,.zlogin,.zlogout,.zprofile,.zshenv,.zshrc,9fs,PKGBUILD,bash_aliases,bash_logout,bash_profile,bashrc,cshrc,gradlew,login,man,profile,zlogin,zlogout,zprofile,zshenv,zshrc,}', + \ 'sh': '{*.sh,*.bash,*.bats,*.cgi,*.command,*.env,*.fcgi,*.ksh,*.sh.in,*.tmux,*.tool,.bash_aliases,.bash_history,.bash_logout,.bash_profile,.bashrc,.cshrc,.env,.env.example,.flaskenv,.login,.profile,9fs,PKGBUILD,bash_aliases,bash_logout,bash_profile,bashrc,cshrc,gradlew,login,man,profile,}', \ 'slim': '{*.slim,}', \ 'slime': '{*.slime,}', \ 'smt2': '{*.smt2,*.smt,}', \ 'solidity': '{*.sol,}', - \ 'sql': '{*.pgsql,*.sql,}', + \ 'sql': '{*.pgsql,}', \ 'stylus': '{*.styl,*.stylus,}', \ 'svelte': '{*.svelte,}', \ 'svg': '{*.svg,}', @@ -204,7 +204,7 @@ let s:globs = { \ 'vmasm': '{*.mar,}', \ 'vue': '{*.vue,*.wpy,}', \ 'xdc': '{*.xdc,}', - \ 'xml': '{*.xml,*.adml,*.admx,*.ant,*.axml,*.builds,*.ccproj,*.ccxml,*.clixml,*.cproject,*.cscfg,*.csdef,*.csl,*.csproj,*.ct,*.depproj,*.dita,*.ditamap,*.ditaval,*.dll.config,*.dotsettings,*.filters,*.fsproj,*.fxml,*.glade,*.gml,*.gmx,*.grxml,*.gst,*.iml,*.ivy,*.jelly,*.jsproj,*.kml,*.launch,*.mdpolicy,*.mjml,*.mm,*.mod,*.mxml,*.natvis,*.ncl,*.ndproj,*.nproj,*.nuspec,*.odd,*.osm,*.pkgproj,*.pluginspec,*.proj,*.props,*.ps1xml,*.psc1,*.pt,*.rdf,*.resx,*.rss,*.sch,*.scxml,*.sfproj,*.shproj,*.srdf,*.storyboard,*.sublime-snippet,*.targets,*.tml,*.ts,*.tsx,*.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,.classpath,.cproject,.project,App.config,NuGet.config,Settings.StyleCop,Web.Debug.config,Web.Release.config,Web.config,packages.config,}', + \ 'xml': '{*.xml,*.adml,*.admx,*.ant,*.axml,*.builds,*.ccproj,*.ccxml,*.clixml,*.cproject,*.cscfg,*.csdef,*.csl,*.csproj,*.ct,*.depproj,*.dita,*.ditamap,*.ditaval,*.dll.config,*.dotsettings,*.filters,*.fsproj,*.fxml,*.glade,*.gml,*.gmx,*.grxml,*.gst,*.iml,*.ivy,*.jelly,*.jsproj,*.kml,*.launch,*.mdpolicy,*.mjml,*.mm,*.mod,*.mxml,*.natvis,*.ncl,*.ndproj,*.nproj,*.nuspec,*.odd,*.osm,*.pkgproj,*.pluginspec,*.proj,*.props,*.ps1xml,*.psc1,*.pt,*.rdf,*.resx,*.rss,*.sch,*.scxml,*.sfproj,*.shproj,*.srdf,*.storyboard,*.sublime-snippet,*.targets,*.tml,*.ui,*.urdf,*.ux,*.vbproj,*.vcxproj,*.vsixmanifest,*.vssettings,*.vstemplate,*.vxml,*.wixproj,*.workflow,*.wsdl,*.wsf,*.wxi,*.wxl,*.wxs,*.x3d,*.xacro,*.xaml,*.xib,*.xlf,*.xliff,*.xmi,*.xml.dist,*.xproj,*.xsd,*.xspec,*.xul,*.zcml,*.cdxml,.classpath,.cproject,.project,App.config,NuGet.config,Settings.StyleCop,Web.Debug.config,Web.Release.config,Web.config,packages.config,}', \ 'xml.twig': '{*.xml.twig,}', \ 'xsl': '{*.xslt,*.xsl,}', \ 'yaml': '{*.yml,*.mir,*.reek,*.rviz,*.sublime-syntax,*.syntax,*.yaml,*.yaml-tmlanguage,*.yaml.sed,*.yml.mysql,.clang-format,.clang-tidy,.gemrc,glide.lock,yarn.lock,fish_history,fish_read_history,}', diff --git a/ftdetect/polyglot.vim b/ftdetect/polyglot.vim index 9e86a7ad7..87b0cf259 100644 --- a/ftdetect/polyglot.vim +++ b/ftdetect/polyglot.vim @@ -59,6 +59,230 @@ if !exists('g:python_highlight_all') call s:SetDefault('g:python_highlight_file_headers_as_comments', 1) call s:SetDefault('g:python_slow_sync', 1) endif +if !has_key(s:disabled_packages, '8th') + au! BufRead,BufNewFile *.8th +endif + +if !has_key(s:disabled_packages, 'a65') + au! BufRead,BufNewFile *.a65 +endif + +if !has_key(s:disabled_packages, 'aap') + au! BufRead,BufNewFile *.aap +endif + +if !has_key(s:disabled_packages, 'abap') + au! BufRead,BufNewFile *.abap +endif + +if !has_key(s:disabled_packages, 'abc') + au! BufRead,BufNewFile *.abc +endif + +if !has_key(s:disabled_packages, 'acpiasl') + au! BufRead,BufNewFile *.dsl +endif + +if !has_key(s:disabled_packages, 'ada') + au! BufRead,BufNewFile *.ada +endif + +if !has_key(s:disabled_packages, 'aidl') + au! BufRead,BufNewFile *.aidl +endif + +if !has_key(s:disabled_packages, 'aml') + au! BufRead,BufNewFile *.aml +endif + +if !has_key(s:disabled_packages, 'applescript') + au! BufRead,BufNewFile *.applescript +endif + +if !has_key(s:disabled_packages, 'art') + au! BufRead,BufNewFile *.art +endif + +if !has_key(s:disabled_packages, 'asciidoc') + au! BufRead,BufNewFile *.asciidoc +endif + +if !has_key(s:disabled_packages, 'asn') + au! BufRead,BufNewFile *.asn +endif + +if !has_key(s:disabled_packages, 'ave') + au! BufRead,BufNewFile *.ave +endif + +if !has_key(s:disabled_packages, 'awk') + au! BufRead,BufNewFile *.awk +endif + +if !has_key(s:disabled_packages, 'c/c++') + au! BufRead,BufNewFile *.c,*.cpp,*.tpp +endif + +if !has_key(s:disabled_packages, 'cmake') + au! BufRead,BufNewFile *.cmake +endif + +if !has_key(s:disabled_packages, 'dart') + au! BufRead,BufNewFile *.dart +endif + +if !has_key(s:disabled_packages, 'dlang') + au! BufRead,BufNewFile *.sdl +endif + +if !has_key(s:disabled_packages, 'dockerfile') + au! BufRead,BufNewFile *.dockerfile +endif + +if !has_key(s:disabled_packages, 'elm') + au! BufRead,BufNewFile *.elm +endif + +if !has_key(s:disabled_packages, 'git') + au! BufRead,BufNewFile *.gitconfig +endif + +if !has_key(s:disabled_packages, 'gnuplot') + au! BufRead,BufNewFile *.gp,*.gnuplot +endif + +if !has_key(s:disabled_packages, 'go') + au! BufRead,BufNewFile *.go +endif + +if !has_key(s:disabled_packages, 'haml') + au! BufRead,BufNewFile *.haml +endif + +if !has_key(s:disabled_packages, 'handlebars') + au! BufRead,BufNewFile *.hb +endif + +if !has_key(s:disabled_packages, 'haproxy') + au! BufRead,BufNewFile *.cfg +endif + +if !has_key(s:disabled_packages, 'html5') + au! BufRead,BufNewFile *.st,*.xhtml +endif + +if !has_key(s:disabled_packages, 'json') + au! BufRead,BufNewFile *.json,*.template +endif + +if !has_key(s:disabled_packages, 'less') + au! BufRead,BufNewFile *.less +endif + +if !has_key(s:disabled_packages, 'lua') + au! BufRead,BufNewFile *.lua +endif + +if !has_key(s:disabled_packages, 'm4') + au! BufRead,BufNewFile *.m4 +endif + +if !has_key(s:disabled_packages, 'markdown') + au! BufRead,BufNewFile *.markdown +endif + +if !has_key(s:disabled_packages, 'opencl') + au! BufRead,BufNewFile *.cl +endif + +if !has_key(s:disabled_packages, 'perl') + au! BufRead,BufNewFile *.perl +endif + +if !has_key(s:disabled_packages, 'php') + au! BufRead,BufNewFile *.php +endif + +if !has_key(s:disabled_packages, 'protobuf') + au! BufRead,BufNewFile *.proto +endif + +if !has_key(s:disabled_packages, 'python') + au! BufRead,BufNewFile *.spec +endif + +if !has_key(s:disabled_packages, 'r-lang') + au! BufRead,BufNewFile *.r +endif + +if !has_key(s:disabled_packages, 'raku') + au! BufRead,BufNewFile *.pod6 +endif + +if !has_key(s:disabled_packages, 'raml') + au! BufRead,BufNewFile *.raml +endif + +if !has_key(s:disabled_packages, 'rst') + au! BufRead,BufNewFile *.rst +endif + +if !has_key(s:disabled_packages, 'ruby') + au! BufRead,BufNewFile *.ruby,*.spec +endif + +if !has_key(s:disabled_packages, 'scala') + au! BufRead,BufNewFile *.scala +endif + +if !has_key(s:disabled_packages, 'sbt') + au! BufRead,BufNewFile *.sbt +endif + +if !has_key(s:disabled_packages, 'scss') + au! BufRead,BufNewFile *.scss +endif + +if !has_key(s:disabled_packages, 'sh') + au! BufRead,BufNewFile *.sh,*.tmux,*.zsh +endif + +if !has_key(s:disabled_packages, 'svg') + au! BufRead,BufNewFile *.svg +endif + +if !has_key(s:disabled_packages, 'swift') + au! BufRead,BufNewFile *.swift +endif + +if !has_key(s:disabled_packages, 'terraform') + au! BufRead,BufNewFile *.tf +endif + +if !has_key(s:disabled_packages, 'twig') + au! BufRead,BufNewFile *.twig +endif + +if !has_key(s:disabled_packages, 'vbnet') + au! BufRead,BufNewFile *.vb +endif + +if !has_key(s:disabled_packages, 'vue') + au! BufRead,BufNewFile *.vue +endif + +if !has_key(s:disabled_packages, 'xml') + au! BufRead,BufNewFile *.xml,*.ant,*.xsd +endif + +if !has_key(s:disabled_packages, 'xsl') + au! BufRead,BufNewFile *.xslt +endif + +if !has_key(s:disabled_packages, 'yaml') + au! BufRead,BufNewFile *.yaml +endif + if !has_key(s:disabled_packages, '8th') au BufNewFile,BufRead *.8th setf 8th endif @@ -240,11 +464,9 @@ if !has_key(s:disabled_packages, 'c/c++') au BufNewFile,BufRead *.hxx setf cpp au BufNewFile,BufRead *.inc setf cpp au BufNewFile,BufRead *.inl setf cpp - au BufNewFile,BufRead *.ino setf cpp au BufNewFile,BufRead *.ipp setf cpp au BufNewFile,BufRead *.tcc setf cpp au BufNewFile,BufRead *.tpp setf cpp - au! BufNewFile,BufRead *.re call polyglot#DetectReFiletype() endif if !has_key(s:disabled_packages, 'caddyfile') @@ -535,8 +757,6 @@ endif if !has_key(s:disabled_packages, 'hcl') au BufNewFile,BufRead *.hcl setf hcl au BufNewFile,BufRead *.nomad setf hcl - au BufNewFile,BufRead *.tf setf hcl - au BufNewFile,BufRead *.tfvars setf hcl au BufNewFile,BufRead *.workflow setf hcl au BufNewFile,BufRead Appfile setf hcl endif @@ -621,7 +841,6 @@ if !has_key(s:disabled_packages, 'jinja') au BufNewFile,BufRead *.j2 setf jinja.html au BufNewFile,BufRead *.jinja setf jinja.html au BufNewFile,BufRead *.jinja2 setf jinja.html - au BufNewFile,BufRead *.njk setf jinja.html endif if !has_key(s:disabled_packages, 'jq') @@ -768,7 +987,6 @@ if !has_key(s:disabled_packages, 'markdown') au BufNewFile,BufRead *.md setf markdown au BufNewFile,BufRead *.mdown setf markdown au BufNewFile,BufRead *.mdwn setf markdown - au BufNewFile,BufRead *.mdx setf markdown au BufNewFile,BufRead *.mkd setf markdown au BufNewFile,BufRead *.mkdn setf markdown au BufNewFile,BufRead *.mkdown setf markdown @@ -881,7 +1099,6 @@ endif if !has_key(s:disabled_packages, 'pgsql') au BufNewFile,BufRead *.pgsql let b:sql_type_override='pgsql' | set ft=sql - au BufNewFile,BufRead *.sql let b:sql_type_override='pgsql' | set ft=sql endif if !has_key(s:disabled_packages, 'cql') @@ -1002,7 +1219,6 @@ endif if !has_key(s:disabled_packages, 'r-lang') au BufNewFile,BufRead *.S setf r au BufNewFile,BufRead *.r setf r - au BufNewFile,BufRead *.rd setf r au BufNewFile,BufRead *.rsx setf r au BufNewFile,BufRead *.s setf r au BufNewFile,BufRead {.,}Rprofile setf r @@ -1093,7 +1309,6 @@ if !has_key(s:disabled_packages, 'ruby') au BufNewFile,BufRead {.,}simplecov setf ruby au BufNewFile,BufRead Appraisals setf ruby au BufNewFile,BufRead Berksfile setf ruby - au BufNewFile,BufRead Brewfile setf ruby au BufNewFile,BufRead Buildfile setf ruby au BufNewFile,BufRead Capfile setf ruby au BufNewFile,BufRead Cheffile setf ruby @@ -1140,7 +1355,6 @@ endif if !has_key(s:disabled_packages, 'scala') au BufNewFile,BufRead *.kojo setf scala - au BufNewFile,BufRead *.sbt setf scala au BufNewFile,BufRead *.sc setf scala au BufNewFile,BufRead *.scala setf scala endif @@ -1165,7 +1379,6 @@ if !has_key(s:disabled_packages, 'sh') au BufNewFile,BufRead *.sh.in setf sh au BufNewFile,BufRead *.tmux setf sh au BufNewFile,BufRead *.tool setf sh - au BufNewFile,BufRead *.zsh setf sh au BufNewFile,BufRead {.,}bash_aliases setf sh au BufNewFile,BufRead {.,}bash_history setf sh au BufNewFile,BufRead {.,}bash_logout setf sh @@ -1177,11 +1390,6 @@ if !has_key(s:disabled_packages, 'sh') au BufNewFile,BufRead {.,}flaskenv setf sh au BufNewFile,BufRead {.,}login setf sh au BufNewFile,BufRead {.,}profile setf sh - au BufNewFile,BufRead {.,}zlogin setf sh - au BufNewFile,BufRead {.,}zlogout setf sh - au BufNewFile,BufRead {.,}zprofile setf sh - au BufNewFile,BufRead {.,}zshenv setf sh - au BufNewFile,BufRead {.,}zshrc setf sh au BufNewFile,BufRead 9fs setf sh au BufNewFile,BufRead PKGBUILD setf sh au BufNewFile,BufRead bash_aliases setf sh @@ -1193,11 +1401,6 @@ if !has_key(s:disabled_packages, 'sh') au BufNewFile,BufRead login setf sh au BufNewFile,BufRead man setf sh au BufNewFile,BufRead profile setf sh - au BufNewFile,BufRead zlogin setf sh - au BufNewFile,BufRead zlogout setf sh - au BufNewFile,BufRead zprofile setf sh - au BufNewFile,BufRead zshenv setf sh - au BufNewFile,BufRead zshrc setf sh au BufNewFile,BufRead *.zsh setf zsh au BufNewFile,BufRead {.,}zlogin setf zsh au BufNewFile,BufRead {.,}zlogout setf zsh @@ -1416,8 +1619,6 @@ if !has_key(s:disabled_packages, 'xml') au BufNewFile,BufRead *.sublime-snippet setf xml au BufNewFile,BufRead *.targets setf xml au BufNewFile,BufRead *.tml setf xml - au BufNewFile,BufRead *.ts setf xml - au BufNewFile,BufRead *.tsx setf xml au BufNewFile,BufRead *.ui setf xml au BufNewFile,BufRead *.urdf setf xml au BufNewFile,BufRead *.ux setf xml diff --git a/packages.yaml b/packages.yaml index d4042c5ef..f4f801cf6 100644 --- a/packages.yaml +++ b/packages.yaml @@ -302,6 +302,8 @@ filetypes: ignored_extensions: # conflicts with more popular reason, remove after heuristics work - re + # implemented by arduino + - ino --- name: caddyfile remote: isobit/vim-caddyfile diff --git a/scripts/build b/scripts/build index 2fcbe235a..f8efb850f 100755 --- a/scripts/build +++ b/scripts/build @@ -59,17 +59,20 @@ def load_data() linguist = languages.fetch(filetype["linguist"]) - filetype["extensions"] = (linguist["extensions"] || []).map { |e| e[1..-1] } | - filetype.fetch("extra_extensions", []) - - filetype.fetch("ignored_extensions", []).uniq - - filetype["filenames"] = (linguist["filenames"] || []) | - filetype.fetch("extra_filenames", []) - - filetype.fetch("ignored_filenames", []).uniq + filetype["extensions"] = (( + (linguist["extensions"] || []).map { |e| e[1..-1] } | + filetype.fetch("extra_extensions", []) + ) - filetype.fetch("ignored_extensions", [])).uniq + + filetype["filenames"] = (( + (linguist["filenames"] || []) | + filetype.fetch("extra_filenames", []) + ) - filetype.fetch("ignored_filenames", [])).uniq - filetype["interpreters"] = (linguist["interpreters"] || []) | - filetype.fetch("extra_interpreters", []) - - filetype.fetch("ignored_interpreters", []).uniq + filetype["interpreters"] = (( + (linguist["interpreters"] || []) | + filetype.fetch("extra_interpreters", []) + ) - filetype.fetch("ignored_interpreters", []).uniq) else filetype["extensions"] ||= [] filetype["filenames"] ||= [] @@ -445,7 +448,29 @@ def generate_ftdetect(packages, heuristics) ambiguous_extensions = extensions .select { |a, b| b.uniq.size > 1 }.keys.sort - expected_filetypes = detect_filetypes + expected_filetypes = detect_filetypes('tmp/**/ftdetect/*.vim') + native_filetypes = detect_filetypes('tmp/vim/vim/runtime/filetype.vim') + native_extensions = native_filetypes.flat_map { |k, v| v["extensions"] } + + for package in packages + name = package.fetch("name") + + to_disable = [] + + for filetype in package["filetypes"] + for extension in filetype["extensions"] + if native_filetypes.has_key?(extension) + to_disable << "*." + extension + end + end + end + + if to_disable.size > 0 + output << "if !has_key(s:disabled_packages, '#{name}')\n" + output << " au! BufRead,BufNewFile #{to_disable.join(",")}\n" + output << "endif\n\n" + end + end for package in packages name = package.fetch("name") @@ -690,8 +715,8 @@ def expand_all(pattern) end end -def detect_filetypes - filetypes = Dir['tmp/**/ftdetect/*.vim'].flat_map do |file| +def detect_filetypes(glob) + filetypes = Dir[glob].flat_map do |file| contents = File.read(file).gsub(/^\s*au(tocmd)?!?\s*$/, '') results = contents.scan(/^\s*(?:au!|au|au[^g][^ ]*) +(?:\S+)\s+(\S+)[\s\\]+([^\n]+)/) results = results.map do |a, b| From 520389bbfd1696806392be3c2d48ab4d4b2fde09 Mon Sep 17 00:00:00 2001 From: Adam Stankiewicz Date: Thu, 3 Sep 2020 05:38:07 +0200 Subject: [PATCH 004/299] Add test for terraform --- scripts/test_extensions.vim | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/test_extensions.vim b/scripts/test_extensions.vim index dfe2f3a33..c45431d5e 100644 --- a/scripts/test_extensions.vim +++ b/scripts/test_extensions.vim @@ -188,6 +188,7 @@ call TestExtension('yaml.ansible', 'host_vars/foobar', '') call TestExtension('yaml.ansible', 'handlers.foobar.yaml', '') call TestExtension('yaml.ansible', 'requirements.yaml', '') call TestExtension('ps1xml', 'foobar.ps1xml', '') +call TestExtension('terraform', 'terraform.tf', '') " .m extension call TestExtension('octave', 'matlab.m', '') From 96179c95ba1bc76e792ce06beb7525be1412de48 Mon Sep 17 00:00:00 2001 From: Adam Stankiewicz Date: Thu, 3 Sep 2020 17:16:08 +0200 Subject: [PATCH 005/299] Update contribution info --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f53acd5f0..a1dd0de31 100644 --- a/README.md +++ b/README.md @@ -257,7 +257,7 @@ Please note that disabling a language won't make in your vim startup any faster Language packs are periodically updated using automated `scripts/build` script. -Feel free to add your language to `packages.yaml`, and send pull-request. Please don't run `make` and include that in your PR, send just changes to `packages.yaml` and build scripts if really necessary. You can run `make test` to run rough tests. +Feel free to add your language to `packages.yaml` + `heuristics.yaml`, and send pull-request. You can run `make test` to run rough tests. And `make dev` for easy development. ## License From 48f59577c8fa68d85ac73bfd9f257d606c4660b5 Mon Sep 17 00:00:00 2001 From: Adam Stankiewicz Date: Fri, 4 Sep 2020 12:11:55 +0200 Subject: [PATCH 006/299] Switch to neovim version of help filetype, fixes #536 --- README.md | 2 +- autoload/csv.vim | 111 ++++++++++++++++++++-------------------------- doc/ft-csv.txt | 24 +++++----- ftplugin/help.vim | 77 +++++++++++++++++++++++++++++++- packages.yaml | 2 +- syntax/help.vim | 26 ++++------- 6 files changed, 149 insertions(+), 93 deletions(-) diff --git a/README.md b/README.md index a1dd0de31..bf51320bc 100644 --- a/README.md +++ b/README.md @@ -125,7 +125,7 @@ If you need full functionality of any plugin, please use it directly with your p - [haxe](https://github.com/yaymukund/vim-haxe) - [hcl](https://github.com/b4b4r07/vim-hcl) - [helm](https://github.com/towolf/vim-helm) -- [help](https://github.com/vim/vim/tree/master/runtime) +- [help](https://github.com/neovim/neovim/tree/master/runtime) - [hive](https://github.com/zebradil/hive.vim) - [html5](https://github.com/othree/html5.vim) - [i3](https://github.com/mboughaba/i3config.vim) diff --git a/autoload/csv.vim b/autoload/csv.vim index 8561f30f5..16eeb676e 100644 --- a/autoload/csv.vim +++ b/autoload/csv.vim @@ -1450,7 +1450,7 @@ fu! csv#SumColumn(list) "{{{3 let b:csv_result = '0' return 0 else - let sum = has("float") ? 0.0 : 0 + let sum = 0.0 for item in a:list if empty(item) continue @@ -1460,33 +1460,25 @@ fu! csv#SumColumn(list) "{{{3 let format2 = '\d\+\zs\V' . s:nr_format[1] . '\m\ze\d' try let nr = substitute(nr, format1, '', '') - if has("float") && s:nr_format[1] != '.' + if s:nr_format[1] != '.' let nr = substitute(nr, format2, '.', '') endif catch - let nr = 0 + let nr = '0' endtry - let sum += (has("float") ? str2float(nr) : (nr + 0)) + let sum += str2float(nr) endfor - if has("float") - let b:csv_result = string(float2nr(sum)) - if float2nr(sum) == sum - return float2nr(sum) - else - return printf("%.2f", sum) - endif - endif - let b:csv_result = string(sum) - return sum + let b:csv_result = sum + return printf("%.2f", sum) endif endfu fu! csv#AvgColumn(list) "{{{3 if empty(a:list) let b:csv_result = '0' - return 0 + return 0.0 else let cnt = 0 - let sum = has("float") ? 0.0 : 0 + let sum = 0.0 for item in a:list if empty(item) continue @@ -1496,30 +1488,25 @@ fu! csv#AvgColumn(list) "{{{3 let format2 = '\d\+\zs\V' . s:nr_format[1] . '\m\ze\d' try let nr = substitute(nr, format1, '', '') - if has("float") && s:nr_format[1] != '.' + if s:nr_format[1] != '.' let nr = substitute(nr, format2, '.', '') endif catch - let nr = 0 + let nr ='0' endtry - let sum += (has("float") ? str2float(nr) : (nr + 0)) + let sum += str2float(nr) let cnt += 1 endfor - if has("float") - let b:csv_result = printf("%.2f", sum/cnt) - return str2float(b:csv_result) - else - let b:csv_result = printf("%s", sum/cnt) - return b:csv_result + 0 - endif + let b:csv_result = printf("%.2f", sum/cnt) + return sum/cnt endif endfu fu! csv#VarianceColumn(list, is_population) "{{{3 if empty(a:list) - return 0 + return 0.0 else let cnt = 0 - let sum = has("float") ? 0.0 : 0 + let sum = 0.0 let avg = csv#AvgColumn(a:list) for item in a:list if empty(item) @@ -1530,64 +1517,64 @@ fu! csv#VarianceColumn(list, is_population) "{{{3 let format2 = '\d\+\zs\V' . s:nr_format[1] . '\m\ze\d' try let nr = substitute(nr, format1, '', '') - if has("float") && s:nr_format[1] != '.' + if s:nr_format[1] != '.' let nr = substitute(nr, format2, '.', '') endif catch - let nr = 0 + let nr = '0' endtry - let sum += pow((has("float") ? (str2float(nr)-avg) : ((nr + 0)-avg)), 2) + let nr = str2float(nr) + let sum += pow((nr-avg), 2) let cnt += 1 endfor if(a:is_population == 0) let cnt = cnt-1 endif - if has("float") - let b:csv_result = printf("%." . get(b:, 'csv_accuracy', get(g:, 'csv_accuracy', 2)) . "f", sum/cnt) - return b:csv_result - else - let b:csv_result = printf("%s", sum/cnt) - return sum/(cnt) - endif + let b:csv_result = sum/cnt + return b:csv_result endif endfu fu! csv#SmplVarianceColumn(list) "{{{2 + unlet! b:csv_result if empty(a:list) - let b:csv_result = '0' - return 0 + let b:csv_result = 0.0 + return 0.0 else return csv#VarianceColumn(a:list, 0) endif endfu fu! csv#PopVarianceColumn(list) "{{{2 + unlet! b:csv_result if empty(a:list) - let b:csv_result = '0' - return 0 + let b:csv_result = 0.0 + return 0.0 else return csv#VarianceColumn(a:list, 1) endif endfu fu! csv#SmplStdDevColumn(list) "{{{2 + unlet! b:csv_result if empty(a:list) - let b:csv_result = '0' - return 0 + let b:csv_result = 0.0 + return 0.0 else - let result = sqrt(str2float(csv#VarianceColumn(a:list, 0))) - let b:csv_result = string(result) + let result = sqrt(csv#VarianceColumn(a:list, 0)) + let b:csv_result = result return result endif endfu fu! csv#PopStdDevColumn(list) "{{{2 + unlet! b:csv_result if empty(a:list) - let b:csv_result = '0' - return 0 + let b:csv_result = 0.0 + return 0.0 else - let result = sqrt(str2float(csv#VarianceColumn(a:list, 1))) - let b:csv_result = string(result) + let result = sqrt(csv#VarianceColumn(a:list, 1)) + let b:csv_result = result return result endif endfu @@ -1610,13 +1597,13 @@ fu! csv#MaxColumn(list) "{{{3 let format2 = '\d\+\zs\V' . s:nr_format[1] . '\m\ze\d' try let nr = substitute(nr, format1, '', '') - if has("float") && s:nr_format[1] != '.' + if s:nr_format[1] != '.' let nr = substitute(nr, format2, '.', '') endif catch - let nr = 0 + let nr = '0' endtry - call add(result, has("float") ? str2float(nr) : nr+0) + call add(result, str2float(nr)) endfor let result = sort(result, s:csv_numeric_sort ? 'n' : 'csv#CSVSortValues') let ind = len(result) > 9 ? 9 : len(result) @@ -1995,10 +1982,7 @@ fu! csv#AnalyzeColumn(...) "{{{3 call filter(res, 'v:val =~ ''^''.join(max_items, ''\|'').''$''') endif - if has("float") - let title="Nr\tCount\t % \tValue" - else - let title="Nr\tCount\tValue" + let title="Nr\tCount\t % \tValue" endif echohl Title echo printf("%s", title) @@ -2014,12 +1998,8 @@ fu! csv#AnalyzeColumn(...) "{{{3 else let k = key endif - if has("float") - echo printf("%02d\t%02d\t%2.0f%%\t%.50s", i, res[key], - \ ((res[key] + 0.0)/qty)*100, k) - else - echo printf("%02d\t%02d\t%.50s", i, res[key], k) - endif + echo printf("%02d\t%02d\t%2.0f%%\t%.50s", i, res[key], + \ ((res[key] + 0.0)/qty)*100, k) call remove(res,key) let i+=1 else @@ -2950,6 +2930,11 @@ fu! csv#EvalColumn(nr, func, first, last, ...) range "{{{3 call csv#Warn("File is no CSV file!") return endif + " Need a Vim with floating point feature + if !has("float") + call csv#Warn("Your Vim is missing floating point feature!") + return + endif let save = winsaveview() call csv#CheckHeaderLine() let nr = matchstr(a:nr, '^\-\?\d\+') diff --git a/doc/ft-csv.txt b/doc/ft-csv.txt index 7e2a00adc..7f8f6eb39 100644 --- a/doc/ft-csv.txt +++ b/doc/ft-csv.txt @@ -969,8 +969,7 @@ The result is also available in the buffer-local variable `b:csv_result`. See also |csv-aggregate-functions| - *MinCol_CSV* -3.27 Maximum/Minimum value of a Column *MaxCol_CSV* +3.27 Maximum/Minimum value of a Column *MaxCol_CSV* *MinCol_CSV* --------------------------------------- You can let Vim output the 10 maximum/minimum values of a column using the `:CSVMaxCol` command > @@ -984,6 +983,7 @@ given, this calculates the sum for the column the cursor is on. Note, that the delimiter will be stripped away from each value and also empty values won't be considered. + *format_number_csv* By default, Vim uses the a numerical format that uses the '.' as decimal separator while there is no thousands separator. If youre file contains the numbers in a different format, you can use the /format/ option to specify @@ -1003,10 +1003,6 @@ uses the Space as thousands separator and the '.' as decimal separator. If [distinct] is given, only returns the number of distinct values. -Note, if you Vim is compiled without floating point number format (|+float|), -Vim will only aggregate the integer part and therefore won't use the 'y' -argument in the /format/ specifier. - The result is also available in the buffer-local variable `b:csv_result`. 3.28 Average value of a Column *AvgCol_CSV* @@ -1021,19 +1017,21 @@ given, this calculates the sum for the column the cursor is on. Note, that the delimiter will be stripped away from each value and also empty values won't be considered. -For the [/format/] part, see |MaxCol_CSV|. +For the [/format/] part, see |format_number_csv|. The result is also available in the buffer-local variable `b:csv_result`. See also |csv-aggregate-functions| -3.29 Variance of a Column *VarCol_CSV* +3.29 Variance of a Column *VarCol_CSV* *SmplVarCol* *PopVarCol* _________________________ :[range]PopVarCol [nr] [/format/] :[range]SmplVarCol [nr] [/format/] +Calculate the Population or Sample Variance for the specified column. + This outputs the result of the column `` within the range given. If no range is given, this will calculate the statistical variance of the whole column. If is not given, this calculates the variance for the column the cursor is on. Note, that the delimiter @@ -1041,13 +1039,17 @@ will be stripped away from each value and also empty values won't be considered. The result is also available in the buffer-local variable `b:csv_result`. -3.30 Standard Deviation of a Column *StdDevCol_CSV* +For the [/format/] part, see |format_number_csv|. + +3.30 Standard Deviation of a Column *StdDevCol_CSV* *PopStdCol* *SmplStdCol* ___________________________________ :[range]PopStdCol [nr] [/format/] :[range]SmplStdCol [nr] [/format/] +Calculate the Population or Sample Standard Deviation for the specified column. + This outputs the result of the column `` within the range given. If no range is given, this will calculate the standard deviation of the whole column. If is not given, this calculates the standard deviation for the column the cursor is on. Note, that @@ -1055,6 +1057,8 @@ the delimiter will be stripped away from each value and also empty values won't The result is also available in the buffer-local variable `b:csv_result`. +For the [/format/] part, see |format_number_csv|. + *:CSVDupColumn* 3.31 Duplicate columns *DupColumn_CSV* ---------------------- @@ -1089,7 +1093,7 @@ This outputs the sum of the row [range]. If no range is given, this will calculate the sum for the current row. Note, that the delimiter will be stripped away from each value and also empty values won't be considered. -For the [/format/] part, see |MaxCol_CSV|. +For the [/format/] part, see |format_number_csv| ============================================================================== 4. CSV Configuration *csv-configuration* diff --git a/ftplugin/help.vim b/ftplugin/help.vim index 5e9a4aa00..bb6d43e82 100644 --- a/ftplugin/help.vim +++ b/ftplugin/help.vim @@ -15,11 +15,86 @@ set cpo&vim let b:undo_ftplugin = "setl fo< tw< cole< cocu< keywordprg<" -setlocal formatoptions+=tcroql textwidth=78 keywordprg=:help +setlocal formatoptions+=tcroql textwidth=78 if has("conceal") setlocal cole=2 cocu=nc endif +" Prefer Vim help instead of manpages. +setlocal keywordprg=:help + +if !exists('g:no_plugin_maps') + function! s:show_toc() abort + let bufname = bufname('%') + let info = getloclist(0, {'winid': 1}) + if !empty(info) && getwinvar(info.winid, 'qf_toc') ==# bufname + lopen + return + endif + + let toc = [] + let lnum = 2 + let last_line = line('$') - 1 + let last_added = 0 + let has_section = 0 + let has_sub_section = 0 + + while lnum && lnum <= last_line + let level = 0 + let add_text = '' + let text = getline(lnum) + + if text =~# '^=\+$' && lnum + 1 < last_line + " A de-facto section heading. Other headings are inferred. + let has_section = 1 + let has_sub_section = 0 + let lnum = nextnonblank(lnum + 1) + let text = getline(lnum) + let add_text = text + while add_text =~# '\*[^*]\+\*\s*$' + let add_text = matchstr(add_text, '.*\ze\*[^*]\+\*\s*$') + endwhile + elseif text =~# '^[A-Z0-9][-A-ZA-Z0-9 .][-A-Z0-9 .():]*\%([ \t]\+\*.\+\*\)\?$' + " Any line that's yelling is important. + let has_sub_section = 1 + let level = has_section + let add_text = matchstr(text, '.\{-}\ze\s*\%([ \t]\+\*.\+\*\)\?$') + elseif text =~# '\~$' + \ && matchstr(text, '^\s*\zs.\{-}\ze\s*\~$') !~# '\t\|\s\{2,}' + \ && getline(lnum - 1) =~# '^\s*<\?$\|^\s*\*.*\*$' + \ && getline(lnum + 1) =~# '^\s*>\?$\|^\s*\*.*\*$' + " These lines could be headers or code examples. We only want the + " ones that have subsequent lines at the same indent or more. + let l = nextnonblank(lnum + 1) + if getline(l) =~# '\*[^*]\+\*$' + " Ignore tag lines + let l = nextnonblank(l + 1) + endif + + if indent(lnum) <= indent(l) + let level = has_section + has_sub_section + let add_text = matchstr(text, '\S.*') + endif + endif + + let add_text = substitute(add_text, '\s\+$', '', 'g') + if !empty(add_text) && last_added != lnum + let last_added = lnum + call add(toc, {'bufnr': bufnr('%'), 'lnum': lnum, + \ 'text': repeat(' ', level) . add_text}) + endif + let lnum = nextnonblank(lnum + 1) + endwhile + + call setloclist(0, toc, ' ') + call setloclist(0, [], 'a', {'title': 'Help TOC'}) + lopen + let w:qf_toc = bufname + endfunction + + nnoremap gO :call show_toc() +endif + let &cpo = s:cpo_save unlet s:cpo_save diff --git a/packages.yaml b/packages.yaml index f4f801cf6..1ff3f0ebd 100644 --- a/packages.yaml +++ b/packages.yaml @@ -1672,7 +1672,7 @@ filetypes: - "*/templates/*.tpl" --- name: help -remote: vim/vim:runtime +remote: neovim/neovim:runtime glob: '**/help.vim' filetypes: - name: help diff --git a/syntax/help.vim b/syntax/help.vim index aca620ee9..a031e48e0 100644 --- a/syntax/help.vim +++ b/syntax/help.vim @@ -3,7 +3,7 @@ if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'help') == -1 " Vim syntax file " Language: Vim help file " Maintainer: Bram Moolenaar (Bram@vim.org) -" Last Change: 2020 Jul 28 +" Last Change: 2019 May 12 " Quit when a (custom) syntax file was already loaded if exists("b:current_syntax") @@ -13,7 +13,7 @@ endif let s:cpo_save = &cpo set cpo&vim -syn match helpHeadline "^[-A-Z .][-A-Z0-9 .()_]*\ze\(\s\+\*\|$\)" +syn match helpHeadline "^[-A-Z .][-A-Z0-9 .()_]*[ \t]\+\*"me=e-1 syn match helpSectionDelim "^===.*===$" syn match helpSectionDelim "^---.*--$" if has("conceal") @@ -21,15 +21,9 @@ if has("conceal") else syn region helpExample matchgroup=helpIgnore start=" >$" start="^>$" end="^[^ \t]"me=e-1 end="^<" endif -if has("ebcdic") - syn match helpHyperTextJump "\\\@.,]\+}" +syn match helpSpecial "{[-_a-zA-Z0-9'"*+/:%#=[\]<>.,]\+}" syn match helpSpecial "\s\[[-a-z^A-Z0-9_]\{2,}]"ms=s+1 syn match helpSpecial "<[-a-zA-Z0-9_]\+>" syn match helpSpecial "<[SCM]-.>" @@ -92,15 +87,14 @@ syn match helpSpecial "\[group]" syn match helpNormal "\[\(readonly\|fifo\|socket\|converted\|crypted\)]" syn match helpSpecial "CTRL-." -syn match helpSpecial "CTRL-SHIFT-." syn match helpSpecial "CTRL-Break" syn match helpSpecial "CTRL-PageUp" syn match helpSpecial "CTRL-PageDown" syn match helpSpecial "CTRL-Insert" syn match helpSpecial "CTRL-Del" syn match helpSpecial "CTRL-{char}" -syn region helpNotVi start="{Vi[: ]" start="{not" start="{only" end="}" contains=helpLeadBlank,helpHyperTextJump -syn match helpLeadBlank "^\s\+" contained +syn match helpSpecial "META-." +syn match helpSpecial "ALT-." " Highlight group items in their own color. syn match helpComment "\t[* ]Comment\t\+[a-z].*" @@ -154,7 +148,6 @@ if v:lang =~ '\' || v:lang =~ '_IT\>' || v:lang =~? "italian" syn match helpSpecial "Nmi"me=e-2 syn match helpSpecial "Nmo"me=e-2 syn match helpSpecial "\[interv.]" - syn region helpNotVi start="{non" start="{solo" start="{disponibile" end="}" contains=helpLeadBlank,helpHyperTextJump endif syn sync minlines=40 @@ -175,7 +168,6 @@ hi def link helpVim Identifier hi def link helpCommand Comment hi def link helpExample Comment hi def link helpOption Type -hi def link helpNotVi Special hi def link helpSpecial Special hi def link helpNote Todo hi def link helpWarning Todo From 4df00e657481fa77c129acdda4d2b367cf64afab Mon Sep 17 00:00:00 2001 From: Adam Stankiewicz Date: Fri, 4 Sep 2020 14:18:37 +0200 Subject: [PATCH 007/299] Allow to disable autoindent with g:polyglot_disabled --- README.md | 8 +++++++- plugin/sleuth.vim | 7 ++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index bf51320bc..8c744c10a 100644 --- a/README.md +++ b/README.md @@ -245,7 +245,7 @@ Please make sure you have `syntax on` in your `.vimrc` (or use something like [s Individual language packs can be disabled by setting `g:polyglot_disabled` as follows: -```viml +```vim let g:polyglot_disabled = ['css'] ``` @@ -253,6 +253,12 @@ let g:polyglot_disabled = ['css'] Please note that disabling a language won't make in your vim startup any faster / slower (only for specific this specific filetype). All plugins are loaded lazily, on demand. +Vim Polyglot tries to automatically detect indentation settings (just like vim-sleuth). If this feature is not working for you for some reason, please file an issue and disable it temporarily with: + +```vim +let g:polyglot_disabled = ['autoindent'] +``` + ## Contributing Language packs are periodically updated using automated `scripts/build` script. diff --git a/plugin/sleuth.vim b/plugin/sleuth.vim index 120861730..d7b9b7731 100644 --- a/plugin/sleuth.vim +++ b/plugin/sleuth.vim @@ -7,10 +7,15 @@ " - check maximum of files 2 per directory level instead of 8 " - maximum of 3 directory levels are checked " - globs are concatenated for performance +" - tabstop setting is not configured, it's up to user +if exists('g:polyglot_disabled') && index(g:polyglot_disabled, 'autoindent') != -1 + finish +endif -if exists("g:loaded_sleuth") || v:version < 700 || &cp +if exists("g:loaded_sleuth") || exists("g:polyglot_disabled") || v:version < 700 || &cp finish endif + let g:loaded_sleuth = 1 function! s:guess(lines) abort From c30ba66d2211d0c5764855d099e171fb2cd1108d Mon Sep 17 00:00:00 2001 From: Adam Stankiewicz Date: Fri, 4 Sep 2020 14:23:18 +0200 Subject: [PATCH 008/299] Let user select tabstop, by not changing it --- plugin/sleuth.vim | 3 --- 1 file changed, 3 deletions(-) diff --git a/plugin/sleuth.vim b/plugin/sleuth.vim index d7b9b7731..a0bba8c40 100644 --- a/plugin/sleuth.vim +++ b/plugin/sleuth.vim @@ -100,9 +100,6 @@ function! s:guess(lines) abort return {'expandtab': 0, 'shiftwidth': &tabstop} elseif heuristics.soft != heuristics.hard let options.expandtab = heuristics.soft > heuristics.hard - if heuristics.hard - let options.tabstop = 2 - endif endif return options From b2640b5b760e6fc68b8cc49d3c8bab6cdef4f889 Mon Sep 17 00:00:00 2001 From: Adam Stankiewicz Date: Fri, 4 Sep 2020 17:31:22 +0200 Subject: [PATCH 009/299] Fix detection of indentation, #537 --- autoload/sleuth.vim | 430 ++++++++++++++++++++++---------------------- plugin/polyglot.vim | 149 +++++++++++++++ plugin/sleuth.vim | 166 ----------------- scripts/build | 4 +- 4 files changed, 366 insertions(+), 383 deletions(-) create mode 100644 plugin/polyglot.vim delete mode 100644 plugin/sleuth.vim diff --git a/autoload/sleuth.vim b/autoload/sleuth.vim index 92b531723..a912cda45 100644 --- a/autoload/sleuth.vim +++ b/autoload/sleuth.vim @@ -1,219 +1,219 @@ let s:globs = { - \ '8th': '{*.8th,}', - \ 'Dockerfile': '{*.dockerfile,*.dock,*.Dockerfile,Dockerfile,dockerfile,Dockerfile*,}', - \ 'Jenkinsfile': '{*.jenkinsfile,*.Jenkinsfile,Jenkinsfile,Jenkinsfile*,}', - \ 'a2ps': '{a2psrc,.a2psrc,}', - \ 'a65': '{*.a65,}', - \ 'aap': '{*.aap,}', - \ 'abap': '{*.abap,}', - \ 'abaqus': '{*.inp,}', - \ 'abc': '{*.abc,}', - \ 'abel': '{*.abl,}', - \ 'acedb': '{*.wrm,}', - \ 'ada': '{*.adb,*.ads,*.ada,*.gpr,}', - \ 'ahdl': '{*.tdf,}', - \ 'aidl': '{*.aidl,}', - \ 'alsaconf': '{.asoundrc,}', - \ 'aml': '{*.aml,}', - \ 'ampl': '{*.run,}', - \ 'ant': '{build.xml,}', - \ 'apache': '{.htaccess,}', - \ 'apiblueprint': '{*.apib,}', - \ 'applescript': '{*.applescript,*.scpt,}', - \ 'aptconf': '{apt.conf,}', - \ 'arch': '{.arch-inventory,=tagging-method,}', - \ 'arduino': '{*.pde,*.ino,}', - \ 'art': '{*.art,}', - \ 'asciidoc': '{*.asciidoc,*.adoc,*.asc,}', - \ 'asl': '{*.asl,*.dsl,}', - \ 'asn': '{*.asn,*.asn1,}', - \ 'aspperl': '{*.asp,}', - \ 'aspvbs': '{*.asa,*.asp,}', - \ 'atlas': '{*.atl,*.as,}', - \ 'autohotkey': '{*.ahk,*.ahkl,}', - \ 'autoit': '{*.au3,}', - \ 'automake': '{[Mm]akefile.am,GNUmakefile.am,}', - \ 'ave': '{*.ave,}', - \ 'awk': '{*.awk,}', - \ 'blade': '{*.blade,*.blade.php,}', - \ 'brewfile': '{Brewfile,}', - \ 'c': '{*.c,*.cats,*.h,*.idc,}', - \ 'caddyfile': '{Caddyfile,}', - \ 'carp': '{*.carp,}', - \ 'clojure': '{*.clj,*.boot,*.cl2,*.cljc,*.cljs,*.cljs.hl,*.cljscm,*.cljx,*.hic,*.edn,riemann.config,build.boot,profile.boot,}', - \ 'cmake': '{*.cmake,*.cmake.in,CMakeLists.txt,}', - \ 'coffee': '{*.coffee,*._coffee,*.cake,*.cjsx,*.iced,*.coffeekup,Cakefile,}', - \ 'cpp': '{*.cpp,*.c++,*.cc,*.cp,*.cxx,*.h,*.h++,*.hh,*.hpp,*.hxx,*.inc,*.inl,*.ipp,*.tcc,*.tpp,}', - \ 'cql': '{*.cql,}', - \ 'cryptol': '{*.cry,*.cyl,*.lcry,*.lcyl,}', - \ 'crystal': '{*.cr,Projectfile,}', - \ 'csv': '{*.csv,*.tsv,*.tab,}', - \ 'cucumber': '{*.feature,*.story,}', - \ 'cuesheet': '{*.cue,}', - \ 'd': '{*.d,*.di,}', - \ 'dart': '{*.dart,}', - \ 'dcov': '{*.lst,}', - \ 'dd': '{*.dd,}', - \ 'ddoc': '{*.ddoc,}', - \ 'dhall': '{*.dhall,}', - \ 'dosini': '{*.wrap,}', - \ 'dsdl': '{*.sdl,}', - \ 'dune': '{jbuild,dune,dune-project,dune-workspace,}', - \ 'ecrystal': '{*.ecr,}', - \ 'eelixir': '{*.eex,*.leex,}', - \ 'elf': '{*.am,}', - \ 'elixir': '{*.ex,*.exs,mix.lock,}', - \ 'elm': '{*.elm,}', - \ 'embeddedpuppet': '{*.epp,}', - \ 'ember-script': '{*.em,*.emberscript,}', - \ 'emblem': '{*.emblem,*.em,}', - \ 'erlang': '{*.erl,*.app.src,*.es,*.escript,*.hrl,*.xrl,*.yrl,*.app,*.yaws,Emakefile,rebar.config,rebar.config.lock,rebar.lock,}', - \ 'eruby': '{*.erb,*.erb.deface,*.rhtml,}', - \ 'fbs': '{*.fbs,}', - \ 'fennel': '{*.fnl,}', - \ 'ferm': '{*.ferm,ferm.conf,}', - \ 'fish': '{*.fish,}', - \ 'flow': '{*.flow,}', - \ 'forth': '{*.fs,*.ft,*.fth,}', - \ 'fsharp': '{*.fs,*.fsi,*.fsx,}', - \ 'gdscript3': '{*.gd,}', - \ 'gitcommit': '{,}', - \ 'gitconfig': '{*.gitconfig,.gitconfig,.gitmodules,}', - \ 'gitrebase': '{git-rebase-todo,}', - \ 'gitsendemail': '{.gitsendemail.*,}', - \ 'glsl': '{*.glsl,*.fp,*.frag,*.frg,*.fs,*.fsh,*.fshader,*.geo,*.geom,*.glslf,*.glslv,*.gs,*.gshader,*.shader,*.tesc,*.tese,*.vert,*.vrx,*.vsh,*.vshader,*.comp,}', - \ 'gmpl': '{*.mod,}', - \ 'gnuplot': '{*.gp,*.gnu,*.gnuplot,*.p,*.plot,*.plt,}', - \ 'go': '{*.go,}', - \ 'gohtmltmpl': '{*.tmpl,}', - \ 'gomod': '{go.mod,}', - \ 'graphql': '{*.graphql,*.gql,*.graphqls,}', - \ 'groovy': '{*.gradle,}', - \ 'grub': '{,}', - \ 'haml': '{*.haml,*.haml.deface,*.hamlc,*.hamlbars,}', - \ 'haproxy': '{*.cfg,haproxy.cfg,haproxy*.c*,}', - \ 'haskell': '{*.hs,*.hs-boot,*.hsc,*.bpk,*.hsig,}', - \ 'haxe': '{*.hx,*.hxsl,}', - \ 'hcl': '{*.hcl,*.nomad,*.workflow,Appfile,}', - \ 'helm': '{,}', - \ 'help': '{,}', - \ 'hive': '{*.q,*.hql,*.ql,}', - \ 'html': '{*.html,*.htm,*.html.hl,*.inc,*.st,*.xht,*.xhtml,}', - \ 'html.twig': '{*.twig,}', - \ 'i3config': '{*.i3.config,*.i3config,i3.config,i3config,.i3.config,.i3config,}', - \ 'icalendar': '{*.ics,}', - \ 'idris': '{*.idr,*.lidr,idris-response,}', - \ 'ion': '{*.ion,}', - \ 'javascript': '{*.js,*._js,*.bones,*.cjs,*.es,*.es6,*.frag,*.gs,*.jake,*.jsb,*.jscad,*.jsfl,*.jsm,*.jss,*.mjs,*.njs,*.pac,*.sjs,*.ssjs,*.xsjs,*.xsjslib,Jakefile,}', - \ 'javascriptreact': '{*.jsx,}', - \ 'jinja.html': '{*.jinja,*.j2,*.jinja2,}', - \ 'jq': '{*.jq,.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,}', - \ 'json5': '{*.json5,}', - \ 'jsonnet': '{*.jsonnet,*.libsonnet,}', - \ 'jst': '{*.ejs,*.ect,*.jst,}', - \ 'julia': '{*.jl,}', - \ 'kotlin': '{*.kt,*.ktm,*.kts,}', - \ 'ledger': '{*.ldg,*.ledger,*.journal,}', - \ 'less': '{*.less,}', - \ 'lilypond': '{*.ly,*.ily,}', - \ 'litcoffee': '{*.litcoffee,*.coffee.md,}', - \ 'livescript': '{*.ls,*._ls,Slakefile,}', - \ 'llvm': '{*.ll,}', - \ 'log': '{*.log,*.LOG,*_log,*_LOG,}', - \ 'lua': '{*.lua,*.fcgi,*.nse,*.p8,*.pd_lua,*.rbxs,*.rockspec,*.wlua,.luacheckrc,}', - \ 'm4': '{*.m4,*.at,}', - \ 'mako': '{*.mako,*.mao,}', - \ 'markdown': '{*.md,*.markdown,*.mdown,*.mdwn,*.mkd,*.mkdn,*.mkdown,*.ronn,*.workbook,contents.lr,}', - \ 'markdown.mdx': '{*.mdx,}', - \ 'meson': '{meson.build,meson_options.txt,}', - \ 'mma': '{*.mathematica,*.cdf,*.m,*.ma,*.mt,*.nb,*.nbp,*.wl,*.wlt,*.wls,}', - \ 'moon': '{*.moon,}', - \ 'murphi': '{*.m,}', - \ 'mustache': '{*.handlebars,*.hbs,*.hulk,*.hjs,*.mustache,*.njk,*.hogan,*.hdbs,*.hb,}', - \ 'nginx': '{*.nginx,*.nginxconf,*.vhost,nginx.conf,nginx*.conf,*nginx.conf,}', - \ 'nim': '{*.nim,*.nim.cfg,*.nimble,*.nimrod,*.nims,nim.cfg,}', - \ 'nix': '{*.nix,}', - \ 'oasis': '{_oasis,}', - \ 'objc': '{*.m,*.h,}', - \ 'ocaml': '{*.ml,*.eliom,*.eliomi,*.ml4,*.mli,*.mll,*.mly,*.mlt,*.mlp,*.mlip,*.mli.cppo,*.ml.cppo,.ocamlinit,}', - \ 'ocamlbuild_tags': '{_tags,}', - \ 'ocpbuild': '{*.ocp,}', - \ 'ocpbuildroot': '{*.root,}', - \ 'octave': '{*.oct,*.m,}', - \ 'omake': '{*.om,OMakefile,OMakeroot,OMakeroot.in,}', - \ 'opam': '{*.opam,*.opam.template,opam,}', - \ 'opencl': '{*.cl,*.opencl,}', - \ 'perl': '{*.pl,*.al,*.cgi,*.fcgi,*.perl,*.ph,*.plx,*.pm,*.psgi,*.t,Makefile.PL,Rexfile,ack,cpanfile,}', - \ 'php': '{*.php,*.aw,*.ctp,*.fcgi,*.inc,*.php3,*.php4,*.php5,*.phps,*.phpt,.php,.php_cs,.php_cs.dist,Phakefile,}', - \ 'plantuml': '{*.puml,*.iuml,*.plantuml,*.uml,*.pu,}', - \ 'pony': '{*.pony,}', - \ 'proto': '{*.proto,}', - \ 'ps1': '{*.ps1,*.psd1,*.psm1,*.pssc,}', - \ 'ps1xml': '{*.ps1xml,}', - \ 'pug': '{*.jade,*.pug,}', - \ 'puppet': '{*.pp,Modulefile,}', - \ 'purescript': '{*.purs,}', - \ 'python': '{*.py,*.cgi,*.fcgi,*.gyp,*.gypi,*.lmi,*.py3,*.pyde,*.pyi,*.pyp,*.pyt,*.pyw,*.rpy,*.smk,*.spec,*.tac,*.wsgi,*.xpy,.gclient,DEPS,SConscript,SConstruct,Snakefile,wscript,}', - \ 'qmake': '{*.pro,*.pri,}', - \ 'qml': '{*.qml,*.qbs,}', - \ 'r': '{*.r,*.rsx,*.s,*.S,.Rprofile,expr-dist,}', - \ 'racket': '{*.rkt,*.rktd,*.rktl,*.scrbl,}', - \ 'ragel': '{*.rl,}', - \ 'raku': '{*.6pl,*.6pm,*.nqp,*.p6,*.p6l,*.p6m,*.pl,*.pl6,*.pm,*.pm6,*.t,*.rakudoc,*.rakutest,*.raku,*.rakumod,*.pod6,*.t6,}', - \ 'raml': '{*.raml,}', - \ 'razor': '{*.cshtml,*.razor,}', - \ 'reason': '{*.re,*.rei,}', - \ 'requirements': '{*.pip,*requirements.{txt,in},*require.{txt,in},constraints.{txt,in},}', - \ 'rhelp': '{*.rd,}', - \ 'rst': '{*.rst,*.rest,*.rest.txt,*.rst.txt,}', - \ 'ruby': '{*.rb,*.builder,*.eye,*.fcgi,*.gemspec,*.god,*.jbuilder,*.mspec,*.pluginspec,*.podspec,*.rabl,*.rake,*.rbi,*.rbuild,*.rbw,*.rbx,*.ru,*.ruby,*.spec,*.thor,*.watchr,*.rxml,*.rjs,*.rant,*.axlsx,*.cap,*.opal,.irbrc,.pryrc,.simplecov,Appraisals,Berksfile,Buildfile,Capfile,Dangerfile,Deliverfile,Fastfile,Gemfile,Gemfile.lock,Guardfile,Jarfile,Mavenfile,Podfile,Puppetfile,Rakefile,Snapfile,Thorfile,Vagrantfile,buildfile,Rantfile,.autotest,Cheffile,KitchenSink,Routefile,.Guardfile,.Brewfile,vagrantfile,[Rr]akefile*,*_spec.rb,}', - \ 'rust': '{*.rs,*.rs.in,}', - \ 'sbt.scala': '{*.sbt,}', - \ 'scala': '{*.scala,*.kojo,*.sc,}', - \ 'scss': '{*.scss,}', - \ 'sexplib': '{*.sexp,}', - \ 'sh': '{*.sh,*.bash,*.bats,*.cgi,*.command,*.env,*.fcgi,*.ksh,*.sh.in,*.tmux,*.tool,.bash_aliases,.bash_history,.bash_logout,.bash_profile,.bashrc,.cshrc,.env,.env.example,.flaskenv,.login,.profile,9fs,PKGBUILD,bash_aliases,bash_logout,bash_profile,bashrc,cshrc,gradlew,login,man,profile,}', - \ 'slim': '{*.slim,}', - \ 'slime': '{*.slime,}', - \ 'smt2': '{*.smt2,*.smt,}', - \ 'solidity': '{*.sol,}', - \ 'sql': '{*.pgsql,}', - \ 'stylus': '{*.styl,*.stylus,}', - \ 'svelte': '{*.svelte,}', - \ 'svg': '{*.svg,}', - \ 'swift': '{*.swift,}', - \ 'sxhkdrc': '{*.sxhkdrc,sxhkdrc,}', - \ 'systemd': '{*.automount,*.mount,*.path,*.service,*.socket,*.swap,*.target,*.timer,}', - \ 'tablegen': '{*.td,}', - \ 'terraform': '{*.hcl,*.nomad,*.tf,*.tfvars,*.workflow,}', - \ 'textile': '{*.textile,}', - \ 'thrift': '{*.thrift,}', - \ 'tmux': '{.tmux.conf,}', - \ 'toml': '{*.toml,Cargo.lock,Gopkg.lock,poetry.lock,Pipfile,}', - \ 'tptp': '{*.p,*.tptp,*.ax,}', - \ 'trasys': '{*.inp,}', - \ 'typescript': '{*.ts,}', - \ 'typescriptreact': '{*.tsx,}', - \ 'unison': '{*.u,*.uu,}', - \ 'v': '{*.v,}', - \ 'vala': '{*.vala,*.vapi,*.valadoc,}', - \ 'vbnet': '{*.vb,*.vbhtml,}', - \ 'vcl': '{*.vcl,}', - \ 'velocity': '{*.vm,}', - \ 'vmasm': '{*.mar,}', - \ 'vue': '{*.vue,*.wpy,}', - \ 'xdc': '{*.xdc,}', - \ 'xml': '{*.xml,*.adml,*.admx,*.ant,*.axml,*.builds,*.ccproj,*.ccxml,*.clixml,*.cproject,*.cscfg,*.csdef,*.csl,*.csproj,*.ct,*.depproj,*.dita,*.ditamap,*.ditaval,*.dll.config,*.dotsettings,*.filters,*.fsproj,*.fxml,*.glade,*.gml,*.gmx,*.grxml,*.gst,*.iml,*.ivy,*.jelly,*.jsproj,*.kml,*.launch,*.mdpolicy,*.mjml,*.mm,*.mod,*.mxml,*.natvis,*.ncl,*.ndproj,*.nproj,*.nuspec,*.odd,*.osm,*.pkgproj,*.pluginspec,*.proj,*.props,*.ps1xml,*.psc1,*.pt,*.rdf,*.resx,*.rss,*.sch,*.scxml,*.sfproj,*.shproj,*.srdf,*.storyboard,*.sublime-snippet,*.targets,*.tml,*.ui,*.urdf,*.ux,*.vbproj,*.vcxproj,*.vsixmanifest,*.vssettings,*.vstemplate,*.vxml,*.wixproj,*.workflow,*.wsdl,*.wsf,*.wxi,*.wxl,*.wxs,*.x3d,*.xacro,*.xaml,*.xib,*.xlf,*.xliff,*.xmi,*.xml.dist,*.xproj,*.xsd,*.xspec,*.xul,*.zcml,*.cdxml,.classpath,.cproject,.project,App.config,NuGet.config,Settings.StyleCop,Web.Debug.config,Web.Release.config,Web.config,packages.config,}', - \ 'xml.twig': '{*.xml.twig,}', - \ 'xsl': '{*.xslt,*.xsl,}', - \ 'yaml': '{*.yml,*.mir,*.reek,*.rviz,*.sublime-syntax,*.syntax,*.yaml,*.yaml-tmlanguage,*.yaml.sed,*.yml.mysql,.clang-format,.clang-tidy,.gemrc,glide.lock,yarn.lock,fish_history,fish_read_history,}', - \ 'yaml.ansible': '{playbook.y{a,}ml,site.y{a,}ml,main.y{a,}ml,local.y{a,}ml,requirements.y{a,}ml,tasks.*.y{a,}ml,roles.*.y{a,}ml,handlers.*.y{a,}ml,}', - \ 'yaml.docker-compose': '{docker-compose*.yaml,docker-compose*.yml,}', - \ 'zephir': '{*.zep,}', - \ 'zig': '{*.zig,*.zir,}', - \ 'zir': '{*.zir,}', - \ 'zsh': '{*.zsh,.zshrc,.zshenv,.zlogin,.zprofile,.zlogout,}', + \ '8th': '*.8th', + \ 'Dockerfile': '*.dockerfile,*.dock,*.Dockerfile,Dockerfile,dockerfile,Dockerfile*', + \ 'Jenkinsfile': '*.jenkinsfile,*.Jenkinsfile,Jenkinsfile,Jenkinsfile*', + \ 'a2ps': 'a2psrc', + \ 'a65': '*.a65', + \ 'aap': '*.aap', + \ 'abap': '*.abap', + \ 'abaqus': '*.inp', + \ 'abc': '*.abc', + \ 'abel': '*.abl', + \ 'acedb': '*.wrm', + \ 'ada': '*.adb,*.ads,*.ada,*.gpr', + \ 'ahdl': '*.tdf', + \ 'aidl': '*.aidl', + \ 'alsaconf': '', + \ 'aml': '*.aml', + \ 'ampl': '*.run', + \ 'ant': 'build.xml', + \ 'apache': '', + \ 'apiblueprint': '*.apib', + \ 'applescript': '*.applescript,*.scpt', + \ 'aptconf': 'apt.conf', + \ 'arch': '=tagging-method', + \ 'arduino': '*.pde,*.ino', + \ 'art': '*.art', + \ 'asciidoc': '*.asciidoc,*.adoc,*.asc', + \ 'asl': '*.asl,*.dsl', + \ 'asn': '*.asn,*.asn1', + \ 'aspperl': '*.asp', + \ 'aspvbs': '*.asa,*.asp', + \ 'atlas': '*.atl,*.as', + \ 'autohotkey': '*.ahk,*.ahkl', + \ 'autoit': '*.au3', + \ 'automake': '[Mm]akefile.am,GNUmakefile.am', + \ 'ave': '*.ave', + \ 'awk': '*.awk', + \ 'blade': '*.blade,*.blade.php', + \ 'brewfile': 'Brewfile', + \ 'c': '*.c,*.cats,*.h,*.idc', + \ 'caddyfile': 'Caddyfile', + \ 'carp': '*.carp', + \ 'clojure': '*.clj,*.boot,*.cl2,*.cljc,*.cljs,*.cljs.hl,*.cljscm,*.cljx,*.hic,*.edn,riemann.config,build.boot,profile.boot', + \ 'cmake': '*.cmake,*.cmake.in,CMakeLists.txt', + \ 'coffee': '*.coffee,*._coffee,*.cake,*.cjsx,*.iced,*.coffeekup,Cakefile', + \ 'cpp': '*.cpp,*.c++,*.cc,*.cp,*.cxx,*.h,*.h++,*.hh,*.hpp,*.hxx,*.inc,*.inl,*.ipp,*.tcc,*.tpp', + \ 'cql': '*.cql', + \ 'cryptol': '*.cry,*.cyl,*.lcry,*.lcyl', + \ 'crystal': '*.cr,Projectfile', + \ 'csv': '*.csv,*.tsv,*.tab', + \ 'cucumber': '*.feature,*.story', + \ 'cuesheet': '*.cue', + \ 'd': '*.d,*.di', + \ 'dart': '*.dart', + \ 'dcov': '*.lst', + \ 'dd': '*.dd', + \ 'ddoc': '*.ddoc', + \ 'dhall': '*.dhall', + \ 'dosini': '*.wrap', + \ 'dsdl': '*.sdl', + \ 'dune': 'jbuild,dune,dune-project,dune-workspace', + \ 'ecrystal': '*.ecr', + \ 'eelixir': '*.eex,*.leex', + \ 'elf': '*.am', + \ 'elixir': '*.ex,*.exs,mix.lock', + \ 'elm': '*.elm', + \ 'embeddedpuppet': '*.epp', + \ 'ember-script': '*.em,*.emberscript', + \ 'emblem': '*.emblem,*.em', + \ 'erlang': '*.erl,*.app.src,*.es,*.escript,*.hrl,*.xrl,*.yrl,*.app,*.yaws,Emakefile,rebar.config,rebar.config.lock,rebar.lock', + \ 'eruby': '*.erb,*.erb.deface,*.rhtml', + \ 'fbs': '*.fbs', + \ 'fennel': '*.fnl', + \ 'ferm': '*.ferm,ferm.conf', + \ 'fish': '*.fish', + \ 'flow': '*.flow', + \ 'forth': '*.fs,*.ft,*.fth', + \ 'fsharp': '*.fs,*.fsi,*.fsx', + \ 'gdscript3': '*.gd', + \ 'gitcommit': '', + \ 'gitconfig': '*.gitconfig', + \ 'gitrebase': 'git-rebase-todo', + \ 'gitsendemail': '', + \ 'glsl': '*.glsl,*.fp,*.frag,*.frg,*.fs,*.fsh,*.fshader,*.geo,*.geom,*.glslf,*.glslv,*.gs,*.gshader,*.shader,*.tesc,*.tese,*.vert,*.vrx,*.vsh,*.vshader,*.comp', + \ 'gmpl': '*.mod', + \ 'gnuplot': '*.gp,*.gnu,*.gnuplot,*.p,*.plot,*.plt', + \ 'go': '*.go', + \ 'gohtmltmpl': '*.tmpl', + \ 'gomod': 'go.mod', + \ 'graphql': '*.graphql,*.gql,*.graphqls', + \ 'groovy': '*.gradle', + \ 'grub': '', + \ 'haml': '*.haml,*.haml.deface,*.hamlc,*.hamlbars', + \ 'haproxy': '*.cfg,haproxy.cfg,haproxy*.c*', + \ 'haskell': '*.hs,*.hs-boot,*.hsc,*.bpk,*.hsig', + \ 'haxe': '*.hx,*.hxsl', + \ 'hcl': '*.hcl,*.nomad,*.workflow,Appfile', + \ 'helm': '', + \ 'help': '', + \ 'hive': '*.q,*.hql,*.ql', + \ 'html': '*.html,*.htm,*.html.hl,*.inc,*.st,*.xht,*.xhtml', + \ 'html.twig': '*.twig', + \ 'i3config': '*.i3.config,*.i3config,i3.config,i3config', + \ 'icalendar': '*.ics', + \ 'idris': '*.idr,*.lidr,idris-response', + \ 'ion': '*.ion', + \ 'javascript': '*.js,*._js,*.bones,*.cjs,*.es,*.es6,*.frag,*.gs,*.jake,*.jsb,*.jscad,*.jsfl,*.jsm,*.jss,*.mjs,*.njs,*.pac,*.sjs,*.ssjs,*.xsjs,*.xsjslib,Jakefile', + \ 'javascriptreact': '*.jsx', + \ 'jinja.html': '*.jinja,*.j2,*.jinja2', + \ 'jq': '*.jq', + \ 'json': '*.json,*.avsc,*.geojson,*.gltf,*.har,*.ice,*.JSON-tmLanguage,*.jsonl,*.mcmeta,*.tfstate,*.tfstate.backup,*.topojson,*.webapp,*.webmanifest,*.yy,*.yyp,*.jsonp,*.template,composer.lock,mcmod.info', + \ 'json5': '*.json5', + \ 'jsonnet': '*.jsonnet,*.libsonnet', + \ 'jst': '*.ejs,*.ect,*.jst', + \ 'julia': '*.jl', + \ 'kotlin': '*.kt,*.ktm,*.kts', + \ 'ledger': '*.ldg,*.ledger,*.journal', + \ 'less': '*.less', + \ 'lilypond': '*.ly,*.ily', + \ 'litcoffee': '*.litcoffee,*.coffee.md', + \ 'livescript': '*.ls,*._ls,Slakefile', + \ 'llvm': '*.ll', + \ 'log': '*.log,*.LOG,*_log,*_LOG', + \ 'lua': '*.lua,*.fcgi,*.nse,*.p8,*.pd_lua,*.rbxs,*.rockspec,*.wlua', + \ 'm4': '*.m4,*.at', + \ 'mako': '*.mako,*.mao', + \ 'markdown': '*.md,*.markdown,*.mdown,*.mdwn,*.mkd,*.mkdn,*.mkdown,*.ronn,*.workbook,contents.lr', + \ 'markdown.mdx': '*.mdx', + \ 'meson': 'meson.build,meson_options.txt', + \ 'mma': '*.mathematica,*.cdf,*.m,*.ma,*.mt,*.nb,*.nbp,*.wl,*.wlt,*.wls', + \ 'moon': '*.moon', + \ 'murphi': '*.m', + \ 'mustache': '*.handlebars,*.hbs,*.hulk,*.hjs,*.mustache,*.njk,*.hogan,*.hdbs,*.hb', + \ 'nginx': '*.nginx,*.nginxconf,*.vhost,nginx.conf,nginx*.conf,*nginx.conf', + \ 'nim': '*.nim,*.nim.cfg,*.nimble,*.nimrod,*.nims,nim.cfg', + \ 'nix': '*.nix', + \ 'oasis': '_oasis', + \ 'objc': '*.m,*.h', + \ 'ocaml': '*.ml,*.eliom,*.eliomi,*.ml4,*.mli,*.mll,*.mly,*.mlt,*.mlp,*.mlip,*.mli.cppo,*.ml.cppo', + \ 'ocamlbuild_tags': '_tags', + \ 'ocpbuild': '*.ocp', + \ 'ocpbuildroot': '*.root', + \ 'octave': '*.oct,*.m', + \ 'omake': '*.om,OMakefile,OMakeroot,OMakeroot.in', + \ 'opam': '*.opam,*.opam.template,opam', + \ 'opencl': '*.cl,*.opencl', + \ 'perl': '*.pl,*.al,*.cgi,*.fcgi,*.perl,*.ph,*.plx,*.pm,*.psgi,*.t,Makefile.PL,Rexfile,ack,cpanfile', + \ 'php': '*.php,*.aw,*.ctp,*.fcgi,*.inc,*.php3,*.php4,*.php5,*.phps,*.phpt,Phakefile', + \ 'plantuml': '*.puml,*.iuml,*.plantuml,*.uml,*.pu', + \ 'pony': '*.pony', + \ 'proto': '*.proto', + \ 'ps1': '*.ps1,*.psd1,*.psm1,*.pssc', + \ 'ps1xml': '*.ps1xml', + \ 'pug': '*.jade,*.pug', + \ 'puppet': '*.pp,Modulefile', + \ 'purescript': '*.purs', + \ 'python': '*.py,*.cgi,*.fcgi,*.gyp,*.gypi,*.lmi,*.py3,*.pyde,*.pyi,*.pyp,*.pyt,*.pyw,*.rpy,*.smk,*.spec,*.tac,*.wsgi,*.xpy,DEPS,SConscript,SConstruct,Snakefile,wscript', + \ 'qmake': '*.pro,*.pri', + \ 'qml': '*.qml,*.qbs', + \ 'r': '*.r,*.rsx,*.s,*.S,expr-dist', + \ 'racket': '*.rkt,*.rktd,*.rktl,*.scrbl', + \ 'ragel': '*.rl', + \ 'raku': '*.6pl,*.6pm,*.nqp,*.p6,*.p6l,*.p6m,*.pl,*.pl6,*.pm,*.pm6,*.t,*.rakudoc,*.rakutest,*.raku,*.rakumod,*.pod6,*.t6', + \ 'raml': '*.raml', + \ 'razor': '*.cshtml,*.razor', + \ 'reason': '*.re,*.rei', + \ 'requirements': '*.pip,*requirements.{txt,in},*require.{txt,in},constraints.{txt,in}', + \ 'rhelp': '*.rd', + \ 'rst': '*.rst,*.rest,*.rest.txt,*.rst.txt', + \ 'ruby': '*.rb,*.builder,*.eye,*.fcgi,*.gemspec,*.god,*.jbuilder,*.mspec,*.pluginspec,*.podspec,*.rabl,*.rake,*.rbi,*.rbuild,*.rbw,*.rbx,*.ru,*.ruby,*.spec,*.thor,*.watchr,*.rxml,*.rjs,*.rant,*.axlsx,*.cap,*.opal,Appraisals,Berksfile,Buildfile,Capfile,Dangerfile,Deliverfile,Fastfile,Gemfile,Gemfile.lock,Guardfile,Jarfile,Mavenfile,Podfile,Puppetfile,Rakefile,Snapfile,Thorfile,Vagrantfile,buildfile,Rantfile,Cheffile,KitchenSink,Routefile,vagrantfile,[Rr]akefile*,*_spec.rb', + \ 'rust': '*.rs,*.rs.in', + \ 'sbt.scala': '*.sbt', + \ 'scala': '*.scala,*.kojo,*.sc', + \ 'scss': '*.scss', + \ 'sexplib': '*.sexp', + \ 'sh': '*.sh,*.bash,*.bats,*.cgi,*.command,*.env,*.fcgi,*.ksh,*.sh.in,*.tmux,*.tool,9fs,PKGBUILD,bash_aliases,bash_logout,bash_profile,bashrc,cshrc,gradlew,login,man,profile', + \ 'slim': '*.slim', + \ 'slime': '*.slime', + \ 'smt2': '*.smt2,*.smt', + \ 'solidity': '*.sol', + \ 'sql': '*.pgsql', + \ 'stylus': '*.styl,*.stylus', + \ 'svelte': '*.svelte', + \ 'svg': '*.svg', + \ 'swift': '*.swift', + \ 'sxhkdrc': '*.sxhkdrc,sxhkdrc', + \ 'systemd': '*.automount,*.mount,*.path,*.service,*.socket,*.swap,*.target,*.timer', + \ 'tablegen': '*.td', + \ 'terraform': '*.hcl,*.nomad,*.tf,*.tfvars,*.workflow', + \ 'textile': '*.textile', + \ 'thrift': '*.thrift', + \ 'tmux': '', + \ 'toml': '*.toml,Cargo.lock,Gopkg.lock,poetry.lock,Pipfile', + \ 'tptp': '*.p,*.tptp,*.ax', + \ 'trasys': '*.inp', + \ 'typescript': '*.ts', + \ 'typescriptreact': '*.tsx', + \ 'unison': '*.u,*.uu', + \ 'v': '*.v', + \ 'vala': '*.vala,*.vapi,*.valadoc', + \ 'vbnet': '*.vb,*.vbhtml', + \ 'vcl': '*.vcl', + \ 'velocity': '*.vm', + \ 'vmasm': '*.mar', + \ 'vue': '*.vue,*.wpy', + \ 'xdc': '*.xdc', + \ 'xml': '*.xml,*.adml,*.admx,*.ant,*.axml,*.builds,*.ccproj,*.ccxml,*.clixml,*.cproject,*.cscfg,*.csdef,*.csl,*.csproj,*.ct,*.depproj,*.dita,*.ditamap,*.ditaval,*.dll.config,*.dotsettings,*.filters,*.fsproj,*.fxml,*.glade,*.gml,*.gmx,*.grxml,*.gst,*.iml,*.ivy,*.jelly,*.jsproj,*.kml,*.launch,*.mdpolicy,*.mjml,*.mm,*.mod,*.mxml,*.natvis,*.ncl,*.ndproj,*.nproj,*.nuspec,*.odd,*.osm,*.pkgproj,*.pluginspec,*.proj,*.props,*.ps1xml,*.psc1,*.pt,*.rdf,*.resx,*.rss,*.sch,*.scxml,*.sfproj,*.shproj,*.srdf,*.storyboard,*.sublime-snippet,*.targets,*.tml,*.ui,*.urdf,*.ux,*.vbproj,*.vcxproj,*.vsixmanifest,*.vssettings,*.vstemplate,*.vxml,*.wixproj,*.workflow,*.wsdl,*.wsf,*.wxi,*.wxl,*.wxs,*.x3d,*.xacro,*.xaml,*.xib,*.xlf,*.xliff,*.xmi,*.xml.dist,*.xproj,*.xsd,*.xspec,*.xul,*.zcml,*.cdxml,App.config,NuGet.config,Settings.StyleCop,Web.Debug.config,Web.Release.config,Web.config,packages.config', + \ 'xml.twig': '*.xml.twig', + \ 'xsl': '*.xslt,*.xsl', + \ 'yaml': '*.yml,*.mir,*.reek,*.rviz,*.sublime-syntax,*.syntax,*.yaml,*.yaml-tmlanguage,*.yaml.sed,*.yml.mysql,glide.lock,yarn.lock,fish_history,fish_read_history', + \ 'yaml.ansible': 'playbook.y{a,}ml,site.y{a,}ml,main.y{a,}ml,local.y{a,}ml,requirements.y{a,}ml,tasks.*.y{a,}ml,roles.*.y{a,}ml,handlers.*.y{a,}ml', + \ 'yaml.docker-compose': 'docker-compose*.yaml,docker-compose*.yml', + \ 'zephir': '*.zep', + \ 'zig': '*.zig,*.zir', + \ 'zir': '*.zir', + \ 'zsh': '*.zsh', \} func! sleuth#GlobForFiletype(type) diff --git a/plugin/polyglot.vim b/plugin/polyglot.vim new file mode 100644 index 000000000..db2976e6d --- /dev/null +++ b/plugin/polyglot.vim @@ -0,0 +1,149 @@ +" Heuristically set expandtab and shiftwidth options +" +" Modified version of vim-sleuth: +" - tabstop is not set, it's up to user to set it +" - check maximum of 32 lines, instead of 1024 +" - check maximum 6 files, instead of 20 +" - check maximum of 2 filer per directory level, instead of 8 +" - check maximum of 3 directory levels +" - check only to the nearest .git, .hg, or .svn directory +" - globs are concatenated for performance +if exists('g:polyglot_disabled') && index(g:polyglot_disabled, 'autoindent') != -1 + finish +endif + +if exists("g:loaded_polyglot") || v:version < 700 || &cp + finish +endif + +let g:loaded_sleuth = 1 +let g:loaded_polyglot = 1 + +function! s:guess(lines) abort + let options = {} + let ccomment = 0 + let podcomment = 0 + let triplequote = 0 + let backtick = 0 + let xmlcomment = 0 + let minindent = 10 + let spaces_minus_tabs = 0 + + for line in a:lines + if !len(line) || line =~# '^\s*$' + continue + endif + + if line =~# '^\s*/\*' + let ccomment = 1 + endif + if ccomment + if line =~# '\*/' + let ccomment = 0 + endif + continue + endif + + if line =~# '^=\w' + let podcomment = 1 + endif + if podcomment + if line =~# '^=\%(end\|cut\)\>' + let podcomment = 0 + endif + continue + endif + + if triplequote + if line =~# '^[^"]*"""[^"]*$' + let triplequote = 0 + endif + continue + elseif line =~# '^[^"]*"""[^"]*$' + let triplequote = 1 + endif + + if backtick + if line =~# '^[^`]*`[^`]*$' + let backtick = 0 + endif + continue + elseif &filetype ==# 'go' && line =~# '^[^`]*`[^`]*$' + let backtick = 1 + endif + + if line =~# '^\s*<\!--' + let xmlcomment = 1 + endif + if xmlcomment + if line =~# '-->' + let xmlcomment = 0 + endif + continue + endif + + let spaces_minus_tabs += line[0] == "\t" ? 1 : -1 + + if line[0] == "\t" + setlocal noexpandtab + return 1 + elseif line[0] == " " + let indent = len(matchstr(line, '^ *')) + if indent % 2 == 0 && indent < minindent + let minindent = indent + endif + endif + endfor + + if minindent < 10 + setlocal expandtab + let &shiftwidth=minindent + return 1 + endif + + return 0 +endfunction + +function! s:detect_indent() abort + if &buftype ==# 'help' + return + endif + + if s:guess(getline(1, 32)) + return + endif + let pattern = sleuth#GlobForFiletype(&filetype) + if len(pattern) == 0 + return + endif + let pattern = '{' . pattern . ',.git,.svn,.hg}' + let dir = expand('%:p:h') + let level = 3 + while isdirectory(dir) && dir !=# fnamemodify(dir, ':h') && level > 0 + for neighbor in glob(dir . '/' . pattern, 0, 1)[0:level] + " Do not consider directories above .git, .svn or .hg + if fnamemodify(neighbor, ":h:t")[0] == "." + return + endif + if neighbor !=# expand('%:p') && filereadable(neighbor) + if s:guess(readfile(neighbor, '', 32)) + return + endif + endif + endfor + + let dir = fnamemodify(dir, ':h') + let level -= 1 + endwhile +endfunction + +setglobal smarttab + +if !exists('g:did_indent_on') + filetype indent on +endif + +augroup polyglot + autocmd! + autocmd FileType * call s:detect_indent() +augroup END diff --git a/plugin/sleuth.vim b/plugin/sleuth.vim deleted file mode 100644 index a0bba8c40..000000000 --- a/plugin/sleuth.vim +++ /dev/null @@ -1,166 +0,0 @@ -" Heuristically set buffer options -" -" Modified version of vim-sleuth: -" - softtab and tabstop reduced from 8 to 2 -" - number of considered lines reduced from 1024 to 64 -" - maximum 6 other files are checked instead of 20 -" - check maximum of files 2 per directory level instead of 8 -" - maximum of 3 directory levels are checked -" - globs are concatenated for performance -" - tabstop setting is not configured, it's up to user -if exists('g:polyglot_disabled') && index(g:polyglot_disabled, 'autoindent') != -1 - finish -endif - -if exists("g:loaded_sleuth") || exists("g:polyglot_disabled") || v:version < 700 || &cp - finish -endif - -let g:loaded_sleuth = 1 - -function! s:guess(lines) abort - let options = {} - let heuristics = {'spaces': 0, 'hard': 0, 'soft': 0} - let ccomment = 0 - let podcomment = 0 - let triplequote = 0 - let backtick = 0 - let xmlcomment = 0 - let softtab = repeat(' ', 2) - - for line in a:lines - if !len(line) || line =~# '^\s*$' - continue - endif - - if line =~# '^\s*/\*' - let ccomment = 1 - endif - if ccomment - if line =~# '\*/' - let ccomment = 0 - endif - continue - endif - - if line =~# '^=\w' - let podcomment = 1 - endif - if podcomment - if line =~# '^=\%(end\|cut\)\>' - let podcomment = 0 - endif - continue - endif - - if triplequote - if line =~# '^[^"]*"""[^"]*$' - let triplequote = 0 - endif - continue - elseif line =~# '^[^"]*"""[^"]*$' - let triplequote = 1 - endif - - if backtick - if line =~# '^[^`]*`[^`]*$' - let backtick = 0 - endif - continue - elseif &filetype ==# 'go' && line =~# '^[^`]*`[^`]*$' - let backtick = 1 - endif - - if line =~# '^\s*<\!--' - let xmlcomment = 1 - endif - if xmlcomment - if line =~# '-->' - let xmlcomment = 0 - endif - continue - endif - - if line =~# '^\t' - let heuristics.hard += 1 - elseif line =~# '^' . softtab - let heuristics.soft += 1 - endif - if line =~# '^ ' - let heuristics.spaces += 1 - endif - let indent = len(matchstr(substitute(line, '\t', softtab, 'g'), '^ *')) - if indent > 1 && (indent < 4 || indent % 2 == 0) && - \ get(options, 'shiftwidth', 99) > indent - let options.shiftwidth = indent - endif - endfor - - if heuristics.hard && !heuristics.spaces - return {'expandtab': 0, 'shiftwidth': &tabstop} - elseif heuristics.soft != heuristics.hard - let options.expandtab = heuristics.soft > heuristics.hard - endif - - return options -endfunction - -function! s:apply_if_ready(options) abort - if !has_key(a:options, 'expandtab') || !has_key(a:options, 'shiftwidth') - return 0 - else - for [option, value] in items(a:options) - call setbufvar('', '&'.option, value) - endfor - return 1 - endif -endfunction - -function! s:detect() abort - if &buftype ==# 'help' - return - endif - - let options = s:guess(getline(1, 64)) - if s:apply_if_ready(options) - return - endif - let c = 6 - let pattern = c > 0 ? sleuth#GlobForFiletype(&filetype) : '' - let dir = expand('%:p:h') - let level = 3 - while isdirectory(dir) && dir !=# fnamemodify(dir, ':h') && c > 0 && level > 0 - let level -= 1 - for neighbor in glob(dir.'/'.pattern,0,1)[0:1] - if neighbor !=# expand('%:p') && filereadable(neighbor) - call extend(options, s:guess(readfile(neighbor, '', 32)), 'keep') - let c -= 1 - endif - if s:apply_if_ready(options) - let b:sleuth_culprit = neighbor - return - endif - if c <= 0 - break - endif - endfor - if c <= 0 - break - endif - let dir = fnamemodify(dir, ':h') - endwhile - if has_key(options, 'shiftwidth') - return s:apply_if_ready(extend({'expandtab': 1}, options)) - endif -endfunction - -setglobal smarttab - -if !exists('g:did_indent_on') - filetype indent on -endif - -augroup polyglot - autocmd! - autocmd FileType * call s:detect() -augroup END diff --git a/scripts/build b/scripts/build index f8efb850f..892424aa0 100755 --- a/scripts/build +++ b/scripts/build @@ -751,14 +751,14 @@ def generate_plugins(packages) for package in packages for filetype in package["filetypes"] extensions = (filetype["extensions"] || []).map { |e| "*.#{e}" } - files = (filetype["filenames"] || []).reject { |e| e.match(/\*\*|\//) } + files = (filetype["filenames"] || []).reject { |e| e.match(/\*\*|\//) || e[0] == "." } patterns[filetype["name"]].concat(extensions) patterns[filetype["name"]].concat(files) end end for filetype in patterns.keys.sort - output << " \\ '#{filetype}': '{#{patterns[filetype].uniq.join(",")},}',\n" + output << " \\ '#{filetype}': '#{patterns[filetype].uniq.join(",")}',\n" end output << " \\}\n\n" From 262960fa223139eb5e02647e77af6bac13a17066 Mon Sep 17 00:00:00 2001 From: Adam Stankiewicz Date: Fri, 4 Sep 2020 18:29:53 +0200 Subject: [PATCH 010/299] Synchronize shiftwidth with tabstop by default --- ftdetect/polyglot.vim | 9 ++++- packages.yaml | 3 +- plugin/polyglot.vim | 5 +++ scripts/build | 77 ++----------------------------------------- 4 files changed, 18 insertions(+), 76 deletions(-) diff --git a/ftdetect/polyglot.vim b/ftdetect/polyglot.vim index 87b0cf259..de4665b2a 100644 --- a/ftdetect/polyglot.vim +++ b/ftdetect/polyglot.vim @@ -59,6 +59,9 @@ if !exists('g:python_highlight_all') call s:SetDefault('g:python_highlight_file_headers_as_comments', 1) call s:SetDefault('g:python_slow_sync', 1) endif + +" filetypes + if !has_key(s:disabled_packages, '8th') au! BufRead,BufNewFile *.8th endif @@ -377,7 +380,8 @@ endif if !has_key(s:disabled_packages, 'aptconf') au BufNewFile,BufRead */.aptitude/config setf aptconf - au BufNewFile,BufRead */etc/apt/apt.conf.d/{[-_[:alnum:]]\+,[-_.[:alnum:]]\+.conf} setf aptconf + au BufNewFile,BufRead */etc/apt/apt.conf.d/*.conf setf aptconf + au BufNewFile,BufRead */etc/apt/apt.conf.d/[^.]* setf aptconf au BufNewFile,BufRead apt.conf setf aptconf endif @@ -1722,6 +1726,9 @@ if !has_key(s:disabled_packages, 'trasys') au! BufNewFile,BufRead *.inp call polyglot#DetectInpFiletype() endif + +" end filetypes + au BufNewFile,BufRead,StdinReadPost * \ if !did_filetype() && expand("") !~ g:ft_ignore_pat \ | call polyglot#Heuristics() | endif diff --git a/packages.yaml b/packages.yaml index 1ff3f0ebd..ca5de3a39 100644 --- a/packages.yaml +++ b/packages.yaml @@ -179,7 +179,8 @@ filetypes: filenames: - apt.conf - '*/.aptitude/config' - - '*/etc/apt/apt.conf.d/{[-_[:alnum:]]\+,[-_.[:alnum:]]\+.conf}' + - '*/etc/apt/apt.conf.d/[^.]*' + - '*/etc/apt/apt.conf.d/*.conf' --- name: arch remote: vim/vim:runtime diff --git a/plugin/polyglot.vim b/plugin/polyglot.vim index db2976e6d..ccdef1128 100644 --- a/plugin/polyglot.vim +++ b/plugin/polyglot.vim @@ -19,6 +19,11 @@ endif let g:loaded_sleuth = 1 let g:loaded_polyglot = 1 +" Makes shiftwidth to be synchronized with tabstop by default +if &shiftwidth == &tabstop + let &shiftwidth = 0 +endif + function! s:guess(lines) abort let options = {} let ccomment = 0 diff --git a/scripts/build b/scripts/build index 892424aa0..c7f4846fb 100755 --- a/scripts/build +++ b/scripts/build @@ -371,69 +371,7 @@ def extract(packages) end def generate_ftdetect(packages, heuristics) - output = <<~EOS - " don't spam the user when Vim is started in Vi compatibility mode - let s:cpo_save = &cpo - set cpo&vim - - " Disable all native vim ftdetect - if exists('g:polyglot_test') - autocmd! - endif - - let s:disabled_packages = {} - - if exists('g:polyglot_disabled') - for pkg in g:polyglot_disabled - let s:disabled_packages[pkg] = 1 - endfor - endif - - function! s:SetDefault(name, value) - if !exists(a:name) - let {a:name} = a:value - endif - endfunction - - call s:SetDefault('g:markdown_enable_spell_checking', 0) - call s:SetDefault('g:markdown_enable_input_abbreviations', 0) - call s:SetDefault('g:markdown_enable_mappings', 0) - - " Enable jsx syntax by default - call s:SetDefault('g:jsx_ext_required', 0) - - " Needed for sql highlighting - call s:SetDefault('g:javascript_sql_dialect', 'sql') - - " Make csv loading faster - call s:SetDefault('g:csv_start', 1) - call s:SetDefault('g:csv_end', 2) - - " Disable json concealing by default - call s:SetDefault('g:vim_json_syntax_conceal', 0) - - call s:SetDefault('g:filetype_euphoria', 'elixir') - - if !exists('g:python_highlight_all') - call s:SetDefault('g:python_highlight_builtins', 1) - call s:SetDefault('g:python_highlight_builtin_objs', 1) - call s:SetDefault('g:python_highlight_builtin_types', 1) - call s:SetDefault('g:python_highlight_builtin_funcs', 1) - call s:SetDefault('g:python_highlight_builtin_funcs_kwarg', 1) - call s:SetDefault('g:python_highlight_exceptions', 1) - call s:SetDefault('g:python_highlight_string_formatting', 1) - call s:SetDefault('g:python_highlight_string_format', 1) - call s:SetDefault('g:python_highlight_string_templates', 1) - call s:SetDefault('g:python_highlight_indent_errors', 1) - call s:SetDefault('g:python_highlight_space_errors', 1) - call s:SetDefault('g:python_highlight_doctests', 1) - call s:SetDefault('g:python_highlight_func_calls', 1) - call s:SetDefault('g:python_highlight_class_vars', 1) - call s:SetDefault('g:python_highlight_operators', 1) - call s:SetDefault('g:python_highlight_file_headers_as_comments', 1) - call s:SetDefault('g:python_slow_sync', 1) - endif - EOS + output = "\n" extensions = Hash.new { |h, k| h[k] = [] } @@ -542,18 +480,9 @@ def generate_ftdetect(packages, heuristics) output << "endif\n\n" end - - output << <<~EOS - au BufNewFile,BufRead,StdinReadPost * - \\ if !did_filetype() && expand("") !~ g:ft_ignore_pat - \\ | call polyglot#Heuristics() | endif - - " restore Vi compatibility settings - let &cpo = s:cpo_save - unlet s:cpo_save - EOS - File.write('ftdetect/polyglot.vim', output) + ftdetect = File.read('ftdetect/polyglot.vim') + File.write('ftdetect/polyglot.vim', ftdetect.gsub(/(?<=" filetypes\n).*(?=\n" end filetypes)/m, output)) output = <<~EOS " Line continuation is used here, remove 'C' from 'cpoptions' From 556ba05ceeb3e1053c2a99a303a13b2b8e82f0f9 Mon Sep 17 00:00:00 2001 From: Adam Stankiewicz Date: Fri, 4 Sep 2020 18:55:51 +0200 Subject: [PATCH 011/299] Ignore heredoc when detecting indent --- plugin/polyglot.vim | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/plugin/polyglot.vim b/plugin/polyglot.vim index ccdef1128..bcf255f05 100644 --- a/plugin/polyglot.vim +++ b/plugin/polyglot.vim @@ -31,6 +31,7 @@ function! s:guess(lines) abort let triplequote = 0 let backtick = 0 let xmlcomment = 0 + let heredoc = '' let minindent = 10 let spaces_minus_tabs = 0 @@ -87,6 +88,18 @@ function! s:guess(lines) abort continue endif + " This is correct order because both "< 0 + let heredoc = herematch[1] . '$' + endif + let spaces_minus_tabs += line[0] == "\t" ? 1 : -1 if line[0] == "\t" From 48b4f233c57f1439e8c2381fb91d36641ea146eb Mon Sep 17 00:00:00 2001 From: Adam Stankiewicz Date: Fri, 4 Sep 2020 19:02:39 +0200 Subject: [PATCH 012/299] Fix detecting indentation in some CSS This is done by ignoring lines that don't have any alphanumeric characters, e.g. following would be detected as 4-spaces indentation instead of 2-spaces .android { height: 404px; width: 334px; margin: 100px auto; } https://github.com/tpope/vim-sleuth/issues/22 --- plugin/polyglot.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin/polyglot.vim b/plugin/polyglot.vim index bcf255f05..bb31dc07d 100644 --- a/plugin/polyglot.vim +++ b/plugin/polyglot.vim @@ -36,7 +36,7 @@ function! s:guess(lines) abort let spaces_minus_tabs = 0 for line in a:lines - if !len(line) || line =~# '^\s*$' + if !len(line) || line =~# '^\W*$' continue endif From 99166bd51f2f4f304f03ba762ab4067b00d55bbe Mon Sep 17 00:00:00 2001 From: Adam Stankiewicz Date: Fri, 4 Sep 2020 19:21:08 +0200 Subject: [PATCH 013/299] Do not set indent on by default https://github.com/tpope/vim-sleuth/issues/21 --- plugin/polyglot.vim | 4 ---- 1 file changed, 4 deletions(-) diff --git a/plugin/polyglot.vim b/plugin/polyglot.vim index bb31dc07d..fad7609b9 100644 --- a/plugin/polyglot.vim +++ b/plugin/polyglot.vim @@ -157,10 +157,6 @@ endfunction setglobal smarttab -if !exists('g:did_indent_on') - filetype indent on -endif - augroup polyglot autocmd! autocmd FileType * call s:detect_indent() From b0124dc88082f5ed8c96faa16d3b334d38f5949f Mon Sep 17 00:00:00 2001 From: Adam Stankiewicz Date: Fri, 4 Sep 2020 19:45:47 +0200 Subject: [PATCH 014/299] Ignore files from homedir and root for indent https://github.com/tpope/vim-sleuth/pull/57 --- plugin/polyglot.vim | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/plugin/polyglot.vim b/plugin/polyglot.vim index fad7609b9..762e4fcd5 100644 --- a/plugin/polyglot.vim +++ b/plugin/polyglot.vim @@ -138,6 +138,10 @@ function! s:detect_indent() abort let dir = expand('%:p:h') let level = 3 while isdirectory(dir) && dir !=# fnamemodify(dir, ':h') && level > 0 + " Ignore files from homedir and root + if dir == expand('~') || dir == '/' + return + endif for neighbor in glob(dir . '/' . pattern, 0, 1)[0:level] " Do not consider directories above .git, .svn or .hg if fnamemodify(neighbor, ":h:t")[0] == "." From 3baafd5c336d18d87898ae87f16df7cd76bc8d65 Mon Sep 17 00:00:00 2001 From: CodingCellist Date: Sat, 5 Sep 2020 21:37:11 +0200 Subject: [PATCH 015/299] Add support for Idris2, closes #534 (#535) --- README.md | 3 +- after/ftplugin/idris2.vim | 5 + after/syntax/idris2.vim | 82 +++++++++ autoload/cargo/quickfix.vim | 3 +- autoload/polyglot.vim | 44 +++++ autoload/rustfmt.vim | 4 +- autoload/sleuth.vim | 2 + doc/idris2-vim.txt | 158 +++++++++++++++++ ftdetect/polyglot.vim | 11 +- ftplugin/idris2.vim | 334 ++++++++++++++++++++++++++++++++++++ heuristics.yaml | 30 ++++ indent/idris2.vim | 148 ++++++++++++++++ packages.yaml | 13 ++ scripts/build | 6 + scripts/test_extensions.vim | 30 ++++ scripts/test_filetypes.vim | 2 + syntax/idris2.vim | 85 +++++++++ syntax/lidris2.vim | 26 +++ syntax/rust.vim | 3 +- 19 files changed, 982 insertions(+), 7 deletions(-) create mode 100644 after/ftplugin/idris2.vim create mode 100644 after/syntax/idris2.vim create mode 100644 doc/idris2-vim.txt create mode 100644 ftplugin/idris2.vim create mode 100644 indent/idris2.vim create mode 100644 syntax/idris2.vim create mode 100644 syntax/lidris2.vim diff --git a/README.md b/README.md index 8c744c10a..6789eb72a 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ A collection of language packs for Vim. > One to rule them all, one to find them, one to bring them all and in the darkness bind them. - It **won't affect your startup time**, as scripts are loaded only on demand\*. -- It **installs and updates 120+ times faster** than the 190 packages it consists of. +- It **installs and updates 120+ times faster** than the 191 packages it consists of. - It is more secure because scripts loaded for all extensions are generated by vim-polyglot (ftdetect). - Solid syntax and indentation support (other features skipped). Only the best language packs. - All unnecessary files are ignored (like enormous documentation from php support). @@ -130,6 +130,7 @@ If you need full functionality of any plugin, please use it directly with your p - [html5](https://github.com/othree/html5.vim) - [i3](https://github.com/mboughaba/i3config.vim) - [icalendar](https://github.com/chutzpah/icalendar.vim) +- [idris2](https://github.com/edwinb/idris2-vim) - [idris](https://github.com/idris-hackers/idris-vim) - [ion](https://github.com/vmchale/ion-vim) - [javascript-sql](https://github.com/statico/vim-javascript-sql) diff --git a/after/ftplugin/idris2.vim b/after/ftplugin/idris2.vim new file mode 100644 index 000000000..b96ae5b6c --- /dev/null +++ b/after/ftplugin/idris2.vim @@ -0,0 +1,5 @@ +if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'idris2') == -1 + +setlocal iskeyword+=' + +endif diff --git a/after/syntax/idris2.vim b/after/syntax/idris2.vim new file mode 100644 index 000000000..85f674a99 --- /dev/null +++ b/after/syntax/idris2.vim @@ -0,0 +1,82 @@ +if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'idris2') == -1 + +" This script allows for unicode concealing of certain characters +" For instance -> goes to → +" +" It needs vim >= 7.3, set nocompatible, set enc=utf-8 +" +" If you want to turn this on, let g:idris_conceal = 1 + +if !exists('g:idris_conceal') || !has('conceal') || &enc != 'utf-8' + finish +endif + +" vim: set fenc=utf-8: +syntax match idrNiceOperator "\\\ze[[:alpha:][:space:]_([]" conceal cchar=λ +syntax match idrNiceOperator "<-" conceal cchar=← +syntax match idrNiceOperator "->" conceal cchar=→ +syntax match idrNiceOperator "\" conceal cchar=∑ +syntax match idrNiceOperator "\" conceal cchar=∏ +syntax match idrNiceOperator "\" conceal cchar=√ +syntax match idrNiceOperator "\" conceal cchar=π +syntax match idrNiceOperator "==" conceal cchar=≡ +syntax match idrNiceOperator "\/=" conceal cchar=≠ + + +let s:extraConceal = 1 + +let s:doubleArrow = 1 +" Set this to 0 to use the more technically correct arrow from bar + +" Some windows font don't support some of the characters, +" so if they are the main font, we don't load them :) +if has("win32") + let s:incompleteFont = [ 'Consolas' + \ , 'Lucida Console' + \ , 'Courier New' + \ ] + let s:mainfont = substitute( &guifont, '^\([^:,]\+\).*', '\1', '') + for s:fontName in s:incompleteFont + if s:mainfont ==? s:fontName + let s:extraConceal = 0 + break + endif + endfor +endif + +if s:extraConceal + syntax match idrNiceOperator "Void" conceal cchar=⊥ + + " Match greater than and lower than w/o messing with Kleisli composition + syntax match idrNiceOperator "<=\ze[^<]" conceal cchar=≤ + syntax match idrNiceOperator ">=\ze[^>]" conceal cchar=≥ + + if s:doubleArrow + syntax match idrNiceOperator "=>" conceal cchar=⇒ + else + syntax match idrNiceOperator "=>" conceal cchar=↦ + endif + + syntax match idrNiceOperator "=\zs<<" conceal cchar=« + + syntax match idrNiceOperator "++" conceal cchar=⧺ + syntax match idrNiceOperator "::" conceal cchar=∷ + syntax match idrNiceOperator "-<" conceal cchar=↢ + syntax match idrNiceOperator ">-" conceal cchar=↣ + syntax match idrNiceOperator "-<<" conceal cchar=⤛ + syntax match idrNiceOperator ">>-" conceal cchar=⤜ + + " Only replace the dot, avoid taking spaces around. + syntax match idrNiceOperator /\s\.\s/ms=s+1,me=e-1 conceal cchar=∘ + syntax match idrNiceOperator "\.\." conceal cchar=‥ + + syntax match idrNiceOperator "`elem`" conceal cchar=∈ + syntax match idrNiceOperator "`notElem`" conceal cchar=∉ +endif + +hi link idrNiceOperator Operator +hi! link Conceal Operator +setlocal conceallevel=2 + + +endif diff --git a/autoload/cargo/quickfix.vim b/autoload/cargo/quickfix.vim index e1e5b9d25..cce7fcbb7 100644 --- a/autoload/cargo/quickfix.vim +++ b/autoload/cargo/quickfix.vim @@ -1,7 +1,8 @@ if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'rust') == -1 function! cargo#quickfix#CmdPre() abort - if &filetype ==# 'rust' && get(b:, 'current_compiler', '') ==# 'cargo' + if &filetype ==# 'rust' && get(b:, 'current_compiler', '') ==# 'cargo' && + \ &makeprg =~ '\V\^cargo\ \.\*' " Preserve the current directory, and 'lcd' to the nearest Cargo file. let b:rust_compiler_cargo_qf_has_lcd = haslocaldir() let b:rust_compiler_cargo_qf_prev_cd = getcwd() diff --git a/autoload/polyglot.vim b/autoload/polyglot.vim index 3753dc8e4..eca7e304e 100644 --- a/autoload/polyglot.vim +++ b/autoload/polyglot.vim @@ -212,6 +212,50 @@ func! polyglot#DetectReFiletype() endfor endfunc +func! polyglot#DetectIdrFiletype() + for lnum in range(1, min([line("$"), 5])) + let line = getline(lnum) + if line =~# '^\s*--.*[Ii]dris \=1' + setf idris | return + endif + if line =~# '^\s*--.*[Ii]dris \=2' + setf idris2 | return + endif + endfor + for lnum in range(1, min([line("$"), 30])) + let line = getline(lnum) + if line =~# '^pkgs =.*' + setf idris | return + endif + if line =~# '^depends =.*' + setf idris2 | return + endif + if line =~# '^%language \(TypeProviders\|ElabReflection\)' + setf idris | return + endif + if line =~# '^%language PostfixProjections' + setf idris2 | return + endif + if line =~# '^%access .*' + setf idris | return + endif + if exists("g:filetype_idr") + exe "setf " . g:filetype_idr | return + endif + endfor + setf idris2 | return +endfunc + +func! polyglot#DetectLidrFiletype() + for lnum in range(1, min([line("$"), 200])) + let line = getline(lnum) + if line =~# '^>\s*--.*[Ii]dris \=1' + setf lidris | return + endif + endfor + setf lidris2 | return +endfunc + " Restore 'cpoptions' let &cpo = s:cpo_save unlet s:cpo_save diff --git a/autoload/rustfmt.vim b/autoload/rustfmt.vim index 514e41474..60e2029e8 100644 --- a/autoload/rustfmt.vim +++ b/autoload/rustfmt.vim @@ -65,12 +65,12 @@ endfunction function! s:RustfmtConfigOptions() let l:rustfmt_toml = findfile('rustfmt.toml', expand('%:p:h') . ';') if l:rustfmt_toml !=# '' - return '--config-path '.fnamemodify(l:rustfmt_toml, ":p") + return '--config-path '.shellescape(fnamemodify(l:rustfmt_toml, ":p")) endif let l:_rustfmt_toml = findfile('.rustfmt.toml', expand('%:p:h') . ';') if l:_rustfmt_toml !=# '' - return '--config-path '.fnamemodify(l:_rustfmt_toml, ":p") + return '--config-path '.shellescape(fnamemodify(l:_rustfmt_toml, ":p")) endif " Default to edition 2018 in case no rustfmt.toml was found. diff --git a/autoload/sleuth.vim b/autoload/sleuth.vim index a912cda45..e70169cb9 100644 --- a/autoload/sleuth.vim +++ b/autoload/sleuth.vim @@ -103,6 +103,7 @@ let s:globs = { \ 'i3config': '*.i3.config,*.i3config,i3.config,i3config', \ 'icalendar': '*.ics', \ 'idris': '*.idr,*.lidr,idris-response', + \ 'idris2': '*.idr,*.ipkg,idris-response', \ 'ion': '*.ion', \ 'javascript': '*.js,*._js,*.bones,*.cjs,*.es,*.es6,*.frag,*.gs,*.jake,*.jsb,*.jscad,*.jsfl,*.jsm,*.jss,*.mjs,*.njs,*.pac,*.sjs,*.ssjs,*.xsjs,*.xsjslib,Jakefile', \ 'javascriptreact': '*.jsx', @@ -116,6 +117,7 @@ let s:globs = { \ 'kotlin': '*.kt,*.ktm,*.kts', \ 'ledger': '*.ldg,*.ledger,*.journal', \ 'less': '*.less', + \ 'lidris2': '*.lidr', \ 'lilypond': '*.ly,*.ily', \ 'litcoffee': '*.litcoffee,*.coffee.md', \ 'livescript': '*.ls,*._ls,Slakefile', diff --git a/doc/idris2-vim.txt b/doc/idris2-vim.txt new file mode 100644 index 000000000..80a53cfc5 --- /dev/null +++ b/doc/idris2-vim.txt @@ -0,0 +1,158 @@ +if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'idris2') == -1 + +*idris2-vim.txt* Last change 2020 February 22 +=============================================================================== +=============================================================================== + @@@@ @@@@@@@@ @@@@@@@@ @@@@ @@@@@@ @@ @@ @@@@ @@ @@ + @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@@ @@@ + @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@@@ @@@@ + @@ @@ @@ @@@@@@@@ @@ @@@@@@ @@@@@@@ @@ @@ @@ @@ @@@ @@ + @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ + @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ + @@@@ @@@@@@@@ @@ @@ @@@@ @@@@@@ @@@ @@@@ @@ @@ +=============================================================================== +CONTENTS *idris-vim-contents* + + 1. Features: |idris-vim-features| + 2. Requirements: |idris-vim-requirements| + 3. Functions: |idris-vim-functions| + 4. Troubleshooting |idris-vim-troubleshooting| + 5. Examples: |idris-vim-examples| + 6. Information: |idris-vim-information| + +=============================================================================== +FEATURES *idris-vim-features* + + * Syntax Highlighting + * Indentation + * Unicode Concealing + * Syntax Checking (via Syntastic(https://github.com/scrooloose/syntastic)) + * Interactive Editing via the REPL + +=============================================================================== +REQUIREMENTS *idris-vim-requirements* + + * Idris2 (https://github.com/edwinb/Idris2/) + + OPTIONAL: + + * Syntastic(https://github.com/scrooloose/syntastic) for syntax checking + * Vimshell(https://github.com/Shougo/vimshell.vim) for a REPL + +=============================================================================== +FUNCTIONS *idris-vim-functions* + +All of the functions in idris-vim are essentially just calls back to the REPL, +so documentation for each of them is also available there. + +IdrisDocumentation *IdrisDocumentation* + Shows internal documentation of the primitive under the cursor. + + Mapped to '_h' by default. + +IdrisResponseWin *IdrisResponseWin* + This opens an idris response window in a new pane. + + Mapped to '_i' by default. + +IdrisShowType *IdrisShowType* + This shows the type of the name under the cursor (or, if the cursor happens + to be over a metavariable, a bit more information about its context). + + Mapped to '_t' by default. + +IdrisReload *IdrisReload* + This reloads the file and type-checks the file in the current buffer. + + Mapped to '_r' by default. + +IdrisEval *IdrisEval* + This prompts for an expression and then evaluates it in the REPL, then + returns the result. + + Mapped to '_e' by default. + +IdrisCaseSplit *IdrisCaseSplit* + When the cursor is over a variable in a pattern match clause or case + expression, this splits the variable into all well-typed patterns. + + Mapped to '_c' by default + +IdrisAddClause *IdrisAddClause* + When the cursor is at a type declaration this creates a new clause for that + signature. + + By default mapped to '_d' for an ordinary top-level definition, + '_b' for a typeclass instance definition, and + '_md' to add a pattern-matching proof clause. + +IdrisAddMissing: *IdrisAddMissing* + When the cursor is over a function, this adds all clauses necessary to make + that function cover all inputs. This also eliminates clauses which would + lead to unification errors from appearing. + + Mapped to '_m' by default + +IdrisRefine: *IdrisRefine* + Refines the item the cursor is over (applies the name and fills in any + arguments which can be filled in via unification) + + Mapped to '_f' by default + +IdrisProofSearch: *IdrisProofSearch* + This attempts to find a value for the metavariable it was called on by + looking at the rest of the code. It can also be called with hints, which + are functions that can apply to help solve for the metavariable. + + Mapped to '_o' without hints and 'p' with hints by + default + +IdrisMakeWith: *IdrisMakeWith* + When the cursor is over a pattern clause and this is called, it creates a + new with clause. + + Mapped to '_w' by default + +IdrisMakeLemma: *IdrisMakeLemma* + When the cursor is over a metavariable and this is called, it creates a new + top-level definition to solve the metavariable. + + Mapped to '_l' by default + +=============================================================================== +TROUBLESHOOTING *idris-vim-troubleshooting* + +If this isn't working for you, make sure that: + + * There is an Idris REPL running + * For syntax checking, you have syntastic installed + * The plugins mappings exists and don't conflict with anything else installed + (You can use ':map' to check. There should be mappings similar to + '\h * :call IdrisShowDoc()'.) + * Vim recognizes you're in an idris file (you can use ':verb set ft' to check) + +If none of this works, check to issue tracker on github and if nothing is +there create an issue with a detailed description of the problem. + +=============================================================================== +EXAMPLES *idris-vim-examples* + +Some excellent tutorials/examples for interactive editing using the above +functions can be found at: + http://edwinb.wordpress.com/2013/10/28/interactive-idris-editing-with-vim/ +and + http://www.scribd.com/doc/214031954/60/Interactive-Editing-in-Vim + +=============================================================================== +INFORMATION *idris-vim-information* + +Author: edwinb +Repo: https://github.com/idris-hackers/idris-vim + +Documentation by japesinator + +=============================================================================== +=============================================================================== +" vim:ft=help:et:ts=2:sw=2:sts=2:norl: + +endif diff --git a/ftdetect/polyglot.vim b/ftdetect/polyglot.vim index de4665b2a..186ba9daf 100644 --- a/ftdetect/polyglot.vim +++ b/ftdetect/polyglot.vim @@ -795,9 +795,16 @@ if !has_key(s:disabled_packages, 'icalendar') endif if !has_key(s:disabled_packages, 'idris') - au BufNewFile,BufRead *.idr setf idris - au BufNewFile,BufRead *.lidr setf idris au BufNewFile,BufRead idris-response setf idris + au! BufNewFile,BufRead *.idr call polyglot#DetectIdrFiletype() + au! BufNewFile,BufRead *.lidr call polyglot#DetectLidrFiletype() +endif + +if !has_key(s:disabled_packages, 'idris2') + au BufNewFile,BufRead *.ipkg setf idris2 + au BufNewFile,BufRead idris-response setf idris2 + au! BufNewFile,BufRead *.idr call polyglot#DetectIdrFiletype() + au! BufNewFile,BufRead *.lidr call polyglot#DetectLidrFiletype() endif if !has_key(s:disabled_packages, 'ion') diff --git a/ftplugin/idris2.vim b/ftplugin/idris2.vim new file mode 100644 index 000000000..420bc52d2 --- /dev/null +++ b/ftplugin/idris2.vim @@ -0,0 +1,334 @@ +if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'idris2') == -1 + +if bufname('%') == "idris-response" + finish +endif + +if exists("b:did_ftplugin") + finish +endif + +setlocal shiftwidth=2 +setlocal tabstop=2 +if !exists("g:idris_allow_tabchar") || g:idris_allow_tabchar == 0 + setlocal expandtab +endif +setlocal comments=s1:{-,mb:-,ex:-},:\|\|\|,:-- +setlocal commentstring=--%s +setlocal iskeyword+=? +setlocal wildignore+=*.ibc + +let idris_response = 0 +let b:did_ftplugin = 1 + +" Text near cursor position that needs to be passed to a command. +" Refinment of `expand()` to accomodate differences between +" a (n)vim word and what Idris requires. +function! s:currentQueryObject() + let word = expand("") + if word =~ '^?' + " Cut off '?' that introduces a hole identifier. + let word = strpart(word, 1) + endif + return word +endfunction + +function! s:IdrisCommand(...) + let idriscmd = shellescape(join(a:000)) +" echo("idris2 " . expand ('%:p') . " --client " . idriscmd) + return system("idris2 --find-ipkg " . shellescape(expand('%:p')) . " --client " . idriscmd) +endfunction + +function! IdrisDocFold(lineNum) + let line = getline(a:lineNum) + + if line =~ "^\s*|||" + return "1" + endif + + return "0" +endfunction + +function! IdrisFold(lineNum) + return IdrisDocFold(a:lineNum) +endfunction + +setlocal foldmethod=expr +setlocal foldexpr=IdrisFold(v:lnum) + +function! IdrisResponseWin() + if (!bufexists("idris-response")) + botright 10split + badd idris-response + b idris-response + let g:idris_respwin = "active" + set buftype=nofile + wincmd k + elseif (bufexists("idris-response") && g:idris_respwin == "hidden") + botright 10split + b idris-response + let g:idris_respwin = "active" + wincmd k + endif +endfunction + +function! IdrisHideResponseWin() + let g:idris_respwin = "hidden" +endfunction + +function! IdrisShowResponseWin() + let g:idris_respwin = "active" +endfunction + +function! IWrite(str) + if (bufexists("idris-response")) + let save_cursor = getcurpos() + b idris-response + %delete + let resp = split(a:str, '\n') + call append(1, resp) + b # + call setpos('.', save_cursor) + else + echo a:str + endif +endfunction + +function! IdrisReload(q) + w + let file = expand('%:p') + let tc = system("idris2 --find-ipkg " . shellescape(file) . " --client ''") + if (! (tc is "")) + call IWrite(tc) + else + if (a:q==0) + call IWrite("Successfully reloaded " . file) + endif + endif + return tc +endfunction + +function! IdrisReloadToLine(cline) + return IdrisReload(1) + "w + "let file = expand("%:p") + "let tc = s:IdrisCommand(":lto", a:cline, file) + "if (! (tc is "")) + " call IWrite(tc) + "endif + "return tc +endfunction + +function! IdrisShowType() + w + let word = s:currentQueryObject() + let cline = line(".") + let ccol = col(".") + let ty = s:IdrisCommand(":t", word) + call IWrite(ty) +endfunction + +function! IdrisShowDoc() + w + let word = expand("") + let ty = s:IdrisCommand(":doc", word) + call IWrite(ty) +endfunction + +function! IdrisProofSearch(hint) + let view = winsaveview() + w + let cline = line(".") + let word = s:currentQueryObject() + + if (a:hint==0) + let hints = "" + else + let hints = input ("Hints: ") + endif + + let result = s:IdrisCommand(":ps!", cline, word, hints) + if (! (result is "")) + call IWrite(result) + else + e + call winrestview(view) + endif +endfunction + +function! IdrisGenerateDef() + let view = winsaveview() + w + let cline = line(".") + let word = s:currentQueryObject() + + let result = s:IdrisCommand(":gd!", cline, word) + if (! (result is "")) + call IWrite(result) + else + e + call winrestview(view) + endif +endfunction + +function! IdrisMakeLemma() + let view = winsaveview() + w + let cline = line(".") + let word = s:currentQueryObject() + + let result = s:IdrisCommand(":ml!", cline, word) + if (! (result is "")) + call IWrite(result) + else + e + call winrestview(view) + call search(word, "b") + endif +endfunction + +function! IdrisRefine() + let view = winsaveview() + w + let cline = line(".") + let word = expand("") + let name = input ("Name: ") + + let result = s:IdrisCommand(":ref!", cline, word, name) + if (! (result is "")) + call IWrite(result) + else + e + call winrestview(view) + endif +endfunction + +function! IdrisAddMissing() + let view = winsaveview() + w + let cline = line(".") + let word = expand("") + + let result = s:IdrisCommand(":am!", cline, word) + if (! (result is "")) + call IWrite(result) + else + e + call winrestview(view) + endif +endfunction + +function! IdrisCaseSplit() + w + let view = winsaveview() + let cline = line(".") + let ccol = col(".") + let word = expand("") + let result = s:IdrisCommand(":cs!", cline, ccol, word) + if (! (result is "")) + call IWrite(result) + else + e + call winrestview(view) + endif +endfunction + +function! IdrisMakeWith() + let view = winsaveview() + w + let cline = line(".") + let word = s:currentQueryObject() + let tc = IdrisReload(1) + + let result = s:IdrisCommand(":mw!", cline, word) + if (! (result is "")) + call IWrite(result) + else + e + call winrestview(view) + call search("_") + endif +endfunction + +function! IdrisMakeCase() + let view = winsaveview() + w + let cline = line(".") + let word = s:currentQueryObject() + + let result = s:IdrisCommand(":mc!", cline, word) + if (! (result is "")) + call IWrite(result) + else + e + call winrestview(view) + call search("_") + endif +endfunction + +function! IdrisAddClause(proof) + let view = winsaveview() + w + let cline = line(".") + let word = expand("") + + if (a:proof==0) + let fn = ":ac!" + else + let fn = ":apc!" + endif + + let result = s:IdrisCommand(fn, cline, word) + if (! (result is "")) + call IWrite(result) + else + e + call winrestview(view) + call search(word) + + endif +endfunction + +function! IdrisEval() + w + let expr = input ("Expression: ") + let result = s:IdrisCommand(expr) + call IWrite(" = " . result) +endfunction + +nnoremap t :call IdrisShowType() +nnoremap r :call IdrisReload(0) +nnoremap c :call IdrisCaseSplit() +nnoremap a 0:call search(":")b:call IdrisAddClause(0)w +nnoremap d 0:call search(":")b:call IdrisAddClause(0)w +nnoremap b 0:call IdrisAddClause(0) +nnoremap m :call IdrisAddMissing() +nnoremap md 0:call search(":")b:call IdrisAddClause(1)w +nnoremap f :call IdrisRefine() +nnoremap o :call IdrisProofSearch(0) +nnoremap s :call IdrisProofSearch(0) +nnoremap g :call IdrisGenerateDef() +nnoremap p :call IdrisProofSearch(1) +nnoremap l :call IdrisMakeLemma() +nnoremap e :call IdrisEval() +nnoremap w 0:call IdrisMakeWith() +nnoremap mc :call IdrisMakeCase() +nnoremap i 0:call IdrisResponseWin() +nnoremap h :call IdrisShowDoc() + +menu Idris.Reload r +menu Idris.Show\ Type t +menu Idris.Evaluate e +menu Idris.-SEP0- : +menu Idris.Add\ Clause a +menu Idris.Generate\ Definition g +menu Idris.Add\ with w +menu Idris.Case\ Split c +menu Idris.Add\ missing\ cases m +menu Idris.Proof\ Search s +menu Idris.Proof\ Search\ with\ hints p + +au BufHidden idris-response call IdrisHideResponseWin() +au BufEnter idris-response call IdrisShowResponseWin() + +endif diff --git a/heuristics.yaml b/heuristics.yaml index 97999022b..33c1c6906 100644 --- a/heuristics.yaml +++ b/heuristics.yaml @@ -63,3 +63,33 @@ rules: - pattern: '^\s*#(?:(?:if|ifdef|define|pragma)\s+\w|\s*include\s+[<"]|template\s*<)' filetype: cpp - filetype: reason +--- +extensions: [idr] +rules: +- lines: 5 + rules: + - pattern: '^\s*--.*[Ii]dris ?1' + filetype: idris + - pattern: '^\s*--.*[Ii]dris ?2' + filetype: idris2 +- lines: 30 + rules: + - pattern: '^pkgs =.*' + filetype: idris + - pattern: '^depends =.*' + filetype: idris2 + - pattern: '^%language (TypeProviders|ElabReflection)' + filetype: idris + - pattern: '^%language PostfixProjections' + filetype: idris2 + - pattern: '^%access .*' + filetype: idris + - override: 'g:filetype_idr' +- filetype: idris2 +--- +extensions: [lidr] +rules: +- lines: 200 + pattern: '^>\s*--.*[Ii]dris ?1' + filetype: lidris +- filetype: lidris2 diff --git a/indent/idris2.vim b/indent/idris2.vim new file mode 100644 index 000000000..83995423f --- /dev/null +++ b/indent/idris2.vim @@ -0,0 +1,148 @@ +if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'idris2') == -1 + +" indentation for idris (idris-lang.org) +" +" Based on haskell indentation by motemen +" +" author: raichoo (raichoo@googlemail.com) +" +" Modify g:idris_indent_if and g:idris_indent_case to +" change indentation for `if'(default 3) and `case'(default 5). +" Example (in .vimrc): +" > let g:idris_indent_if = 2 + +if exists('b:did_indent') + finish +endif + +let b:did_indent = 1 + +if !exists('g:idris_indent_if') + " if bool + " >>>then ... + " >>>else ... + let g:idris_indent_if = 3 +endif + +if !exists('g:idris_indent_case') + " case xs of + " >>>>>[] => ... + " >>>>>(y::ys) => ... + let g:idris_indent_case = 5 +endif + +if !exists('g:idris_indent_let') + " let x : Nat = O in + " >>>>x + let g:idris_indent_let = 4 +endif + +if !exists('g:idris_indent_rewrite') + " rewrite prf in expr + " >>>>>>>>x + let g:idris_indent_rewrite = 8 +endif + +if !exists('g:idris_indent_where') + " where f : Nat -> Nat + " >>>>>>f x = x + let g:idris_indent_where = 6 +endif + +if !exists('g:idris_indent_do') + " do x <- a + " >>>y <- b + let g:idris_indent_do = 3 +endif + +setlocal indentexpr=GetIdrisIndent() +setlocal indentkeys=!^F,o,O,} + +function! GetIdrisIndent() + let prevline = getline(v:lnum - 1) + + if prevline =~ '\s\+(\s*.\+\s\+:\s\+.\+\s*)\s\+->\s*$' + return match(prevline, '(') + elseif prevline =~ '\s\+{\s*.\+\s\+:\s\+.\+\s*}\s\+->\s*$' + return match(prevline, '{') + endif + + if prevline =~ '[!#$%&*+./<>?@\\^|~-]\s*$' + let s = match(prevline, '[:=]') + if s > 0 + return s + 2 + else + return match(prevline, '\S') + endif + endif + + if prevline =~ '[{([][^})\]]\+$' + return match(prevline, '[{([]') + endif + + if prevline =~ '\\s\+.\+\\s*$' + return match(prevline, '\') + g:idris_indent_let + endif + + if prevline =~ '\\s\+.\+\\s*$' + return match(prevline, '\') + g:idris_indent_rewrite + endif + + if prevline !~ '\' + let s = match(prevline, '\.*\&.*\zs\') + if s > 0 + return s + endif + + let s = match(prevline, '\') + if s > 0 + return s + g:idris_indent_if + endif + endif + + if prevline =~ '\(\\|\\|=\|[{([]\)\s*$' + return match(prevline, '\S') + &shiftwidth + endif + + if prevline =~ '\\s\+\S\+.*$' + return match(prevline, '\') + g:idris_indent_where + endif + + if prevline =~ '\\s\+\S\+.*$' + return match(prevline, '\') + g:idris_indent_do + endif + + if prevline =~ '^\s*\<\(co\)\?data\>\s\+[^=]\+\s\+=\s\+\S\+.*$' + return match(prevline, '=') + endif + + if prevline =~ '\\s\+([^)]*)\s*$' + return match(prevline, '\S') + &shiftwidth + endif + + if prevline =~ '\\s\+.\+\\s*$' + return match(prevline, '\') + g:idris_indent_case + endif + + if prevline =~ '^\s*\(\\|\<\(co\)\?data\>\)\s\+\S\+\s*$' + return match(prevline, '\(\\|\<\(co\)\?data\>\)') + &shiftwidth + endif + + if prevline =~ '^\s*\(\\|\\)\s*([^(]*)\s*$' + return match(prevline, '\(\\|\\)') + &shiftwidth + endif + + if prevline =~ '^\s*\\s*$' + return match(prevline, '\') + &shiftwidth + endif + + let line = getline(v:lnum) + + if (line =~ '^\s*}\s*' && prevline !~ '^\s*;') + return match(prevline, '\S') - &shiftwidth + endif + + return match(prevline, '\S') +endfunction + +endif diff --git a/packages.yaml b/packages.yaml index ca5de3a39..04dd4cd41 100644 --- a/packages.yaml +++ b/packages.yaml @@ -755,6 +755,19 @@ filetypes: extra_filenames: - idris-response --- +name: idris2 +remote: edwinb/idris2-vim +filetypes: +- name: idris2 + extensions: + - idr + - ipkg + filenames: + - idris-response +- name: lidris2 + extensions: + - lidr +--- name: ion remote: vmchale/ion-vim filetypes: diff --git a/scripts/build b/scripts/build index c7f4846fb..79a1cfe77 100755 --- a/scripts/build +++ b/scripts/build @@ -77,6 +77,12 @@ def load_data() filetype["extensions"] ||= [] filetype["filenames"] ||= [] filetype["interpreters"] ||= [] + + filetype.keys.each do |key| + if key.start_with?("extra_") + raise "[#{filetype["name"]}]: #{key} is not allowed if linguist is not used" + end + end end end end diff --git a/scripts/test_extensions.vim b/scripts/test_extensions.vim index c45431d5e..9211818d5 100644 --- a/scripts/test_extensions.vim +++ b/scripts/test_extensions.vim @@ -190,6 +190,11 @@ call TestExtension('yaml.ansible', 'requirements.yaml', '') call TestExtension('ps1xml', 'foobar.ps1xml', '') call TestExtension('terraform', 'terraform.tf', '') +call TestExtension('idris2', 'foobar.idr', '') +call TestExtension('idris', 'foobar.idr', "pkgs : List String\npkgs = [\"NCurses\", \"Readline\"]") +let g:filetype_idr = 'fizfuz' +call TestExtension('fizfuz', 'fizfuz.idr', '') + " .m extension call TestExtension('octave', 'matlab.m', '') call TestExtension('objc', 'objc.m', "\n\n #import ") @@ -215,3 +220,28 @@ call TestExtension('cpp', 'cpp.re', '#include "config.h"') call TestExtension('cpp', 'cpp2.re', '#ifdef HAVE_CONFIG_H') call TestExtension('cpp', 'cpp3.re', '#define YYCTYPE unsigned char') call TestExtension('reason', 'react.re', 'ReasonReact.Router.push("");') + +" Idris +call TestExtension('idris', 'lowercase.idr', '--idris1') +call TestExtension('idris', 'uppercase.idr', '--Idris1') +call TestExtension('idris', 'start-space-l.idr', '-- idris1') +call TestExtension('idris', 'start-space-u.idr', '-- Idris1') +call TestExtension('idris', 'two-spaces-l.idr', '-- idris 1') +call TestExtension('idris', 'two-spaces-u.idr', '-- Idris 1') +"call TestExtension('idris', 'mypkg.ipkg', 'package mypkg\n\npkgs = pruviloj, lightyear') +call TestExtension('idris', 'use-type-prov.idr', '%language TypeProviders') +call TestExtension('idris', 'use-elab-refl.idr', '%language ElabReflection') +call TestExtension('idris', 'access-modifier.idr', '%access export\n\npublic export\nMyTest : Type-> Type\n\nfact : Nat -> Nat') +call TestExtension('idris2', 'lowercase.idr', '--idris2') +call TestExtension('idris2', 'uppercase.idr', '--Idris2') +call TestExtension('idris2', 'start-space-l.idr', '-- idris2') +call TestExtension('idris2', 'start-space-u.idr', '-- Idris2') +call TestExtension('idris2', 'two-spaces-l.idr', '-- idris 2') +call TestExtension('idris2', 'two-spaces-u.idr', '-- Idris 2') +call TestExtension('idris2', 'mypkg.ipkg', 'package mypkg\n\ndepends = effects') +call TestExtension('idris2', 'use-post-proj.idr', '%language PostfixProjections') + +" Literate Idris +call TestExtension('lidris', 'lidris-1.lidr', "Some test plaintext\n\n> --idris1\n> myfact : Nat -> Nat\n> myfact Z = 1\n> myfact (S k) = (S k) * myfact k\n\nMore plaintext") +call TestExtension('lidris2', 'lidris-2.lidr', "Some test plaintext\n\n> --idris2\n> myfact : Nat -> Nat\n> myfact Z = 1\n> myfact (S k) = (S k) * myfact k\n\nMore plaintext") + diff --git a/scripts/test_filetypes.vim b/scripts/test_filetypes.vim index d0bec4ccb..0f870d5a2 100644 --- a/scripts/test_filetypes.vim +++ b/scripts/test_filetypes.vim @@ -106,6 +106,8 @@ call TestFiletype('html') call TestFiletype('i3config') call TestFiletype('icalendar') call TestFiletype('idris') +call TestFiletype('idris2') +call TestFiletype('lidris2') call TestFiletype('ion') call TestFiletype('javascript') call TestFiletype('flow') diff --git a/syntax/idris2.vim b/syntax/idris2.vim new file mode 100644 index 000000000..6bd18c584 --- /dev/null +++ b/syntax/idris2.vim @@ -0,0 +1,85 @@ +if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'idris2') == -1 + +" syntax highlighting for Idris 2 (idris-lang.org) +" +" Heavily modified version of the haskell syntax +" highlighter to support Idris 2. +" +" author: raichoo (raichoo@googlemail.com) + +if exists("b:current_syntax") + finish +endif + +syn match idrisTypeDecl "[a-zA-Z][a-zA-z0-9_']*\s\+:\s\+" + \ contains=idrisIdentifier,idrisOperators +syn region idrisParens matchgroup=idrisDelimiter start="(" end=")" contains=TOP,idrisTypeDecl +syn region idrisBrackets matchgroup=idrisDelimiter start="\[" end="]" contains=TOP,idrisTypeDecl +syn region idrisBlock matchgroup=idrisDelimiter start="{" end="}" contains=TOP,idrisTypeDecl +syn keyword idrisModule module namespace +syn keyword idrisImport import +syn keyword idrisStructure data record interface implementation +syn keyword idrisWhere where +syn keyword idrisVisibility public abstract private export +syn keyword idrisBlock parameters mutual using +syn keyword idrisTotality total partial covering +syn keyword idrisAnnotation auto impossible default constructor +syn keyword idrisStatement do case of rewrite with +syn keyword idrisLet let in +syn keyword idrisForall forall +syn keyword idrisDataOpt noHints uniqueSearch search external noNewtype containedin=idrisBrackets +syn match idrisSyntax "\(pattern \+\|term \+\)\?syntax" +syn keyword idrisConditional if then else +syn match idrisNumber "\<[0-9]\+\>\|\<0[xX][0-9a-fA-F]\+\>\|\<0[oO][0-7]\+\>" +syn match idrisFloat "\<[0-9]\+\.[0-9]\+\([eE][-+]\=[0-9]\+\)\=\>" +syn match idrisDelimiter "[,;]" +syn keyword idrisInfix prefix infix infixl infixr +syn match idrisOperators "\([-!#$%&\*\+./<=>\?@\\^|~:]\|\<_\>\)" +syn match idrisType "\<[A-Z][a-zA-Z0-9_']*\>" +syn keyword idrisTodo TODO FIXME XXX HACK contained +syn match idrisLineComment "---*\([^-!#$%&\*\+./<=>\?@\\^|~].*\)\?$" contains=idrisTodo,@Spell +syn match idrisDocComment "|||\([^-!#$%&\*\+./<=>\?@\\^|~].*\)\?$" contains=idrisTodo,@Spell +syn match idrisMetaVar "?[a-z][A-Za-z0-9_']*" +syn match idrisPragma "%\(hide\|logging\|auto_lazy\|unbound_implicits\|undotted_record_projections\|amibguity_depth\|pair\|rewrite\|integerLit\|stringLit\|charLit\|name\|start\|allow_overloads\|language\|default\|transform\|hint\|global_hint\|defaulthint\|inline\|extern\|macro\|spec\|foreign\|runElab\|tcinline\)" +syn match idrisChar "'[^'\\]'\|'\\.'\|'\\u[0-9a-fA-F]\{4}'" +syn match idrisBacktick "`[A-Za-z][A-Za-z0-9_']*`" +syn region idrisString start=+"+ skip=+\\\\\|\\"+ end=+"+ contains=@Spell +syn region idrisBlockComment start="{-" end="-}" contains=idrisBlockComment,idrisTodo,@Spell +syn match idrisIdentifier "[a-zA-Z][a-zA-z0-9_']*" contained + +highlight def link idrisDeprecated Error +highlight def link idrisIdentifier Identifier +highlight def link idrisImport Structure +highlight def link idrisModule Structure +highlight def link idrisStructure Structure +highlight def link idrisStatement Statement +highlight def link idrisForall Structure +highlight def link idrisDataOpt Statement +highlight def link idrisDSL Statement +highlight def link idrisBlock Statement +highlight def link idrisAnnotation Statement +highlight def link idrisWhere Structure +highlight def link idrisLet Structure +highlight def link idrisTotality Statement +highlight def link idrisSyntax Statement +highlight def link idrisVisibility Statement +highlight def link idrisConditional Conditional +highlight def link idrisPragma Statement +highlight def link idrisNumber Number +highlight def link idrisFloat Float +highlight def link idrisDelimiter Delimiter +highlight def link idrisInfix PreProc +highlight def link idrisOperators Operator +highlight def link idrisType Include +highlight def link idrisDocComment Comment +highlight def link idrisLineComment Comment +highlight def link idrisBlockComment Comment +highlight def link idrisTodo Todo +highlight def link idrisMetaVar Macro +highlight def link idrisString String +highlight def link idrisChar String +highlight def link idrisBacktick Operator + +let b:current_syntax = "idris2" + +endif diff --git a/syntax/lidris2.vim b/syntax/lidris2.vim new file mode 100644 index 000000000..a47572050 --- /dev/null +++ b/syntax/lidris2.vim @@ -0,0 +1,26 @@ +if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'idris2') == -1 + +" Vim syntax file +" Language: Literate Idris 2 +" Maintainer: Idris Hackers (https://github.com/edwinb/idris2-vim) +" Last Change: 2020 May 19 +" Version: 0.1 +" +" This is just a minimal adaption of the Literate Haskell syntax file. + + +" Read Idris highlighting. +if version < 600 + syntax include @idrisTop :p:h/idris2.vim +else + syntax include @idrisTop syntax/idris2.vim +endif + +" Recognize blocks of Bird tracks, highlight as Idris. +syntax region lidrisBirdTrackBlock start="^>" end="\%(^[^>]\)\@=" contains=@idrisTop,lidrisBirdTrack +syntax match lidrisBirdTrack "^>" contained +hi def link lidrisBirdTrack Comment + +let b:current_syntax = "lidris2" + +endif diff --git a/syntax/rust.vim b/syntax/rust.vim index d1e9d8d4b..2ad37ed84 100644 --- a/syntax/rust.vim +++ b/syntax/rust.vim @@ -67,10 +67,11 @@ syn match rustExternCrateString /".*"\_s*as/ contained nextgroup=rustIdentifie syn keyword rustObsoleteExternMod mod contained nextgroup=rustIdentifier skipwhite skipempty syn match rustIdentifier contains=rustIdentifierPrime "\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*" display contained -syn match rustFuncName "\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*" display contained +syn match rustFuncName "\%(r#\)\=\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*" display contained syn region rustMacroRepeat matchgroup=rustMacroRepeatDelimiters start="$(" end="),\=[*+]" contains=TOP syn match rustMacroVariable "$\w\+" +syn match rustRawIdent "\ Date: Sun, 6 Sep 2020 02:34:46 +0200 Subject: [PATCH 016/299] Ignore idris2 doc, fixes #538 --- doc/idris2-vim.txt | 158 --------------------------------------------- packages.yaml | 2 + 2 files changed, 2 insertions(+), 158 deletions(-) delete mode 100644 doc/idris2-vim.txt diff --git a/doc/idris2-vim.txt b/doc/idris2-vim.txt deleted file mode 100644 index 80a53cfc5..000000000 --- a/doc/idris2-vim.txt +++ /dev/null @@ -1,158 +0,0 @@ -if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'idris2') == -1 - -*idris2-vim.txt* Last change 2020 February 22 -=============================================================================== -=============================================================================== - @@@@ @@@@@@@@ @@@@@@@@ @@@@ @@@@@@ @@ @@ @@@@ @@ @@ - @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@@ @@@ - @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@@@ @@@@ - @@ @@ @@ @@@@@@@@ @@ @@@@@@ @@@@@@@ @@ @@ @@ @@ @@@ @@ - @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ - @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ - @@@@ @@@@@@@@ @@ @@ @@@@ @@@@@@ @@@ @@@@ @@ @@ -=============================================================================== -CONTENTS *idris-vim-contents* - - 1. Features: |idris-vim-features| - 2. Requirements: |idris-vim-requirements| - 3. Functions: |idris-vim-functions| - 4. Troubleshooting |idris-vim-troubleshooting| - 5. Examples: |idris-vim-examples| - 6. Information: |idris-vim-information| - -=============================================================================== -FEATURES *idris-vim-features* - - * Syntax Highlighting - * Indentation - * Unicode Concealing - * Syntax Checking (via Syntastic(https://github.com/scrooloose/syntastic)) - * Interactive Editing via the REPL - -=============================================================================== -REQUIREMENTS *idris-vim-requirements* - - * Idris2 (https://github.com/edwinb/Idris2/) - - OPTIONAL: - - * Syntastic(https://github.com/scrooloose/syntastic) for syntax checking - * Vimshell(https://github.com/Shougo/vimshell.vim) for a REPL - -=============================================================================== -FUNCTIONS *idris-vim-functions* - -All of the functions in idris-vim are essentially just calls back to the REPL, -so documentation for each of them is also available there. - -IdrisDocumentation *IdrisDocumentation* - Shows internal documentation of the primitive under the cursor. - - Mapped to '_h' by default. - -IdrisResponseWin *IdrisResponseWin* - This opens an idris response window in a new pane. - - Mapped to '_i' by default. - -IdrisShowType *IdrisShowType* - This shows the type of the name under the cursor (or, if the cursor happens - to be over a metavariable, a bit more information about its context). - - Mapped to '_t' by default. - -IdrisReload *IdrisReload* - This reloads the file and type-checks the file in the current buffer. - - Mapped to '_r' by default. - -IdrisEval *IdrisEval* - This prompts for an expression and then evaluates it in the REPL, then - returns the result. - - Mapped to '_e' by default. - -IdrisCaseSplit *IdrisCaseSplit* - When the cursor is over a variable in a pattern match clause or case - expression, this splits the variable into all well-typed patterns. - - Mapped to '_c' by default - -IdrisAddClause *IdrisAddClause* - When the cursor is at a type declaration this creates a new clause for that - signature. - - By default mapped to '_d' for an ordinary top-level definition, - '_b' for a typeclass instance definition, and - '_md' to add a pattern-matching proof clause. - -IdrisAddMissing: *IdrisAddMissing* - When the cursor is over a function, this adds all clauses necessary to make - that function cover all inputs. This also eliminates clauses which would - lead to unification errors from appearing. - - Mapped to '_m' by default - -IdrisRefine: *IdrisRefine* - Refines the item the cursor is over (applies the name and fills in any - arguments which can be filled in via unification) - - Mapped to '_f' by default - -IdrisProofSearch: *IdrisProofSearch* - This attempts to find a value for the metavariable it was called on by - looking at the rest of the code. It can also be called with hints, which - are functions that can apply to help solve for the metavariable. - - Mapped to '_o' without hints and 'p' with hints by - default - -IdrisMakeWith: *IdrisMakeWith* - When the cursor is over a pattern clause and this is called, it creates a - new with clause. - - Mapped to '_w' by default - -IdrisMakeLemma: *IdrisMakeLemma* - When the cursor is over a metavariable and this is called, it creates a new - top-level definition to solve the metavariable. - - Mapped to '_l' by default - -=============================================================================== -TROUBLESHOOTING *idris-vim-troubleshooting* - -If this isn't working for you, make sure that: - - * There is an Idris REPL running - * For syntax checking, you have syntastic installed - * The plugins mappings exists and don't conflict with anything else installed - (You can use ':map' to check. There should be mappings similar to - '\h * :call IdrisShowDoc()'.) - * Vim recognizes you're in an idris file (you can use ':verb set ft' to check) - -If none of this works, check to issue tracker on github and if nothing is -there create an issue with a detailed description of the problem. - -=============================================================================== -EXAMPLES *idris-vim-examples* - -Some excellent tutorials/examples for interactive editing using the above -functions can be found at: - http://edwinb.wordpress.com/2013/10/28/interactive-idris-editing-with-vim/ -and - http://www.scribd.com/doc/214031954/60/Interactive-Editing-in-Vim - -=============================================================================== -INFORMATION *idris-vim-information* - -Author: edwinb -Repo: https://github.com/idris-hackers/idris-vim - -Documentation by japesinator - -=============================================================================== -=============================================================================== -" vim:ft=help:et:ts=2:sw=2:sts=2:norl: - -endif diff --git a/packages.yaml b/packages.yaml index 04dd4cd41..f757cf994 100644 --- a/packages.yaml +++ b/packages.yaml @@ -757,6 +757,8 @@ filetypes: --- name: idris2 remote: edwinb/idris2-vim +ignored_dirs: +- doc filetypes: - name: idris2 extensions: From d9ee362537a34473b32ad3b4a1d7feb56a6b6811 Mon Sep 17 00:00:00 2001 From: Adam Stankiewicz Date: Sun, 6 Sep 2020 15:08:20 +0200 Subject: [PATCH 017/299] Fix weird indentation issue of yaml --- README.md | 5 +- after/ftplugin/yaml.vim | 2 +- after/syntax/yaml.vim | 2 +- ftdetect/polyglot.vim | 3 + ftplugin/yaml.vim | 29 +++++ indent/yaml.vim | 159 ++++++++++++++++++++++++++ packages.yaml | 9 +- scripts/build | 9 +- syntax/yaml.vim | 247 ++++++++++++++++++++++++++++++++++++++++ 9 files changed, 455 insertions(+), 10 deletions(-) create mode 100644 ftplugin/yaml.vim create mode 100644 indent/yaml.vim create mode 100644 syntax/yaml.vim diff --git a/README.md b/README.md index 6789eb72a..deaa86660 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ A collection of language packs for Vim. > One to rule them all, one to find them, one to bring them all and in the darkness bind them. - It **won't affect your startup time**, as scripts are loaded only on demand\*. -- It **installs and updates 120+ times faster** than the 191 packages it consists of. +- It **installs and updates 120+ times faster** than the 192 packages it consists of. - It is more secure because scripts loaded for all extensions are generated by vim-polyglot (ftdetect). - Solid syntax and indentation support (other features skipped). Only the best language packs. - All unnecessary files are ignored (like enormous documentation from php support). @@ -229,7 +229,8 @@ If you need full functionality of any plugin, please use it directly with your p - [xdc](https://github.com/amal-khailtash/vim-xdc-syntax) - [xml](https://github.com/amadeus/vim-xml) - [xsl](https://github.com/vim-scripts/XSLT-syntax) -- [yaml](https://github.com/stephpy/vim-yaml) +- [yaml-extras](https://github.com/stephpy/vim-yaml) +- [yaml](https://github.com/vim/vim/tree/df44a27b53586fccfc6a3aedc89061fdd9a515ff/runtime) - [yard](https://github.com/sheerun/vim-yardoc) - [zephir](https://github.com/xwsoul/vim-zephir) - [zig](https://github.com/ziglang/zig.vim) diff --git a/after/ftplugin/yaml.vim b/after/ftplugin/yaml.vim index db608fa4d..69785fc2a 100644 --- a/after/ftplugin/yaml.vim +++ b/after/ftplugin/yaml.vim @@ -1,4 +1,4 @@ -if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'yaml') == -1 +if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'yaml-extras') == -1 " Vim indent file " Language: Yaml diff --git a/after/syntax/yaml.vim b/after/syntax/yaml.vim index 097d15359..3a1e89a25 100644 --- a/after/syntax/yaml.vim +++ b/after/syntax/yaml.vim @@ -1,4 +1,4 @@ -if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'yaml') == -1 +if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'yaml-extras') == -1 " To make this file do stuff, add something like the following (without the " leading ") to your ~/.vimrc: diff --git a/ftdetect/polyglot.vim b/ftdetect/polyglot.vim index 186ba9daf..792c24323 100644 --- a/ftdetect/polyglot.vim +++ b/ftdetect/polyglot.vim @@ -1677,6 +1677,9 @@ if !has_key(s:disabled_packages, 'xsl') au BufNewFile,BufRead *.xslt setf xsl endif +if !has_key(s:disabled_packages, 'yaml-extras') +endif + if !has_key(s:disabled_packages, 'ansible') au BufNewFile,BufRead group_vars/* setf yaml.ansible au BufNewFile,BufRead handlers.*.y{a,}ml setf yaml.ansible diff --git a/ftplugin/yaml.vim b/ftplugin/yaml.vim new file mode 100644 index 000000000..2e9728bd6 --- /dev/null +++ b/ftplugin/yaml.vim @@ -0,0 +1,29 @@ +if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'yaml') == -1 + +" Vim filetype plugin file +" Language: YAML (YAML Ain't Markup Language) +" Previous Maintainer: Nikolai Weibull (inactive) +" Last Change: 2020 Mar 02 + +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< et< fo<" + +setlocal comments=:# commentstring=#\ %s expandtab +setlocal formatoptions-=t formatoptions+=croql + +if !exists("g:yaml_recommended_style") || g:yaml_recommended_style != 0 + let b:undo_ftplugin ..= " sw< sts<" + setlocal shiftwidth=2 softtabstop=2 +endif + +let &cpo = s:cpo_save +unlet s:cpo_save + +endif diff --git a/indent/yaml.vim b/indent/yaml.vim new file mode 100644 index 000000000..c7fdebcff --- /dev/null +++ b/indent/yaml.vim @@ -0,0 +1,159 @@ +if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'yaml') == -1 + +" Vim indent file +" Language: YAML +" Maintainer: Nikolai Pavlov +" Last Change: 2019 Sep 28 + +" Only load this indent file when no other was loaded. +if exists('b:did_indent') + finish +endif + +let s:save_cpo = &cpo +set cpo&vim + +let b:did_indent = 1 + +setlocal indentexpr=GetYAMLIndent(v:lnum) +setlocal indentkeys=!^F,o,O,0#,0},0],<:>,0- +setlocal nosmartindent + +let b:undo_indent = 'setlocal indentexpr< indentkeys< smartindent<' + +" Only define the function once. +if exists('*GetYAMLIndent') + finish +endif + +function s:FindPrevLessIndentedLine(lnum, ...) + let prevlnum = prevnonblank(a:lnum-1) + let curindent = a:0 ? a:1 : indent(a:lnum) + while prevlnum + \&& indent(prevlnum) >= curindent + \&& getline(prevlnum) !~# '^\s*#' + let prevlnum = prevnonblank(prevlnum-1) + endwhile + return prevlnum +endfunction + +function s:FindPrevLEIndentedLineMatchingRegex(lnum, regex) + let plilnum = s:FindPrevLessIndentedLine(a:lnum, indent(a:lnum)+1) + while plilnum && getline(plilnum) !~# a:regex + let plilnum = s:FindPrevLessIndentedLine(plilnum) + endwhile + return plilnum +endfunction + +let s:mapkeyregex='\v^\s*\#@!\S@=%(\''%([^'']|\''\'')*\'''. + \ '|\"%([^"\\]|\\.)*\"'. + \ '|%(%(\:\ )@!.)*)\:%(\ |$)' +let s:liststartregex='\v^\s*%(\-%(\ |$))' + +let s:c_ns_anchor_char = '\v%([\n\r\uFEFF \t,[\]{}]@!\p)' +let s:c_ns_anchor_name = s:c_ns_anchor_char.'+' +let s:c_ns_anchor_property = '\v\&'.s:c_ns_anchor_name + +let s:ns_word_char = '\v[[:alnum:]_\-]' +let s:ns_tag_char = '\v%(%\x\x|'.s:ns_word_char.'|[#/;?:@&=+$.~*''()])' +let s:c_named_tag_handle = '\v\!'.s:ns_word_char.'+\!' +let s:c_secondary_tag_handle = '\v\!\!' +let s:c_primary_tag_handle = '\v\!' +let s:c_tag_handle = '\v%('.s:c_named_tag_handle. + \ '|'.s:c_secondary_tag_handle. + \ '|'.s:c_primary_tag_handle.')' +let s:c_ns_shorthand_tag = '\v'.s:c_tag_handle . s:ns_tag_char.'+' +let s:c_non_specific_tag = '\v\!' +let s:ns_uri_char = '\v%(%\x\x|'.s:ns_word_char.'\v|[#/;?:@&=+$,.!~*''()[\]])' +let s:c_verbatim_tag = '\v\!\<'.s:ns_uri_char.'+\>' +let s:c_ns_tag_property = '\v'.s:c_verbatim_tag. + \ '\v|'.s:c_ns_shorthand_tag. + \ '\v|'.s:c_non_specific_tag + +let s:block_scalar_header = '\v[|>]%([+-]?[1-9]|[1-9]?[+-])?' + +function GetYAMLIndent(lnum) + if a:lnum == 1 || !prevnonblank(a:lnum-1) + return 0 + endif + + let prevlnum = prevnonblank(a:lnum-1) + let previndent = indent(prevlnum) + + let line = getline(a:lnum) + if line =~# '^\s*#' && getline(a:lnum-1) =~# '^\s*#' + " Comment blocks should have identical indent + return previndent + elseif line =~# '^\s*[\]}]' + " Lines containing only closing braces should have previous indent + return indent(s:FindPrevLessIndentedLine(a:lnum)) + endif + + " Ignore comment lines when calculating indent + while getline(prevlnum) =~# '^\s*#' + let prevlnum = prevnonblank(prevlnum-1) + if !prevlnum + return previndent + endif + endwhile + + let prevline = getline(prevlnum) + let previndent = indent(prevlnum) + + " Any examples below assume that shiftwidth=2 + if prevline =~# '\v[{[:]$|[:-]\ [|>][+\-]?%(\s+\#.*|\s*)$' + " Mapping key: + " nested mapping: ... + " + " - { + " key: [ + " list value + " ] + " } + " + " - |- + " Block scalar without indentation indicator + return previndent+shiftwidth() + elseif prevline =~# '\v[:-]\ [|>]%(\d+[+\-]?|[+\-]?\d+)%(\#.*|\s*)$' + " - |+2 + " block scalar with indentation indicator + "#^^ indent+2, not indent+shiftwidth + return previndent + str2nr(matchstr(prevline, + \'\v([:-]\ [|>])@<=[+\-]?\d+%([+\-]?%(\s+\#.*|\s*)$)@=')) + elseif prevline =~# '\v\"%([^"\\]|\\.)*\\$' + " "Multiline string \ + " with escaped end" + let qidx = match(prevline, '\v\"%([^"\\]|\\.)*\\') + return virtcol([prevlnum, qidx+1]) + elseif line =~# s:liststartregex + " List line should have indent equal to previous list line unless it was + " caught by one of the previous rules + return indent(s:FindPrevLEIndentedLineMatchingRegex(a:lnum, + \ s:liststartregex)) + elseif line =~# s:mapkeyregex + " Same for line containing mapping key + let prevmapline = s:FindPrevLEIndentedLineMatchingRegex(a:lnum, + \ s:mapkeyregex) + if getline(prevmapline) =~# '^\s*- ' + return indent(prevmapline) + 2 + else + return indent(prevmapline) + endif + elseif prevline =~# '^\s*- ' + " - List with + " multiline scalar + return previndent+2 + elseif prevline =~# s:mapkeyregex . '\v\s*%(%('.s:c_ns_tag_property. + \ '\v|'.s:c_ns_anchor_property. + \ '\v|'.s:block_scalar_header. + \ '\v)%(\s+|\s*%(\#.*)?$))*' + " Mapping with: value + " that is multiline scalar + return previndent+shiftwidth() + endif + return previndent +endfunction + +let &cpo = s:save_cpo + +endif diff --git a/packages.yaml b/packages.yaml index f757cf994..65df8369d 100644 --- a/packages.yaml +++ b/packages.yaml @@ -1650,7 +1650,9 @@ filetypes: linguist: XSLT --- name: yaml -remote: stephpy/vim-yaml +# Fixes indentation issue: https://github.com/vim/vim/issues/6417 +remote: vim/vim@df44a27b53586fccfc6a3aedc89061fdd9a515ff:runtime +glob: '**/yaml.vim' filetypes: - name: yaml linguist: YAML @@ -1659,6 +1661,11 @@ filetypes: - fish_read_history ignored_filenames: - '~/.config/fish/fish_{read_,}history' +--- +name: yaml-extras +remote: stephpy/vim-yaml +after: yaml +filetypes: [] # Ansible needs to be after YAML --- name: ansible diff --git a/scripts/build b/scripts/build index 79a1cfe77..c9a12743c 100755 --- a/scripts/build +++ b/scripts/build @@ -155,7 +155,8 @@ end def parse_remote(remote) match = remote.match(/(?[^@:]+)(?:@(?[^:]+))?(?::(?.*))?/) - [match[:repo], match[:branch] || "master", match[:path]] + dir = "tmp/" + match[:repo] + (match[:branch] ? "-#{match[:branch]}" : "") + [match[:repo], match[:branch] || "master", match[:path], dir] end def copy_file(package, src, dest) @@ -179,8 +180,7 @@ def download(packages) packages.map { |p| p["remote"] or raise "No remote for: " + p["name"] }.uniq.each_slice(20) do |remotes| remotes.map do |remote| Thread.new do - repo, branch, path = parse_remote(remote) - dir = "tmp/" + repo + repo, branch, path, dir = parse_remote(remote) unless File.exist?(dir) FileUtils.mkdir_p(dir) url = "https://codeload.github.com/#{repo}/tar.gz/#{branch}" @@ -321,8 +321,7 @@ def extract(packages) output = [] packages.map do |package| - repo, branch, path = parse_remote(package["remote"]) - dir = "tmp/" + repo + repo, branch, path, dir = parse_remote(package["remote"]) dirs = package.fetch("dirs", default_dirs) ignored_dirs = package.fetch("ignored_dirs", []) if ignored_dirs.size > 0 diff --git a/syntax/yaml.vim b/syntax/yaml.vim new file mode 100644 index 000000000..53e606846 --- /dev/null +++ b/syntax/yaml.vim @@ -0,0 +1,247 @@ +if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'yaml') == -1 + +" Vim syntax file +" Language: YAML (YAML Ain't Markup Language) 1.2 +" Maintainer: Nikolai Pavlov +" First author: Nikolai Weibull +" Latest Revision: 2015-03-28 +" removed duplicate yamlKeyValueDelimiter (pull #4799) + +if exists('b:current_syntax') + finish +endif + +let s:cpo_save = &cpo +set cpo&vim + +" Choose the schema to use +" TODO: Validate schema +if !exists('b:yaml_schema') + if exists('g:yaml_schema') + let b:yaml_schema = g:yaml_schema + else + let b:yaml_schema = 'core' + endif +endif + +let s:ns_char = '\%([\n\r\uFEFF \t]\@!\p\)' +let s:ns_word_char = '[[:alnum:]_\-]' +let s:ns_uri_char = '\%(%\x\x\|'.s:ns_word_char.'\|[#/;?:@&=+$,.!~*''()[\]]\)' +let s:ns_tag_char = '\%(%\x\x\|'.s:ns_word_char.'\|[#/;?:@&=+$.~*''()]\)' +let s:c_ns_anchor_char = '\%([\n\r\uFEFF \t,[\]{}]\@!\p\)' +let s:c_indicator = '[\-?:,[\]{}#&*!|>''"%@`]' +let s:c_flow_indicator = '[,[\]{}]' + +let s:ns_char_without_c_indicator = substitute(s:ns_char, '\v\C[\zs', '\=s:c_indicator[1:-2]', '') + +let s:_collection = '[^\@!\(\%(\\\.\|\[^\\\]]\)\+\)]' +let s:_neg_collection = '[^\(\%(\\\.\|\[^\\\]]\)\+\)]' +function s:SimplifyToAssumeAllPrintable(p) + return substitute(a:p, '\V\C\\%('.s:_collection.'\\@!\\p\\)', '[^\1]', '') +endfunction +let s:ns_char = s:SimplifyToAssumeAllPrintable(s:ns_char) +let s:ns_char_without_c_indicator = s:SimplifyToAssumeAllPrintable(s:ns_char_without_c_indicator) +let s:c_ns_anchor_char = s:SimplifyToAssumeAllPrintable(s:c_ns_anchor_char) + +function s:SimplifyAdjacentCollections(p) + return substitute(a:p, '\V\C'.s:_collection.'\\|'.s:_collection, '[\1\2]', 'g') +endfunction +let s:ns_uri_char = s:SimplifyAdjacentCollections(s:ns_uri_char) +let s:ns_tag_char = s:SimplifyAdjacentCollections(s:ns_tag_char) + +let s:c_verbatim_tag = '!<'.s:ns_uri_char.'\+>' +let s:c_named_tag_handle = '!'.s:ns_word_char.'\+!' +let s:c_secondary_tag_handle = '!!' +let s:c_primary_tag_handle = '!' +let s:c_tag_handle = '\%('.s:c_named_tag_handle. + \ '\|'.s:c_secondary_tag_handle. + \ '\|'.s:c_primary_tag_handle.'\)' +let s:c_ns_shorthand_tag = s:c_tag_handle . s:ns_tag_char.'\+' +let s:c_non_specific_tag = '!' +let s:c_ns_tag_property = s:c_verbatim_tag. + \ '\|'.s:c_ns_shorthand_tag. + \ '\|'.s:c_non_specific_tag + +let s:c_ns_anchor_name = s:c_ns_anchor_char.'\+' +let s:c_ns_anchor_property = '&'.s:c_ns_anchor_name +let s:c_ns_alias_node = '\*'.s:c_ns_anchor_name + +let s:ns_directive_name = s:ns_char.'\+' + +let s:ns_local_tag_prefix = '!'.s:ns_uri_char.'*' +let s:ns_global_tag_prefix = s:ns_tag_char.s:ns_uri_char.'*' +let s:ns_tag_prefix = s:ns_local_tag_prefix. + \ '\|'.s:ns_global_tag_prefix + +let s:ns_plain_safe_out = s:ns_char +let s:ns_plain_safe_in = '\%('.s:c_flow_indicator.'\@!'.s:ns_char.'\)' + +let s:ns_plain_safe_in = substitute(s:ns_plain_safe_in, '\V\C\\%('.s:_collection.'\\@!'.s:_neg_collection.'\\)', '[^\1\2]', '') +let s:ns_plain_safe_in_without_colhash = substitute(s:ns_plain_safe_in, '\V\C'.s:_neg_collection, '[^\1:#]', '') +let s:ns_plain_safe_out_without_colhash = substitute(s:ns_plain_safe_out, '\V\C'.s:_neg_collection, '[^\1:#]', '') + +let s:ns_plain_first_in = '\%('.s:ns_char_without_c_indicator.'\|[?:\-]\%('.s:ns_plain_safe_in.'\)\@=\)' +let s:ns_plain_first_out = '\%('.s:ns_char_without_c_indicator.'\|[?:\-]\%('.s:ns_plain_safe_out.'\)\@=\)' + +let s:ns_plain_char_in = '\%('.s:ns_char.'#\|:'.s:ns_plain_safe_in.'\|'.s:ns_plain_safe_in_without_colhash.'\)' +let s:ns_plain_char_out = '\%('.s:ns_char.'#\|:'.s:ns_plain_safe_out.'\|'.s:ns_plain_safe_out_without_colhash.'\)' + +let s:ns_plain_out = s:ns_plain_first_out . s:ns_plain_char_out.'*' +let s:ns_plain_in = s:ns_plain_first_in . s:ns_plain_char_in.'*' + + +syn keyword yamlTodo contained TODO FIXME XXX NOTE + +syn region yamlComment display oneline start='\%\(^\|\s\)#' end='$' + \ contains=yamlTodo + +execute 'syn region yamlDirective oneline start='.string('^\ze%'.s:ns_directive_name.'\s\+').' '. + \ 'end="$" '. + \ 'contains=yamlTAGDirective,'. + \ 'yamlYAMLDirective,'. + \ 'yamlReservedDirective '. + \ 'keepend' + +syn match yamlTAGDirective '%TAG\s\+' contained nextgroup=yamlTagHandle +execute 'syn match yamlTagHandle contained nextgroup=yamlTagPrefix '.string(s:c_tag_handle.'\s\+') +execute 'syn match yamlTagPrefix contained nextgroup=yamlComment ' . string(s:ns_tag_prefix) + +syn match yamlYAMLDirective '%YAML\s\+' contained nextgroup=yamlYAMLVersion +syn match yamlYAMLVersion '\d\+\.\d\+' contained nextgroup=yamlComment + +execute 'syn match yamlReservedDirective contained nextgroup=yamlComment '. + \string('%\%(\%(TAG\|YAML\)\s\)\@!'.s:ns_directive_name) + +syn region yamlFlowString matchgroup=yamlFlowStringDelimiter start='"' skip='\\"' end='"' + \ contains=yamlEscape + \ nextgroup=yamlKeyValueDelimiter +syn region yamlFlowString matchgroup=yamlFlowStringDelimiter start="'" skip="''" end="'" + \ contains=yamlSingleEscape + \ nextgroup=yamlKeyValueDelimiter +syn match yamlEscape contained '\\\%([\\"abefnrtv\^0_ NLP\n]\|x\x\x\|u\x\{4}\|U\x\{8}\)' +syn match yamlSingleEscape contained "''" + +syn match yamlBlockScalarHeader contained '\s\+\zs[|>]\%([+-]\=[1-9]\|[1-9]\=[+-]\)\=' + +syn cluster yamlConstant contains=yamlBool,yamlNull + +syn cluster yamlFlow contains=yamlFlowString,yamlFlowMapping,yamlFlowCollection +syn cluster yamlFlow add=yamlFlowMappingKey,yamlFlowMappingMerge +syn cluster yamlFlow add=@yamlConstant,yamlPlainScalar,yamlFloat +syn cluster yamlFlow add=yamlTimestamp,yamlInteger,yamlMappingKeyStart +syn cluster yamlFlow add=yamlComment +syn region yamlFlowMapping matchgroup=yamlFlowIndicator start='{' end='}' contains=@yamlFlow +syn region yamlFlowCollection matchgroup=yamlFlowIndicator start='\[' end='\]' contains=@yamlFlow + +execute 'syn match yamlPlainScalar /'.s:ns_plain_out.'/' +execute 'syn match yamlPlainScalar contained /'.s:ns_plain_in.'/' + +syn match yamlMappingKeyStart '?\ze\s' +syn match yamlMappingKeyStart '?' contained + +execute 'syn match yamlFlowMappingKey /\%#=1'.s:ns_plain_in.'\%(\s\+'.s:ns_plain_in.'\)*\ze\s*:/ contained '. + \'nextgroup=yamlKeyValueDelimiter' +syn match yamlFlowMappingMerge /<<\ze\s*:/ contained nextgroup=yamlKeyValueDelimiter + +syn match yamlBlockCollectionItemStart '^\s*\zs-\%(\s\+-\)*\s' nextgroup=yamlBlockMappingKey,yamlBlockMappingMerge +" Use the old regexp engine, the NFA engine doesn't like all the \@ items. +execute 'syn match yamlBlockMappingKey /\%#=1^\s*\zs'.s:ns_plain_out.'\%(\s\+'.s:ns_plain_out.'\)*\ze\s*:\%(\s\|$\)/ '. + \'nextgroup=yamlKeyValueDelimiter' +execute 'syn match yamlBlockMappingKey /\%#=1\s*\zs'.s:ns_plain_out.'\%(\s\+'.s:ns_plain_out.'\)*\ze\s*:\%(\s\|$\)/ contained '. + \'nextgroup=yamlKeyValueDelimiter' +syn match yamlBlockMappingMerge /^\s*\zs<<\ze:\%(\s\|$\)/ nextgroup=yamlKeyValueDelimiter +syn match yamlBlockMappingMerge /<<\ze\s*:\%(\s\|$\)/ nextgroup=yamlKeyValueDelimiter contained + +syn match yamlKeyValueDelimiter /\s*:/ contained + +syn cluster yamlScalarWithSpecials contains=yamlPlainScalar,yamlBlockMappingKey,yamlFlowMappingKey + +let s:_bounder = s:SimplifyToAssumeAllPrintable('\%([[\]{}, \t]\@!\p\)') +if b:yaml_schema is# 'json' + syn keyword yamlNull null contained containedin=@yamlScalarWithSpecials + syn keyword yamlBool true false + exe 'syn match yamlInteger /'.s:_bounder.'\@1 Date: Sun, 6 Sep 2020 19:20:09 +0200 Subject: [PATCH 018/299] Ensure duplicate tags do not happen in the future, #538 --- scripts/test | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/scripts/test b/scripts/test index 974804399..e5418fa46 100755 --- a/scripts/test +++ b/scripts/test @@ -9,3 +9,8 @@ vim --clean -N -u <(echo " \"source scripts/test_filetypes.vim qa! ") + +if ! expect -c 'set timeout 1' -c 'spawn vim -N --clean -c "set nomore | :helptags ./doc | q"' -c 'expect "ENTER" { exit 1 }' > /dev/null; then + echo "Please ensure ':helptags ./doc' works properly" + exit 1 +fi From 3169f801699b7e95318f3ebe7b4cb44365d21276 Mon Sep 17 00:00:00 2001 From: Adam Stankiewicz Date: Sun, 6 Sep 2020 19:23:23 +0200 Subject: [PATCH 019/299] Remove empty blocks --- ftdetect/polyglot.vim | 24 ------------------------ scripts/build | 21 +++++++++++---------- 2 files changed, 11 insertions(+), 34 deletions(-) diff --git a/ftdetect/polyglot.vim b/ftdetect/polyglot.vim index 792c24323..bc79d0a6f 100644 --- a/ftdetect/polyglot.vim +++ b/ftdetect/polyglot.vim @@ -515,9 +515,6 @@ if !has_key(s:disabled_packages, 'coffee-script') au BufNewFile,BufRead *.litcoffee setf litcoffee endif -if !has_key(s:disabled_packages, 'cjsx') -endif - if !has_key(s:disabled_packages, 'cryptol') au BufNewFile,BufRead *.cry setf cryptol au BufNewFile,BufRead *.cyl setf cryptol @@ -812,9 +809,6 @@ if !has_key(s:disabled_packages, 'ion') au BufNewFile,BufRead ~/.config/ion/initrc setf ion endif -if !has_key(s:disabled_packages, 'javascript-sql') -endif - if !has_key(s:disabled_packages, 'javascript') au BufNewFile,BufRead *._js setf javascript au BufNewFile,BufRead *.bones setf javascript @@ -1204,12 +1198,6 @@ if !has_key(s:disabled_packages, 'python') au BufNewFile,BufRead wscript setf python endif -if !has_key(s:disabled_packages, 'python-indent') -endif - -if !has_key(s:disabled_packages, 'python-compiler') -endif - if !has_key(s:disabled_packages, 'requirements') au BufNewFile,BufRead *.pip setf requirements au BufNewFile,BufRead *require.{txt,in} setf requirements @@ -1352,9 +1340,6 @@ if !has_key(s:disabled_packages, 'rspec') au BufNewFile,BufRead *_spec.rb if !did_filetype() | set ft=ruby syntax=rspec | endif endif -if !has_key(s:disabled_packages, 'yard') -endif - if !has_key(s:disabled_packages, 'brewfile') au BufNewFile,BufRead Brewfile setf brewfile endif @@ -1420,9 +1405,6 @@ if !has_key(s:disabled_packages, 'sh') au BufNewFile,BufRead {.,}zshrc setf zsh endif -if !has_key(s:disabled_packages, 'zinit') -endif - if !has_key(s:disabled_packages, 'slim') au BufNewFile,BufRead *.slim setf slim endif @@ -1453,9 +1435,6 @@ if !has_key(s:disabled_packages, 'svg') au BufNewFile,BufRead *.svg setf svg endif -if !has_key(s:disabled_packages, 'svg-indent') -endif - if !has_key(s:disabled_packages, 'swift') au BufNewFile,BufRead *.swift setf swift endif @@ -1677,9 +1656,6 @@ if !has_key(s:disabled_packages, 'xsl') au BufNewFile,BufRead *.xslt setf xsl endif -if !has_key(s:disabled_packages, 'yaml-extras') -endif - if !has_key(s:disabled_packages, 'ansible') au BufNewFile,BufRead group_vars/* setf yaml.ansible au BufNewFile,BufRead handlers.*.y{a,}ml setf yaml.ansible diff --git a/scripts/build b/scripts/build index c9a12743c..b868ebfc5 100755 --- a/scripts/build +++ b/scripts/build @@ -416,14 +416,11 @@ def generate_ftdetect(packages, heuristics) end for package in packages - name = package.fetch("name") - - output << "if !has_key(s:disabled_packages, '#{name}')\n" - filetypes = package["filetypes"] or raise "Unknown filetype for: #{package["name"]}" package_heuristics = [] + autocommands = "" for filetype in filetypes name = filetype.fetch("name") syntax = filetype["syntax"] ? " | set syntax=#{filetype["syntax"]}" : "" @@ -454,8 +451,8 @@ def generate_ftdetect(packages, heuristics) for extension in extensions.sort outer_filetype = filetype["outer_filetype"] if outer_filetype - output << " au BufNewFile *.*.#{extension} execute \"do BufNewFile filetypedetect \" . expand(\":r\") | #{outer_filetype}\n" - output << " au BufReadPre *.*.#{extension} execute \"do BufRead filetypedetect \" . expand(\":r\") | #{outer_filetype}\n" + autocommands << " au BufNewFile *.*.#{extension} execute \"do BufNewFile filetypedetect \" . expand(\":r\") | #{outer_filetype}\n" + autocommands << " au BufReadPre *.*.#{extension} execute \"do BufRead filetypedetect \" . expand(\":r\") | #{outer_filetype}\n" end heuristic = heuristics.find { |h| h["extensions"].include?(extension) } @@ -466,7 +463,7 @@ def generate_ftdetect(packages, heuristics) # puts "Ambiguous extension without heuristic: #{extension} => #{filetype["name"]}" # end # - output << " au BufNewFile,BufRead *.#{extension} #{set_command}\n" + autocommands << " au BufNewFile,BufRead *.#{extension} #{set_command}\n" end end @@ -474,16 +471,20 @@ def generate_ftdetect(packages, heuristics) if filename[0] == "." filename = "{.,}" + filename[1..] end - output << " au BufNewFile,BufRead #{filename} #{set_command}\n" + autocommands << " au BufNewFile,BufRead #{filename} #{set_command}\n" end end for heuristic in package_heuristics.uniq extensions = heuristic["extensions"].map { |e| "*.#{e}" } - output << " au! BufNewFile,BufRead #{extensions.join(",")} call polyglot#Detect#{camelize(heuristic["extensions"].first)}Filetype()\n" + autocommands << " au! BufNewFile,BufRead #{extensions.join(",")} call polyglot#Detect#{camelize(heuristic["extensions"].first)}Filetype()\n" end - output << "endif\n\n" + if autocommands != "" + output << "if !has_key(s:disabled_packages, '#{package["name"]}')\n" + output << autocommands + output << "endif\n\n" + end end ftdetect = File.read('ftdetect/polyglot.vim') From 255345bf9525c94479a7ff9b787d2f9848cb7a18 Mon Sep 17 00:00:00 2001 From: Adam Stankiewicz Date: Sun, 6 Sep 2020 19:25:34 +0200 Subject: [PATCH 020/299] Remove stephpy/vim-yaml syntax It causes issues: - https://github.com/dracula/vim/pull/163 - https://github.com/stephpy/vim-yaml/issues/22 --- README.md | 3 +- after/ftplugin/yaml.vim | 11 ------- after/syntax/yaml.vim | 65 ----------------------------------------- packages.yaml | 5 ---- 4 files changed, 1 insertion(+), 83 deletions(-) delete mode 100644 after/ftplugin/yaml.vim delete mode 100644 after/syntax/yaml.vim diff --git a/README.md b/README.md index deaa86660..a78562e99 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ A collection of language packs for Vim. > One to rule them all, one to find them, one to bring them all and in the darkness bind them. - It **won't affect your startup time**, as scripts are loaded only on demand\*. -- It **installs and updates 120+ times faster** than the 192 packages it consists of. +- It **installs and updates 120+ times faster** than the 191 packages it consists of. - It is more secure because scripts loaded for all extensions are generated by vim-polyglot (ftdetect). - Solid syntax and indentation support (other features skipped). Only the best language packs. - All unnecessary files are ignored (like enormous documentation from php support). @@ -229,7 +229,6 @@ If you need full functionality of any plugin, please use it directly with your p - [xdc](https://github.com/amal-khailtash/vim-xdc-syntax) - [xml](https://github.com/amadeus/vim-xml) - [xsl](https://github.com/vim-scripts/XSLT-syntax) -- [yaml-extras](https://github.com/stephpy/vim-yaml) - [yaml](https://github.com/vim/vim/tree/df44a27b53586fccfc6a3aedc89061fdd9a515ff/runtime) - [yard](https://github.com/sheerun/vim-yardoc) - [zephir](https://github.com/xwsoul/vim-zephir) diff --git a/after/ftplugin/yaml.vim b/after/ftplugin/yaml.vim deleted file mode 100644 index 69785fc2a..000000000 --- a/after/ftplugin/yaml.vim +++ /dev/null @@ -1,11 +0,0 @@ -if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'yaml-extras') == -1 - -" Vim indent file -" Language: Yaml -" Author: Henrique Barcelos -" Date: 2014-10-08 -" URL: https://github.com/hjpbarcelos -setlocal autoindent sw=2 ts=2 expandtab -" vim:set sw=2: - -endif diff --git a/after/syntax/yaml.vim b/after/syntax/yaml.vim deleted file mode 100644 index 3a1e89a25..000000000 --- a/after/syntax/yaml.vim +++ /dev/null @@ -1,65 +0,0 @@ -if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'yaml-extras') == -1 - -" To make this file do stuff, add something like the following (without the -" leading ") to your ~/.vimrc: -" au BufNewFile,BufRead *.yaml,*.yml so ~/src/PyYaml/YAML.vim - -" Vim syntax/macro file -" Language: YAML -" Author: Igor Vergeichik -" Sponsor: Tom Sawyer -" Stayven: Ryan King -" Copyright (c) 2002 Tom Saywer - -" Add an item to a gangly list: -"map , o-o -" Convert to Canonical form: -"map \c :%!python -c 'from yaml.redump import redump; import sys; print redump(sys.stdin.read()).rstrip()' - -if version < 600 - syntax clear -endif -syntax clear - -syn match yamlInline "[\[\]\{\}]" -syn match yamlBlock "[>|]\d\?[+-]" - -syn region yamlComment start="\#" end="$" -syn match yamlIndicator "#YAML:\S\+" - -syn region yamlString start="\(^\|\s\|\[\|\,\|\-\)\@<='" end="'" skip="\\'" -syn region yamlString start='"' end='"' skip='\\"' contains=yamlEscape -syn region yamlString matchgroup=yamlBlock start=/[>|]\s*\n\+\z(\s\+\)\S/rs=s+1 skip=/^\%(\z1\S\|^$\)/ end=/^\z1\@!.*/me=s-1 -syn region yamlString matchgroup=yamlBlock start=/[>|]\(\d\|[+-]\)\s*\n\+\z(\s\+\)\S/rs=s+2 skip=/^\%(\z1\S\|^$\)/ end=/^\z1\@!.*/me=s-1 -syn region yamlString matchgroup=yamlBlock start=/[>|]\d\(\d\|[+-]\)\s*\n\+\z(\s\+\)\S/rs=s+3 skip=/^\%(\z1\S\|^$\)/ end=/^\z1\@!.*/me=s-1 -syn match yamlEscape +\\[abfnrtv'"\\]+ contained -syn match yamlEscape "\\\o\o\=\o\=" contained -syn match yamlEscape "\\x\x\+" contained - -syn match yamlType "!\S\+" - -syn keyword yamlConstant NULL Null null NONE None none NIL Nil nil -syn keyword yamlConstant TRUE True true YES Yes yes ON On on -syn keyword yamlConstant FALSE False false NO No no OFF Off off - -syn match yamlKey "^\s*\zs[^ \t\"\'#]\+\ze\s*:" - syn match yamlKey "^\s*-\s*\zs[^ \t\"\'#]\+\ze\s*:" -syn match yamlAnchor "&\S\+" -syn match yamlAlias "*\S\+" - -" Setup the highlighting links - -hi link yamlConstant Keyword -hi link yamlIndicator PreCondit -hi link yamlAnchor Function -hi link yamlAlias Function -hi link yamlKey Identifier -hi link yamlType Type - -hi link yamlComment Comment -hi link yamlInline Operator -hi link yamlBlock Operator -hi link yamlString String -hi link yamlEscape Special - -endif diff --git a/packages.yaml b/packages.yaml index 65df8369d..0a8361b51 100644 --- a/packages.yaml +++ b/packages.yaml @@ -1661,11 +1661,6 @@ filetypes: - fish_read_history ignored_filenames: - '~/.config/fish/fish_{read_,}history' ---- -name: yaml-extras -remote: stephpy/vim-yaml -after: yaml -filetypes: [] # Ansible needs to be after YAML --- name: ansible From cd2fded0e0abb6b31fceaca128699eca0f300c63 Mon Sep 17 00:00:00 2001 From: Adam Stankiewicz Date: Sun, 6 Sep 2020 20:51:38 +0200 Subject: [PATCH 021/299] Add support for Visual Basic and Basic --- README.md | 4 +- autoload/polyglot.vim | 10 + autoload/sleuth.vim | 2 + ftdetect/polyglot.vim | 16 ++ ftplugin/vb.vim | 49 +++++ heuristics.yaml | 8 + indent/vb.vim | 82 ++++++++ packages.yaml | 46 ++++- scripts/build | 33 +++- scripts/test_extensions.vim | 290 ++++++++++++++-------------- scripts/test_filetypes.vim | 2 + syntax/basic.vim | 170 +++++++++++++++++ syntax/vb.vim | 369 ++++++++++++++++++++++++++++++++++++ 13 files changed, 925 insertions(+), 156 deletions(-) create mode 100644 ftplugin/vb.vim create mode 100644 indent/vb.vim create mode 100644 syntax/basic.vim create mode 100644 syntax/vb.vim diff --git a/README.md b/README.md index a78562e99..114002afc 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ A collection of language packs for Vim. > One to rule them all, one to find them, one to bring them all and in the darkness bind them. - It **won't affect your startup time**, as scripts are loaded only on demand\*. -- It **installs and updates 120+ times faster** than the 191 packages it consists of. +- It **installs and updates 120+ times faster** than the 193 packages it consists of. - It is more secure because scripts loaded for all extensions are generated by vim-polyglot (ftdetect). - Solid syntax and indentation support (other features skipped). Only the best language packs. - All unnecessary files are ignored (like enormous documentation from php support). @@ -78,6 +78,7 @@ If you need full functionality of any plugin, please use it directly with your p - [automake](https://github.com/vim/vim/tree/master/runtime) - [ave](https://github.com/vim/vim/tree/master/runtime) - [awk](https://github.com/vim/vim/tree/master/runtime) +- [basic](https://github.com/vim/vim/tree/master/runtime) - [blade](https://github.com/jwalton512/vim-blade) - [brewfile](https://github.com/bfontaine/Brewfile.vim) - [c/c++](https://github.com/vim-jp/vim-cpp) @@ -224,6 +225,7 @@ If you need full functionality of any plugin, please use it directly with your p - [vbnet](https://github.com/vim-scripts/vbnet.vim) - [vcl](https://github.com/smerrill/vcl-vim-plugin) - [velocity](https://github.com/lepture/vim-velocity) +- [visual-basic](https://github.com/vim/vim/tree/master/runtime) - [vmasm](https://github.com/vim/vim/tree/master/runtime) - [vue](https://github.com/posva/vim-vue) - [xdc](https://github.com/amal-khailtash/vim-xdc-syntax) diff --git a/autoload/polyglot.vim b/autoload/polyglot.vim index eca7e304e..ffb3c43fb 100644 --- a/autoload/polyglot.vim +++ b/autoload/polyglot.vim @@ -256,6 +256,16 @@ func! polyglot#DetectLidrFiletype() setf lidris2 | return endfunc +func! polyglot#DetectBasFiletype() + for lnum in range(1, min([line("$"), 5])) + let line = getline(lnum) + if line =~? 'VB_Name\|Begin VB\.\(Form\|MDIForm\|UserControl\)' + setf vb | return + endif + endfor + setf basic | return +endfunc + " Restore 'cpoptions' let &cpo = s:cpo_save unlet s:cpo_save diff --git a/autoload/sleuth.vim b/autoload/sleuth.vim index e70169cb9..18344723b 100644 --- a/autoload/sleuth.vim +++ b/autoload/sleuth.vim @@ -35,6 +35,7 @@ let s:globs = { \ 'automake': '[Mm]akefile.am,GNUmakefile.am', \ 'ave': '*.ave', \ 'awk': '*.awk', + \ 'basic': '*.basic', \ 'blade': '*.blade,*.blade.php', \ 'brewfile': 'Brewfile', \ 'c': '*.c,*.cats,*.h,*.idc', @@ -200,6 +201,7 @@ let s:globs = { \ 'unison': '*.u,*.uu', \ 'v': '*.v', \ 'vala': '*.vala,*.vapi,*.valadoc', + \ 'vb': '*.bas,*.cls,*.frm,*.frx,*.vba,*.vbs,*.dsm,*.ctl,*.sba', \ 'vbnet': '*.vb,*.vbhtml', \ 'vcl': '*.vcl', \ 'velocity': '*.vm', diff --git a/ftdetect/polyglot.vim b/ftdetect/polyglot.vim index bc79d0a6f..a37b76af8 100644 --- a/ftdetect/polyglot.vim +++ b/ftdetect/polyglot.vim @@ -1712,6 +1712,22 @@ if !has_key(s:disabled_packages, 'trasys') au! BufNewFile,BufRead *.inp call polyglot#DetectInpFiletype() endif +if !has_key(s:disabled_packages, 'basic') + au BufNewFile,BufRead *.basic setf basic +endif + +if !has_key(s:disabled_packages, 'visual-basic') + au BufNewFile,BufRead *.cls setf vb + au BufNewFile,BufRead *.ctl setf vb + au BufNewFile,BufRead *.dsm setf vb + au BufNewFile,BufRead *.frm setf vb + au BufNewFile,BufRead *.frx setf vb + au BufNewFile,BufRead *.sba setf vb + au BufNewFile,BufRead *.vba setf vb + au BufNewFile,BufRead *.vbs setf vb + au! BufNewFile,BufRead *.bas call polyglot#DetectBasFiletype() +endif + " end filetypes diff --git a/ftplugin/vb.vim b/ftplugin/vb.vim new file mode 100644 index 000000000..63bf8efd0 --- /dev/null +++ b/ftplugin/vb.vim @@ -0,0 +1,49 @@ +if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'visual-basic') == -1 + +" Vim filetype plugin file +" Language: VisualBasic (ft=vb) +" Maintainer: Johannes Zellner +" Last Change: Thu, 22 Nov 2001 12:56:14 W. Europe Standard Time + +if exists("b:did_ftplugin") | finish | endif +let b:did_ftplugin = 1 + +setlocal com=sr:'\ -,mb:'\ \ ,el:'\ \ ,:' + +" we need this wrapper, as call doesn't allow a count +fun! VbSearch(pattern, flags) + let cnt = v:count1 + while cnt > 0 + call search(a:pattern, a:flags) + let cnt = cnt - 1 + endwhile +endfun + +let s:cpo_save = &cpo +set cpo&vim + +" NOTE the double escaping \\| +nnoremap [[ :call VbSearch('^\s*\(\(private\|public\)\s\+\)\=\(function\\|sub\)', 'bW') +nnoremap ]] :call VbSearch('^\s*\(\(private\|public\)\s\+\)\=\(function\\|sub\)', 'W') +nnoremap [] :call VbSearch('^\s*\\s\+\(function\\|sub\)', 'bW') +nnoremap ][ :call VbSearch('^\s*\\s\+\(function\\|sub\)', 'W') + +" matchit support +if exists("loaded_matchit") + let b:match_ignorecase=1 + let b:match_words= + \ '\%(^\s*\)\@<=\.*\\s*$:\%(^\s*\)\@<=\:\%(^\s*\)\@<=\:\%(^\s*\)\@<=\\s\+\,' . + \ '\%(^\s*\)\@<=\:\%(^\s*\)\@<=\,' . + \ '\%(^\s*\)\@<=\:\%(^\s*\)\@<=\,' . + \ '\%(^\s*\)\@<=\:\%(^\s*\)\@<=\\s\+\,' . + \ '\%(^\s*\)\@<=\\s\+\:\%(^\s*\)\@<=\:\%(^\s*\)\@<=\\s\+\,' . + \ '\%(^\s*\)\@<=\:\%(^\s*\)\@<=\\s\,' . + \ '\%(^\s*\)\@<=\:\%(^\s*\)\@<=\\s\,' . + \ '\%(^\s*\)\@<=\%(\<\%(private\|public\)\>\s\+\)\=\\s\+\([^ \t(]\+\):\%(^\s*\)\@<=\<\1\>\s*=:\%(^\s*\)\@<=\\s\+\,' . + \ '\%(^\s*\)\@<=\%(\<\%(private\|public\)\>\s\+\)\=\\s\+:\%(^\s*\)\@<=\\s\+\' +endif + +let &cpo = s:cpo_save +unlet s:cpo_save + +endif diff --git a/heuristics.yaml b/heuristics.yaml index 33c1c6906..8c0c16630 100644 --- a/heuristics.yaml +++ b/heuristics.yaml @@ -93,3 +93,11 @@ rules: pattern: '^>\s*--.*[Ii]dris ?1' filetype: lidris - filetype: lidris2 +--- +extensions: [bas] +rules: +- lines: 5 + pattern: 'VB_Name|Begin VB\.(Form|MDIForm|UserControl)' + filetype: vb + ignore_case: true +- filetype: basic diff --git a/indent/vb.vim b/indent/vb.vim new file mode 100644 index 000000000..129c2abde --- /dev/null +++ b/indent/vb.vim @@ -0,0 +1,82 @@ +if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'visual-basic') == -1 + +" Vim indent file +" Language: VisualBasic (ft=vb) / Basic (ft=basic) / SaxBasic (ft=vb) +" Author: Johannes Zellner +" Last Change: Fri, 18 Jun 2004 07:22:42 CEST +" Small update 2010 Jul 28 by Maxim Kim + +if exists("b:did_indent") + finish +endif +let b:did_indent = 1 + +setlocal autoindent +setlocal indentexpr=VbGetIndent(v:lnum) +setlocal indentkeys& +setlocal indentkeys+==~else,=~elseif,=~end,=~wend,=~case,=~next,=~select,=~loop,<:> + +let b:undo_indent = "set ai< indentexpr< indentkeys<" + +" Only define the function once. +if exists("*VbGetIndent") + finish +endif + +fun! VbGetIndent(lnum) + " labels and preprocessor get zero indent immediately + let this_line = getline(a:lnum) + let LABELS_OR_PREPROC = '^\s*\(\<\k\+\>:\s*$\|#.*\)' + if this_line =~? LABELS_OR_PREPROC + return 0 + endif + + " Find a non-blank line above the current line. + " Skip over labels and preprocessor directives. + let lnum = a:lnum + while lnum > 0 + let lnum = prevnonblank(lnum - 1) + let previous_line = getline(lnum) + if previous_line !~? LABELS_OR_PREPROC + break + endif + endwhile + + " Hit the start of the file, use zero indent. + if lnum == 0 + return 0 + endif + + let ind = indent(lnum) + + " Add + if previous_line =~? '^\s*\<\(begin\|\%(\%(private\|public\|friend\)\s\+\)\=\%(function\|sub\|property\)\|select\|case\|default\|if\|else\|elseif\|do\|for\|while\|enum\|with\)\>' + let ind = ind + shiftwidth() + endif + + " Subtract + if this_line =~? '^\s*\\s\+\' + if previous_line !~? '^\s*\' + let ind = ind - 2 * shiftwidth() + else + " this case is for an empty 'select' -- 'end select' + " (w/o any case statements) like: + " + " select case readwrite + " end select + let ind = ind - shiftwidth() + endif + elseif this_line =~? '^\s*\<\(end\|else\|elseif\|until\|loop\|next\|wend\)\>' + let ind = ind - shiftwidth() + elseif this_line =~? '^\s*\<\(case\|default\)\>' + if previous_line !~? '^\s*\' + let ind = ind - shiftwidth() + endif + endif + + return ind +endfun + +" vim:sw=4 + +endif diff --git a/packages.yaml b/packages.yaml index 0a8361b51..e167e0f10 100644 --- a/packages.yaml +++ b/packages.yaml @@ -348,14 +348,14 @@ filetypes: extra_extensions: # 17 results: https://github.com/search?q=extension%3Acoffeekup+html&type=Code - coffeekup - ignored_extensions: + ignored_filenames: + # Probably mistake + - '*Cakefile' + ignored_warnings: # Used by C# - csx # Used by Chuck - ck - ignored_filenames: - # Probably mistake - - '*Cakefile' - name: litcoffee linguist: Literate CoffeeScript extra_extensions: @@ -395,7 +395,7 @@ filetypes: extra_extensions: - tsv - tab - ignored_extensions: + ignored_warnings: # This is definitely not csv-only, maybe re-enable when heuristics done - dat --- @@ -815,8 +815,10 @@ filetypes: extra_extensions: - j2 ignored_extensions: - - mustache - njk + ignore_warnings: + # handled by mustache plugin + - mustache --- name: jq remote: vito-c/jq.vim @@ -857,8 +859,8 @@ filetypes: extra_extensions: - jst - ect - ignored_extensions: - # I haven't found reference to them + ignored_warnings: + # I haven't found reference to them on github - djs - hamljs --- @@ -974,6 +976,7 @@ filetypes: ignored_extensions: # Handled by mdx extension - mdx + ignored_warnings: - '{md,mdx,mdown,mkd,mkdn,markdown,mdwn}.{des3,des,bf,bfa,aes,idea,cast,rc2,rc4,rc5,desx}' --- name: mdx @@ -1551,9 +1554,9 @@ remote: lumiliet/vim-twig filetypes: - name: html.twig linguist: Twig - ignored_extensions: + ignored_warnings: + # handled by other extension - xml.twig - ignored_extensions: # already covered by .twig - html.twig - name: xml.twig @@ -1721,3 +1724,26 @@ filetypes: - name: trasys extensions: - inp +--- +name: basic +remote: vim/vim:runtime +glob: '**/basic.vim' +filetypes: +- name: basic + extensions: + - basic +--- +name: visual-basic +remote: vim/vim:runtime +glob: '**/vb.vim' +filetypes: +- name: vb + linguist: VBA + extra_extensions: + - vbs + - dsm + - ctl + # SaxBasic is close to Visual Basic + - sba + ignore_warnings: + - vb diff --git a/scripts/build b/scripts/build index b868ebfc5..197b4ea3a 100755 --- a/scripts/build +++ b/scripts/build @@ -59,10 +59,15 @@ def load_data() linguist = languages.fetch(filetype["linguist"]) - filetype["extensions"] = (( - (linguist["extensions"] || []).map { |e| e[1..-1] } | + filetype["extensions"] = (linguist["extensions"] || []).map { |e| e[1..-1] } | filetype.fetch("extra_extensions", []) - ) - filetype.fetch("ignored_extensions", [])).uniq + + extra_ignored_extensions = filetype.fetch("ignored_extensions", []) - filetype["extensions"] + if extra_ignored_extensions.size > 0 + raise StandardError.new("[#{filetype["name"]}]: Unnecessary ignored extensions: #{extra_ignored_extensions.join(", ")}") + end + + filetype["extensions"] -= filetype.fetch("ignored_extensions", []) filetype["filenames"] = (( (linguist["filenames"] || []) | @@ -394,7 +399,19 @@ def generate_ftdetect(packages, heuristics) expected_filetypes = detect_filetypes('tmp/**/ftdetect/*.vim') native_filetypes = detect_filetypes('tmp/vim/vim/runtime/filetype.vim') native_extensions = native_filetypes.flat_map { |k, v| v["extensions"] } + + all_filetypes = Hash.new { |h, k| h[k] = { extensions: [], filenames: [] } } + + for k, v in expected_filetypes + all_filetypes[k][:extensions].concat(v[:extensions]) + all_filetypes[k][:filenames].concat(v[:filenames]) + end + for k, v in native_filetypes + all_filetypes[k][:extensions].concat(v[:extensions]) + all_filetypes[k][:filenames].concat(v[:filenames]) + end + for package in packages name = package.fetch("name") @@ -438,12 +455,16 @@ def generate_ftdetect(packages, heuristics) extensions = filetype["extensions"] filenames = filetype["filenames"] - if expected_filetypes[name] && !filetype["syntax"] - for e in expected_filetypes.fetch(name)[:extensions] - extensions - expand_all(filetype.fetch("ignored_extensions", [])) + expected_extensions = all_filetypes.has_key?(name) ? all_filetypes.fetch(name)[:extensions] : [] + ignored_extensions = expand_all(filetype.fetch("ignored_extensions", [])) + ignored_warnings = expand_all(filetype.fetch("ignored_warnings", [])) + + if all_filetypes[name] && !filetype["syntax"] + for e in expected_extensions - extensions - ignored_extensions - ignored_warnings puts "Probable missing extension for #{name}: #{e}" end - for e in expected_filetypes.fetch(name)[:filenames] - expand_all(filenames).flat_map { |e| [e, e.gsub(/^\./, '')] } - expand_all(filetype.fetch("ignored_filenames", [])) - ['*'] + for e in all_filetypes.fetch(name)[:filenames] - expand_all(filenames).flat_map { |e| [e, e.gsub(/^\./, '')] } - expand_all(filetype.fetch("ignored_warnings", [])) - ['*'] puts "Probable missing filename for #{name}: #{e}" end end diff --git a/scripts/test_extensions.vim b/scripts/test_extensions.vim index 9211818d5..9cac0b21a 100644 --- a/scripts/test_extensions.vim +++ b/scripts/test_extensions.vim @@ -9,145 +9,145 @@ function! TestExtension(filetype, filename, content) exec ":bw!" catch echo g:message - echo 'Filename "' . a:filename . '" does not resolve to extension "' . a:filetype . '"' - echo ' instead received: "' . v:exception . '"' - exec ':cq!' + echo "Filename '" . a:filename . "' does not resolve to extension '" . a:filetype . "'" + echo " instead received: '" . v:exception . "'" + exec ":cq!" endtry endfunction -call TestExtension('sh', 'bash1', "#!/bin/bash") -call TestExtension('sh', 'bash2', "#! /bin/bash") -call TestExtension('sh', 'bash3', "#! /bin/bash2.3") -call TestExtension('sh', 'bash4', "#!/usr/bin/env bash") -call TestExtension('sh', 'bash6', "#!/usr/bin/env -i -=split-string foo=bar bash -l foo") -call TestExtension('sh', 'bash1', "#!/bin/bash") +call TestExtension("sh", "bash1", "#!/bin/bash") +call TestExtension("sh", "bash2", "#! /bin/bash") +call TestExtension("sh", "bash3", "#! /bin/bash2.3") +call TestExtension("sh", "bash4", "#!/usr/bin/env bash") +call TestExtension("sh", "bash6", "#!/usr/bin/env -i -=split-string foo=bar bash -l foo") +call TestExtension("sh", "bash1", "#!/bin/bash") " Vim help file -call TestExtension('help', $VIMRUNTIME . '/doc/foobar.txt', '') +call TestExtension("help", $VIMRUNTIME . "/doc/foobar.txt", "") " Abaqus or Trasys -call TestExtension('abaqus', 'foobar.inp', "*HEADING\nFoobar") -call TestExtension('trasys', 'foobar.inp', "MSC PATRAN\n* foobar\nHEADER SURFACE DATA\nBSC ENCLO1") +call TestExtension("abaqus", "foobar.inp", "*HEADING\nFoobar") +call TestExtension("trasys", "foobar.inp", "MSC PATRAN\n* foobar\nHEADER SURFACE DATA\nBSC ENCLO1") " 8th (Firth-derivative) -call TestExtension('8th', 'foobar.8th', '') -call TestExtension('8th', 'foobar.8th', '') +call TestExtension("8th", "foobar.8th", "") +call TestExtension("8th", "foobar.8th", "") " A-A-P recipe -call TestExtension('aap', 'foobar.aap', '') +call TestExtension("aap", "foobar.aap", "") " A2ps printing utility -call TestExtension('a2ps', '/etc/a2ps.cfg', '') -call TestExtension('a2ps', '/usr/local/etc/a2ps.cfg', '') -call TestExtension('a2ps', '/etc/a2ps/foobar.cfg', '') -call TestExtension('a2ps', '/usr/local/etc/a2ps/foobar.cfg', '') -call TestExtension('a2ps', '/tmp/a2psrc', '') -call TestExtension('a2ps', '/tmp/.a2psrc', '') +call TestExtension("a2ps", "/etc/a2ps.cfg", "") +call TestExtension("a2ps", "/usr/local/etc/a2ps.cfg", "") +call TestExtension("a2ps", "/etc/a2ps/foobar.cfg", "") +call TestExtension("a2ps", "/usr/local/etc/a2ps/foobar.cfg", "") +call TestExtension("a2ps", "/tmp/a2psrc", "") +call TestExtension("a2ps", "/tmp/.a2psrc", "") " ABAB/4 -call TestExtension('abap', 'foobar.abap', '') +call TestExtension("abap", "foobar.abap", "") " ABC music notation -call TestExtension('abc', 'foobar.abc', '') +call TestExtension("abc", "foobar.abc", "") " ABEL -call TestExtension('abel', 'foobar.abl', '') +call TestExtension("abel", "foobar.abl", "") " AceDB -call TestExtension('acedb', 'foobar.wrm', '') +call TestExtension("acedb", "foobar.wrm", "") " Ada (83, 9X, 95) -call TestExtension('ada', 'foobar.adb', '') -call TestExtension('ada', 'foobar.ads', '') -call TestExtension('ada', 'foobar.ada', '') -call TestExtension('ada', 'foobar.gpr', '') +call TestExtension("ada", "foobar.adb", "") +call TestExtension("ada", "foobar.ads", "") +call TestExtension("ada", "foobar.ada", "") +call TestExtension("ada", "foobar.gpr", "") " AHDL -call TestExtension('ahdl', 'foobar.tdf', '') +call TestExtension("ahdl", "foobar.tdf", "") " AIDL -call TestExtension('aidl', 'foobar.aidl', '') +call TestExtension("aidl", "foobar.aidl", "") " AMPL -call TestExtension('ampl', 'foobar.run', '') +call TestExtension("ampl", "foobar.run", "") " Ant -call TestExtension('ant', 'build.xml', '') +call TestExtension("ant", "build.xml", "") " Arduino -call TestExtension('arduino', 'foobar.ino', '') -call TestExtension('arduino', 'foobar.pde', '') +call TestExtension("arduino", "foobar.ino", "") +call TestExtension("arduino", "foobar.pde", "") " Apache config file -call TestExtension('apache', '.htaccess', '') -call TestExtension('apache', '/etc/httpd/foobar.conf', '') -call TestExtension('apache', '/etc/apache2/sites-foobar/foobar.com', '') -call TestExtension('apache', '/usr/local/etc/httpd/foobar.conf', '') -call TestExtension('apache', '/usr/local/etc/apache2/sites-foobar/foobar.com', '') +call TestExtension("apache", ".htaccess", "") +call TestExtension("apache", "/etc/httpd/foobar.conf", "") +call TestExtension("apache", "/etc/apache2/sites-foobar/foobar.com", "") +call TestExtension("apache", "/usr/local/etc/httpd/foobar.conf", "") +call TestExtension("apache", "/usr/local/etc/apache2/sites-foobar/foobar.com", "") " XA65 MOS6510 cross assembler -call TestExtension('a65', 'foobar.a65', '') +call TestExtension("a65", "foobar.a65", "") " Applescript -call TestExtension('applescript', 'foobar.scpt', '') +call TestExtension("applescript", "foobar.scpt", "") " Applix ELF -call TestExtension('elf', 'foobar.am', '') -call TestExtension('automake', 'Makefile.am', '') -call TestExtension('automake', 'makefile.am', '') +call TestExtension("elf", "foobar.am", "") +call TestExtension("automake", "Makefile.am", "") +call TestExtension("automake", "makefile.am", "") " ALSA configuration -call TestExtension('alsaconf', '.asoundrc', '') -call TestExtension('alsaconf', '/usr/share/alsa/alsa.conf', '') -call TestExtension('alsaconf', '/media/foo/usr/share/alsa/alsa.conf', '') -call TestExtension('alsaconf', '/etc/asound.conf', '') -call TestExtension('alsaconf', '/media/foo/etc/asound.conf', '') +call TestExtension("alsaconf", ".asoundrc", "") +call TestExtension("alsaconf", "/usr/share/alsa/alsa.conf", "") +call TestExtension("alsaconf", "/media/foo/usr/share/alsa/alsa.conf", "") +call TestExtension("alsaconf", "/etc/asound.conf", "") +call TestExtension("alsaconf", "/media/foo/etc/asound.conf", "") " Arc Macro Language -call TestExtension('aml', 'foobar.aml', '') +call TestExtension("aml", "foobar.aml", "") " APT config file -call TestExtension('aptconf', 'apt.conf', '') -call TestExtension('aptconf', '/root/.aptitude/config', '') -call TestExtension('aptconf', '/etc/apt/apt.conf.d/foo_bar-12', '') -call TestExtension('aptconf', '/etc/apt/apt.conf.d/foo_bar-12.conf', '') -call TestExtension('', '/etc/apt/apt.conf.d/.gsdf', '') +call TestExtension("aptconf", "apt.conf", "") +call TestExtension("aptconf", "/root/.aptitude/config", "") +call TestExtension("aptconf", "/etc/apt/apt.conf.d/foo_bar-12", "") +call TestExtension("aptconf", "/etc/apt/apt.conf.d/foo_bar-12.conf", "") +call TestExtension("", "/etc/apt/apt.conf.d/.gsdf", "") " Arch Inventory file -call TestExtension('arch', '.arch-inventory', '') -call TestExtension('arch', '=tagging-method', '') +call TestExtension("arch", ".arch-inventory", "") +call TestExtension("arch", "=tagging-method", "") " ART*Enterprise (formerly ART-IM) -call TestExtension('art', 'foobar.art', '') +call TestExtension("art", "foobar.art", "") " AsciiDoc -call TestExtension('asciidoc', 'foobar.asciidoc', '') -call TestExtension('asciidoc', 'foobar.adoc', '') +call TestExtension("asciidoc", "foobar.asciidoc", "") +call TestExtension("asciidoc", "foobar.adoc", "") " ASN.1 -call TestExtension('asn', 'foobar.asn', '') -call TestExtension('asn', 'foobar.asn1', '') +call TestExtension("asn", "foobar.asn", "") +call TestExtension("asn", "foobar.asn1", "") " Active Server Pages (with Visual Basic Script) -call TestExtension('aspvbs', 'foobar.asa', '') -let g:filetype_asa = 'fizfuz' -call TestExtension('fizfuz', 'foobar.asa', '') +call TestExtension("aspvbs", "foobar.asa", "") +let g:filetype_asa = "fizfuz" +call TestExtension("fizfuz", "foobar.asa", "") " Active Server Pages (with Perl or Visual Basic Script) -call TestExtension('aspvbs', 'vbs.asp', "") -call TestExtension('aspperl', 'perl.asp', "\n\n") -let g:filetype_asp = 'fizfuz' -call TestExtension('fizfuz', 'fizfuz.asp', '') +call TestExtension("aspvbs", "vbs.asp", "") +call TestExtension("aspperl", "perl.asp", "\n\n") +let g:filetype_asp = "fizfuz" +call TestExtension("fizfuz", "fizfuz.asp", "") " Grub (must be before catch *.lst) -call TestExtension('grub', '/boot/grub/menu.lst', '') -call TestExtension('grub', '/media/foobar/boot/grub/menu.lst', '') -call TestExtension('grub', '/boot/grub/grub.conf', '') -call TestExtension('grub', '/media/foobar/boot/grub/grub.conf', '') -call TestExtension('grub', '/etc/grub.conf', '') -call TestExtension('grub', '/media/foobar/etc/grub.conf', '') +call TestExtension("grub", "/boot/grub/menu.lst", "") +call TestExtension("grub", "/media/foobar/boot/grub/menu.lst", "") +call TestExtension("grub", "/boot/grub/grub.conf", "") +call TestExtension("grub", "/media/foobar/boot/grub/grub.conf", "") +call TestExtension("grub", "/etc/grub.conf", "") +call TestExtension("grub", "/media/foobar/etc/grub.conf", "") " Assembly (all kinds) " *.lst is not pure assembly, it has two extra columns (address, byte codes) @@ -155,93 +155,105 @@ call TestExtension('grub', '/media/foobar/etc/grub.conf', '') au BufNewFile,BufRead *.asm,*.[sS],*.[aA],*.mac,*.lst call dist#ft#FTasm() " Macro (VAX) -call TestExtension('vmasm', 'foobar.mar', '') +call TestExtension("vmasm", "foobar.mar", "") " Atlas -call TestExtension('atlas', 'foobar.atl', '') -call TestExtension('atlas', 'foobar.as', '') +call TestExtension("atlas", "foobar.atl", "") +call TestExtension("atlas", "foobar.as", "") " Autoit v3 -call TestExtension('autoit', 'foobar.au3', '') +call TestExtension("autoit", "foobar.au3", "") " Autohotkey -call TestExtension('autohotkey', 'foobar.ahk', '') +call TestExtension("autohotkey", "foobar.ahk", "") " Automake -call TestExtension('automake', 'Makefile.am', '') -call TestExtension('automake', 'makefile.am', '') -call TestExtension('automake', 'GNUmakefile.am', '') +call TestExtension("automake", "Makefile.am", "") +call TestExtension("automake", "makefile.am", "") +call TestExtension("automake", "GNUmakefile.am", "") " Autotest .at files are actually m4 -call TestExtension('m4', 'foobar.at', '') +call TestExtension("m4", "foobar.at", "") " Avenue -call TestExtension('ave', 'foobar.ave', '') +call TestExtension("ave", "foobar.ave", "") " Awk -call TestExtension('awk', 'foobar.awk', '') +call TestExtension("awk", "foobar.awk", "") " vim-polyglot only -call TestExtension('blade', 'test.blade.php', '') -call TestExtension('yaml.ansible', 'playbook.yml', '') -call TestExtension('yaml.ansible', 'host_vars/foobar', '') -call TestExtension('yaml.ansible', 'handlers.foobar.yaml', '') -call TestExtension('yaml.ansible', 'requirements.yaml', '') -call TestExtension('ps1xml', 'foobar.ps1xml', '') -call TestExtension('terraform', 'terraform.tf', '') - -call TestExtension('idris2', 'foobar.idr', '') -call TestExtension('idris', 'foobar.idr', "pkgs : List String\npkgs = [\"NCurses\", \"Readline\"]") -let g:filetype_idr = 'fizfuz' -call TestExtension('fizfuz', 'fizfuz.idr', '') +call TestExtension("blade", "test.blade.php", "") +call TestExtension("yaml.ansible", "playbook.yml", "") +call TestExtension("yaml.ansible", "host_vars/foobar", "") +call TestExtension("yaml.ansible", "handlers.foobar.yaml", "") +call TestExtension("yaml.ansible", "requirements.yaml", "") +call TestExtension("ps1xml", "foobar.ps1xml", "") +call TestExtension("terraform", "terraform.tf", "") + +call TestExtension("idris2", "foobar.idr", "") +call TestExtension("idris", "foobar.idr", "pkgs : List String\npkgs = [\"NCurses\", \"Readline\"]") +let g:filetype_idr = "fizfuz" +call TestExtension("fizfuz", "fizfuz.idr", "") " .m extension -call TestExtension('octave', 'matlab.m', '') -call TestExtension('objc', 'objc.m', "\n\n #import ") -call TestExtension('octave', 'objc.m', "results_ub_times=zeros(2,2,M);\n%results pour la lower bound") -call TestExtension('mma', 'mathematica.m', "newcase[ \"00003\" ];\n (* Hello world *)") -call TestExtension('murphi', 'murphi.m', "type\n square: 1 .. 9") -call TestExtension('murphi', 'murphi.m', "something\n--foobar") -call TestExtension('octave', 'percentcomment.m', "hello world\n%foobar") -call TestExtension('objc', 'comment.m', "\n/* Hello world */") -let g:filetype_m = 'fizfuz' -call TestExtension('fizfuz', 'fizfuz.m', '') +call TestExtension("octave", "matlab.m", "") +call TestExtension("objc", "objc.m", "\n\n #import ") +call TestExtension("octave", "objc.m", "results_ub_times=zeros(2,2,M);\n%results pour la lower bound") +call TestExtension("mma", "mathematica.m", "newcase[ \"00003\" ];\n (* Hello world *)") +call TestExtension("murphi", "murphi.m", "type\n square: 1 .. 9") +call TestExtension("murphi", "murphi.m", "something\n--foobar") +call TestExtension("octave", "percentcomment.m", "hello world\n%foobar") +call TestExtension("objc", "comment.m", "\n/* Hello world */") +let g:filetype_m = "fizfuz" +call TestExtension("fizfuz", "fizfuz.m", "") " .fs extension -call TestExtension('forth', 'empty.fs', '') -call TestExtension('fsharp', 'fsharp.fs', "let myInt = 5") -call TestExtension('glsl', 'glsl.fs', "//#version 120\nvoid main() {}") -let g:filetype_fs = 'fizfuz' -call TestExtension('fizfuz', 'fizfuz.fs', '') +call TestExtension("forth", "empty.fs", "") +call TestExtension("fsharp", "fsharp.fs", "let myInt = 5") +call TestExtension("glsl", "glsl.fs", "//#version 120\nvoid main() {}") +let g:filetype_fs = "fizfuz" +call TestExtension("fizfuz", "fizfuz.fs", "") " .re extension -call TestExtension('reason', 'empty.re', '') -call TestExtension('cpp', 'cpp.re', '#include "config.h"') -call TestExtension('cpp', 'cpp2.re', '#ifdef HAVE_CONFIG_H') -call TestExtension('cpp', 'cpp3.re', '#define YYCTYPE unsigned char') -call TestExtension('reason', 'react.re', 'ReasonReact.Router.push("");') +call TestExtension("reason", "empty.re", "") +call TestExtension("cpp", "cpp.re", "#include \"config.h\"") +call TestExtension("cpp", "cpp2.re", "#ifdef HAVE_CONFIG_H") +call TestExtension("cpp", "cpp3.re", "#define YYCTYPE unsigned char") +call TestExtension("reason", "react.re", "ReasonReact.Router.push('');") + +" .bas extension +call TestExtension("vbnet", "vb.vb", "") +call TestExtension("basic", "empty.bas", "") +call TestExtension("vb", "vb1.bas", "Attribute VB_Name = \"Class1\"") +call TestExtension("vb", "vb2.bas", "VERSION 5.00\nBegin VB.Form Form1") +call TestExtension("vb", "vb2.bas", "VERSION 5.00\nBegin VB.Form Form1") +call TestExtension("vb", "vb.sba", "") +call TestExtension("vb", "vb.vbs", "") +call TestExtension("vb", "vb.dsm", "") +call TestExtension("vb", "vb.dsm", "") +call TestExtension("vb", "vb.ctl", "") " Idris -call TestExtension('idris', 'lowercase.idr', '--idris1') -call TestExtension('idris', 'uppercase.idr', '--Idris1') -call TestExtension('idris', 'start-space-l.idr', '-- idris1') -call TestExtension('idris', 'start-space-u.idr', '-- Idris1') -call TestExtension('idris', 'two-spaces-l.idr', '-- idris 1') -call TestExtension('idris', 'two-spaces-u.idr', '-- Idris 1') -"call TestExtension('idris', 'mypkg.ipkg', 'package mypkg\n\npkgs = pruviloj, lightyear') -call TestExtension('idris', 'use-type-prov.idr', '%language TypeProviders') -call TestExtension('idris', 'use-elab-refl.idr', '%language ElabReflection') -call TestExtension('idris', 'access-modifier.idr', '%access export\n\npublic export\nMyTest : Type-> Type\n\nfact : Nat -> Nat') -call TestExtension('idris2', 'lowercase.idr', '--idris2') -call TestExtension('idris2', 'uppercase.idr', '--Idris2') -call TestExtension('idris2', 'start-space-l.idr', '-- idris2') -call TestExtension('idris2', 'start-space-u.idr', '-- Idris2') -call TestExtension('idris2', 'two-spaces-l.idr', '-- idris 2') -call TestExtension('idris2', 'two-spaces-u.idr', '-- Idris 2') -call TestExtension('idris2', 'mypkg.ipkg', 'package mypkg\n\ndepends = effects') -call TestExtension('idris2', 'use-post-proj.idr', '%language PostfixProjections') +call TestExtension("idris", "lowercase.idr", "--idris1") +call TestExtension("idris", "uppercase.idr", "--Idris1") +call TestExtension("idris", "start-space-l.idr", "-- idris1") +call TestExtension("idris", "start-space-u.idr", "-- Idris1") +call TestExtension("idris", "two-spaces-l.idr", "-- idris 1") +call TestExtension("idris", "two-spaces-u.idr", "-- Idris 1") +"call TestExtension("idris", "mypkg.ipkg", "package mypkg\n\npkgs = pruviloj, lightyear") +call TestExtension("idris", "use-type-prov.idr", "%language TypeProviders") +call TestExtension("idris", "use-elab-refl.idr", "%language ElabReflection") +call TestExtension("idris", "access-modifier.idr", "%access export\n\npublic export\nMyTest : Type-> Type\n\nfact : Nat -> Nat") +call TestExtension("idris2", "lowercase.idr", "--idris2") +call TestExtension("idris2", "uppercase.idr", "--Idris2") +call TestExtension("idris2", "start-space-l.idr", "-- idris2") +call TestExtension("idris2", "start-space-u.idr", "-- Idris2") +call TestExtension("idris2", "two-spaces-l.idr", "-- idris 2") +call TestExtension("idris2", "two-spaces-u.idr", "-- Idris 2") +call TestExtension("idris2", "mypkg.ipkg", "package mypkg\n\ndepends = effects") +call TestExtension("idris2", "use-post-proj.idr", "%language PostfixProjections") " Literate Idris -call TestExtension('lidris', 'lidris-1.lidr', "Some test plaintext\n\n> --idris1\n> myfact : Nat -> Nat\n> myfact Z = 1\n> myfact (S k) = (S k) * myfact k\n\nMore plaintext") -call TestExtension('lidris2', 'lidris-2.lidr', "Some test plaintext\n\n> --idris2\n> myfact : Nat -> Nat\n> myfact Z = 1\n> myfact (S k) = (S k) * myfact k\n\nMore plaintext") +call TestExtension("lidris", "lidris-1.lidr", "Some test plaintext\n\n> --idris1\n> myfact : Nat -> Nat\n> myfact Z = 1\n> myfact (S k) = (S k) * myfact k\n\nMore plaintext") +call TestExtension("lidris2", "lidris-2.lidr", "Some test plaintext\n\n> --idris2\n> myfact : Nat -> Nat\n> myfact Z = 1\n> myfact (S k) = (S k) * myfact k\n\nMore plaintext") diff --git a/scripts/test_filetypes.vim b/scripts/test_filetypes.vim index 0f870d5a2..e157889d8 100644 --- a/scripts/test_filetypes.vim +++ b/scripts/test_filetypes.vim @@ -228,3 +228,5 @@ call TestFiletype('zephir') call TestFiletype('zir') call TestFiletype('zig') call TestFiletype('trasys') +call TestFiletype('basic') +call TestFiletype('vb') diff --git a/syntax/basic.vim b/syntax/basic.vim new file mode 100644 index 000000000..f2aa1bc44 --- /dev/null +++ b/syntax/basic.vim @@ -0,0 +1,170 @@ +if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'basic') == -1 + +" Vim syntax file +" Language: BASIC +" Maintainer: Allan Kelly +" Last Change: 2011 Dec 25 by Thilo Six + +" 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 +if exists("b:current_syntax") + finish +endif + +let s:cpo_save = &cpo +set cpo&vim + +" A bunch of useful BASIC keywords +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 +syn keyword basicStatement CIRCLE circle Circle CLEAR clear Clear +syn keyword basicStatement CLOSE close Close CLS cls Cls COLOR color Color +syn keyword basicStatement COM com Com COMMON common Common +syn keyword basicStatement CONST const Const DATA data Data +syn keyword basicStatement DECLARE declare Declare DEF def Def +syn keyword basicStatement DEFDBL defdbl Defdbl DEFINT defint Defint +syn keyword basicStatement DEFLNG deflng Deflng DEFSNG defsng Defsng +syn keyword basicStatement DEFSTR defstr Defstr DIM dim Dim +syn keyword basicStatement DO do Do LOOP loop Loop +syn keyword basicStatement DRAW draw Draw END end End +syn keyword basicStatement ENVIRON environ Environ ERASE erase Erase +syn keyword basicStatement ERROR error Error EXIT exit Exit +syn keyword basicStatement FIELD field Field FILES files Files +syn keyword basicStatement FOR for For NEXT next Next +syn keyword basicStatement FUNCTION function Function GET get Get +syn keyword basicStatement GOSUB gosub Gosub GOTO goto Goto +syn keyword basicStatement IF if If THEN then Then ELSE else Else +syn keyword basicStatement INPUT input Input INPUT# input# Input# +syn keyword basicStatement IOCTL ioctl Ioctl KEY key Key +syn keyword basicStatement KILL kill Kill LET let Let +syn keyword basicStatement LINE line Line LOCATE locate Locate +syn keyword basicStatement LOCK lock Lock UNLOCK unlock Unlock +syn keyword basicStatement LPRINT lprint Lprint USING using Using +syn keyword basicStatement LSET lset Lset MKDIR mkdir Mkdir +syn keyword basicStatement NAME name Name ON on On +syn keyword basicStatement ERROR error Error OPEN open Open +syn keyword basicStatement OPTION option Option BASE base Base +syn keyword basicStatement OUT out Out PAINT paint Paint +syn keyword basicStatement PALETTE palette Palette PCOPY pcopy Pcopy +syn keyword basicStatement PEN pen Pen PLAY play Play +syn keyword basicStatement PMAP pmap Pmap POKE poke Poke +syn keyword basicStatement PRESET preset Preset PRINT print Print +syn keyword basicStatement PRINT# print# Print# USING using Using +syn keyword basicStatement PSET pset Pset PUT put Put +syn keyword basicStatement RANDOMIZE randomize Randomize READ read Read +syn keyword basicStatement REDIM redim Redim RESET reset Reset +syn keyword basicStatement RESTORE restore Restore RESUME resume Resume +syn keyword basicStatement RETURN return Return RMDIR rmdir Rmdir +syn keyword basicStatement RSET rset Rset RUN run Run +syn keyword basicStatement SEEK seek Seek SELECT select Select +syn keyword basicStatement CASE case Case SHARED shared Shared +syn keyword basicStatement SHELL shell Shell SLEEP sleep Sleep +syn keyword basicStatement SOUND sound Sound STATIC static Static +syn keyword basicStatement STOP stop Stop STRIG strig Strig +syn keyword basicStatement SUB sub Sub SWAP swap Swap +syn keyword basicStatement SYSTEM system System TIMER timer Timer +syn keyword basicStatement TROFF troff Troff TRON tron Tron +syn keyword basicStatement TYPE type Type UNLOCK unlock Unlock +syn keyword basicStatement VIEW view View WAIT wait Wait +syn keyword basicStatement WHILE while While WEND wend Wend +syn keyword basicStatement WIDTH width Width WINDOW window Window +syn keyword basicStatement WRITE write Write DATE$ date$ Date$ +syn keyword basicStatement MID$ mid$ Mid$ TIME$ time$ Time$ + +syn keyword basicFunction ABS abs Abs ASC asc Asc +syn keyword basicFunction ATN atn Atn CDBL cdbl Cdbl +syn keyword basicFunction CINT cint Cint CLNG clng Clng +syn keyword basicFunction COS cos Cos CSNG csng Csng +syn keyword basicFunction CSRLIN csrlin Csrlin CVD cvd Cvd +syn keyword basicFunction CVDMBF cvdmbf Cvdmbf CVI cvi Cvi +syn keyword basicFunction CVL cvl Cvl CVS cvs Cvs +syn keyword basicFunction CVSMBF cvsmbf Cvsmbf EOF eof Eof +syn keyword basicFunction ERDEV erdev Erdev ERL erl Erl +syn keyword basicFunction ERR err Err EXP exp Exp +syn keyword basicFunction FILEATTR fileattr Fileattr FIX fix Fix +syn keyword basicFunction FRE fre Fre FREEFILE freefile Freefile +syn keyword basicFunction INP inp Inp INSTR instr Instr +syn keyword basicFunction INT int Int LBOUND lbound Lbound +syn keyword basicFunction LEN len Len LOC loc Loc +syn keyword basicFunction LOF lof Lof LOG log Log +syn keyword basicFunction LPOS lpos Lpos PEEK peek Peek +syn keyword basicFunction PEN pen Pen POINT point Point +syn keyword basicFunction POS pos Pos RND rnd Rnd +syn keyword basicFunction SADD sadd Sadd SCREEN screen Screen +syn keyword basicFunction SEEK seek Seek SETMEM setmem Setmem +syn keyword basicFunction SGN sgn Sgn SIN sin Sin +syn keyword basicFunction SPC spc Spc SQR sqr Sqr +syn keyword basicFunction STICK stick Stick STRIG strig Strig +syn keyword basicFunction TAB tab Tab TAN tan Tan +syn keyword basicFunction UBOUND ubound Ubound VAL val Val +syn keyword basicFunction VALPTR valptr Valptr VALSEG valseg Valseg +syn keyword basicFunction VARPTR varptr Varptr VARSEG varseg Varseg +syn keyword basicFunction CHR$ Chr$ chr$ COMMAND$ command$ Command$ +syn keyword basicFunction DATE$ date$ Date$ ENVIRON$ environ$ Environ$ +syn keyword basicFunction ERDEV$ erdev$ Erdev$ HEX$ hex$ Hex$ +syn keyword basicFunction INKEY$ inkey$ Inkey$ INPUT$ input$ Input$ +syn keyword basicFunction IOCTL$ ioctl$ Ioctl$ LCASES$ lcases$ Lcases$ +syn keyword basicFunction LAFT$ laft$ Laft$ LTRIM$ ltrim$ Ltrim$ +syn keyword basicFunction MID$ mid$ Mid$ MKDMBF$ mkdmbf$ Mkdmbf$ +syn keyword basicFunction MKD$ mkd$ Mkd$ MKI$ mki$ Mki$ +syn keyword basicFunction MKL$ mkl$ Mkl$ MKSMBF$ mksmbf$ Mksmbf$ +syn keyword basicFunction MKS$ mks$ Mks$ OCT$ oct$ Oct$ +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. +syn match basicNumber "\<\d\+\>" +"floating point number, with dot +syn match basicNumber "\<\d\+\.\d*\>" +"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 + +syn region basicComment start="REM" end="$" contains=basicTodo +syn region basicComment start="^[ \t]*'" end="$" contains=basicTodo +syn region basicLineNumber start="^\d" end="\s" +syn match basicTypeSpecifier "[a-zA-Z0-9][\$%&!#]"ms=s+1 +" Used with OPEN statement +syn match basicFilenumber "#\d\+" +"syn sync ccomment basicComment +" syn match basicMathsOperator "[<>+\*^/\\=-]" +syn match basicMathsOperator "-\|=\|[:<>+\*^/\\]\|AND\|OR" + +" Define the default highlighting. +" Only when an item doesn't have highlighting yet + +hi def link basicLabel Label +hi def link basicConditional Conditional +hi def link basicRepeat Repeat +hi def link basicLineNumber Comment +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 basicTodo Todo +hi def link basicFunction Identifier +hi def link basicTypeSpecifier Type +hi def link basicFilenumber basicTypeSpecifier +"hi basicMathsOperator term=bold cterm=bold gui=bold + + +let b:current_syntax = "basic" + +let &cpo = s:cpo_save +unlet s:cpo_save +" vim: ts=8 + +endif diff --git a/syntax/vb.vim b/syntax/vb.vim new file mode 100644 index 000000000..04e171ca2 --- /dev/null +++ b/syntax/vb.vim @@ -0,0 +1,369 @@ +if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'visual-basic') == -1 + +" Vim syntax file +" Language: Visual Basic +" Maintainer: Tim Chase +" Former Maintainer: Robert M. Cortopassi +" (tried multiple times to contact, but email bounced) +" Last Change: +" 2005 May 25 Synched with work by Thomas Barthel +" 2004 May 30 Added a few keywords + +" This was thrown together after seeing numerous requests on the +" VIM and VIM-DEV mailing lists. It is by no means complete. +" Send comments, suggestions and requests to the maintainer. + +" quit when a syntax file was already loaded +if exists("b:current_syntax") + finish +endif + +" VB is case insensitive +syn case ignore + +syn keyword vbConditional If Then ElseIf Else Select Case + +syn keyword vbOperator AddressOf And ByRef ByVal Eqv Imp In +syn keyword vbOperator Is Like Mod Not Or To Xor + +syn match vbOperator "[()+.,\-/*=&]" +syn match vbOperator "[<>]=\=" +syn match vbOperator "<>" +syn match vbOperator "\s\+_$" + +syn keyword vbBoolean True False +syn keyword vbConst Null Nothing + +syn keyword vbRepeat Do For ForEach Loop Next +syn keyword vbRepeat Step To Until Wend While + +syn keyword vbEvents AccessKeyPress Activate ActiveRowChanged +syn keyword vbEvents AfterAddFile AfterChangeFileName AfterCloseFile +syn keyword vbEvents AfterColEdit AfterColUpdate AfterDelete +syn keyword vbEvents AfterInsert AfterLabelEdit AfterRemoveFile +syn keyword vbEvents AfterUpdate AfterWriteFile AmbientChanged +syn keyword vbEvents ApplyChanges Associate AsyncProgress +syn keyword vbEvents AsyncReadComplete AsyncReadProgress AxisActivated +syn keyword vbEvents AxisLabelActivated AxisLabelSelected +syn keyword vbEvents AxisLabelUpdated AxisSelected AxisTitleActivated +syn keyword vbEvents AxisTitleSelected AxisTitleUpdated AxisUpdated +syn keyword vbEvents BeforeClick BeforeColEdit BeforeColUpdate +syn keyword vbEvents BeforeConnect BeforeDelete BeforeInsert +syn keyword vbEvents BeforeLabelEdit BeforeLoadFile BeforeUpdate +syn keyword vbEvents BeginRequest BeginTrans ButtonClick +syn keyword vbEvents ButtonCompleted ButtonDropDown ButtonGotFocus +syn keyword vbEvents ButtonLostFocus CallbackKeyDown Change Changed +syn keyword vbEvents ChartActivated ChartSelected ChartUpdated Click +syn keyword vbEvents Close CloseQuery CloseUp ColEdit ColResize +syn keyword vbEvents Collapse ColumnClick CommitTrans Compare +syn keyword vbEvents ConfigChageCancelled ConfigChanged +syn keyword vbEvents ConfigChangedCancelled Connect ConnectionRequest +syn keyword vbEvents CurrentRecordChanged DECommandAdded +syn keyword vbEvents DECommandPropertyChanged DECommandRemoved +syn keyword vbEvents DEConnectionAdded DEConnectionPropertyChanged +syn keyword vbEvents DEConnectionRemoved DataArrival DataChanged +syn keyword vbEvents DataUpdated DateClicked DblClick Deactivate +syn keyword vbEvents DevModeChange DeviceArrival DeviceOtherEvent +syn keyword vbEvents DeviceQueryRemove DeviceQueryRemoveFailed +syn keyword vbEvents DeviceRemoveComplete DeviceRemovePending +syn keyword vbEvents Disconnect DisplayChanged Dissociate +syn keyword vbEvents DoGetNewFileName Done DonePainting DownClick +syn keyword vbEvents DragDrop DragOver DropDown EditProperty EditQuery +syn keyword vbEvents EndRequest EnterCell EnterFocus ExitFocus Expand +syn keyword vbEvents FontChanged FootnoteActivated FootnoteSelected +syn keyword vbEvents FootnoteUpdated Format FormatSize GotFocus +syn keyword vbEvents HeadClick HeightChanged Hide InfoMessage +syn keyword vbEvents IniProperties InitProperties Initialize +syn keyword vbEvents ItemActivated ItemAdded ItemCheck ItemClick +syn keyword vbEvents ItemReloaded ItemRemoved ItemRenamed +syn keyword vbEvents ItemSeletected KeyDown KeyPress KeyUp LeaveCell +syn keyword vbEvents LegendActivated LegendSelected LegendUpdated +syn keyword vbEvents LinkClose LinkError LinkExecute LinkNotify +syn keyword vbEvents LinkOpen Load LostFocus MouseDown MouseMove +syn keyword vbEvents MouseUp NodeCheck NodeClick OLECompleteDrag +syn keyword vbEvents OLEDragDrop OLEDragOver OLEGiveFeedback OLESetData +syn keyword vbEvents OLEStartDrag ObjectEvent ObjectMove OnAddNew +syn keyword vbEvents OnComm Paint PanelClick PanelDblClick PathChange +syn keyword vbEvents PatternChange PlotActivated PlotSelected +syn keyword vbEvents PlotUpdated PointActivated PointLabelActivated +syn keyword vbEvents PointLabelSelected PointLabelUpdated PointSelected +syn keyword vbEvents PointUpdated PowerQuerySuspend PowerResume +syn keyword vbEvents PowerStatusChanged PowerSuspend ProcessTag +syn keyword vbEvents ProcessingTimeout QueryChangeConfig QueryClose +syn keyword vbEvents QueryComplete QueryCompleted QueryTimeout +syn keyword vbEvents QueryUnload ReadProperties RepeatedControlLoaded +syn keyword vbEvents RepeatedControlUnloaded Reposition +syn keyword vbEvents RequestChangeFileName RequestWriteFile Resize +syn keyword vbEvents ResultsChanged RetainedProject RollbackTrans +syn keyword vbEvents RowColChange RowCurrencyChange RowResize +syn keyword vbEvents RowStatusChanged Scroll SelChange SelectionChanged +syn keyword vbEvents SendComplete SendProgress SeriesActivated +syn keyword vbEvents SeriesSelected SeriesUpdated SettingChanged Show +syn keyword vbEvents SplitChange Start StateChanged StatusUpdate +syn keyword vbEvents SysColorsChanged Terminate TimeChanged Timer +syn keyword vbEvents TitleActivated TitleSelected TitleUpdated +syn keyword vbEvents UnboundAddData UnboundDeleteRow +syn keyword vbEvents UnboundGetRelativeBookmark UnboundReadData +syn keyword vbEvents UnboundWriteData Unformat Unload UpClick Updated +syn keyword vbEvents UserEvent Validate ValidationError +syn keyword vbEvents VisibleRecordChanged WillAssociate WillChangeData +syn keyword vbEvents WillDissociate WillExecute WillUpdateRows +syn keyword vbEvents WriteProperties + + +syn keyword vbFunction Abs Array Asc AscB AscW Atn Avg BOF CBool CByte +syn keyword vbFunction CCur CDate CDbl CInt CLng CSng CStr CVDate CVErr +syn keyword vbFunction CVar CallByName Cdec Choose Chr ChrB ChrW Command +syn keyword vbFunction Cos Count CreateObject CurDir DDB Date DateAdd +syn keyword vbFunction DateDiff DatePart DateSerial DateValue Day Dir +syn keyword vbFunction DoEvents EOF Environ Error Exp FV FileAttr +syn keyword vbFunction FileDateTime FileLen FilterFix Fix Format +syn keyword vbFunction FormatCurrency FormatDateTime FormatNumber +syn keyword vbFunction FormatPercent FreeFile GetAllStrings GetAttr +syn keyword vbFunction GetAutoServerSettings GetObject GetSetting Hex +syn keyword vbFunction Hour IIf IMEStatus IPmt InStr Input InputB +syn keyword vbFunction InputBox InstrB Int IsArray IsDate IsEmpty IsError +syn keyword vbFunction IsMissing IsNull IsNumeric IsObject Join LBound +syn keyword vbFunction LCase LOF LTrim Left LeftB Len LenB LoadPicture +syn keyword vbFunction LoadResData LoadResPicture LoadResString Loc Log +syn keyword vbFunction MIRR Max Mid MidB Min Minute Month MonthName +syn keyword vbFunction MsgBox NPV NPer Now Oct PPmt PV Partition Pmt +syn keyword vbFunction QBColor RGB RTrim Rate Replace Right RightB Rnd +syn keyword vbFunction Round SLN SYD Second Seek Sgn Shell Sin Space Spc +syn keyword vbFunction Split Sqr StDev StDevP Str StrComp StrConv +syn keyword vbFunction StrReverse String Sum Switch Tab Tan Time +syn keyword vbFunction TimeSerial TimeValue Timer Trim TypeName UBound +syn keyword vbFunction UCase Val Var VarP VarType Weekday WeekdayName +syn keyword vbFunction Year + +syn keyword vbMethods AboutBox Accept Activate Add AddCustom AddFile +syn keyword vbMethods AddFromFile AddFromGuid AddFromString +syn keyword vbMethods AddFromTemplate AddItem AddNew AddToAddInToolbar +syn keyword vbMethods AddToolboxProgID Append AppendAppendChunk +syn keyword vbMethods AppendChunk Arrange Assert AsyncRead BatchUpdate +syn keyword vbMethods BeginQueryEdit BeginTrans Bind BuildPath +syn keyword vbMethods CanPropertyChange Cancel CancelAsyncRead +syn keyword vbMethods CancelBatch CancelUpdate CaptureImage CellText +syn keyword vbMethods CellValue Circle Clear ClearFields ClearSel +syn keyword vbMethods ClearSelCols ClearStructure Clone Close Cls +syn keyword vbMethods ColContaining CollapseAll ColumnSize CommitTrans +syn keyword vbMethods CompactDatabase Compose Connect Copy CopyFile +syn keyword vbMethods CopyFolder CopyQueryDef Count CreateDatabase +syn keyword vbMethods CreateDragImage CreateEmbed CreateField +syn keyword vbMethods CreateFolder CreateGroup CreateIndex CreateLink +syn keyword vbMethods CreatePreparedStatement CreatePropery CreateQuery +syn keyword vbMethods CreateQueryDef CreateRelation CreateTableDef +syn keyword vbMethods CreateTextFile CreateToolWindow CreateUser +syn keyword vbMethods CreateWorkspace Customize Cut Delete +syn keyword vbMethods DeleteColumnLabels DeleteColumns DeleteFile +syn keyword vbMethods DeleteFolder DeleteLines DeleteRowLabels +syn keyword vbMethods DeleteRows DeselectAll DesignerWindow DoVerb Drag +syn keyword vbMethods Draw DriveExists Edit EditCopy EditPaste EndDoc +syn keyword vbMethods EnsureVisible EstablishConnection Execute Exists +syn keyword vbMethods Expand Export ExportReport ExtractIcon Fetch +syn keyword vbMethods FetchVerbs FileExists Files FillCache Find +syn keyword vbMethods FindFirst FindItem FindLast FindNext FindPrevious +syn keyword vbMethods FolderExists Forward GetAbsolutePathName +syn keyword vbMethods GetBaseName GetBookmark GetChunk GetClipString +syn keyword vbMethods GetData GetDrive GetDriveName GetFile GetFileName +syn keyword vbMethods GetFirstVisible GetFolder GetFormat GetHeader +syn keyword vbMethods GetLineFromChar GetNumTicks GetParentFolderName +syn keyword vbMethods GetRows GetSelectedPart GetSelection +syn keyword vbMethods GetSpecialFolder GetTempName GetText +syn keyword vbMethods GetVisibleCount GoBack GoForward Hide HitTest +syn keyword vbMethods HoldFields Idle Import InitializeLabels Insert +syn keyword vbMethods InsertColumnLabels InsertColumns InsertFile +syn keyword vbMethods InsertLines InsertObjDlg InsertRowLabels +syn keyword vbMethods InsertRows Item Keys KillDoc Layout Line Lines +syn keyword vbMethods LinkExecute LinkPoke LinkRequest LinkSend Listen +syn keyword vbMethods LoadFile LoadResData LoadResPicture LoadResString +syn keyword vbMethods LogEvent MakeCompileFile MakeCompiledFile +syn keyword vbMethods MakeReplica MoreResults Move MoveData MoveFile +syn keyword vbMethods MoveFirst MoveFolder MoveLast MoveNext +syn keyword vbMethods MovePrevious NavigateTo NewPage NewPassword +syn keyword vbMethods NextRecordset OLEDrag OnAddinsUpdate OnConnection +syn keyword vbMethods OnDisconnection OnStartupComplete Open +syn keyword vbMethods OpenAsTextStream OpenConnection OpenDatabase +syn keyword vbMethods OpenQueryDef OpenRecordset OpenResultset OpenURL +syn keyword vbMethods Overlay PSet PaintPicture PastSpecialDlg Paste +syn keyword vbMethods PeekData Play Point PopulatePartial PopupMenu +syn keyword vbMethods Print PrintForm PrintReport PropertyChanged Quit +syn keyword vbMethods Raise RandomDataFill RandomFillColumns +syn keyword vbMethods RandomFillRows ReFill Read ReadAll ReadFromFile +syn keyword vbMethods ReadLine ReadProperty Rebind Refresh RefreshLink +syn keyword vbMethods RegisterDatabase ReleaseInstance Reload Remove +syn keyword vbMethods RemoveAddInFromToolbar RemoveAll RemoveItem Render +syn keyword vbMethods RepairDatabase ReplaceLine Reply ReplyAll Requery +syn keyword vbMethods ResetCustom ResetCustomLabel ResolveName +syn keyword vbMethods RestoreToolbar Resync Rollback RollbackTrans +syn keyword vbMethods RowBookmark RowContaining RowTop Save SaveAs +syn keyword vbMethods SaveFile SaveToFile SaveToOle1File SaveToolbar +syn keyword vbMethods Scale ScaleX ScaleY Scroll SelPrint SelectAll +syn keyword vbMethods SelectPart Send SendData Set SetAutoServerSettings +syn keyword vbMethods SetData SetFocus SetOption SetSelection SetSize +syn keyword vbMethods SetText SetViewport Show ShowColor ShowFont +syn keyword vbMethods ShowHelp ShowOpen ShowPrinter ShowSave +syn keyword vbMethods ShowWhatsThis SignOff SignOn Size Skip SkipLine +syn keyword vbMethods Span Split SplitContaining StartLabelEdit +syn keyword vbMethods StartLogging Stop Synchronize Tag TextHeight +syn keyword vbMethods TextWidth ToDefaults Trace TwipsToChartPart +syn keyword vbMethods TypeByChartType URLFor Update UpdateControls +syn keyword vbMethods UpdateRecord UpdateRow Upto ValidateControls Value +syn keyword vbMethods WhatsThisMode Write WriteBlankLines WriteLine +syn keyword vbMethods WriteProperty WriteTemplate ZOrder +syn keyword vbMethods rdoCreateEnvironment rdoRegisterDataSource + +syn keyword vbStatement Alias AppActivate As Base Beep Begin Call ChDir +syn keyword vbStatement ChDrive Close Const Date Declare DefBool DefByte +syn keyword vbStatement DefCur DefDate DefDbl DefDec DefInt DefLng DefObj +syn keyword vbStatement DefSng DefStr DefVar Deftype DeleteSetting Dim Do +syn keyword vbStatement Each ElseIf End Enum Erase Error Event Exit +syn keyword vbStatement Explicit FileCopy For ForEach Function Get GoSub +syn keyword vbStatement GoTo Gosub Implements Kill LSet Let Lib LineInput +syn keyword vbStatement Load Lock Loop Mid MkDir Name Next On OnError Open +syn keyword vbStatement Option Preserve Private Property Public Put RSet +syn keyword vbStatement RaiseEvent Randomize ReDim Redim Reset Resume +syn keyword vbStatement Return RmDir SavePicture SaveSetting Seek SendKeys +syn keyword vbStatement Sendkeys Set SetAttr Static Step Stop Sub Time +syn keyword vbStatement Type Unload Unlock Until Wend While Width With +syn keyword vbStatement Write + +syn keyword vbKeyword As Binary ByRef ByVal Date Empty Error Friend Get +syn keyword vbKeyword Input Is Len Lock Me Mid New Nothing Null On +syn keyword vbKeyword Option Optional ParamArray Print Private Property +syn keyword vbKeyword Public PublicNotCreateable OnNewProcessSingleUse +syn keyword vbKeyword InSameProcessMultiUse GlobalMultiUse Resume Seek +syn keyword vbKeyword Set Static Step String Time WithEvents + +syn keyword vbTodo contained TODO + +"Datatypes +syn keyword vbTypes Boolean Byte Currency Date Decimal Double Empty +syn keyword vbTypes Integer Long Object Single String Variant + +"VB defined values +syn keyword vbDefine dbBigInt dbBinary dbBoolean dbByte dbChar +syn keyword vbDefine dbCurrency dbDate dbDecimal dbDouble dbFloat +syn keyword vbDefine dbGUID dbInteger dbLong dbLongBinary dbMemo +syn keyword vbDefine dbNumeric dbSingle dbText dbTime dbTimeStamp +syn keyword vbDefine dbVarBinary + +"VB defined values +syn keyword vbDefine vb3DDKShadow vb3DFace vb3DHighlight vb3DLight +syn keyword vbDefine vb3DShadow vbAbort vbAbortRetryIgnore +syn keyword vbDefine vbActiveBorder vbActiveTitleBar vbAlias +syn keyword vbDefine vbApplicationModal vbApplicationWorkspace +syn keyword vbDefine vbAppTaskManager vbAppWindows vbArchive vbArray +syn keyword vbDefine vbBack vbBinaryCompare vbBlack vbBlue vbBoolean +syn keyword vbDefine vbButtonFace vbButtonShadow vbButtonText vbByte +syn keyword vbDefine vbCalGreg vbCalHijri vbCancel vbCr vbCritical +syn keyword vbDefine vbCrLf vbCurrency vbCyan vbDatabaseCompare +syn keyword vbDefine vbDataObject vbDate vbDecimal vbDefaultButton1 +syn keyword vbDefine vbDefaultButton2 vbDefaultButton3 vbDefaultButton4 +syn keyword vbDefine vbDesktop vbDirectory vbDouble vbEmpty vbError +syn keyword vbDefine vbExclamation vbFirstFourDays vbFirstFullWeek +syn keyword vbDefine vbFirstJan1 vbFormCode vbFormControlMenu +syn keyword vbDefine vbFormFeed vbFormMDIForm vbFriday vbFromUnicode +syn keyword vbDefine vbGrayText vbGreen vbHidden vbHide vbHighlight +syn keyword vbDefine vbHighlightText vbHiragana vbIgnore vbIMEAlphaDbl +syn keyword vbDefine vbIMEAlphaSng vbIMEDisable vbIMEHiragana +syn keyword vbDefine vbIMEKatakanaDbl vbIMEKatakanaSng vbIMEModeAlpha +syn keyword vbDefine vbIMEModeAlphaFull vbIMEModeDisable +syn keyword vbDefine vbIMEModeHangul vbIMEModeHangulFull +syn keyword vbDefine vbIMEModeHiragana vbIMEModeKatakana +syn keyword vbDefine vbIMEModeKatakanaHalf vbIMEModeNoControl +syn keyword vbDefine vbIMEModeOff vbIMEModeOn vbIMENoOp vbIMEOff +syn keyword vbDefine vbIMEOn vbInactiveBorder vbInactiveCaptionText +syn keyword vbDefine vbInactiveTitleBar vbInfoBackground vbInformation +syn keyword vbDefine vbInfoText vbInteger vbKatakana vbKey0 vbKey1 +syn keyword vbDefine vbKey2 vbKey3 vbKey4 vbKey5 vbKey6 vbKey7 vbKey8 +syn keyword vbDefine vbKey9 vbKeyA vbKeyAdd vbKeyB vbKeyBack vbKeyC +syn keyword vbDefine vbKeyCancel vbKeyCapital vbKeyClear vbKeyControl +syn keyword vbDefine vbKeyD vbKeyDecimal vbKeyDelete vbKeyDivide +syn keyword vbDefine vbKeyDown vbKeyE vbKeyEnd vbKeyEscape vbKeyExecute +syn keyword vbDefine vbKeyF vbKeyF1 vbKeyF10 vbKeyF11 vbKeyF12 vbKeyF13 +syn keyword vbDefine vbKeyF14 vbKeyF15 vbKeyF16 vbKeyF2 vbKeyF3 vbKeyF4 +syn keyword vbDefine vbKeyF5 vbKeyF6 vbKeyF7 vbKeyF8 vbKeyF9 vbKeyG +syn keyword vbDefine vbKeyH vbKeyHelp vbKeyHome vbKeyI vbKeyInsert +syn keyword vbDefine vbKeyJ vbKeyK vbKeyL vbKeyLButton vbKeyLeft vbKeyM +syn keyword vbDefine vbKeyMButton vbKeyMenu vbKeyMultiply vbKeyN +syn keyword vbDefine vbKeyNumlock vbKeyNumpad0 vbKeyNumpad1 +syn keyword vbDefine vbKeyNumpad2 vbKeyNumpad3 vbKeyNumpad4 +syn keyword vbDefine vbKeyNumpad5 vbKeyNumpad6 vbKeyNumpad7 +syn keyword vbDefine vbKeyNumpad8 vbKeyNumpad9 vbKeyO vbKeyP +syn keyword vbDefine vbKeyPageDown vbKeyPageUp vbKeyPause vbKeyPrint +syn keyword vbDefine vbKeyQ vbKeyR vbKeyRButton vbKeyReturn vbKeyRight +syn keyword vbDefine vbKeyS vbKeySelect vbKeySeparator vbKeyShift +syn keyword vbDefine vbKeySnapshot vbKeySpace vbKeySubtract vbKeyT +syn keyword vbDefine vbKeyTab vbKeyU vbKeyUp vbKeyV vbKeyW vbKeyX +syn keyword vbDefine vbKeyY vbKeyZ vbLf vbLong vbLowerCase vbMagenta +syn keyword vbDefine vbMaximizedFocus vbMenuBar vbMenuText +syn keyword vbDefine vbMinimizedFocus vbMinimizedNoFocus vbMonday +syn keyword vbDefine vbMsgBox vbMsgBoxHelpButton vbMsgBoxRight +syn keyword vbDefine vbMsgBoxRtlReading vbMsgBoxSetForeground +syn keyword vbDefine vbMsgBoxText vbNarrow vbNewLine vbNo vbNormal +syn keyword vbDefine vbNormalFocus vbNormalNoFocus vbNull vbNullChar +syn keyword vbDefine vbNullString vbObject vbObjectError vbOK +syn keyword vbDefine vbOKCancel vbOKOnly vbProperCase vbQuestion +syn keyword vbDefine vbReadOnly vbRed vbRetry vbRetryCancel vbSaturday +syn keyword vbDefine vbScrollBars vbSingle vbString vbSunday vbSystem +syn keyword vbDefine vbSystemModal vbTab vbTextCompare vbThursday +syn keyword vbDefine vbTitleBarText vbTuesday vbUnicode vbUpperCase +syn keyword vbDefine vbUseSystem vbUseSystemDayOfWeek vbVariant +syn keyword vbDefine vbVerticalTab vbVolume vbWednesday vbWhite vbWide +syn keyword vbDefine vbWindowBackground vbWindowFrame vbWindowText +syn keyword vbDefine vbYellow vbYes vbYesNo vbYesNoCancel + +"Numbers +"integer number, or floating point number without a dot. +syn match vbNumber "\<\d\+\>" +"floating point number, with dot +syn match vbNumber "\<\d\+\.\d*\>" +"floating point number, starting with a dot +syn match vbNumber "\.\d\+\>" +"syn match vbNumber "{[[:xdigit:]-]\+}\|&[hH][[:xdigit:]]\+&" +"syn match vbNumber ":[[:xdigit:]]\+" +"syn match vbNumber "[-+]\=\<\d\+\>" +syn match vbFloat "[-+]\=\<\d\+[eE][\-+]\=\d\+" +syn match vbFloat "[-+]\=\<\d\+\.\d*\([eE][\-+]\=\d\+\)\=" +syn match vbFloat "[-+]\=\<\.\d\+\([eE][\-+]\=\d\+\)\=" + +" String and Character contstants +syn region vbString start=+"+ end=+"\|$+ +syn region vbComment start="\(^\|\s\)REM\s" end="$" contains=vbTodo +syn region vbComment start="\(^\|\s\)\'" end="$" contains=vbTodo +syn match vbLineNumber "^\d\+\(\s\|$\)" +syn match vbTypeSpecifier "[a-zA-Z0-9][\$%&!#]"ms=s+1 +syn match vbTypeSpecifier "#[a-zA-Z0-9]"me=e-1 + +" Define the default highlighting. +" Only when an item doesn't have highlighting yet + +hi def link vbBoolean Boolean +hi def link vbLineNumber Comment +hi def link vbComment Comment +hi def link vbConditional Conditional +hi def link vbConst Constant +hi def link vbDefine Constant +hi def link vbError Error +hi def link vbFunction Identifier +hi def link vbIdentifier Identifier +hi def link vbNumber Number +hi def link vbFloat Float +hi def link vbMethods PreProc +hi def link vbOperator Operator +hi def link vbRepeat Repeat +hi def link vbString String +hi def link vbStatement Statement +hi def link vbKeyword Statement +hi def link vbEvents Special +hi def link vbTodo Todo +hi def link vbTypes Type +hi def link vbTypeSpecifier Type + + +let b:current_syntax = "vb" + +" vim: ts=8 + +endif From 48254ec7adc9cbbc2ff15c606faf062d23d7f200 Mon Sep 17 00:00:00 2001 From: Adam Stankiewicz Date: Sun, 6 Sep 2020 21:07:04 +0200 Subject: [PATCH 022/299] Add more apache filetypes --- autoload/sleuth.vim | 2 +- ftdetect/polyglot.vim | 41 +++++++++++++++++++++++++++++++---------- packages.yaml | 14 ++++++++++++-- scripts/build | 6 +++++- 4 files changed, 49 insertions(+), 14 deletions(-) diff --git a/autoload/sleuth.vim b/autoload/sleuth.vim index 18344723b..0460a46e9 100644 --- a/autoload/sleuth.vim +++ b/autoload/sleuth.vim @@ -17,7 +17,7 @@ let s:globs = { \ 'aml': '*.aml', \ 'ampl': '*.run', \ 'ant': 'build.xml', - \ 'apache': '', + \ 'apache': 'access.conf*,apache.conf*,apache2.conf*,httpd.conf*,srm.conf*', \ 'apiblueprint': '*.apib', \ 'applescript': '*.applescript,*.scpt', \ 'aptconf': 'apt.conf', diff --git a/ftdetect/polyglot.vim b/ftdetect/polyglot.vim index a37b76af8..6d080cf3f 100644 --- a/ftdetect/polyglot.vim +++ b/ftdetect/polyglot.vim @@ -60,6 +60,17 @@ if !exists('g:python_highlight_all') call s:SetDefault('g:python_slow_sync', 1) endif + +" Function used for patterns that end in a star: don't set the filetype if the +" file name matches ft_ignore_pat. +" When using this, the entry should probably be further down below with the +" other StarSetf() calls. +func! s:StarSetf(ft) + if expand("") !~ g:ft_ignore_pat + exe 'setf ' . a:ft + endif +endfunc + " filetypes if !has_key(s:disabled_packages, '8th') @@ -364,9 +375,19 @@ if !has_key(s:disabled_packages, 'ant') endif if !has_key(s:disabled_packages, 'apache') + au BufNewFile,BufRead */etc/apache2/*.conf* call s:StarSetf('apache') + au BufNewFile,BufRead */etc/apache2/conf.*/* call s:StarSetf('apache') + au BufNewFile,BufRead */etc/apache2/mods-*/* call s:StarSetf('apache') + au BufNewFile,BufRead */etc/apache2/sites-*/* call s:StarSetf('apache') au BufNewFile,BufRead */etc/apache2/sites-*/*.com setf apache au BufNewFile,BufRead */etc/httpd/*.conf setf apache + au BufNewFile,BufRead */etc/httpd/conf.d/*.conf* call s:StarSetf('apache') au BufNewFile,BufRead {.,}htaccess setf apache + au BufNewFile,BufRead access.conf* call s:StarSetf('apache') + au BufNewFile,BufRead apache.conf* call s:StarSetf('apache') + au BufNewFile,BufRead apache2.conf* call s:StarSetf('apache') + au BufNewFile,BufRead httpd.conf* call s:StarSetf('apache') + au BufNewFile,BufRead srm.conf* call s:StarSetf('apache') endif if !has_key(s:disabled_packages, 'apiblueprint') @@ -381,7 +402,7 @@ endif if !has_key(s:disabled_packages, 'aptconf') au BufNewFile,BufRead */.aptitude/config setf aptconf au BufNewFile,BufRead */etc/apt/apt.conf.d/*.conf setf aptconf - au BufNewFile,BufRead */etc/apt/apt.conf.d/[^.]* setf aptconf + au BufNewFile,BufRead */etc/apt/apt.conf.d/[^.]* call s:StarSetf('aptconf') au BufNewFile,BufRead apt.conf setf aptconf endif @@ -571,7 +592,7 @@ if !has_key(s:disabled_packages, 'dockerfile') au BufNewFile,BufRead *.dock setf Dockerfile au BufNewFile,BufRead *.dockerfile setf Dockerfile au BufNewFile,BufRead Dockerfile setf Dockerfile - au BufNewFile,BufRead Dockerfile* setf Dockerfile + au BufNewFile,BufRead Dockerfile* call s:StarSetf('Dockerfile') au BufNewFile,BufRead dockerfile setf Dockerfile au BufNewFile,BufRead docker-compose*.yaml setf yaml.docker-compose au BufNewFile,BufRead docker-compose*.yml setf yaml.docker-compose @@ -660,7 +681,7 @@ if !has_key(s:disabled_packages, 'git') au BufNewFile,BufRead {.,}gitconfig setf gitconfig au BufNewFile,BufRead {.,}gitmodules setf gitconfig au BufNewFile,BufRead git-rebase-todo setf gitrebase - au BufNewFile,BufRead {.,}gitsendemail.* setf gitsendemail + au BufNewFile,BufRead {.,}gitsendemail.* call s:StarSetf('gitsendemail') au BufNewFile,BufRead *.git/{,modules/**/,worktrees/*/}{COMMIT_EDIT,TAG_EDIT,MERGE_,}MSG setf gitcommit endif @@ -738,7 +759,7 @@ endif if !has_key(s:disabled_packages, 'haproxy') au BufNewFile,BufRead *.cfg setf haproxy - au BufNewFile,BufRead haproxy*.c* setf haproxy + au BufNewFile,BufRead haproxy*.c* call s:StarSetf('haproxy') au BufNewFile,BufRead haproxy.cfg setf haproxy endif @@ -839,7 +860,7 @@ if !has_key(s:disabled_packages, 'jenkins') au BufNewFile,BufRead *.Jenkinsfile setf Jenkinsfile au BufNewFile,BufRead *.jenkinsfile setf Jenkinsfile au BufNewFile,BufRead Jenkinsfile setf Jenkinsfile - au BufNewFile,BufRead Jenkinsfile* setf Jenkinsfile + au BufNewFile,BufRead Jenkinsfile* call s:StarSetf('Jenkinsfile') endif if !has_key(s:disabled_packages, 'jinja') @@ -1022,9 +1043,9 @@ if !has_key(s:disabled_packages, 'nginx') au BufNewFile,BufRead *.nginx setf nginx au BufNewFile,BufRead *.nginxconf setf nginx au BufNewFile,BufRead *.vhost setf nginx - au BufNewFile,BufRead */etc/nginx/* setf nginx + au BufNewFile,BufRead */etc/nginx/* call s:StarSetf('nginx') au BufNewFile,BufRead */nginx/*.conf setf nginx - au BufNewFile,BufRead */usr/local/nginx/conf/* setf nginx + au BufNewFile,BufRead */usr/local/nginx/conf/* call s:StarSetf('nginx') au BufNewFile,BufRead *nginx.conf setf nginx au BufNewFile,BufRead nginx*.conf setf nginx au BufNewFile,BufRead nginx.conf setf nginx @@ -1328,7 +1349,7 @@ if !has_key(s:disabled_packages, 'ruby') au BufNewFile,BufRead Snapfile setf ruby au BufNewFile,BufRead Thorfile setf ruby au BufNewFile,BufRead Vagrantfile setf ruby - au BufNewFile,BufRead [Rr]akefile* setf ruby + au BufNewFile,BufRead [Rr]akefile* call s:StarSetf('ruby') au BufNewFile,BufRead buildfile setf ruby au BufNewFile,BufRead vagrantfile setf ruby au BufNewFile,BufRead *.erb setf eruby @@ -1657,9 +1678,9 @@ if !has_key(s:disabled_packages, 'xsl') endif if !has_key(s:disabled_packages, 'ansible') - au BufNewFile,BufRead group_vars/* setf yaml.ansible + au BufNewFile,BufRead group_vars/* call s:StarSetf('yaml.ansible') au BufNewFile,BufRead handlers.*.y{a,}ml setf yaml.ansible - au BufNewFile,BufRead host_vars/* setf yaml.ansible + au BufNewFile,BufRead host_vars/* call s:StarSetf('yaml.ansible') au BufNewFile,BufRead local.y{a,}ml setf yaml.ansible au BufNewFile,BufRead main.y{a,}ml setf yaml.ansible au BufNewFile,BufRead playbook.y{a,}ml setf yaml.ansible diff --git a/packages.yaml b/packages.yaml index e167e0f10..fb67e6762 100644 --- a/packages.yaml +++ b/packages.yaml @@ -155,6 +155,16 @@ filetypes: - .htaccess - '*/etc/httpd/*.conf' - '*/etc/apache2/sites-*/*.com' + - 'access.conf*' + - 'apache.conf*' + - 'apache2.conf*' + - 'httpd.conf*' + - 'srm.conf*' + - '*/etc/apache2/*.conf*' + - '*/etc/apache2/conf.*/*' + - '*/etc/apache2/mods-*/*' + - '*/etc/apache2/sites-*/*' + - '*/etc/httpd/conf.d/*.conf*' --- name: apiblueprint remote: sheerun/apiblueprint.vim @@ -1662,7 +1672,7 @@ filetypes: extra_filenames: - fish_history - fish_read_history - ignored_filenames: + ignored_warnings: - '~/.config/fish/fish_{read_,}history' # Ansible needs to be after YAML --- @@ -1745,5 +1755,5 @@ filetypes: - ctl # SaxBasic is close to Visual Basic - sba - ignore_warnings: + ignored_warnings: - vb diff --git a/scripts/build b/scripts/build index 197b4ea3a..f688c28f7 100755 --- a/scripts/build +++ b/scripts/build @@ -492,7 +492,11 @@ def generate_ftdetect(packages, heuristics) if filename[0] == "." filename = "{.,}" + filename[1..] end - autocommands << " au BufNewFile,BufRead #{filename} #{set_command}\n" + if filename[-1] == "*" + autocommands << " au BufNewFile,BufRead #{filename} call s:StarSetf('#{name}')\n" + else + autocommands << " au BufNewFile,BufRead #{filename} #{set_command}\n" + end end end From 46040f3ffd35c4a981ca1f3713934f55b58bb525 Mon Sep 17 00:00:00 2001 From: Adam Stankiewicz Date: Sun, 6 Sep 2020 23:37:24 +0200 Subject: [PATCH 023/299] Add heuristics for .h extension --- autoload/polyglot.vim | 19 +++++++++++++++++++ autoload/sleuth.vim | 10 +++++----- ftdetect/polyglot.vim | 19 ++++++++++++------- heuristics.yaml | 14 ++++++++++++++ packages.yaml | 24 +++++++++++++++++++----- scripts/build | 18 +++++++++++++----- scripts/test_extensions.vim | 26 ++++++++++++++++++++++++-- scripts/test_filetypes.vim | 2 +- 8 files changed, 107 insertions(+), 25 deletions(-) diff --git a/autoload/polyglot.vim b/autoload/polyglot.vim index ffb3c43fb..1ed718269 100644 --- a/autoload/polyglot.vim +++ b/autoload/polyglot.vim @@ -154,6 +154,25 @@ func! polyglot#DetectAspFiletype() setf aspvbs | return endfunc +func! polyglot#DetectHFiletype() + for lnum in range(1, min([line("$"), 200])) + let line = getline(lnum) + if line =~# '^\s*\(@\(interface\|class\|protocol\|property\|end\|synchronised\|selector\|implementation\)\(\<\|\>\)\|#import\s\+.\+\.h[">]\)' + if exists("g:c_syntax_for_h") + setf objc | return + endif + setf objcpp | return + endif + endfor + if exists("g:c_syntax_for_h") + setf c | return + endif + if exists("g:ch_syntax_for_h") + setf ch | return + endif + setf cpp | return +endfunc + func! polyglot#DetectMFiletype() let saw_comment = 0 for lnum in range(1, min([line("$"), 100])) diff --git a/autoload/sleuth.vim b/autoload/sleuth.vim index 0460a46e9..2eb95a634 100644 --- a/autoload/sleuth.vim +++ b/autoload/sleuth.vim @@ -10,7 +10,7 @@ let s:globs = { \ 'abc': '*.abc', \ 'abel': '*.abl', \ 'acedb': '*.wrm', - \ 'ada': '*.adb,*.ads,*.ada,*.gpr', + \ 'ada': '*.adb,*.ads,*.ada,*.adc,*.gpr,*.ada_m', \ 'ahdl': '*.tdf', \ 'aidl': '*.aidl', \ 'alsaconf': '', @@ -34,17 +34,17 @@ let s:globs = { \ 'autoit': '*.au3', \ 'automake': '[Mm]akefile.am,GNUmakefile.am', \ 'ave': '*.ave', - \ 'awk': '*.awk', + \ 'awk': '*.awk,*.gawk', \ 'basic': '*.basic', \ 'blade': '*.blade,*.blade.php', \ 'brewfile': 'Brewfile', - \ 'c': '*.c,*.cats,*.h,*.idc', + \ 'c': '*.c,*.cats,*.h,*.idc,*.qc', \ 'caddyfile': 'Caddyfile', \ 'carp': '*.carp', \ 'clojure': '*.clj,*.boot,*.cl2,*.cljc,*.cljs,*.cljs.hl,*.cljscm,*.cljx,*.hic,*.edn,riemann.config,build.boot,profile.boot', \ 'cmake': '*.cmake,*.cmake.in,CMakeLists.txt', \ 'coffee': '*.coffee,*._coffee,*.cake,*.cjsx,*.iced,*.coffeekup,Cakefile', - \ 'cpp': '*.cpp,*.c++,*.cc,*.cp,*.cxx,*.h,*.h++,*.hh,*.hpp,*.hxx,*.inc,*.inl,*.ipp,*.tcc,*.tpp', + \ 'cpp': '*.cpp,*.c++,*.cc,*.cp,*.cxx,*.h,*.h++,*.hh,*.hpp,*.hxx,*.inc,*.inl,*.ipp,*.tcc,*.tpp,*.moc', \ 'cql': '*.cql', \ 'cryptol': '*.cry,*.cyl,*.lcry,*.lcyl', \ 'crystal': '*.cr,Projectfile', @@ -52,7 +52,7 @@ let s:globs = { \ 'cucumber': '*.feature,*.story', \ 'cuesheet': '*.cue', \ 'd': '*.d,*.di', - \ 'dart': '*.dart', + \ 'dart': '*.dart,*.drt', \ 'dcov': '*.lst', \ 'dd': '*.dd', \ 'ddoc': '*.ddoc', diff --git a/ftdetect/polyglot.vim b/ftdetect/polyglot.vim index 6d080cf3f..19d164c5c 100644 --- a/ftdetect/polyglot.vim +++ b/ftdetect/polyglot.vim @@ -134,7 +134,7 @@ if !has_key(s:disabled_packages, 'awk') endif if !has_key(s:disabled_packages, 'c/c++') - au! BufRead,BufNewFile *.c,*.cpp,*.tpp + au! BufRead,BufNewFile *.cpp,*.tpp,*.c endif if !has_key(s:disabled_packages, 'cmake') @@ -343,7 +343,9 @@ endif if !has_key(s:disabled_packages, 'ada') au BufNewFile,BufRead *.ada setf ada + au BufNewFile,BufRead *.ada_m setf ada au BufNewFile,BufRead *.adb setf ada + au BufNewFile,BufRead *.adc setf ada au BufNewFile,BufRead *.ads setf ada au BufNewFile,BufRead *.gpr setf ada endif @@ -465,6 +467,7 @@ endif if !has_key(s:disabled_packages, 'awk') au BufNewFile,BufRead *.awk setf awk + au BufNewFile,BufRead *.gawk setf awk endif if !has_key(s:disabled_packages, 'reason') @@ -473,16 +476,11 @@ if !has_key(s:disabled_packages, 'reason') endif if !has_key(s:disabled_packages, 'c/c++') - au BufNewFile,BufRead *.c setf c - au BufNewFile,BufRead *.cats setf c - au BufNewFile,BufRead *.h setf c - au BufNewFile,BufRead *.idc setf c au BufNewFile,BufRead *.c++ setf cpp au BufNewFile,BufRead *.cc setf cpp au BufNewFile,BufRead *.cp setf cpp au BufNewFile,BufRead *.cpp setf cpp au BufNewFile,BufRead *.cxx setf cpp - au BufNewFile,BufRead *.h setf cpp au BufNewFile,BufRead *.h++ setf cpp au BufNewFile,BufRead *.hh setf cpp au BufNewFile,BufRead *.hpp setf cpp @@ -490,8 +488,14 @@ if !has_key(s:disabled_packages, 'c/c++') au BufNewFile,BufRead *.inc setf cpp au BufNewFile,BufRead *.inl setf cpp au BufNewFile,BufRead *.ipp setf cpp + au BufNewFile,BufRead *.moc setf cpp au BufNewFile,BufRead *.tcc setf cpp au BufNewFile,BufRead *.tpp setf cpp + au BufNewFile,BufRead *.c setf c + au BufNewFile,BufRead *.cats setf c + au BufNewFile,BufRead *.idc setf c + au BufNewFile,BufRead *.qc setf c + au! BufNewFile,BufRead *.h call polyglot#DetectHFiletype() endif if !has_key(s:disabled_packages, 'caddyfile') @@ -566,6 +570,7 @@ endif if !has_key(s:disabled_packages, 'dart') au BufNewFile,BufRead *.dart setf dart + au BufNewFile,BufRead *.drt setf dart endif if !has_key(s:disabled_packages, 'dhall') @@ -1065,7 +1070,7 @@ if !has_key(s:disabled_packages, 'nix') endif if !has_key(s:disabled_packages, 'objc') - au BufNewFile,BufRead *.h setf objc + au! BufNewFile,BufRead *.h call polyglot#DetectHFiletype() au! BufNewFile,BufRead *.m call polyglot#DetectMFiletype() endif diff --git a/heuristics.yaml b/heuristics.yaml index 8c0c16630..901241cb4 100644 --- a/heuristics.yaml +++ b/heuristics.yaml @@ -23,6 +23,20 @@ rules: filetype: aspperl - filetype: aspvbs --- +extensions: [h] +rules: +- lines: 200 + pattern: '^\s*(@(interface|class|protocol|property|end|synchronised|selector|implementation)\b|#import\s+.+\.h[">])' + rules: + - if_exists: "g:c_syntax_for_h" + filetype: objc + - filetype: objcpp +- if_exists: "g:c_syntax_for_h" + filetype: c +- if_exists: "g:ch_syntax_for_h" + filetype: ch +- filetype: cpp +--- extensions: [m] rules: - lines: 100 diff --git a/packages.yaml b/packages.yaml index fb67e6762..e14061013 100644 --- a/packages.yaml +++ b/packages.yaml @@ -93,7 +93,9 @@ filetypes: - adb - ads - ada + - adc - gpr + - ada_m --- name: ahdl remote: vim/vim:runtime @@ -191,6 +193,11 @@ filetypes: - '*/.aptitude/config' - '*/etc/apt/apt.conf.d/[^.]*' - '*/etc/apt/apt.conf.d/*.conf' + ignored_warnings: + # some kind of bugs in filetype detection algorithm + - '*/etc/apt/apt.conf.d/{[-_[:alnum:]]\+,[-_.[:alnum:]]\+.conf}' + - '*/etc/apt/apt.conf.d/]\+' + - '*/etc/apt/apt.conf.d/]\+.conf' --- name: arch remote: vim/vim:runtime @@ -302,19 +309,25 @@ filetypes: - name: awk extensions: - awk + - gawk --- name: c/c++ remote: vim-jp/vim-cpp filetypes: -- name: c - linguist: C - name: cpp linguist: C++ + extra_extensions: + - moc ignored_extensions: # conflicts with more popular reason, remove after heuristics work - re # implemented by arduino - ino +- name: c + linguist: C + extra_extensions: + # Quake C + - qc --- name: caddyfile remote: isobit/vim-caddyfile @@ -358,10 +371,9 @@ filetypes: extra_extensions: # 17 results: https://github.com/search?q=extension%3Acoffeekup+html&type=Code - coffeekup - ignored_filenames: + ignored_warnings: # Probably mistake - '*Cakefile' - ignored_warnings: # Used by C# - csx # Used by Chuck @@ -430,6 +442,8 @@ remote: dart-lang/dart-vim-plugin filetypes: - name: dart linguist: Dart + extra_extensions: + - drt --- name: dhall remote: vmchale/dhall-vim @@ -470,7 +484,7 @@ filetypes: filenames: - 'docker-compose*.yaml' - 'docker-compose*.yml' - ignored_filenames: + ignored_warnings: # Probably mistakes? - 'docker-compose*.yaml*' - 'docker-compose*.yml*' diff --git a/scripts/build b/scripts/build index f688c28f7..67f01ca38 100755 --- a/scripts/build +++ b/scripts/build @@ -268,10 +268,6 @@ def rule_to_code(rule) end end - if rule.has_key?("rules") - return rule["rules"].map { |r| indent(rule_to_code(r), 0) }.join("\n") - end - if rule.has_key?("pattern") || rule.has_key?("or") || rule.has_key?("and") return <<~EOS if #{pattern_to_condition(rule)} @@ -280,6 +276,10 @@ def rule_to_code(rule) EOS end + if rule.has_key?("rules") + return rule["rules"].map { |r| indent(rule_to_code(r), 0) }.join("\n") + end + if rule.has_key?("if_set") return <<~EOS if #{rule["negative"] ? "!" : ""}#{rule["if_set"]} @@ -288,6 +288,14 @@ def rule_to_code(rule) EOS end + if rule.has_key?("if_exists") + return <<~EOS + if #{rule["negative"] ? "!" : ""}exists("#{rule["if_exists"]}") + #{indent(rule_to_code(except(rule, "if_exists", "negative")), 2)} + endif + EOS + end + if rule.has_key?("set") return <<~EOS let #{rule["set"]} = 1 @@ -455,7 +463,7 @@ def generate_ftdetect(packages, heuristics) extensions = filetype["extensions"] filenames = filetype["filenames"] - expected_extensions = all_filetypes.has_key?(name) ? all_filetypes.fetch(name)[:extensions] : [] + expected_extensions = (all_filetypes.has_key?(name) ? all_filetypes.fetch(name)[:extensions] : []).map(&:downcase) ignored_extensions = expand_all(filetype.fetch("ignored_extensions", [])) ignored_warnings = expand_all(filetype.fetch("ignored_warnings", [])) diff --git a/scripts/test_extensions.vim b/scripts/test_extensions.vim index 9cac0b21a..f2aaf66c2 100644 --- a/scripts/test_extensions.vim +++ b/scripts/test_extensions.vim @@ -181,6 +181,18 @@ call TestExtension("ave", "foobar.ave", "") " Awk call TestExtension("awk", "foobar.awk", "") +" C++ +call TestExtension("c", "foobar.c", "") +call TestExtension("cpp", "foobar.cxx", "") +call TestExtension("cpp", "foobar.c++", "") +call TestExtension("cpp", "foobar.hh", "") +call TestExtension("cpp", "foobar.hxx", "") +call TestExtension("cpp", "foobar.hpp", "") +call TestExtension("cpp", "foobar.ipp", "") +call TestExtension("cpp", "foobar.moc", "") +call TestExtension("cpp", "foobar.tcc", "") +call TestExtension("cpp", "foobar.inl", "") + " vim-polyglot only call TestExtension("blade", "test.blade.php", "") call TestExtension("yaml.ansible", "playbook.yml", "") @@ -233,7 +245,7 @@ call TestExtension("vb", "vb.dsm", "") call TestExtension("vb", "vb.dsm", "") call TestExtension("vb", "vb.ctl", "") -" Idris +" .idr extension call TestExtension("idris", "lowercase.idr", "--idris1") call TestExtension("idris", "uppercase.idr", "--Idris1") call TestExtension("idris", "start-space-l.idr", "-- idris1") @@ -253,7 +265,17 @@ call TestExtension("idris2", "two-spaces-u.idr", "-- Idris 2") call TestExtension("idris2", "mypkg.ipkg", "package mypkg\n\ndepends = effects") call TestExtension("idris2", "use-post-proj.idr", "%language PostfixProjections") -" Literate Idris +" .lidr extension call TestExtension("lidris", "lidris-1.lidr", "Some test plaintext\n\n> --idris1\n> myfact : Nat -> Nat\n> myfact Z = 1\n> myfact (S k) = (S k) * myfact k\n\nMore plaintext") call TestExtension("lidris2", "lidris-2.lidr", "Some test plaintext\n\n> --idris2\n> myfact : Nat -> Nat\n> myfact Z = 1\n> myfact (S k) = (S k) * myfact k\n\nMore plaintext") + +" .h extension +call TestExtension("objcpp", "foo.h", "@interface MTNavigationController : UINavigationController") +call TestExtension("cpp", "foo.h", "") +let g:c_syntax_for_h = 1 +call TestExtension("objc", "foo.h", "@interface MTNavigationController : UINavigationController") +call TestExtension("c", "foo.h", "") +unlet g:c_syntax_for_h +let g:ch_syntax_for_h = 1 +call TestExtension("ch", "foo.h", "") diff --git a/scripts/test_filetypes.vim b/scripts/test_filetypes.vim index e157889d8..42e683d17 100644 --- a/scripts/test_filetypes.vim +++ b/scripts/test_filetypes.vim @@ -45,8 +45,8 @@ call TestFiletype('autoit') call TestFiletype('ave') call TestFiletype('awk') call TestFiletype('reason') -call TestFiletype('c') call TestFiletype('cpp') +call TestFiletype('c') call TestFiletype('caddyfile') call TestFiletype('carp') call TestFiletype('clojure') From a4b91124a8fea26575d08c1845e141520e7d33e2 Mon Sep 17 00:00:00 2001 From: Adam Stankiewicz Date: Tue, 8 Sep 2020 16:15:45 +0200 Subject: [PATCH 024/299] Fix auto-detecting indent, closes #540 --- ftdetect/polyglot.vim | 156 +++++++++++++++++++++++++++++++++++++++ plugin/polyglot.vim | 167 ------------------------------------------ 2 files changed, 156 insertions(+), 167 deletions(-) delete mode 100644 plugin/polyglot.vim diff --git a/ftdetect/polyglot.vim b/ftdetect/polyglot.vim index 19d164c5c..0ee86adbe 100644 --- a/ftdetect/polyglot.vim +++ b/ftdetect/polyglot.vim @@ -1761,6 +1761,162 @@ au BufNewFile,BufRead,StdinReadPost * \ if !did_filetype() && expand("") !~ g:ft_ignore_pat \ | call polyglot#Heuristics() | endif + +if v:version < 700 || &cp + finish +endif + + +" Code below re-implements sleuth for vim-polyglot +let g:loaded_sleuth = 1 + +" Makes shiftwidth to be synchronized with tabstop by default +if &shiftwidth == &tabstop + let &shiftwidth = 0 +endif + +function! s:guess(lines) abort + let options = {} + let ccomment = 0 + let podcomment = 0 + let triplequote = 0 + let backtick = 0 + let xmlcomment = 0 + let heredoc = '' + let minindent = 10 + let spaces_minus_tabs = 0 + + for line in a:lines + if !len(line) || line =~# '^\W*$' + continue + endif + + if line =~# '^\s*/\*' + let ccomment = 1 + endif + if ccomment + if line =~# '\*/' + let ccomment = 0 + endif + continue + endif + + if line =~# '^=\w' + let podcomment = 1 + endif + if podcomment + if line =~# '^=\%(end\|cut\)\>' + let podcomment = 0 + endif + continue + endif + + if triplequote + if line =~# '^[^"]*"""[^"]*$' + let triplequote = 0 + endif + continue + elseif line =~# '^[^"]*"""[^"]*$' + let triplequote = 1 + endif + + if backtick + if line =~# '^[^`]*`[^`]*$' + let backtick = 0 + endif + continue + elseif &filetype ==# 'go' && line =~# '^[^`]*`[^`]*$' + let backtick = 1 + endif + + if line =~# '^\s*<\!--' + let xmlcomment = 1 + endif + if xmlcomment + if line =~# '-->' + let xmlcomment = 0 + endif + continue + endif + + " This is correct order because both "< 0 + let heredoc = herematch[1] . '$' + endif + + let spaces_minus_tabs += line[0] == "\t" ? 1 : -1 + + if line[0] == "\t" + setlocal noexpandtab + return 1 + elseif line[0] == " " + let indent = len(matchstr(line, '^ *')) + if (indent % 2 == 0 || indent % 3 == 0) && indent < minindent + let minindent = indent + endif + endif + endfor + + if minindent < 10 + setlocal expandtab + let &shiftwidth=minindent + return 1 + endif + + return 0 +endfunction + +function! s:detect_indent() abort + if &buftype ==# 'help' + return + endif + + if s:guess(getline(1, 32)) + return + endif + let pattern = sleuth#GlobForFiletype(&filetype) + if len(pattern) == 0 + return + endif + let pattern = '{' . pattern . ',.git,.svn,.hg}' + let dir = expand('%:p:h') + let level = 3 + while isdirectory(dir) && dir !=# fnamemodify(dir, ':h') && level > 0 + " Ignore files from homedir and root + if dir == expand('~') || dir == '/' + return + endif + for neighbor in glob(dir . '/' . pattern, 0, 1)[0:level] + " Do not consider directories above .git, .svn or .hg + if fnamemodify(neighbor, ":h:t")[0] == "." + return + endif + if neighbor !=# expand('%:p') && filereadable(neighbor) + if s:guess(readfile(neighbor, '', 32)) + return + endif + endif + endfor + + let dir = fnamemodify(dir, ':h') + let level -= 1 + endwhile +endfunction + +setglobal smarttab + +augroup polyglot + autocmd! + autocmd FileType * call s:detect_indent() +augroup END + " restore Vi compatibility settings let &cpo = s:cpo_save unlet s:cpo_save diff --git a/plugin/polyglot.vim b/plugin/polyglot.vim deleted file mode 100644 index 762e4fcd5..000000000 --- a/plugin/polyglot.vim +++ /dev/null @@ -1,167 +0,0 @@ -" Heuristically set expandtab and shiftwidth options -" -" Modified version of vim-sleuth: -" - tabstop is not set, it's up to user to set it -" - check maximum of 32 lines, instead of 1024 -" - check maximum 6 files, instead of 20 -" - check maximum of 2 filer per directory level, instead of 8 -" - check maximum of 3 directory levels -" - check only to the nearest .git, .hg, or .svn directory -" - globs are concatenated for performance -if exists('g:polyglot_disabled') && index(g:polyglot_disabled, 'autoindent') != -1 - finish -endif - -if exists("g:loaded_polyglot") || v:version < 700 || &cp - finish -endif - -let g:loaded_sleuth = 1 -let g:loaded_polyglot = 1 - -" Makes shiftwidth to be synchronized with tabstop by default -if &shiftwidth == &tabstop - let &shiftwidth = 0 -endif - -function! s:guess(lines) abort - let options = {} - let ccomment = 0 - let podcomment = 0 - let triplequote = 0 - let backtick = 0 - let xmlcomment = 0 - let heredoc = '' - let minindent = 10 - let spaces_minus_tabs = 0 - - for line in a:lines - if !len(line) || line =~# '^\W*$' - continue - endif - - if line =~# '^\s*/\*' - let ccomment = 1 - endif - if ccomment - if line =~# '\*/' - let ccomment = 0 - endif - continue - endif - - if line =~# '^=\w' - let podcomment = 1 - endif - if podcomment - if line =~# '^=\%(end\|cut\)\>' - let podcomment = 0 - endif - continue - endif - - if triplequote - if line =~# '^[^"]*"""[^"]*$' - let triplequote = 0 - endif - continue - elseif line =~# '^[^"]*"""[^"]*$' - let triplequote = 1 - endif - - if backtick - if line =~# '^[^`]*`[^`]*$' - let backtick = 0 - endif - continue - elseif &filetype ==# 'go' && line =~# '^[^`]*`[^`]*$' - let backtick = 1 - endif - - if line =~# '^\s*<\!--' - let xmlcomment = 1 - endif - if xmlcomment - if line =~# '-->' - let xmlcomment = 0 - endif - continue - endif - - " This is correct order because both "< 0 - let heredoc = herematch[1] . '$' - endif - - let spaces_minus_tabs += line[0] == "\t" ? 1 : -1 - - if line[0] == "\t" - setlocal noexpandtab - return 1 - elseif line[0] == " " - let indent = len(matchstr(line, '^ *')) - if indent % 2 == 0 && indent < minindent - let minindent = indent - endif - endif - endfor - - if minindent < 10 - setlocal expandtab - let &shiftwidth=minindent - return 1 - endif - - return 0 -endfunction - -function! s:detect_indent() abort - if &buftype ==# 'help' - return - endif - - if s:guess(getline(1, 32)) - return - endif - let pattern = sleuth#GlobForFiletype(&filetype) - if len(pattern) == 0 - return - endif - let pattern = '{' . pattern . ',.git,.svn,.hg}' - let dir = expand('%:p:h') - let level = 3 - while isdirectory(dir) && dir !=# fnamemodify(dir, ':h') && level > 0 - " Ignore files from homedir and root - if dir == expand('~') || dir == '/' - return - endif - for neighbor in glob(dir . '/' . pattern, 0, 1)[0:level] - " Do not consider directories above .git, .svn or .hg - if fnamemodify(neighbor, ":h:t")[0] == "." - return - endif - if neighbor !=# expand('%:p') && filereadable(neighbor) - if s:guess(readfile(neighbor, '', 32)) - return - endif - endif - endfor - - let dir = fnamemodify(dir, ':h') - let level -= 1 - endwhile -endfunction - -setglobal smarttab - -augroup polyglot - autocmd! - autocmd FileType * call s:detect_indent() -augroup END From 002573265a944381cf8dccf5129fc432e33441e7 Mon Sep 17 00:00:00 2001 From: Adam Stankiewicz Date: Tue, 8 Sep 2020 21:17:24 +0200 Subject: [PATCH 025/299] Fix some ftdetect issues from tests --- README.md | 3 +- autoload/polyglot.vim | 1 + autoload/sleuth.vim | 8 +- ftdetect/polyglot.vim | 21 +- ftplugin/groovy.vim | 23 ++ packages.yaml | 37 ++- scripts/build | 2 +- scripts/test_extensions.vim | 2 +- syntax/groovy.vim | 454 ++++++++++++++++++++++++++++++++++++ 9 files changed, 538 insertions(+), 13 deletions(-) create mode 100644 ftplugin/groovy.vim create mode 100644 syntax/groovy.vim diff --git a/README.md b/README.md index 114002afc..1c98ba15f 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ A collection of language packs for Vim. > One to rule them all, one to find them, one to bring them all and in the darkness bind them. - It **won't affect your startup time**, as scripts are loaded only on demand\*. -- It **installs and updates 120+ times faster** than the 193 packages it consists of. +- It **installs and updates 120+ times faster** than the 194 packages it consists of. - It is more secure because scripts loaded for all extensions are generated by vim-polyglot (ftdetect). - Solid syntax and indentation support (other features skipped). Only the best language packs. - All unnecessary files are ignored (like enormous documentation from php support). @@ -118,6 +118,7 @@ If you need full functionality of any plugin, please use it directly with your p - [go](https://github.com/fatih/vim-go) - [gradle](https://github.com/tfnico/vim-gradle) - [graphql](https://github.com/jparise/vim-graphql) +- [groovy](https://github.com/vim/vim/tree/master/runtime) - [grub](https://github.com/vim/vim/tree/master/runtime) - [haml](https://github.com/sheerun/vim-haml) - [handlebars](https://github.com/sheerun/vim-mustache-handlebars) diff --git a/autoload/polyglot.vim b/autoload/polyglot.vim index 1ed718269..d54cb87e8 100644 --- a/autoload/polyglot.vim +++ b/autoload/polyglot.vim @@ -21,6 +21,7 @@ let s:interpreters = { \ 'escript': 'erlang', \ 'fish': 'fish', \ 'gnuplot': 'gnuplot', + \ 'groovy': 'groovy', \ 'runhaskell': 'haskell', \ 'chakra': 'javascript', \ 'd8': 'javascript', diff --git a/autoload/sleuth.vim b/autoload/sleuth.vim index 2eb95a634..6cf267fa7 100644 --- a/autoload/sleuth.vim +++ b/autoload/sleuth.vim @@ -44,7 +44,7 @@ let s:globs = { \ 'clojure': '*.clj,*.boot,*.cl2,*.cljc,*.cljs,*.cljs.hl,*.cljscm,*.cljx,*.hic,*.edn,riemann.config,build.boot,profile.boot', \ 'cmake': '*.cmake,*.cmake.in,CMakeLists.txt', \ 'coffee': '*.coffee,*._coffee,*.cake,*.cjsx,*.iced,*.coffeekup,Cakefile', - \ 'cpp': '*.cpp,*.c++,*.cc,*.cp,*.cxx,*.h,*.h++,*.hh,*.hpp,*.hxx,*.inc,*.inl,*.ipp,*.tcc,*.tpp,*.moc', + \ 'cpp': '*.cpp,*.c++,*.cc,*.cp,*.cxx,*.h,*.h++,*.hh,*.hpp,*.hxx,*.inc,*.inl,*.ipp,*.tcc,*.tpp,*.moc,*.tlh', \ 'cql': '*.cql', \ 'cryptol': '*.cry,*.cyl,*.lcry,*.lcyl', \ 'crystal': '*.cr,Projectfile', @@ -78,18 +78,18 @@ let s:globs = { \ 'forth': '*.fs,*.ft,*.fth', \ 'fsharp': '*.fs,*.fsi,*.fsx', \ 'gdscript3': '*.gd', - \ 'gitcommit': '', + \ 'gitcommit': 'COMMIT_EDITMSG,MERGE_MSG,TAG_EDITMSG', \ 'gitconfig': '*.gitconfig', \ 'gitrebase': 'git-rebase-todo', \ 'gitsendemail': '', \ 'glsl': '*.glsl,*.fp,*.frag,*.frg,*.fs,*.fsh,*.fshader,*.geo,*.geom,*.glslf,*.glslv,*.gs,*.gshader,*.shader,*.tesc,*.tese,*.vert,*.vrx,*.vsh,*.vshader,*.comp', \ 'gmpl': '*.mod', - \ 'gnuplot': '*.gp,*.gnu,*.gnuplot,*.p,*.plot,*.plt', + \ 'gnuplot': '*.gp,*.gnu,*.gnuplot,*.p,*.plot,*.plt,*.gpi', \ 'go': '*.go', \ 'gohtmltmpl': '*.tmpl', \ 'gomod': 'go.mod', \ 'graphql': '*.graphql,*.gql,*.graphqls', - \ 'groovy': '*.gradle', + \ 'groovy': '*.groovy,*.grt,*.gtpl,*.gvy,*.gradle,Jenkinsfile', \ 'grub': '', \ 'haml': '*.haml,*.haml.deface,*.hamlc,*.hamlbars', \ 'haproxy': '*.cfg,haproxy.cfg,haproxy*.c*', diff --git a/ftdetect/polyglot.vim b/ftdetect/polyglot.vim index 0ee86adbe..9408c2887 100644 --- a/ftdetect/polyglot.vim +++ b/ftdetect/polyglot.vim @@ -169,6 +169,10 @@ if !has_key(s:disabled_packages, 'go') au! BufRead,BufNewFile *.go endif +if !has_key(s:disabled_packages, 'groovy') + au! BufRead,BufNewFile *.groovy +endif + if !has_key(s:disabled_packages, 'haml') au! BufRead,BufNewFile *.haml endif @@ -490,11 +494,13 @@ if !has_key(s:disabled_packages, 'c/c++') au BufNewFile,BufRead *.ipp setf cpp au BufNewFile,BufRead *.moc setf cpp au BufNewFile,BufRead *.tcc setf cpp + au BufNewFile,BufRead *.tlh setf cpp au BufNewFile,BufRead *.tpp setf cpp au BufNewFile,BufRead *.c setf c au BufNewFile,BufRead *.cats setf c au BufNewFile,BufRead *.idc setf c au BufNewFile,BufRead *.qc setf c + au BufNewFile,BufRead *enlightenment/*.cfg setf c au! BufNewFile,BufRead *.h call polyglot#DetectHFiletype() endif @@ -681,13 +687,15 @@ endif if !has_key(s:disabled_packages, 'git') au BufNewFile,BufRead *.gitconfig setf gitconfig au BufNewFile,BufRead *.git/config setf gitconfig - au BufNewFile,BufRead *.git/modules/**/config setf gitconfig + au BufNewFile,BufRead *.git/modules/*/config setf gitconfig au BufNewFile,BufRead */.config/git/config setf gitconfig + au BufNewFile,BufRead */git/config setf gitconfig + au BufNewFile,BufRead */{.,}gitconfig.d/* call s:StarSetf('gitconfig') au BufNewFile,BufRead {.,}gitconfig setf gitconfig au BufNewFile,BufRead {.,}gitmodules setf gitconfig au BufNewFile,BufRead git-rebase-todo setf gitrebase au BufNewFile,BufRead {.,}gitsendemail.* call s:StarSetf('gitsendemail') - au BufNewFile,BufRead *.git/{,modules/**/,worktrees/*/}{COMMIT_EDIT,TAG_EDIT,MERGE_,}MSG setf gitcommit + au BufNewFile,BufRead COMMIT_EDITMSG,MERGE_MSG,TAG_EDITMSG setf gitcommit endif if !has_key(s:disabled_packages, 'glsl') @@ -722,6 +730,7 @@ if !has_key(s:disabled_packages, 'gnuplot') au BufNewFile,BufRead *.gnu setf gnuplot au BufNewFile,BufRead *.gnuplot setf gnuplot au BufNewFile,BufRead *.gp setf gnuplot + au BufNewFile,BufRead *.gpi setf gnuplot au BufNewFile,BufRead *.p setf gnuplot au BufNewFile,BufRead *.plot setf gnuplot au BufNewFile,BufRead *.plt setf gnuplot @@ -739,8 +748,13 @@ if !has_key(s:disabled_packages, 'graphql') au BufNewFile,BufRead *.graphqls setf graphql endif -if !has_key(s:disabled_packages, 'gradle') +if !has_key(s:disabled_packages, 'groovy') au BufNewFile,BufRead *.gradle setf groovy + au BufNewFile,BufRead *.groovy setf groovy + au BufNewFile,BufRead *.grt setf groovy + au BufNewFile,BufRead *.gtpl setf groovy + au BufNewFile,BufRead *.gvy setf groovy + au BufNewFile,BufRead Jenkinsfile setf groovy endif if !has_key(s:disabled_packages, 'haml') @@ -877,6 +891,7 @@ endif if !has_key(s:disabled_packages, 'jq') au BufNewFile,BufRead *.jq setf jq au BufNewFile,BufRead {.,}jqrc setf jq + au BufNewFile,BufRead {.,}jqrc* call s:StarSetf('jq') endif if !has_key(s:disabled_packages, 'json5') diff --git a/ftplugin/groovy.vim b/ftplugin/groovy.vim new file mode 100644 index 000000000..ad78164c2 --- /dev/null +++ b/ftplugin/groovy.vim @@ -0,0 +1,23 @@ +if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'groovy') == -1 + +" Vim filetype plugin file +" Language: groovy +" Maintainer: Justin M. Keyes +" Last Change: 2016 May 22 + +if exists('b:did_ftplugin') + finish +endif +let b:did_ftplugin = 1 + +let s:cpo_save = &cpo +set cpo-=C + +let b:undo_ftplugin = 'setlocal commentstring<' + +setlocal commentstring=//%s + +let &cpo = s:cpo_save +unlet s:cpo_save + +endif diff --git a/packages.yaml b/packages.yaml index e14061013..3ddc5776b 100644 --- a/packages.yaml +++ b/packages.yaml @@ -318,16 +318,25 @@ filetypes: linguist: C++ extra_extensions: - moc + # TLH files are C++ headers generated by Visual C++'s #import from typelibs + - tlh ignored_extensions: # conflicts with more popular reason, remove after heuristics work - re # implemented by arduino - ino + ignored_warnings: + # TODO: fix these + - C + - H - name: c linguist: C extra_extensions: # Quake C - qc + extra_filenames: + # Enlightenment configuration file + - '*enlightenment/*.cfg' --- name: caddyfile remote: isobit/vim-caddyfile @@ -601,16 +610,27 @@ filetypes: extra_filenames: - "*.git/config" - "*/.config/git/config" + - "*.git/modules/*/config" + - "*/git/config" + - "*/{.,}gitconfig.d/*" + ignored_warnings: + - '/etc/gitconfig' + - '$XDG_CONFIG_HOME/git/config' - "*.git/modules/**/config" - - '.gitmodules' + - "*.git/modules/**/config" + - "/etc/gitconfig.d/*" - name: gitrebase filenames: - git-rebase-todo - name: gitsendemail filenames: - ".gitsendemail.*" + ignored_warnings: + - '.gitsendemail.msg.??????' - name: gitcommit filenames: + - 'COMMIT_EDITMSG,MERGE_MSG,TAG_EDITMSG' + ignored_warnings: - '*.git/{,modules/**/,worktrees/*/}{COMMIT_EDIT,TAG_EDIT,MERGE_,}MSG' --- name: glsl @@ -636,6 +656,9 @@ remote: vim-scripts/gnuplot-syntax-highlighting filetypes: - name: gnuplot linguist: Gnuplot + extra_extensions: + # Gnuplot scripts + - gpi --- name: go remote: fatih/vim-go @@ -662,9 +685,18 @@ filetypes: --- name: gradle remote: tfnico/vim-gradle +after: groovy +# Just adds compiler +filetypes: [] +--- +name: groovy +remote: vim/vim:runtime +glob: '**/groovy.vim' filetypes: - name: groovy - linguist: Gradle + linguist: Groovy + extra_extensions: + - gradle --- name: grub remote: vim/vim:runtime @@ -851,7 +883,6 @@ filetypes: linguist: JSONiq extra_filenames: - ".jqrc" - ignored_filenames: - ".jqrc*" --- name: json5 diff --git a/scripts/build b/scripts/build index 67f01ca38..4a36bbace 100755 --- a/scripts/build +++ b/scripts/build @@ -463,7 +463,7 @@ def generate_ftdetect(packages, heuristics) extensions = filetype["extensions"] filenames = filetype["filenames"] - expected_extensions = (all_filetypes.has_key?(name) ? all_filetypes.fetch(name)[:extensions] : []).map(&:downcase) + expected_extensions = (all_filetypes.has_key?(name) ? all_filetypes.fetch(name)[:extensions] : []) ignored_extensions = expand_all(filetype.fetch("ignored_extensions", [])) ignored_warnings = expand_all(filetype.fetch("ignored_warnings", [])) diff --git a/scripts/test_extensions.vim b/scripts/test_extensions.vim index f2aaf66c2..b0dad2988 100644 --- a/scripts/test_extensions.vim +++ b/scripts/test_extensions.vim @@ -6,7 +6,7 @@ function! TestExtension(filetype, filename, content) 1delete _ filetype detect exec "if &filetype != '" . a:filetype . "' \nthrow &filetype\nendif" - exec ":bw!" + exec ":q!" catch echo g:message echo "Filename '" . a:filename . "' does not resolve to extension '" . a:filetype . "'" diff --git a/syntax/groovy.vim b/syntax/groovy.vim new file mode 100644 index 000000000..6a4de4d5f --- /dev/null +++ b/syntax/groovy.vim @@ -0,0 +1,454 @@ +if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'groovy') == -1 + +" Vim syntax file +" Language: Groovy +" Original Author: Alessio Pace +" Maintainer: Tobias Rapp +" Version: 0.1.17 +" URL: http://www.vim.org/scripts/script.php?script_id=945 +" Last Change: 2020 May 26 + +" THE ORIGINAL AUTHOR'S NOTES: +" +" This is my very first vim script, I hope to have +" done it the right way. +" +" I must directly or indirectly thank the author of java.vim and ruby.vim: +" I copied from them most of the stuff :-) +" +" Relies on html.vim + +" For version 5.x: Clear all syntax items +" For version 6.x: Quit when a syntax file was already loaded +" +" HOWTO USE IT (INSTALL) when not part of the distribution: +" +" 1) copy the file in the (global or user's $HOME/.vim/syntax/) syntax folder +" +" 2) add this line to recognize groovy files by filename extension: +" +" au BufNewFile,BufRead *.groovy setf groovy +" in the global vim filetype.vim file or inside $HOME/.vim/filetype.vim +" +" 3) add this part to recognize by content groovy script (no extension needed :-) +" +" if did_filetype() +" finish +" endif +" if getline(1) =~ '^#!.*[/\\]groovy\>' +" setf groovy +" endif +" +" in the global scripts.vim file or in $HOME/.vim/scripts.vim +" +" 4) open/write a .groovy file or a groovy script :-) +" +" Let me know if you like it or send me patches, so that I can improve it +" when I have time + +" quit when a syntax file was already loaded +if !exists("main_syntax") + if exists("b:current_syntax") + finish + endif + " we define it here so that included files can test for it + let main_syntax='groovy' +endif + +let s:cpo_save = &cpo +set cpo&vim + +" ########################## +" Java stuff taken from java.vim +" some characters that cannot be in a groovy program (outside a string) +" syn match groovyError "[\\@`]" +"syn match groovyError "<<<\|\.\.\|=>\|<>\|||=\|&&=\|[^-]->\|\*\/" +"syn match groovyOK "\.\.\." + +" keyword definitions +syn keyword groovyExternal native package +syn match groovyExternal "\\(\s\+static\>\)\?" +syn keyword groovyError goto const +syn keyword groovyConditional if else switch +syn keyword groovyRepeat while for do +syn keyword groovyBoolean true false +syn keyword groovyConstant null +syn keyword groovyTypedef this super +syn keyword groovyOperator new instanceof +syn keyword groovyType boolean char byte short int long float double +syn keyword groovyType void +syn keyword groovyType Integer Double Date Boolean Float String Array Vector List +syn keyword groovyStatement return +syn keyword groovyStorageClass static synchronized transient volatile final strictfp serializable +syn keyword groovyExceptions throw try catch finally +syn keyword groovyAssert assert +syn keyword groovyMethodDecl synchronized throws +syn keyword groovyClassDecl extends implements interface +" to differentiate the keyword class from MyClass.class we use a match here +syn match groovyTypedef "\.\s*\"ms=s+1 +syn keyword groovyClassDecl enum +syn match groovyClassDecl "^class\>" +syn match groovyClassDecl "[^.]\s*\"ms=s+1 +syn keyword groovyBranch break continue nextgroup=groovyUserLabelRef skipwhite +syn match groovyUserLabelRef "\k\+" contained +syn keyword groovyScopeDecl public protected private abstract + + +if exists("groovy_highlight_groovy_lang_ids") || exists("groovy_highlight_groovy_lang") || exists("groovy_highlight_all") + " groovy.lang.* + syn keyword groovyLangClass Closure MetaMethod GroovyObject + + syn match groovyJavaLangClass "\" + syn keyword groovyJavaLangClass Cloneable Comparable Runnable Serializable Boolean Byte Class Object + syn keyword groovyJavaLangClass Character CharSequence ClassLoader Compiler + " syn keyword groovyJavaLangClass Integer Double Float Long + syn keyword groovyJavaLangClass InheritableThreadLocal Math Number Object Package Process + syn keyword groovyJavaLangClass Runtime RuntimePermission InheritableThreadLocal + syn keyword groovyJavaLangClass SecurityManager Short StrictMath StackTraceElement + syn keyword groovyJavaLangClass StringBuffer Thread ThreadGroup + syn keyword groovyJavaLangClass ThreadLocal Throwable Void ArithmeticException + syn keyword groovyJavaLangClass ArrayIndexOutOfBoundsException AssertionError + syn keyword groovyJavaLangClass ArrayStoreException ClassCastException + syn keyword groovyJavaLangClass ClassNotFoundException + syn keyword groovyJavaLangClass CloneNotSupportedException Exception + syn keyword groovyJavaLangClass IllegalAccessException + syn keyword groovyJavaLangClass IllegalArgumentException + syn keyword groovyJavaLangClass IllegalMonitorStateException + syn keyword groovyJavaLangClass IllegalStateException + syn keyword groovyJavaLangClass IllegalThreadStateException + syn keyword groovyJavaLangClass IndexOutOfBoundsException + syn keyword groovyJavaLangClass InstantiationException InterruptedException + syn keyword groovyJavaLangClass NegativeArraySizeException NoSuchFieldException + syn keyword groovyJavaLangClass NoSuchMethodException NullPointerException + syn keyword groovyJavaLangClass NumberFormatException RuntimeException + syn keyword groovyJavaLangClass SecurityException StringIndexOutOfBoundsException + syn keyword groovyJavaLangClass UnsupportedOperationException + syn keyword groovyJavaLangClass AbstractMethodError ClassCircularityError + syn keyword groovyJavaLangClass ClassFormatError Error ExceptionInInitializerError + syn keyword groovyJavaLangClass IllegalAccessError InstantiationError + syn keyword groovyJavaLangClass IncompatibleClassChangeError InternalError + syn keyword groovyJavaLangClass LinkageError NoClassDefFoundError + syn keyword groovyJavaLangClass NoSuchFieldError NoSuchMethodError + syn keyword groovyJavaLangClass OutOfMemoryError StackOverflowError + syn keyword groovyJavaLangClass ThreadDeath UnknownError UnsatisfiedLinkError + syn keyword groovyJavaLangClass UnsupportedClassVersionError VerifyError + syn keyword groovyJavaLangClass VirtualMachineError + + syn keyword groovyJavaLangObject clone equals finalize getClass hashCode + syn keyword groovyJavaLangObject notify notifyAll toString wait + + hi def link groovyLangClass groovyConstant + hi def link groovyJavaLangClass groovyExternal + hi def link groovyJavaLangObject groovyConstant + syn cluster groovyTop add=groovyJavaLangObject,groovyJavaLangClass,groovyLangClass + syn cluster groovyClasses add=groovyJavaLangClass,groovyLangClass +endif + + +" Groovy stuff +syn match groovyOperator "\.\." +syn match groovyOperator "<\{2,3}" +syn match groovyOperator ">\{2,3}" +syn match groovyOperator "->" +syn match groovyLineComment '^\%1l#!.*' " Shebang line +syn match groovyExceptions "\\|\<[A-Z]\{1,}[a-zA-Z0-9]*Exception\>" + +" Groovy JDK stuff +syn keyword groovyJDKBuiltin as def in +syn keyword groovyJDKOperOverl div minus plus abs round power multiply +syn keyword groovyJDKMethods each call inject sort print println +syn keyword groovyJDKMethods getAt putAt size push pop toList getText writeLine eachLine readLines +syn keyword groovyJDKMethods withReader withStream withWriter withPrintWriter write read leftShift +syn keyword groovyJDKMethods withWriterAppend readBytes splitEachLine +syn keyword groovyJDKMethods newInputStream newOutputStream newPrintWriter newReader newWriter +syn keyword groovyJDKMethods compareTo next previous isCase +syn keyword groovyJDKMethods times step toInteger upto any collect dump every find findAll grep +syn keyword groovyJDKMethods inspect invokeMethods join +syn keyword groovyJDKMethods getErr getIn getOut waitForOrKill +syn keyword groovyJDKMethods count tokenize asList flatten immutable intersect reverse reverseEach +syn keyword groovyJDKMethods subMap append asWritable eachByte eachLine eachFile +syn cluster groovyTop add=groovyJDKBuiltin,groovyJDKOperOverl,groovyJDKMethods + +" no useful I think, so I comment it.. +"if filereadable(expand(":p:h")."/groovyid.vim") + " source :p:h/groovyid.vim +"endif + +if exists("groovy_space_errors") + if !exists("groovy_no_trail_space_error") + syn match groovySpaceError "\s\+$" + endif + if !exists("groovy_no_tab_space_error") + syn match groovySpaceError " \+\t"me=e-1 + endif +endif + +" it is a better case construct than java.vim to match groovy syntax +syn region groovyLabelRegion transparent matchgroup=groovyLabel start="\" matchgroup=NONE end=":\|$" contains=groovyNumber,groovyString,groovyLangClass,groovyJavaLangClass +syn match groovyUserLabel "^\s*[_$a-zA-Z][_$a-zA-Z0-9_]*\s*:"he=e-1 contains=groovyLabel +syn keyword groovyLabel default + +if !exists("groovy_allow_cpp_keywords") + syn keyword groovyError auto delete extern friend inline redeclared + syn keyword groovyError register signed sizeof struct template typedef union + syn keyword groovyError unsigned operator +endif + +" The following cluster contains all groovy groups except the contained ones +syn cluster groovyTop add=groovyExternal,groovyError,groovyError,groovyBranch,groovyLabelRegion,groovyLabel,groovyConditional,groovyRepeat,groovyBoolean,groovyConstant,groovyTypedef,groovyOperator,groovyType,groovyType,groovyStatement,groovyStorageClass,groovyAssert,groovyExceptions,groovyMethodDecl,groovyClassDecl,groovyClassDecl,groovyClassDecl,groovyScopeDecl,groovyError,groovyError2,groovyUserLabel,groovyLangObject + + +" Comments +syn keyword groovyTodo contained TODO FIXME XXX +if exists("groovy_comment_strings") + syn region groovyCommentString contained start=+"+ end=+"+ end=+$+ end=+\*/+me=s-1,he=s-1 contains=groovySpecial,groovyCommentStar,groovySpecialChar,@Spell + syn region groovyComment2String contained start=+"+ end=+$\|"+ contains=groovySpecial,groovySpecialChar,@Spell + syn match groovyCommentCharacter contained "'\\[^']\{1,6\}'" contains=groovySpecialChar + syn match groovyCommentCharacter contained "'\\''" contains=groovySpecialChar + syn match groovyCommentCharacter contained "'[^\\]'" + syn cluster groovyCommentSpecial add=groovyCommentString,groovyCommentCharacter,groovyNumber + syn cluster groovyCommentSpecial2 add=groovyComment2String,groovyCommentCharacter,groovyNumber +endif +syn region groovyComment start="/\*" end="\*/" contains=@groovyCommentSpecial,groovyTodo,@Spell +syn match groovyCommentStar contained "^\s*\*[^/]"me=e-1 +syn match groovyCommentStar contained "^\s*\*$" +syn match groovyLineComment "//.*" contains=@groovyCommentSpecial2,groovyTodo,@Spell +hi def link groovyCommentString groovyString +hi def link groovyComment2String groovyString +hi def link groovyCommentCharacter groovyCharacter + +syn cluster groovyTop add=groovyComment,groovyLineComment + +if !exists("groovy_ignore_groovydoc") && main_syntax != 'jsp' + syntax case ignore + " syntax coloring for groovydoc comments (HTML) + " syntax include @groovyHtml :p:h/html.vim + syntax include @groovyHtml runtime! syntax/html.vim + unlet b:current_syntax + syntax spell default " added by Bram + syn region groovyDocComment start="/\*\*" end="\*/" keepend contains=groovyCommentTitle,@groovyHtml,groovyDocTags,groovyTodo,@Spell + syn region groovyCommentTitle contained matchgroup=groovyDocComment start="/\*\*" matchgroup=groovyCommentTitle keepend end="\.$" end="\.[ \t\r<&]"me=e-1 end="[^{]@"me=s-2,he=s-1 end="\*/"me=s-1,he=s-1 contains=@groovyHtml,groovyCommentStar,groovyTodo,@Spell,groovyDocTags + + syn region groovyDocTags contained start="{@\(link\|linkplain\|inherit[Dd]oc\|doc[rR]oot\|value\)" end="}" + syn match groovyDocTags contained "@\(see\|param\|exception\|throws\|since\)\s\+\S\+" contains=groovyDocParam + syn match groovyDocParam contained "\s\S\+" + syn match groovyDocTags contained "@\(version\|author\|return\|deprecated\|serial\|serialField\|serialData\)\>" + syntax case match +endif + +" match the special comment /**/ +syn match groovyComment "/\*\*/" + +" Strings and constants +syn match groovySpecialError contained "\\." +syn match groovySpecialCharError contained "[^']" +syn match groovySpecialChar contained "\\\([4-9]\d\|[0-3]\d\d\|[\"\\'ntbrf]\|u\x\{4\}\|\$\)" +syn match groovyRegexChar contained "\\." +syn region groovyString start=+"+ end=+"+ end=+$+ contains=groovySpecialChar,groovySpecialError,@Spell,groovyELExpr +syn region groovyString start=+'+ end=+'+ end=+$+ contains=groovySpecialChar,groovySpecialError,@Spell +syn region groovyString start=+"""+ end=+"""+ contains=groovySpecialChar,groovySpecialError,@Spell,groovyELExpr +syn region groovyString start=+'''+ end=+'''+ contains=groovySpecialChar,groovySpecialError,@Spell +if exists("groovy_regex_strings") + " regex strings interfere with the division operator and thus are disabled + " by default + syn region groovyString start='/[^/*]' end='/' contains=groovySpecialChar,groovyRegexChar,groovyELExpr +endif +" syn region groovyELExpr start=+${+ end=+}+ keepend contained +syn match groovyELExpr /\${.\{-}}/ contained +syn match groovyELExpr /\$[a-zA-Z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u00FF\u0100-\uFFFE_][a-zA-Z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u00FF\u0100-\uFFFE0-9_.]*/ contained +hi def link groovyELExpr Identifier + +" TODO: better matching. I am waiting to understand how it really works in groovy +" syn region groovyClosureParamsBraces start=+|+ end=+|+ contains=groovyClosureParams +" syn match groovyClosureParams "[ a-zA-Z0-9_*]\+" contained +" hi def link groovyClosureParams Identifier + +" next line disabled, it can cause a crash for a long line +"syn match groovyStringError +"\([^"\\]\|\\.\)*$+ + +" disabled: in groovy strings or characters are written the same +" syn match groovyCharacter "'[^']*'" contains=groovySpecialChar,groovySpecialCharError +" syn match groovyCharacter "'\\''" contains=groovySpecialChar +" syn match groovyCharacter "'[^\\]'" +syn match groovyNumber "\<\(0[0-7]*\|0[xX]\x\+\|\d\+\)[lL]\=\>" +syn match groovyNumber "\(\<\d\+\.\d*\|\.\d\+\)\([eE][-+]\=\d\+\)\=[fFdD]\=" +syn match groovyNumber "\<\d\+[eE][-+]\=\d\+[fFdD]\=\>" +syn match groovyNumber "\<\d\+\([eE][-+]\=\d\+\)\=[fFdD]\>" + +" unicode characters +syn match groovySpecial "\\u\d\{4\}" + +syn cluster groovyTop add=groovyString,groovyCharacter,groovyNumber,groovySpecial,groovyStringError + +if exists("groovy_highlight_functions") + if groovy_highlight_functions == "indent" + syn match groovyFuncDef "^\(\t\| \{8\}\)[_$a-zA-Z][_$a-zA-Z0-9_. \[\]]*([^-+*/()]*)" contains=groovyScopeDecl,groovyType,groovyStorageClass,@groovyClasses + syn region groovyFuncDef start=+^\(\t\| \{8\}\)[$_a-zA-Z][$_a-zA-Z0-9_. \[\]]*([^-+*/()]*,\s*+ end=+)+ contains=groovyScopeDecl,groovyType,groovyStorageClass,@groovyClasses + syn match groovyFuncDef "^ [$_a-zA-Z][$_a-zA-Z0-9_. \[\]]*([^-+*/()]*)" contains=groovyScopeDecl,groovyType,groovyStorageClass,@groovyClasses + syn region groovyFuncDef start=+^ [$_a-zA-Z][$_a-zA-Z0-9_. \[\]]*([^-+*/()]*,\s*+ end=+)+ contains=groovyScopeDecl,groovyType,groovyStorageClass,@groovyClasses + else + " This line catches method declarations at any indentation>0, but it assumes + " two things: + " 1. class names are always capitalized (ie: Button) + " 2. method names are never capitalized (except constructors, of course) + syn region groovyFuncDef start=+^\s\+\(\(public\|protected\|private\|static\|abstract\|final\|native\|synchronized\)\s\+\)*\(\(void\|boolean\|char\|byte\|short\|int\|long\|float\|double\|\([A-Za-z_][A-Za-z0-9_$]*\.\)*[A-Z][A-Za-z0-9_$]*\)\(<[^>]*>\)\=\(\[\]\)*\s\+[a-z][A-Za-z0-9_$]*\|[A-Z][A-Za-z0-9_$]*\)\s*([^0-9]+ end=+)+ contains=groovyScopeDecl,groovyType,groovyStorageClass,groovyComment,groovyLineComment,@groovyClasses + endif + syn match groovyBraces "[{}]" + syn cluster groovyTop add=groovyFuncDef,groovyBraces +endif + +if exists("groovy_highlight_debug") + + " Strings and constants + syn match groovyDebugSpecial contained "\\\d\d\d\|\\." + syn region groovyDebugString contained start=+"+ end=+"+ contains=groovyDebugSpecial + syn match groovyDebugStringError +"\([^"\\]\|\\.\)*$+ + syn match groovyDebugCharacter contained "'[^\\]'" + syn match groovyDebugSpecialCharacter contained "'\\.'" + syn match groovyDebugSpecialCharacter contained "'\\''" + syn match groovyDebugNumber contained "\<\(0[0-7]*\|0[xX]\x\+\|\d\+\)[lL]\=\>" + syn match groovyDebugNumber contained "\(\<\d\+\.\d*\|\.\d\+\)\([eE][-+]\=\d\+\)\=[fFdD]\=" + syn match groovyDebugNumber contained "\<\d\+[eE][-+]\=\d\+[fFdD]\=\>" + syn match groovyDebugNumber contained "\<\d\+\([eE][-+]\=\d\+\)\=[fFdD]\>" + syn keyword groovyDebugBoolean contained true false + syn keyword groovyDebugType contained null this super + syn region groovyDebugParen start=+(+ end=+)+ contained contains=groovyDebug.*,groovyDebugParen + + " to make this work you must define the highlighting for these groups + syn match groovyDebug "\\|\<[A-Z]\{1,}[a-zA-Z0-9]*Exception\>" + + +if !exists("groovy_minlines") + let groovy_minlines = 10 +endif +exec "syn sync ccomment groovyComment minlines=" . groovy_minlines + + +" ################### +" Groovy stuff +" syn match groovyOperator "|[ ,a-zA-Z0-9_*]\+|" + +" All groovy valid tokens +" syn match groovyTokens ";\|,\|<=>\|<>\|:\|:=\|>\|>=\|=\|==\|<\|<=\|!=\|/\|/=\|\.\.|\.\.\.\|\~=\|\~==" +" syn match groovyTokens "\*=\|&\|&=\|\*\|->\|\~\|+\|-\|/\|?\|<<<\|>>>\|<<\|>>" + +" Must put explicit these ones because groovy.vim mark them as errors otherwise +" syn match groovyTokens "<=>\|<>\|==\~" +"syn cluster groovyTop add=groovyTokens + +" Mark these as operators + +" Hightlight brackets +" syn match groovyBraces "[{}]" +" syn match groovyBraces "[\[\]]" +" syn match groovyBraces "[\|]" + +if exists("groovy_mark_braces_in_parens_as_errors") + syn match groovyInParen contained "[{}]" + hi def link groovyInParen groovyError + syn cluster groovyTop add=groovyInParen +endif + +" catch errors caused by wrong parenthesis +syn region groovyParenT transparent matchgroup=groovyParen start="(" end=")" contains=@groovyTop,groovyParenT1 +syn region groovyParenT1 transparent matchgroup=groovyParen1 start="(" end=")" contains=@groovyTop,groovyParenT2 contained +syn region groovyParenT2 transparent matchgroup=groovyParen2 start="(" end=")" contains=@groovyTop,groovyParenT contained +syn match groovyParenError ")" +hi def link groovyParenError groovyError + +" catch errors caused by wrong square parenthesis +syn region groovyParenT transparent matchgroup=groovyParen start="\[" end="\]" contains=@groovyTop,groovyParenT1 +syn region groovyParenT1 transparent matchgroup=groovyParen1 start="\[" end="\]" contains=@groovyTop,groovyParenT2 contained +syn region groovyParenT2 transparent matchgroup=groovyParen2 start="\[" end="\]" contains=@groovyTop,groovyParenT contained +syn match groovyParenError "\]" + +" ############################### +" java.vim default highlighting +hi def link groovyFuncDef Function +hi def link groovyBraces Function +hi def link groovyBranch Conditional +hi def link groovyUserLabelRef groovyUserLabel +hi def link groovyLabel Label +hi def link groovyUserLabel Label +hi def link groovyConditional Conditional +hi def link groovyRepeat Repeat +hi def link groovyExceptions Exception +hi def link groovyAssert Statement +hi def link groovyStorageClass StorageClass +hi def link groovyMethodDecl groovyStorageClass +hi def link groovyClassDecl groovyStorageClass +hi def link groovyScopeDecl groovyStorageClass +hi def link groovyBoolean Boolean +hi def link groovySpecial Special +hi def link groovySpecialError Error +hi def link groovySpecialCharError Error +hi def link groovyString String +hi def link groovyRegexChar String +hi def link groovyCharacter Character +hi def link groovySpecialChar SpecialChar +hi def link groovyNumber Number +hi def link groovyError Error +hi def link groovyStringError Error +hi def link groovyStatement Statement +hi def link groovyOperator Operator +hi def link groovyComment Comment +hi def link groovyDocComment Comment +hi def link groovyLineComment Comment +hi def link groovyConstant Constant +hi def link groovyTypedef Typedef +hi def link groovyTodo Todo + +hi def link groovyCommentTitle SpecialComment +hi def link groovyDocTags Special +hi def link groovyDocParam Function +hi def link groovyCommentStar groovyComment + +hi def link groovyType Type +hi def link groovyExternal Include + +hi def link htmlComment Special +hi def link htmlCommentPart Special +hi def link groovySpaceError Error +hi def link groovyJDKBuiltin Special +hi def link groovyJDKOperOverl Operator +hi def link groovyJDKMethods Function + + +let b:current_syntax = "groovy" +if main_syntax == 'groovy' + unlet main_syntax +endif + +let b:spell_options="contained" + +let &cpo = s:cpo_save +unlet s:cpo_save + +" vim: ts=8 + +endif From 5e5d127eb8a9a9f4339b60b7f46ec36a359c0211 Mon Sep 17 00:00:00 2001 From: Adam Stankiewicz Date: Tue, 8 Sep 2020 22:41:51 +0200 Subject: [PATCH 026/299] Add expect (fix tests) --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index f9005acb4..2e31e4044 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -14,7 +14,7 @@ jobs: run: | sudo add-apt-repository ppa:jonathonf/vim -y sudo apt-get update -q - sudo apt-get install -y vim + sudo apt-get install -y vim expect vim --version - uses: actions/checkout@v2 - name: Run Tests From a4a9481d372af2e8bb0469f533e4b047b3a384fb Mon Sep 17 00:00:00 2001 From: Adam Stankiewicz Date: Wed, 9 Sep 2020 11:58:14 +0200 Subject: [PATCH 027/299] Fix disabling autoindent, closes #541 --- ftdetect/polyglot.vim | 244 +++++++++++++++++++++--------------------- 1 file changed, 121 insertions(+), 123 deletions(-) diff --git a/ftdetect/polyglot.vim b/ftdetect/polyglot.vim index 9408c2887..aed797ab9 100644 --- a/ftdetect/polyglot.vim +++ b/ftdetect/polyglot.vim @@ -1777,160 +1777,158 @@ au BufNewFile,BufRead,StdinReadPost * \ | call polyglot#Heuristics() | endif -if v:version < 700 || &cp - finish -endif - +if !has_key(s:disabled_packages, 'helm') -" Code below re-implements sleuth for vim-polyglot -let g:loaded_sleuth = 1 + " Code below re-implements sleuth for vim-polyglot + let g:loaded_sleuth = 1 -" Makes shiftwidth to be synchronized with tabstop by default -if &shiftwidth == &tabstop - let &shiftwidth = 0 -endif - -function! s:guess(lines) abort - let options = {} - let ccomment = 0 - let podcomment = 0 - let triplequote = 0 - let backtick = 0 - let xmlcomment = 0 - let heredoc = '' - let minindent = 10 - let spaces_minus_tabs = 0 + " Makes shiftwidth to be synchronized with tabstop by default + if &shiftwidth == &tabstop + let &shiftwidth = 0 + endif - for line in a:lines - if !len(line) || line =~# '^\W*$' - continue - endif + function! s:guess(lines) abort + let options = {} + let ccomment = 0 + let podcomment = 0 + let triplequote = 0 + let backtick = 0 + let xmlcomment = 0 + let heredoc = '' + let minindent = 10 + let spaces_minus_tabs = 0 + + for line in a:lines + if !len(line) || line =~# '^\W*$' + continue + endif - if line =~# '^\s*/\*' - let ccomment = 1 - endif - if ccomment - if line =~# '\*/' - let ccomment = 0 + if line =~# '^\s*/\*' + let ccomment = 1 + endif + if ccomment + if line =~# '\*/' + let ccomment = 0 + endif + continue endif - continue - endif - if line =~# '^=\w' - let podcomment = 1 - endif - if podcomment - if line =~# '^=\%(end\|cut\)\>' - let podcomment = 0 + if line =~# '^=\w' + let podcomment = 1 + endif + if podcomment + if line =~# '^=\%(end\|cut\)\>' + let podcomment = 0 + endif + continue endif - continue - endif - if triplequote - if line =~# '^[^"]*"""[^"]*$' - let triplequote = 0 + if triplequote + if line =~# '^[^"]*"""[^"]*$' + let triplequote = 0 + endif + continue + elseif line =~# '^[^"]*"""[^"]*$' + let triplequote = 1 endif - continue - elseif line =~# '^[^"]*"""[^"]*$' - let triplequote = 1 - endif - if backtick - if line =~# '^[^`]*`[^`]*$' - let backtick = 0 + if backtick + if line =~# '^[^`]*`[^`]*$' + let backtick = 0 + endif + continue + elseif &filetype ==# 'go' && line =~# '^[^`]*`[^`]*$' + let backtick = 1 endif - continue - elseif &filetype ==# 'go' && line =~# '^[^`]*`[^`]*$' - let backtick = 1 - endif - if line =~# '^\s*<\!--' - let xmlcomment = 1 - endif - if xmlcomment - if line =~# '-->' - let xmlcomment = 0 + if line =~# '^\s*<\!--' + let xmlcomment = 1 + endif + if xmlcomment + if line =~# '-->' + let xmlcomment = 0 + endif + continue endif - continue - endif - " This is correct order because both "< 0 + let heredoc = herematch[1] . '$' endif - continue - endif - let herematch = matchlist(line, '\C<<\W*\([A-Z]\+\)\s*$') - if len(herematch) > 0 - let heredoc = herematch[1] . '$' - endif - let spaces_minus_tabs += line[0] == "\t" ? 1 : -1 + let spaces_minus_tabs += line[0] == "\t" ? 1 : -1 - if line[0] == "\t" - setlocal noexpandtab - return 1 - elseif line[0] == " " - let indent = len(matchstr(line, '^ *')) - if (indent % 2 == 0 || indent % 3 == 0) && indent < minindent - let minindent = indent + if line[0] == "\t" + setlocal noexpandtab + return 1 + elseif line[0] == " " + let indent = len(matchstr(line, '^ *')) + if (indent % 2 == 0 || indent % 3 == 0) && indent < minindent + let minindent = indent + endif endif - endif - endfor + endfor - if minindent < 10 - setlocal expandtab - let &shiftwidth=minindent - return 1 - endif + if minindent < 10 + setlocal expandtab + let &shiftwidth=minindent + return 1 + endif - return 0 -endfunction + return 0 + endfunction -function! s:detect_indent() abort - if &buftype ==# 'help' - return - endif + function! s:detect_indent() abort + if &buftype ==# 'help' + return + endif - if s:guess(getline(1, 32)) - return - endif - let pattern = sleuth#GlobForFiletype(&filetype) - if len(pattern) == 0 - return - endif - let pattern = '{' . pattern . ',.git,.svn,.hg}' - let dir = expand('%:p:h') - let level = 3 - while isdirectory(dir) && dir !=# fnamemodify(dir, ':h') && level > 0 - " Ignore files from homedir and root - if dir == expand('~') || dir == '/' + if s:guess(getline(1, 32)) + return + endif + let pattern = sleuth#GlobForFiletype(&filetype) + if len(pattern) == 0 return endif - for neighbor in glob(dir . '/' . pattern, 0, 1)[0:level] - " Do not consider directories above .git, .svn or .hg - if fnamemodify(neighbor, ":h:t")[0] == "." + let pattern = '{' . pattern . ',.git,.svn,.hg}' + let dir = expand('%:p:h') + let level = 3 + while isdirectory(dir) && dir !=# fnamemodify(dir, ':h') && level > 0 + " Ignore files from homedir and root + if dir == expand('~') || dir == '/' return endif - if neighbor !=# expand('%:p') && filereadable(neighbor) - if s:guess(readfile(neighbor, '', 32)) + for neighbor in glob(dir . '/' . pattern, 0, 1)[0:level] + " Do not consider directories above .git, .svn or .hg + if fnamemodify(neighbor, ":h:t")[0] == "." return endif - endif - endfor + if neighbor !=# expand('%:p') && filereadable(neighbor) + if s:guess(readfile(neighbor, '', 32)) + return + endif + endif + endfor - let dir = fnamemodify(dir, ':h') - let level -= 1 - endwhile -endfunction + let dir = fnamemodify(dir, ':h') + let level -= 1 + endwhile + endfunction -setglobal smarttab + setglobal smarttab -augroup polyglot - autocmd! - autocmd FileType * call s:detect_indent() -augroup END + augroup polyglot + autocmd! + autocmd FileType * call s:detect_indent() + augroup END +endif " restore Vi compatibility settings let &cpo = s:cpo_save From cecfb5dd10497d09fc46e85c15c383166d9fb22a Mon Sep 17 00:00:00 2001 From: Adam Stankiewicz Date: Wed, 9 Sep 2020 16:45:51 +0200 Subject: [PATCH 028/299] Fix disabling autoindent, #541 --- ftdetect/polyglot.vim | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/ftdetect/polyglot.vim b/ftdetect/polyglot.vim index aed797ab9..7b2439015 100644 --- a/ftdetect/polyglot.vim +++ b/ftdetect/polyglot.vim @@ -1777,8 +1777,7 @@ au BufNewFile,BufRead,StdinReadPost * \ | call polyglot#Heuristics() | endif -if !has_key(s:disabled_packages, 'helm') - +if !has_key(s:disabled_packages, 'autoindent') " Code below re-implements sleuth for vim-polyglot let g:loaded_sleuth = 1 From 2e1a9806326445c5cbdbb3b0cc7d82c7a16881b0 Mon Sep 17 00:00:00 2001 From: Adam Stankiewicz Date: Wed, 9 Sep 2020 16:48:49 +0200 Subject: [PATCH 029/299] Add missing functions from Sleuth, #541 --- ftdetect/polyglot.vim | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/ftdetect/polyglot.vim b/ftdetect/polyglot.vim index 7b2439015..fd1dd3d70 100644 --- a/ftdetect/polyglot.vim +++ b/ftdetect/polyglot.vim @@ -1923,10 +1923,24 @@ if !has_key(s:disabled_packages, 'autoindent') setglobal smarttab + function! SleuthIndicator() abort + let sw = &shiftwidth ? &shiftwidth : &tabstop + if &expandtab + return 'sw='.sw + elseif &tabstop == sw + return 'ts='.&tabstop + else + return 'sw='.sw.',ts='.&tabstop + endif + endfunction + augroup polyglot autocmd! autocmd FileType * call s:detect_indent() + autocmd User Flags call Hoist('buffer', 5, 'SleuthIndicator') augroup END + + command! -bar -bang Sleuth call s:detect_indent() endif " restore Vi compatibility settings From 2fe310256e82ec8c4c160ebc171fe18c8da06330 Mon Sep 17 00:00:00 2001 From: Adam Stankiewicz Date: Wed, 9 Sep 2020 17:08:29 +0200 Subject: [PATCH 030/299] Transcompile ..= operator to support old vims, fixes #542 --- ftplugin/yaml.vim | 2 +- scripts/build | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/ftplugin/yaml.vim b/ftplugin/yaml.vim index 2e9728bd6..261d71ca8 100644 --- a/ftplugin/yaml.vim +++ b/ftplugin/yaml.vim @@ -19,7 +19,7 @@ setlocal comments=:# commentstring=#\ %s expandtab setlocal formatoptions-=t formatoptions+=croql if !exists("g:yaml_recommended_style") || g:yaml_recommended_style != 0 - let b:undo_ftplugin ..= " sw< sts<" + let b:undo_ftplugin .= " sw< sts<" setlocal shiftwidth=2 softtabstop=2 endif diff --git a/scripts/build b/scripts/build index 4a36bbace..699933740 100755 --- a/scripts/build +++ b/scripts/build @@ -175,7 +175,9 @@ def copy_file(package, src, dest) else output << "if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, '#{name}') == -1\n\n" end - IO.copy_stream(input, output) + contents = File.read(input) + contents.gsub!(' ..= ', ' .= ') + output << contents output << "\nendif\n" end end From a4cc3f64f98e71373e5ee9e566cde17bee723b63 Mon Sep 17 00:00:00 2001 From: Adam Stankiewicz Date: Wed, 9 Sep 2020 17:39:27 +0200 Subject: [PATCH 031/299] Make it easier to debug indentation issues, #542 --- ftdetect/polyglot.vim | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ftdetect/polyglot.vim b/ftdetect/polyglot.vim index fd1dd3d70..c5a47471e 100644 --- a/ftdetect/polyglot.vim +++ b/ftdetect/polyglot.vim @@ -1780,6 +1780,7 @@ au BufNewFile,BufRead,StdinReadPost * if !has_key(s:disabled_packages, 'autoindent') " Code below re-implements sleuth for vim-polyglot let g:loaded_sleuth = 1 + let g:loaded_foobar = 1 " Makes shiftwidth to be synchronized with tabstop by default if &shiftwidth == &tabstop @@ -1871,6 +1872,7 @@ if !has_key(s:disabled_packages, 'autoindent') let indent = len(matchstr(line, '^ *')) if (indent % 2 == 0 || indent % 3 == 0) && indent < minindent let minindent = indent + let b:sleuth_culprit .= ":" . line endif endif endfor @@ -1881,6 +1883,7 @@ if !has_key(s:disabled_packages, 'autoindent') return 1 endif + unlet b:sleuth_culprit return 0 endfunction @@ -1889,6 +1892,7 @@ if !has_key(s:disabled_packages, 'autoindent') return endif + let b:sleuth_culprit = expand("") if s:guess(getline(1, 32)) return endif @@ -1905,6 +1909,7 @@ if !has_key(s:disabled_packages, 'autoindent') return endif for neighbor in glob(dir . '/' . pattern, 0, 1)[0:level] + let b:sleuth_culprit = neighbor " Do not consider directories above .git, .svn or .hg if fnamemodify(neighbor, ":h:t")[0] == "." return From 46affb6153698d9b5678fdb59b5921ffd53aff13 Mon Sep 17 00:00:00 2001 From: Adam Stankiewicz Date: Wed, 9 Sep 2020 17:50:40 +0200 Subject: [PATCH 032/299] Show warning if g:polyglot_disabled is not at the top of .vimrc --- ftdetect/polyglot.vim | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/ftdetect/polyglot.vim b/ftdetect/polyglot.vim index c5a47471e..37a2525e8 100644 --- a/ftdetect/polyglot.vim +++ b/ftdetect/polyglot.vim @@ -13,6 +13,8 @@ if exists('g:polyglot_disabled') for pkg in g:polyglot_disabled let s:disabled_packages[pkg] = 1 endfor +else + let g:polyglot_disabled_not_set = 1 endif function! s:SetDefault(name, value) @@ -1948,6 +1950,20 @@ if !has_key(s:disabled_packages, 'autoindent') command! -bar -bang Sleuth call s:detect_indent() endif +func! s:verify() + if exists("g:polyglot_disabled_not_set") + if exists("g:polyglot_disabled") + echohl WarningMsg + echo "vim-polyglot: g:polyglot_disabled should be at the top of .vimrc" + echohl None + endif + + unlet g:polyglot_disabled_not_set + endif +endfunc + +autocmd VimEnter * call s:verify() + " restore Vi compatibility settings let &cpo = s:cpo_save unlet s:cpo_save From 2369cd5d2290c97b69a540dd88222a4ddcb1fe14 Mon Sep 17 00:00:00 2001 From: Adam Stankiewicz Date: Wed, 9 Sep 2020 18:02:38 +0200 Subject: [PATCH 033/299] Make b:sleuth_culprit more readable --- ftdetect/polyglot.vim | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ftdetect/polyglot.vim b/ftdetect/polyglot.vim index 37a2525e8..f44a19591 100644 --- a/ftdetect/polyglot.vim +++ b/ftdetect/polyglot.vim @@ -1799,8 +1799,10 @@ if !has_key(s:disabled_packages, 'autoindent') let heredoc = '' let minindent = 10 let spaces_minus_tabs = 0 + let i = 1 for line in a:lines + let i += 1 if !len(line) || line =~# '^\W*$' continue endif @@ -1874,7 +1876,7 @@ if !has_key(s:disabled_packages, 'autoindent') let indent = len(matchstr(line, '^ *')) if (indent % 2 == 0 || indent % 3 == 0) && indent < minindent let minindent = indent - let b:sleuth_culprit .= ":" . line + let b:sleuth_culprit .= ':' . i endif endif endfor From 2dc954d6fa15c897da59ff14aa4d5991a3329eb5 Mon Sep 17 00:00:00 2001 From: Adam Stankiewicz Date: Wed, 9 Sep 2020 18:07:03 +0200 Subject: [PATCH 034/299] Last fixes to b:sleuth_culprit --- ftdetect/polyglot.vim | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/ftdetect/polyglot.vim b/ftdetect/polyglot.vim index f44a19591..ee74a2935 100644 --- a/ftdetect/polyglot.vim +++ b/ftdetect/polyglot.vim @@ -1887,7 +1887,6 @@ if !has_key(s:disabled_packages, 'autoindent') return 1 endif - unlet b:sleuth_culprit return 0 endfunction @@ -1910,13 +1909,15 @@ if !has_key(s:disabled_packages, 'autoindent') while isdirectory(dir) && dir !=# fnamemodify(dir, ':h') && level > 0 " Ignore files from homedir and root if dir == expand('~') || dir == '/' + unlet b:sleuth_culprit return endif for neighbor in glob(dir . '/' . pattern, 0, 1)[0:level] let b:sleuth_culprit = neighbor " Do not consider directories above .git, .svn or .hg if fnamemodify(neighbor, ":h:t")[0] == "." - return + let level = 0 + continue endif if neighbor !=# expand('%:p') && filereadable(neighbor) if s:guess(readfile(neighbor, '', 32)) @@ -1928,6 +1929,8 @@ if !has_key(s:disabled_packages, 'autoindent') let dir = fnamemodify(dir, ':h') let level -= 1 endwhile + + unlet b:sleuth_culprit endfunction setglobal smarttab From 49840b1893a9ad442c5b7cf65203af47c032e156 Mon Sep 17 00:00:00 2001 From: Adam Stankiewicz Date: Wed, 9 Sep 2020 18:28:23 +0200 Subject: [PATCH 035/299] Show full path in b:sleuth_culprit --- ftdetect/polyglot.vim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ftdetect/polyglot.vim b/ftdetect/polyglot.vim index ee74a2935..273cf26b9 100644 --- a/ftdetect/polyglot.vim +++ b/ftdetect/polyglot.vim @@ -1775,7 +1775,7 @@ endif " end filetypes au BufNewFile,BufRead,StdinReadPost * - \ if !did_filetype() && expand("") !~ g:ft_ignore_pat + \ if !did_filetype() && expand("") !~ g:ft_ignore_pat \ | call polyglot#Heuristics() | endif @@ -1895,7 +1895,7 @@ if !has_key(s:disabled_packages, 'autoindent') return endif - let b:sleuth_culprit = expand("") + let b:sleuth_culprit = expand(":p") if s:guess(getline(1, 32)) return endif From 0ff5d451b0079f5be723276007cfbcc3d1fd06ca Mon Sep 17 00:00:00 2001 From: Adam Stankiewicz Date: Wed, 9 Sep 2020 18:31:30 +0200 Subject: [PATCH 036/299] Fix b:sleuth_culprit for tabs --- ftdetect/polyglot.vim | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ftdetect/polyglot.vim b/ftdetect/polyglot.vim index 273cf26b9..c13df5169 100644 --- a/ftdetect/polyglot.vim +++ b/ftdetect/polyglot.vim @@ -1799,10 +1799,11 @@ if !has_key(s:disabled_packages, 'autoindent') let heredoc = '' let minindent = 10 let spaces_minus_tabs = 0 - let i = 1 + let i = 0 for line in a:lines let i += 1 + if !len(line) || line =~# '^\W*$' continue endif @@ -1871,6 +1872,7 @@ if !has_key(s:disabled_packages, 'autoindent') if line[0] == "\t" setlocal noexpandtab + let b:sleuth_culprit .= ':' . i return 1 elseif line[0] == " " let indent = len(matchstr(line, '^ *')) From 4f7a4036eb4f4d64fa5f30e55f23fbb0de4680dc Mon Sep 17 00:00:00 2001 From: Adam Stankiewicz Date: Wed, 9 Sep 2020 19:08:17 +0200 Subject: [PATCH 037/299] Finally fix issues with tab detection, #541 --- ftdetect/polyglot.vim | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ftdetect/polyglot.vim b/ftdetect/polyglot.vim index c13df5169..a7f808e6a 100644 --- a/ftdetect/polyglot.vim +++ b/ftdetect/polyglot.vim @@ -1872,13 +1872,13 @@ if !has_key(s:disabled_packages, 'autoindent') if line[0] == "\t" setlocal noexpandtab + let &shiftwidth=&tabstop let b:sleuth_culprit .= ':' . i return 1 elseif line[0] == " " let indent = len(matchstr(line, '^ *')) if (indent % 2 == 0 || indent % 3 == 0) && indent < minindent let minindent = indent - let b:sleuth_culprit .= ':' . i endif endif endfor @@ -1886,6 +1886,7 @@ if !has_key(s:disabled_packages, 'autoindent') if minindent < 10 setlocal expandtab let &shiftwidth=minindent + let b:sleuth_culprit .= ':' . i return 1 endif @@ -1971,6 +1972,9 @@ endfunc autocmd VimEnter * call s:verify() +set sw=3 +set ts=8 + " restore Vi compatibility settings let &cpo = s:cpo_save unlet s:cpo_save From 19a69cf77d521d6f3856d2f5c1a2faa678b937ba Mon Sep 17 00:00:00 2001 From: Adam Stankiewicz Date: Wed, 9 Sep 2020 19:22:27 +0200 Subject: [PATCH 038/299] Remove debugging code... --- ftdetect/polyglot.vim | 3 --- 1 file changed, 3 deletions(-) diff --git a/ftdetect/polyglot.vim b/ftdetect/polyglot.vim index a7f808e6a..432b5e010 100644 --- a/ftdetect/polyglot.vim +++ b/ftdetect/polyglot.vim @@ -1972,9 +1972,6 @@ endfunc autocmd VimEnter * call s:verify() -set sw=3 -set ts=8 - " restore Vi compatibility settings let &cpo = s:cpo_save unlet s:cpo_save From fb7cf8a9ab782d67db5aa71bffac67e63fcc0c4c Mon Sep 17 00:00:00 2001 From: Adam Stankiewicz Date: Thu, 10 Sep 2020 10:30:32 +0200 Subject: [PATCH 039/299] Update --- after/ftplugin/javascript.vim | 44 +++++----------------- after/ftplugin/javascriptreact.vim | 2 +- after/ftplugin/jsx.vim | 35 ++++++++++++++++++ after/indent/javascript.vim | 30 ++------------- after/indent/javascriptreact.vim | 2 +- after/indent/jsx.vim | 33 +++++++++++++++++ after/syntax/javascript.vim | 56 ++-------------------------- after/syntax/javascriptreact.vim | 2 +- after/syntax/jsx.vim | 59 ++++++++++++++++++++++++++++++ after/syntax/reason/graphql.vim | 2 +- autoload/go/config.vim | 8 ++++ doc/graphql.txt | 3 +- doc/vim-go.txt | 20 +++++++++- doc/vim-jsx-pretty-doc.txt | 1 + ftdetect/polyglot.vim | 8 ++-- packages.yaml | 1 + scripts/test_filetypes.vim | 2 +- syntax/go.vim | 4 +- 18 files changed, 183 insertions(+), 129 deletions(-) create mode 100644 after/ftplugin/jsx.vim create mode 100644 after/indent/jsx.vim create mode 100644 after/syntax/jsx.vim diff --git a/after/ftplugin/javascript.vim b/after/ftplugin/javascript.vim index a590e11d5..8ff3938a3 100644 --- a/after/ftplugin/javascript.vim +++ b/after/ftplugin/javascript.vim @@ -1,3 +1,12 @@ +if !exists('g:polyglot_disabled') || (index(g:polyglot_disabled, 'javascript') == -1 && index(g:polyglot_disabled, 'jsx') == -1) + +if get(g:, 'vim_jsx_pretty_disable_js', 0) + finish +endif + +source :h/jsx.vim + +endif if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'javascript') == -1 " Vim filetype plugin file @@ -14,38 +23,3 @@ else endif endif -if !exists('g:polyglot_disabled') || (index(g:polyglot_disabled, 'javascript') == -1 && index(g:polyglot_disabled, 'jsx') == -1) - -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -" Vim ftplugin file -" -" Language: javascript.jsx -" Maintainer: MaxMEllon -" -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" - -" modified from html.vim -" For matchit plugin -if exists("loaded_matchit") - let b:match_ignorecase = 0 - let b:match_words = '(:),\[:\],{:},<:>,' . - \ '<\@<=\([^/][^ \t>]*\)[^>]*\%(>\|$\):<\@<=/\1>' -endif - -" For andymass/vim-matchup plugin -if exists("loaded_matchup") - setlocal matchpairs=(:),{:},[:],<:> - let b:match_words = '<\@<=\([^/][^ \t>]*\)\g{hlend}[^>]*\%(/\@\|$\):<\@<=/\1>' - let b:match_skip = 's:comment\|string' -endif - -let b:jsx_pretty_old_cms = &l:commentstring - -augroup jsx_comment - autocmd! CursorMoved - autocmd CursorMoved call jsx_pretty#comment#update_commentstring(b:jsx_pretty_old_cms) -augroup end - -setlocal suffixesadd+=.jsx - -endif diff --git a/after/ftplugin/javascriptreact.vim b/after/ftplugin/javascriptreact.vim index ab847072d..265415d0e 100644 --- a/after/ftplugin/javascriptreact.vim +++ b/after/ftplugin/javascriptreact.vim @@ -1,5 +1,5 @@ if !exists('g:polyglot_disabled') || (index(g:polyglot_disabled, 'javascript') == -1 && index(g:polyglot_disabled, 'jsx') == -1) -source :h/javascript.vim +source :h/jsx.vim endif diff --git a/after/ftplugin/jsx.vim b/after/ftplugin/jsx.vim new file mode 100644 index 000000000..94f90c13f --- /dev/null +++ b/after/ftplugin/jsx.vim @@ -0,0 +1,35 @@ +if !exists('g:polyglot_disabled') || (index(g:polyglot_disabled, 'javascript') == -1 && index(g:polyglot_disabled, 'jsx') == -1) + +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" Vim ftplugin file +" +" Language: javascript.jsx +" Maintainer: MaxMEllon +" +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" + +" modified from html.vim +" For matchit plugin +if exists("loaded_matchit") + let b:match_ignorecase = 0 + let b:match_words = '(:),\[:\],{:},<:>,' . + \ '<\@<=\([^/][^ \t>]*\)[^>]*\%(>\|$\):<\@<=/\1>' +endif + +" For andymass/vim-matchup plugin +if exists("loaded_matchup") + setlocal matchpairs=(:),{:},[:],<:> + let b:match_words = '<\@<=\([^/][^ \t>]*\)\g{hlend}[^>]*\%(/\@\|$\):<\@<=/\1>' + let b:match_skip = 's:comment\|string' +endif + +let b:jsx_pretty_old_cms = &l:commentstring + +augroup jsx_comment + autocmd! CursorMoved + autocmd CursorMoved call jsx_pretty#comment#update_commentstring(b:jsx_pretty_old_cms) +augroup end + +setlocal suffixesadd+=.jsx + +endif diff --git a/after/indent/javascript.vim b/after/indent/javascript.vim index dd280edb6..0add1da1a 100644 --- a/after/indent/javascript.vim +++ b/after/indent/javascript.vim @@ -47,34 +47,10 @@ endfunction endif if !exists('g:polyglot_disabled') || (index(g:polyglot_disabled, 'javascript') == -1 && index(g:polyglot_disabled, 'jsx') == -1) -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -" Vim indent file -" -" Language: javascript.jsx -" Maintainer: MaxMellon -" -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" - -if exists('b:did_indent') - let s:did_indent = b:did_indent - unlet b:did_indent -endif - -let s:keepcpo = &cpo -set cpo&vim - -if exists('s:did_indent') - let b:did_indent = s:did_indent +if get(g:, 'vim_jsx_pretty_disable_js', 0) + finish endif -setlocal indentexpr=GetJsxIndent() -setlocal indentkeys=0.,0{,0},0),0],0?,0\*,0\,,!^F,:,<:>,o,O,e,<>>,=*/ - -function! GetJsxIndent() - return jsx_pretty#indent#get(function('GetJavascriptIndent')) -endfunction - -let &cpo = s:keepcpo -unlet s:keepcpo +source :h/jsx.vim endif diff --git a/after/indent/javascriptreact.vim b/after/indent/javascriptreact.vim index ab847072d..265415d0e 100644 --- a/after/indent/javascriptreact.vim +++ b/after/indent/javascriptreact.vim @@ -1,5 +1,5 @@ if !exists('g:polyglot_disabled') || (index(g:polyglot_disabled, 'javascript') == -1 && index(g:polyglot_disabled, 'jsx') == -1) -source :h/javascript.vim +source :h/jsx.vim endif diff --git a/after/indent/jsx.vim b/after/indent/jsx.vim new file mode 100644 index 000000000..fcd7b5adc --- /dev/null +++ b/after/indent/jsx.vim @@ -0,0 +1,33 @@ +if !exists('g:polyglot_disabled') || (index(g:polyglot_disabled, 'javascript') == -1 && index(g:polyglot_disabled, 'jsx') == -1) + +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" Vim indent file +" +" Language: javascript.jsx +" Maintainer: MaxMellon +" +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" + +if exists('b:did_indent') + let s:did_indent = b:did_indent + unlet b:did_indent +endif + +let s:keepcpo = &cpo +set cpo&vim + +if exists('s:did_indent') + let b:did_indent = s:did_indent +endif + +setlocal indentexpr=GetJsxIndent() +setlocal indentkeys=0.,0{,0},0),0],0?,0\*,0\,,!^F,:,<:>,o,O,e,<>>,=*/ + +function! GetJsxIndent() + return jsx_pretty#indent#get(function('GetJavascriptIndent')) +endfunction + +let &cpo = s:keepcpo +unlet s:keepcpo + +endif diff --git a/after/syntax/javascript.vim b/after/syntax/javascript.vim index 00c4b0791..2992e9427 100644 --- a/after/syntax/javascript.vim +++ b/after/syntax/javascript.vim @@ -1,59 +1,9 @@ if !exists('g:polyglot_disabled') || (index(g:polyglot_disabled, 'javascript') == -1 && index(g:polyglot_disabled, 'jsx') == -1) -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -" Vim syntax file -" -" Language: javascript.jsx -" Maintainer: MaxMellon -" -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" - -let s:jsx_cpo = &cpo -set cpo&vim - -syntax case match - -if exists('b:current_syntax') - let s:current_syntax = b:current_syntax - unlet b:current_syntax -endif - -if exists('s:current_syntax') - let b:current_syntax = s:current_syntax -endif - -if hlexists("jsDebugger") || hlexists("jsNoise") " yuezk/vim-js or pangloss/vim-javascript - syntax cluster jsExpression add=jsxRegion -elseif hlexists("javascriptOpSymbols") " othree/yajs.vim - " refine the javascript line comment - syntax region javascriptLineComment start=+//+ end=/$/ contains=@Spell,javascriptCommentTodo extend keepend - syntax cluster javascriptValue add=jsxRegion - syntax cluster javascriptNoReserved add=jsxElement,jsxTag -else " build-in javascript syntax - " refine the javascript line comment - syntax region javaScriptLineComment start=+//+ end=/$/ contains=@Spell,javascriptCommentTodo extend keepend - - " refine the template string syntax - syntax region javaScriptEmbed matchgroup=javaScriptEmbedBraces start=+\${+ end=+}+ contained contains=@javaScriptEmbededExpr - - " add a javaScriptBlock group for build-in syntax - syntax region javaScriptBlock - \ matchgroup=javaScriptBraces - \ start="{" - \ end="}" - \ contained - \ extend - \ contains=javaScriptBlock,@javaScriptEmbededExpr,javaScript.* - \ fold - - syntax cluster javaScriptEmbededExpr add=jsxRegion,javaScript.* +if get(g:, 'vim_jsx_pretty_disable_js', 0) + finish endif -runtime syntax/jsx_pretty.vim - -let b:current_syntax = 'javascript.jsx' - -let &cpo = s:jsx_cpo -unlet s:jsx_cpo +source :h/jsx.vim endif diff --git a/after/syntax/javascriptreact.vim b/after/syntax/javascriptreact.vim index ab847072d..265415d0e 100644 --- a/after/syntax/javascriptreact.vim +++ b/after/syntax/javascriptreact.vim @@ -1,5 +1,5 @@ if !exists('g:polyglot_disabled') || (index(g:polyglot_disabled, 'javascript') == -1 && index(g:polyglot_disabled, 'jsx') == -1) -source :h/javascript.vim +source :h/jsx.vim endif diff --git a/after/syntax/jsx.vim b/after/syntax/jsx.vim new file mode 100644 index 000000000..00c4b0791 --- /dev/null +++ b/after/syntax/jsx.vim @@ -0,0 +1,59 @@ +if !exists('g:polyglot_disabled') || (index(g:polyglot_disabled, 'javascript') == -1 && index(g:polyglot_disabled, 'jsx') == -1) + +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" Vim syntax file +" +" Language: javascript.jsx +" Maintainer: MaxMellon +" +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" + +let s:jsx_cpo = &cpo +set cpo&vim + +syntax case match + +if exists('b:current_syntax') + let s:current_syntax = b:current_syntax + unlet b:current_syntax +endif + +if exists('s:current_syntax') + let b:current_syntax = s:current_syntax +endif + +if hlexists("jsDebugger") || hlexists("jsNoise") " yuezk/vim-js or pangloss/vim-javascript + syntax cluster jsExpression add=jsxRegion +elseif hlexists("javascriptOpSymbols") " othree/yajs.vim + " refine the javascript line comment + syntax region javascriptLineComment start=+//+ end=/$/ contains=@Spell,javascriptCommentTodo extend keepend + syntax cluster javascriptValue add=jsxRegion + syntax cluster javascriptNoReserved add=jsxElement,jsxTag +else " build-in javascript syntax + " refine the javascript line comment + syntax region javaScriptLineComment start=+//+ end=/$/ contains=@Spell,javascriptCommentTodo extend keepend + + " refine the template string syntax + syntax region javaScriptEmbed matchgroup=javaScriptEmbedBraces start=+\${+ end=+}+ contained contains=@javaScriptEmbededExpr + + " add a javaScriptBlock group for build-in syntax + syntax region javaScriptBlock + \ matchgroup=javaScriptBraces + \ start="{" + \ end="}" + \ contained + \ extend + \ contains=javaScriptBlock,@javaScriptEmbededExpr,javaScript.* + \ fold + + syntax cluster javaScriptEmbededExpr add=jsxRegion,javaScript.* +endif + +runtime syntax/jsx_pretty.vim + +let b:current_syntax = 'javascript.jsx' + +let &cpo = s:jsx_cpo +unlet s:jsx_cpo + +endif diff --git a/after/syntax/reason/graphql.vim b/after/syntax/reason/graphql.vim index 44a5c846d..4f4ba44c7 100644 --- a/after/syntax/reason/graphql.vim +++ b/after/syntax/reason/graphql.vim @@ -32,6 +32,6 @@ if exists('s:current_syntax') let b:current_syntax = s:current_syntax endif -syntax region graphqlMultilineString matchgroup=reasonMultilineString start=+graphql\_s*\zs{|+ end=+|}+ contains=@GraphQLSyntax,reasonEscape,reasonEscapeUnicode,reasonEscapeError,reasonStringContinuation keepend +syntax region graphqlExtensionPoint matchgroup=Noise start=+\[%graphql\_s*{|+lc=10 end=+|}\_s*]+he=s+1 contains=@GraphQLSyntax keepend endif diff --git a/autoload/go/config.vim b/autoload/go/config.vim index 956da2207..55bc1902c 100644 --- a/autoload/go/config.vim +++ b/autoload/go/config.vim @@ -552,6 +552,14 @@ function! go#config#GoplsLocal() abort return get(g:, 'go_gopls_local', v:null) endfunction +function! go#config#GoplsGofumpt() abort + return get(g:, 'go_gopls_gofumpt', v:null) +endfunction + +function! go#config#GoplsSettings() abort + return get(g:, 'go_gopls_settings', v:null) +endfunction + function! go#config#GoplsEnabled() abort return get(g:, 'go_gopls_enabled', 1) endfunction diff --git a/doc/graphql.txt b/doc/graphql.txt index 3f41deaa4..868c74d85 100644 --- a/doc/graphql.txt +++ b/doc/graphql.txt @@ -46,8 +46,7 @@ the list of recognized template tag names. REASONML *graphql-reasonml* GraphQL syntax support inside of ReasonML template strings using graphql-ppx -is available when vim-reasonml (https://github.com/jordwalke/vim-reasonml) is -also installed. +is available. ------------------------------------------------------------------------------ vim:tw=78:ft=help:norl: diff --git a/doc/vim-go.txt b/doc/vim-go.txt index e00dec9b1..b92ab5b9c 100644 --- a/doc/vim-go.txt +++ b/doc/vim-go.txt @@ -802,7 +802,7 @@ CTRL-t You can define a constant value instead of the default field based value. For example the following command will add ``valid:"1"`` to all fields. > - :GoAddTags valid=1 + :GoAddTags valid:1 < *:GoRemoveTags* :[range]GoRemoveTags [key],[option] [key1],[option1] ... @@ -1876,6 +1876,24 @@ is `v:null`. let g:go_gopls_local = v:null < + *'g:go_gopls_gofumpt'* + +Specifies whether `gopls` should use `gofumpt` for formatting. When it is +`v:null`, `gopls`' default will be used. By default it is `v:null`. +> + let g:go_gopls_gofumpt = v:null +< + + *'g:go_gopls_settings'* + +Specifies `gopls` workspace settings for `gopls` that are not yet officially +supported by vim-go. Any value in the dictionary will be overridden by values +provided in the specific options supported by vim-go (e.g. +g:go_gopls_staticcheck) or settings statically configured by vim-go to ensure +expected behavior. By default it is `v:null`. +> + let g:go_gopls_settings = v:null +< *'g:go_diagnostics_enabled'* Specifies whether `gopls` diagnostics are enabled. Only the diagnostics for diff --git a/doc/vim-jsx-pretty-doc.txt b/doc/vim-jsx-pretty-doc.txt index a561e4754..cc170976d 100644 --- a/doc/vim-jsx-pretty-doc.txt +++ b/doc/vim-jsx-pretty-doc.txt @@ -46,6 +46,7 @@ CONFIG *vim-jsx-pretty-config* |---------------------------------------|---------|----------------------| | g:vim_jsx_pretty_enable_jsx_highlight | 1 | jsx highlight flag | | g:vim_jsx_pretty_colorful_config | 0 | colorful config flag | + | g:vim_jsx_pretty_disable_js | 0 | js toggle flag | < - *g:vim_jsx_pretty_enable_jsx_highlight* diff --git a/ftdetect/polyglot.vim b/ftdetect/polyglot.vim index 432b5e010..e49a966d4 100644 --- a/ftdetect/polyglot.vim +++ b/ftdetect/polyglot.vim @@ -851,6 +851,10 @@ if !has_key(s:disabled_packages, 'ion') au BufNewFile,BufRead ~/.config/ion/initrc setf ion endif +if !has_key(s:disabled_packages, 'jsx') + au BufNewFile,BufRead *.jsx setf javascriptreact +endif + if !has_key(s:disabled_packages, 'javascript') au BufNewFile,BufRead *._js setf javascript au BufNewFile,BufRead *.bones setf javascript @@ -939,10 +943,6 @@ if !has_key(s:disabled_packages, 'jst') au BufNewFile,BufRead *.jst setf jst endif -if !has_key(s:disabled_packages, 'jsx') - au BufNewFile,BufRead *.jsx setf javascriptreact -endif - if !has_key(s:disabled_packages, 'julia') au BufNewFile,BufRead *.jl setf julia endif diff --git a/packages.yaml b/packages.yaml index 3ddc5776b..dfb17252f 100644 --- a/packages.yaml +++ b/packages.yaml @@ -921,6 +921,7 @@ filetypes: --- name: jsx remote: MaxMEllon/vim-jsx-pretty +after: javascript filetypes: - name: javascriptreact linguist: JSX diff --git a/scripts/test_filetypes.vim b/scripts/test_filetypes.vim index 42e683d17..e7ae65114 100644 --- a/scripts/test_filetypes.vim +++ b/scripts/test_filetypes.vim @@ -109,6 +109,7 @@ call TestFiletype('idris') call TestFiletype('idris2') call TestFiletype('lidris2') call TestFiletype('ion') +call TestFiletype('javascriptreact') call TestFiletype('javascript') call TestFiletype('flow') call TestFiletype('Jenkinsfile') @@ -118,7 +119,6 @@ call TestFiletype('json5') call TestFiletype('json') call TestFiletype('jsonnet') call TestFiletype('jst') -call TestFiletype('javascriptreact') call TestFiletype('julia') call TestFiletype('kotlin') call TestFiletype('ledger') diff --git a/syntax/go.vim b/syntax/go.vim index 93d6fbc4d..73f280370 100644 --- a/syntax/go.vim +++ b/syntax/go.vim @@ -424,8 +424,8 @@ function! s:hi() " :GoDebug commands if go#config#HighlightDebug() - hi GoDebugBreakpoint term=standout ctermbg=117 ctermfg=0 guibg=#BAD4F5 guifg=Black - hi GoDebugCurrent term=reverse ctermbg=12 ctermfg=7 guibg=DarkBlue guifg=White + hi def GoDebugBreakpoint term=standout ctermbg=117 ctermfg=0 guibg=#BAD4F5 guifg=Black + hi def GoDebugCurrent term=reverse ctermbg=12 ctermfg=7 guibg=DarkBlue guifg=White endif endfunction From be092d6f430ca802d7200e68a5c987195bccd0e9 Mon Sep 17 00:00:00 2001 From: Adam Stankiewicz Date: Thu, 10 Sep 2020 12:18:29 +0200 Subject: [PATCH 040/299] Fix jsx indentation, closes #543 --- after/ftplugin/javascript-1.vim | 16 ++ after/ftplugin/javascript-2.vim | 9 + after/ftplugin/javascript.vim | 28 +-- after/indent/javascript.vim | 47 ----- after/indent/typescript.vim | 47 ----- packages.yaml | 5 + scripts/build | 31 +++- syntax/html-1.vim | 94 ++++++++++ syntax/html-2.vim | 196 +++++++++++++++++++++ syntax/html.vim | 293 +------------------------------- 10 files changed, 355 insertions(+), 411 deletions(-) create mode 100644 after/ftplugin/javascript-1.vim create mode 100644 after/ftplugin/javascript-2.vim delete mode 100644 after/indent/typescript.vim create mode 100644 syntax/html-1.vim create mode 100644 syntax/html-2.vim diff --git a/after/ftplugin/javascript-1.vim b/after/ftplugin/javascript-1.vim new file mode 100644 index 000000000..9f6c9314b --- /dev/null +++ b/after/ftplugin/javascript-1.vim @@ -0,0 +1,16 @@ +if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'javascript') == -1 + +" Vim filetype plugin file +" Language: JavaScript +" Maintainer: vim-javascript community +" URL: https://github.com/pangloss/vim-javascript + +setlocal iskeyword+=$ suffixesadd+=.js + +if exists('b:undo_ftplugin') + let b:undo_ftplugin .= ' | setlocal iskeyword< suffixesadd<' +else + let b:undo_ftplugin = 'setlocal iskeyword< suffixesadd<' +endif + +endif diff --git a/after/ftplugin/javascript-2.vim b/after/ftplugin/javascript-2.vim new file mode 100644 index 000000000..2992e9427 --- /dev/null +++ b/after/ftplugin/javascript-2.vim @@ -0,0 +1,9 @@ +if !exists('g:polyglot_disabled') || (index(g:polyglot_disabled, 'javascript') == -1 && index(g:polyglot_disabled, 'jsx') == -1) + +if get(g:, 'vim_jsx_pretty_disable_js', 0) + finish +endif + +source :h/jsx.vim + +endif diff --git a/after/ftplugin/javascript.vim b/after/ftplugin/javascript.vim index 8ff3938a3..e3d355fcb 100644 --- a/after/ftplugin/javascript.vim +++ b/after/ftplugin/javascript.vim @@ -1,25 +1,3 @@ -if !exists('g:polyglot_disabled') || (index(g:polyglot_disabled, 'javascript') == -1 && index(g:polyglot_disabled, 'jsx') == -1) - -if get(g:, 'vim_jsx_pretty_disable_js', 0) - finish -endif - -source :h/jsx.vim - -endif -if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'javascript') == -1 - -" Vim filetype plugin file -" Language: JavaScript -" Maintainer: vim-javascript community -" URL: https://github.com/pangloss/vim-javascript - -setlocal iskeyword+=$ suffixesadd+=.js - -if exists('b:undo_ftplugin') - let b:undo_ftplugin .= ' | setlocal iskeyword< suffixesadd<' -else - let b:undo_ftplugin = 'setlocal iskeyword< suffixesadd<' -endif - -endif +" Polyglot metafile +source :h/javascript-1.vim +source :h/javascript-2.vim diff --git a/after/indent/javascript.vim b/after/indent/javascript.vim index 0add1da1a..2992e9427 100644 --- a/after/indent/javascript.vim +++ b/after/indent/javascript.vim @@ -1,50 +1,3 @@ -if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'graphql') == -1 - -" Copyright (c) 2016-2020 Jon Parise -" -" Permission is hereby granted, free of charge, to any person obtaining a copy -" of this software and associated documentation files (the "Software"), to -" deal in the Software without restriction, including without limitation the -" rights to use, copy, modify, merge, publish, distribute, sublicense, and/or -" sell copies of the Software, and to permit persons to whom the Software is -" furnished to do so, subject to the following conditions: -" -" The above copyright notice and this permission notice shall be included in -" all copies or substantial portions of the Software. -" -" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -" IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -" FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -" AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -" LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -" FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS -" IN THE SOFTWARE. -" -" Language: GraphQL -" Maintainer: Jon Parise - -runtime! indent/graphql.vim - -" Don't redefine our function and also require the standard Javascript indent -" function to exist. -if exists('*GetJavascriptGraphQLIndent') || !exists('*GetJavascriptIndent') - finish -endif - -" Set the indentexpr with our own version that will call GetGraphQLIndent when -" we're inside of a GraphQL string and otherwise defer to GetJavascriptIndent. -setlocal indentexpr=GetJavascriptGraphQLIndent() - -function GetJavascriptGraphQLIndent() - let l:stack = map(synstack(v:lnum, 1), "synIDattr(v:val,'name')") - if !empty(l:stack) && l:stack[0] ==# 'graphqlTemplateString' - return GetGraphQLIndent() - endif - - return GetJavascriptIndent() -endfunction - -endif if !exists('g:polyglot_disabled') || (index(g:polyglot_disabled, 'javascript') == -1 && index(g:polyglot_disabled, 'jsx') == -1) if get(g:, 'vim_jsx_pretty_disable_js', 0) diff --git a/after/indent/typescript.vim b/after/indent/typescript.vim deleted file mode 100644 index 968517c89..000000000 --- a/after/indent/typescript.vim +++ /dev/null @@ -1,47 +0,0 @@ -if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'graphql') == -1 - -" Copyright (c) 2016-2020 Jon Parise -" -" Permission is hereby granted, free of charge, to any person obtaining a copy -" of this software and associated documentation files (the "Software"), to -" deal in the Software without restriction, including without limitation the -" rights to use, copy, modify, merge, publish, distribute, sublicense, and/or -" sell copies of the Software, and to permit persons to whom the Software is -" furnished to do so, subject to the following conditions: -" -" The above copyright notice and this permission notice shall be included in -" all copies or substantial portions of the Software. -" -" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -" IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -" FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -" AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -" LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -" FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS -" IN THE SOFTWARE. -" -" Language: GraphQL -" Maintainer: Jon Parise - -runtime! indent/graphql.vim - -" Don't redefine our function and also require the standard Typescript indent -" function to exist. -if exists('*GetTypescriptGraphQLIndent') || !exists('*GetTypescriptIndent') - finish -endif - -" Set the indentexpr with our own version that will call GetGraphQLIndent when -" we're inside of a GraphQL string and otherwise defer to GetTypescriptIndent. -setlocal indentexpr=GetTypescriptGraphQLIndent() - -function GetTypescriptGraphQLIndent() - let l:stack = map(synstack(v:lnum, 1), "synIDattr(v:val,'name')") - if !empty(l:stack) && l:stack[0] ==# 'graphqlTemplateString' - return GetGraphQLIndent() - endif - - return GetTypescriptIndent() -endfunction - -endif diff --git a/packages.yaml b/packages.yaml index dfb17252f..483672545 100644 --- a/packages.yaml +++ b/packages.yaml @@ -679,6 +679,11 @@ filetypes: --- name: graphql remote: jparise/vim-graphql +after: [javascript, jsx] +ignored_dirs: +# TODO: remove after bug is fixed: +# https://github.com/jparise/vim-graphql/issues/62 +- after/indent filetypes: - name: graphql linguist: GraphQL diff --git a/scripts/build b/scripts/build index 699933740..7503ebff1 100755 --- a/scripts/build +++ b/scripts/build @@ -36,6 +36,7 @@ def load_data() end end + puts deps["javascript"] each_node = lambda {|&b| packages.keys.each(&b) } each_child = lambda {|n, &b| deps[n].each(&b) } @@ -168,8 +169,33 @@ def copy_file(package, src, dest) FileUtils.mkdir_p(File.dirname(dest)) name = package.fetch("name") + header = '" Polyglot metafile' + if File.exist?(dest) + meta_dest = dest + new_dest = dest + i = 0 + while File.exist?(new_dest) + i += 1 + new_dest = "#{dest.gsub(/\.vim$/, '')}-#{i}.vim" + end + + if File.read(dest).include?(header) + dest = new_dest + else + FileUtils.mv(dest, new_dest) + File.write(meta_dest, "#{header}\n") + open(meta_dest, "a+") do |output| + output << "source :h/#{File.basename(new_dest)}\n" + end + dest = "#{dest.gsub(/\.vim$/, '')}-#{i+1}.vim" + end + open(meta_dest, "a+") do |output| + output << "source :h/#{File.basename(dest)}\n" + end + end + open(src, "r") do |input| - open(dest, "a+") do |output| + open(dest, "w") do |output| if name == "jsx" output << "if !exists('g:polyglot_disabled') || (index(g:polyglot_disabled, 'javascript') == -1 && index(g:polyglot_disabled, 'jsx') == -1)\n\n" else @@ -335,7 +361,8 @@ def extract(packages) FileUtils.rm_rf(all_dirs) output = [] - packages.map do |package| + # We need to reverse packages so they are included in proper order + packages.reverse.map do |package| repo, branch, path, dir = parse_remote(package["remote"]) dirs = package.fetch("dirs", default_dirs) ignored_dirs = package.fetch("ignored_dirs", []) diff --git a/syntax/html-1.vim b/syntax/html-1.vim new file mode 100644 index 000000000..ddca92d4c --- /dev/null +++ b/syntax/html-1.vim @@ -0,0 +1,94 @@ +if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'jinja') == -1 + +" Vim syntax file +" Language: HTML (version 5) +" Maintainer: Rodrigo Machado +" URL: http://rm.blog.br/vim/syntax/html.vim +" Last Change: 2009 Aug 19 +" License: Public domain +" (but let me know if you like :) ) +" +" Note: This file just adds the new tags from HTML 5 +" and don't replace default html.vim syntax file +" +" Modified: othree +" Changes: update to Draft 28 August 2010 +" add complete new attributes +" add wai-aria attributes +" add microdata attributes +" add rdfa attributes + + +syn keyword htmlTagName contained script +" HTML 5 tags +syn keyword htmlTagName contained article aside audio canvas command +syn keyword htmlTagName contained datalist details dialog embed figcaption figure footer +syn keyword htmlTagName contained header hgroup keygen mark meter menu nav output +syn keyword htmlTagName contained progress time ruby rt rp section source summary time track video wbr + +" HTML 5 arguments +" Core Attributes +syn keyword htmlArg contained accesskey class contenteditable contextmenu dir +syn keyword htmlArg contained draggable hidden id lang spellcheck style tabindex title +" Event-handler Attributes +syn keyword htmlArg contained onabort onblur oncanplay oncanplaythrough onchange +syn keyword htmlArg contained onclick oncontextmenu ondblclick ondrag ondragend ondragenter ondragleave ondragover +syn keyword htmlArg contained ondragstart ondrop ondurationchange onemptied onended onerror onfocus onformchange +syn keyword htmlArg contained onforminput oninput oninvalid onkeydown onkeypress onkeyup onload onloadeddata +syn keyword htmlArg contained onloadedmetadata onloadstart onmousedown onmousemove onmouseout onmouseover onmouseup +syn keyword htmlArg contained onmousewheel onpause onplay onplaying onprogress onratechange onreadystatechange +syn keyword htmlArg contained onscroll onseeked onseeking onselect onshow onstalled onsubmit onsuspend ontimeupdate +syn keyword htmlArg contained onvolumechange onwaiting +" XML Attributes +syn keyword htmlArg contained xml:lang xml:space xml:base +" new features +" +syn keyword htmlArg contained onafterprint onbeforeprint onbeforeunload onblur onerror onfocus onhashchange onload +syn keyword htmlArg contained onmessage onoffline ononline onpopstate onredo onresize onstorage onundo onunload +"