diff options
author | Adam Stankiewicz <sheerun@sher.pl> | 2020-08-06 13:42:56 +0200 |
---|---|---|
committer | Adam Stankiewicz <sheerun@sher.pl> | 2020-08-06 13:42:56 +0200 |
commit | 34e01b8b62701afbd6b4ab1ffb4057617f540dce (patch) | |
tree | a124fcdc4f9205174c78564c02892099f2b754fb | |
parent | 1e533e5982a9c80f262b09fbe94e1ac4555ad915 (diff) | |
download | vim-polyglot-34e01b8b62701afbd6b4ab1ffb4057617f540dce.tar.gz vim-polyglot-34e01b8b62701afbd6b4ab1ffb4057617f540dce.zip |
Start github-linguist rewrite
-rwxr-xr-x | build | 2 | ||||
-rwxr-xr-x | build.py | 43 | ||||
-rw-r--r-- | ftdetect/polyglot.vim | 42 | ||||
-rw-r--r-- | ftdetect/polyglot_auto.vim | 59 |
4 files changed, 104 insertions, 42 deletions
@@ -291,6 +291,8 @@ PACKS=" zinit:zinit-zsh/zplugin-vim-syntax " +python3 build.py + rm -rf tmp rm -rf "${DIRS_RM[@]}" mkdir tmp diff --git a/build.py b/build.py new file mode 100755 index 00000000..ffe09471 --- /dev/null +++ b/build.py @@ -0,0 +1,43 @@ +#!/usr/bin/env python3 + +import yaml +import urllib.request as request + +url = 'https://raw.githubusercontent.com/github/linguist/master/lib/linguist/languages.yml' +data = yaml.safe_load(request.urlopen(url)) + +lines = [] + +def language(name, + filetype=None, + polyglot=None, + extensions=None, + filenames=None, + extra_extensions=[], + extra_filenames=[] +): + language = data.get(name, {}) + filetype_name = filetype or name.lower().replace(" ", "") + polyglot_name = polyglot or filetype_name + lines.append(f"if index(g:polyglot_disabled, '{polyglot_name}') == -1") + for ext in (extensions or language.get("extensions", [])) + extra_extensions: + lines.append(f" au BufNewFile,BufRead *{ext} set ft={filetype_name}") + for fn in (filenames or language.get("filenames", [])) + extra_filenames: + lines.append(f" au BufNewFile,BufRead {fn} set ft={filetype_name}") + lines.append("endif") + lines.append("") + +language("ASL", polyglot="acpiasl", extensions=[".asl", ".dsl"]) +language("API Blueprint") +language("AppleScript") +language("Processing", filetype="arduino", extra_extensions=[".ino"]) +language("AsciiDoc") +language("Blade") +language("Caddyfile", extensions=["Caddyfile"]) +language("Carp", extensions=[".carp"]) +language("CoffeeScript", filetype="coffee") +language("Clojure") + +f = open("ftdetect/polyglot_auto.vim", "w") +f.write("\n".join(lines)) +f.close() diff --git a/ftdetect/polyglot.vim b/ftdetect/polyglot.vim index 9bf5a146..b6b51ac1 100644 --- a/ftdetect/polyglot.vim +++ b/ftdetect/polyglot.vim @@ -46,48 +46,6 @@ 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) -if index(g:polyglot_disabled, 'acpiasl') == -1 - au BufNewFile,BufRead *.asl set ft=asl - au BufNewFile,BufRead *.dsl set ft=asl -endif - -if index(g:polyglot_disabled, 'apiblueprint') == -1 - au BufNewFile,BufRead *.apib set ft=apiblueprint -endif - -if index(g:polyglot_disabled, 'applescript') == -1 - au BufNewFile,BufRead *.scpt set ft=applescript - au BufNewFile,BufRead *.applescript set ft=applescript -endif - -if index(g:polyglot_disabled, 'arduino') == -1 - au BufNewFile,BufRead *.ino,*.pde set ft=arduino -endif - -if index(g:polyglot_disabled, 'asciidoc') == -1 - au BufNewFile,BufRead *.asciidoc,*.adoc set ft=asciidoc -endif - -if index(g:polyglot_disabled, 'blade') == -1 - au BufNewFile,BufRead *.blade.php set ft=blade -endif - -if index(g:polyglot_disabled, 'brewfile') == -1 - au BufNewFile,BufRead Brewfile,.Brewfile set ft=ruby syn=brewfile -endif - -if index(g:polyglot_disabled, 'caddyfile') == -1 - au BufNewFile,BufRead Caddyfile set ft=caddyfile -endif - -if index(g:polyglot_disabled, 'carp') == -1 - au BufNewFile,BufRead *.carp set ft=carp -endif - -if index(g:polyglot_disabled, 'cjsx') == -1 - au BufNewFile,BufRead *.csx,*.cjsx set ft=coffee -endif - if index(g:polyglot_disabled, 'clojure') == -1 au BufNewFile,BufRead *.clj,*.cljs,*.edn,*.cljx,*.cljc,{build,profile}.boot set ft=clojure endif diff --git a/ftdetect/polyglot_auto.vim b/ftdetect/polyglot_auto.vim new file mode 100644 index 00000000..75dd91fd --- /dev/null +++ b/ftdetect/polyglot_auto.vim @@ -0,0 +1,59 @@ +if index(g:polyglot_disabled, 'acpiasl') == -1 + au BufNewFile,BufRead *.asl set ft=asl + au BufNewFile,BufRead *.dsl set ft=asl +endif + +if index(g:polyglot_disabled, 'apiblueprint') == -1 + au BufNewFile,BufRead *.apib set ft=apiblueprint +endif + +if index(g:polyglot_disabled, 'applescript') == -1 + au BufNewFile,BufRead *.applescript set ft=applescript + au BufNewFile,BufRead *.scpt set ft=applescript +endif + +if index(g:polyglot_disabled, 'arduino') == -1 + au BufNewFile,BufRead *.pde set ft=arduino + au BufNewFile,BufRead *.ino set ft=arduino +endif + +if index(g:polyglot_disabled, 'asciidoc') == -1 + au BufNewFile,BufRead *.asciidoc set ft=asciidoc + au BufNewFile,BufRead *.adoc set ft=asciidoc + au BufNewFile,BufRead *.asc set ft=asciidoc +endif + +if index(g:polyglot_disabled, 'blade') == -1 + au BufNewFile,BufRead *.blade set ft=blade + au BufNewFile,BufRead *.blade.php set ft=blade +endif + +if index(g:polyglot_disabled, 'caddyfile') == -1 + au BufNewFile,BufRead *Caddyfile set ft=caddyfile +endif + +if index(g:polyglot_disabled, 'carp') == -1 + au BufNewFile,BufRead *.carp set ft=carp +endif + +if index(g:polyglot_disabled, 'coffee') == -1 + au BufNewFile,BufRead *.coffee set ft=coffee + au BufNewFile,BufRead *._coffee set ft=coffee + au BufNewFile,BufRead *.cake set ft=coffee + au BufNewFile,BufRead *.cjsx set ft=coffee + au BufNewFile,BufRead *.iced set ft=coffee + au BufNewFile,BufRead Cakefile set ft=coffee +endif + +if index(g:polyglot_disabled, 'clojure') == -1 + au BufNewFile,BufRead *.clj set ft=clojure + au BufNewFile,BufRead *.boot set ft=clojure + au BufNewFile,BufRead *.cl2 set ft=clojure + au BufNewFile,BufRead *.cljc set ft=clojure + au BufNewFile,BufRead *.cljs set ft=clojure + au BufNewFile,BufRead *.cljs.hl set ft=clojure + au BufNewFile,BufRead *.cljscm set ft=clojure + au BufNewFile,BufRead *.cljx set ft=clojure + au BufNewFile,BufRead *.hic set ft=clojure + au BufNewFile,BufRead riemann.config set ft=clojure +endif |