Compare commits

..

17 Commits

Author SHA1 Message Date
Adam Stankiewicz
25db54573a Mention vim-polyglot is more secure than using individual packs 2020-08-24 10:32:03 +02:00
Adam Stankiewicz
d1bfe50419 Ignore compiler for javascript, fixes #521 2020-08-24 10:29:39 +02:00
Adam Stankiewicz
22e8e01c1e Use setf for ambiguous extensions 2020-08-24 09:52:25 +02:00
Adam Stankiewicz
30bef582ba Fix blade ftdetect 2020-08-24 09:31:34 +02:00
Adam Stankiewicz
74d940cda3 Remove travis 2020-08-24 00:21:35 +02:00
Adam Stankiewicz
54d2386262 Update readme 2020-08-24 00:05:31 +02:00
Adam Stankiewicz
a47c315b01 Update readme 2020-08-24 00:04:36 +02:00
Adam Stankiewicz
ff0ada0dc3 Fix CI 2020-08-24 00:01:53 +02:00
Adam Stankiewicz
e194de5875 Debug CI 2020-08-23 23:59:02 +02:00
Adam Stankiewicz
012cf89210 Fix CI 2020-08-23 23:54:23 +02:00
Adam Stankiewicz
ac71777dc2 Fix CI 2020-08-23 23:40:50 +02:00
Adam Stankiewicz
23defeb610 fix: Migrate build script to ruby 2020-08-23 23:35:05 +02:00
Adam Stankiewicz
114a93bb7c Migrate ftdetect generation to ruby 2020-08-23 23:25:06 +02:00
Adam Stankiewicz
f3ab28a287 Move packages to yaml file 2020-08-23 19:39:42 +02:00
Adam Stankiewicz
bc3b36088e Update 2020-08-23 17:26:30 +02:00
Adam Stankiewicz
5d0150e326 Migrate build script to ruby 2020-08-21 19:49:36 +02:00
Adam Stankiewicz
cf8e31ff7f Update 2020-08-21 14:51:19 +02:00
23 changed files with 3232 additions and 964 deletions

21
.github/workflows/test.yml vendored Normal file
View File

@@ -0,0 +1,21 @@
name: Vim Polyglot CI
on:
push:
pull_request:
schedule:
- cron: '0 0 * * 0' # weekly
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Install Vim
run: |
sudo add-apt-repository ppa:jonathonf/vim -y
sudo apt-get update -q
sudo apt-get install -y vim
vim --version
- uses: actions/checkout@v2
- name: Run Tests
run: scripts/test

View File

@@ -1,7 +0,0 @@
language: vim
before_script:
- sudo add-apt-repository ppa:jonathonf/vim -y
- sudo apt-get update -q
- sudo apt-get install -y vim
- vim --version
script: ./test

View File

@@ -1,22 +1,20 @@
![vim-polyglot](https://i.imgur.com/9RxQK6k.png)
[![Build Status][travis-img-url]][travis-url] [![Maintenance](https://img.shields.io/maintenance/yes/2020.svg?maxAge=2592000)]()
[travis-img-url]: https://travis-ci.org/sheerun/vim-polyglot.svg
[travis-url]: https://travis-ci.org/sheerun/vim-polyglot
![build](https://github.com/sheerun/vim-polyglot/workflows/Vim%20Polyglot%20CI/badge.svg) [![Maintenance](https://img.shields.io/maintenance/yes/2020.svg?maxAge=2592000)]()
A collection of language packs for Vim.
> One to rule them all, one to find them, one to bring them all and in the darkness bind them.
- It **won't affect your startup time**, as scripts are loaded only on demand\*.
- It **installs and updates 120+ times faster** than the <!--Package Count-->157<!--/Package Count--> packages it consists of.
- It **installs and updates 120+ times faster** than the <!--Package Count-->156<!--/Package Count--> packages it consists of.
- It is more secure because scripts loaded for all extensions are generated by vim-polyglot (ftdetect).
- Solid syntax and indentation support (other features skipped). Only the best language packs.
- All unnecessary files are ignored (like enormous documentation from php support).
- No support for esoteric languages, only most popular ones (modern too, like `slim`).
- Each build is tested by automated vimrunner script on CI. See `spec` directory.
\*To be completely honest, optimized `ftdetect` script takes up to `19ms` to load.
\*To be completely honest, optimized `ftdetect` script takes around `19ms` to load.
## Installation
@@ -38,7 +36,7 @@ mkdir -p ~/.vim/pack/default/start
git clone https://github.com/sheerun/vim-polyglot ~/.vim/pack/default/start/vim-polyglot
```
NOTE: Not all features of listed language packs are available. We strip them from functionality slowing vim startup in general (for example we ignore `plugins` folder that is loaded regardless of file type, use `ftplugin` instead).
NOTE: Not all features of individual language packs are available. We strip them from functionality slowing vim startup (for example we ignore `plugins` folder that is loaded regardless of file type, instead we prefer `ftplugin` which is loaded lazily).
If you need full functionality of any plugin, please use it directly with your plugin manager.
@@ -100,10 +98,10 @@ If you need full functionality of any plugin, please use it directly with your p
- [hive](https://github.com/zebradil/hive.vim) (syntax, ftplugin)
- [html5](https://github.com/othree/html5.vim) (syntax, indent, autoload, ftplugin)
- [i3](https://github.com/mboughaba/i3config.vim) (syntax, ftplugin)
- [icalenadr](https://github.com/chutzpah/icalendar.vim) (syntax)
- [icalendar](https://github.com/chutzpah/icalendar.vim) (syntax)
- [idris](https://github.com/idris-hackers/idris-vim) (syntax, indent, ftplugin)
- [ion](https://github.com/vmchale/ion-vim) (syntax, ftplugin)
- [javascript](https://github.com/pangloss/vim-javascript) (syntax, indent, compiler, ftplugin, extras)
- [javascript](https://github.com/pangloss/vim-javascript) (syntax, indent, ftplugin, extras)
- [jenkins](https://github.com/martinda/Jenkinsfile-vim-syntax) (syntax, indent)
- [jinja](https://github.com/lepture/vim-jinja) (syntax, indent)
- [jq](https://github.com/vito-c/jq.vim) (syntax, ftplugin)
@@ -171,7 +169,7 @@ If you need full functionality of any plugin, please use it directly with your p
- [solidity](https://github.com/tomlion/vim-solidity) (syntax, indent, ftplugin)
- [sql](https://github.com/shmup/vim-sql-syntax) (syntax)
- [stylus](https://github.com/wavded/vim-stylus) (syntax, indent, ftplugin)
- [svelte](https://github.com/evanleck/vim-svelte#main) (syntax, indent, ftplugin)
- [svelte](https://github.com/evanleck/vim-svelte) (syntax, indent, ftplugin)
- [svg-indent](https://github.com/jasonshell/vim-svg-indent) (indent)
- [svg](https://github.com/vim-scripts/svg.vim) (syntax)
- [swift](https://github.com/keith/swift.vim) (syntax, indent, compiler, ftplugin, ctags)
@@ -181,22 +179,21 @@ If you need full functionality of any plugin, please use it directly with your p
- [textile](https://github.com/timcharper/textile.vim) (syntax, ftplugin)
- [thrift](https://github.com/solarnz/thrift.vim) (syntax)
- [tmux](https://github.com/ericpruitt/tmux.vim) (syntax, ftplugin)
- [tomdoc](https://github.com/wellbredgrapefruit/tomdoc.vim) (syntax)
- [toml](https://github.com/cespare/vim-toml) (syntax, ftplugin)
- [tptp](https://github.com/c-cube/vim-tptp) (syntax)
- [twig](https://github.com/lumiliet/vim-twig) (syntax, indent, ftplugin)
- [typescript](https://github.com/HerringtonDarkholme/yats.vim) (syntax, indent, compiler, ftplugin, ctags)
- [unison](https://github.com/unisonweb/unison#trunk) (syntax)
- [unison](https://github.com/unisonweb/unison) (syntax)
- [v](https://github.com/ollykel/v-vim) (syntax, indent, ftplugin)
- [vala](https://github.com/arrufat/vala.vim) (syntax, indent, ftplugin)
- [vbnet](https://github.com/vim-scripts/vbnet.vim) (syntax)
- [vcl](https://github.com/smerrill/vcl-vim-plugin) (syntax)
- [velocity](https://github.com/lepture/vim-velocity) (syntax, indent)
- [vifm](https://github.com/vifm/vifm.vim) (syntax, autoload, ftplugin)
- [vm](https://github.com/lepture/vim-velocity) (syntax, indent)
- [vue](https://github.com/posva/vim-vue) (syntax, indent, ftplugin)
- [xdc](https://github.com/amal-khailtash/vim-xdc-syntax) (syntax)
- [xls](https://github.com/vim-scripts/XSLT-syntax) (syntax)
- [xml](https://github.com/amadeus/vim-xml) (syntax)
- [xsl](https://github.com/vim-scripts/XSLT-syntax) (syntax)
- [yaml](https://github.com/stephpy/vim-yaml) (syntax, ftplugin)
- [yard](https://github.com/sheerun/vim-yardoc) (syntax)
- [zephir](https://github.com/xwsoul/vim-zephir) (syntax)
@@ -206,7 +203,7 @@ If you need full functionality of any plugin, please use it directly with your p
## Updating
You can either wait for new patch release with updates or run the `./build` script by yourself.
You can either wait for new patch release with updates or run the `scripts/build` script by yourself.
## Troubleshooting
@@ -219,19 +216,14 @@ Individual language packs can be disabled by setting `g:polyglot_disabled` as fo
let g:polyglot_disabled = ['css']
```
Note that disabling languages won't make in general your vim startup any faster / slower (only for specific file type). Vim-polyglot is selection of language plugins that are loaded only on demand.
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.
## Contributing
Language packs are periodically updated using automated `build` script.
Language packs are periodically updated using automated `scripts/build` script.
Feel free to add your language, and send pull-request. In your pull request, please include:
1. How you chose the particular repo from which to pull support for this language.
2. An updated https://github.com/sheerun/vim-polyglot/blob/master/build .
3. If at all possible, absolutely nothing else (in particular, please don't run `build` and include that in your PR).
The easier it is to validate that the new language won't do anything wacky, the faster it'll be merged. In particular, languages that utilize global plugins (loaded for every filetype), or plugins with dangerous features (like `call` based on the contents of a file being edited), will never be merged, as they will be slow or dangerous, respectively.
Feel free to add your language to `packages.yaml`, and send pull-request. Please don't run `scripts/build` and include that in your PR, send just changes to `packages.yaml` and `build` script if really necessary. You can run `scripts/test` to run rough tests.
## License
See linked repositories for detailed license information.
See linked repositories for detailed license information. This repository is MIT-licensed.

312
build
View File

@@ -1,312 +0,0 @@
#!/usr/bin/env bash
set -eo pipefail
DIRS="syntax indent compiler autoload ftplugin ctags after/syntax after/indent after/ftplugin"
# shellcheck disable=SC2034
DIRS_BASIC="syntax compiler indent after/syntax after/indent"
# shellcheck disable=SC2034
DIRS_ALL="syntax indent compiler autoload ftplugin after extras ctags"
# shellcheck disable=SC2034
DIRS_SYNTAX="syntax indent after/syntax after/indent"
# shellcheck disable=SC2034
DIRS_NOAFTER="syntax compiler indent autoload ftplugin"
DIRS_JAVASCRIPT="${DIRS} extras"
read -r -a DIRS_RM <<<"$DIRS_ALL"
OUTPUT=""
output() {
OUTPUT="$OUTPUT$1"
echo -n "$1"
}
download() {
for pack in $1; do
path="$(cut -d ':' -f 2 <<<"$pack")"
dir="tmp/$(cut -d '/' -f 2 <<<"$path")"
repo="$(awk -F\# '{print $1}' <<<"$path")"
branch="$(awk -F\# '{print $2}' <<<"$path")"
rm -rf "$dir"
(mkdir -p "$dir" && curl --silent -fL "https://codeload.github.com/$repo/tar.gz/${branch:-master}" | tar -zx -C "$dir" --strip 1 && printf '.' || echo "Failed to download: $repo") &
done
wait
}
extract() {
echo
for pack in $1; do
name="$(cut -d ':' -f 1 <<<"$pack")"
path="$(cut -d ':' -f 2 <<<"$pack")"
dir="tmp/$(cut -d '/' -f 2 <<<"$path")"
directories="DIRS$(cut -d ':' -f 3 <<<"$pack")"
subtree="$(cut -d ':' -f 4 <<<"$pack")"
output "- [$name](https://github.com/$path) ("
subdirs=""
for subdir in ${!directories}; do
if [ -d "${dir}${subtree:-/}${subdir}" ]; then
base="$(basename "$subdir")"
if [[ "$subdirs" != *"$base"* ]]; then
subdirs="$subdirs, $base"
fi
copy_dir "${dir}${subtree}" "$subdir" "$name"
fi
done
# syntax for go.vim depends on autoload for go.vim, but we exclude the
# autoload always and the ftplugin because it's too complex. FML.
if [ "${pack%%:*}" = "go" ]; then
copy_file "${dir}${subtree}" "${dir}${subtree}/autoload/go/config.vim" "${name}"
fi
output "${subdirs##, })"$'\n'
done
for pack in $1; do
name="$(cut -d ':' -f 1 <<<"$pack")"
path="$(cut -d ':' -f 2 <<<"$pack")"
dir="tmp/$(cut -d '/' -f 2 <<<"$path")"
subtree="$(cut -d ':' -f 4 <<<"$pack")"
if [ -d "$dir${subtree:-/}plugin" ]; then
echo "Possible error (plugin directory exists): $path" >&2
fi
done
}
copy_dir() {
find "$1/$2" \( -name '*.vim' -o -name '*.vital' -o -name '*.ctags' \) -print0 | while read -r -d $'\0' file; do
copy_file "$1" "$file" "$3"
done
}
copy_file() {
## $1 is the build dir (e.g. tmp/vim-go)
## $2 is the full file path, as returned by `find` (e.g. tmp/vim-go/indent/go.vim)
## $3 is the name of the package (so that we can detect if it's disabled at runtime)
local tmp_dir="$1"
local file_in_tmp="$2"
local file_basename="${2##*/}"
local file_path="${file_in_tmp##$tmp_dir/}" # Just this file's (full) path
file_path="${file_path%/*}" # Minus the actual name of the file
local file_in_dst="${file_path}/${file_basename}" # Could also be ${file_in_tmp##$tmp_dir/}
local package_name="$3"
if [ "${file_in_tmp##$tmp_dir/}" != "${file_in_dst}" ]; then
echo "Failure in logic in build script; '${file_in_tmp##$tmp_dir/}' != '${file_in_dst}'. Bailing." >&2
exit 1
fi
mkdir -p "${file_path}"
(
if [[ "${package_name}" == "jsx" ]]; then
printf "if !exists('g:polyglot_disabled') || !(index(g:polyglot_disabled, 'typescript') != -1 || index(g:polyglot_disabled, 'typescript') != -1 || index(g:polyglot_disabled, 'jsx') != -1)\n\n"
else
printf "if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, '$package_name') == -1\n\n"
fi
cat "$file_in_tmp"
printf "\nendif\n"
) >> "$file_in_dst"
}
update_readme() {
local tf of
tf="$(mktemp)"
of="$(mktemp)"
LC_ALL=C sort <<<"$OUTPUT" | grep -vxE '[[:space:]]*' > "$of"
awk 'suppress == 0 {
gsub(/<!--Package Count-->[^<]*<!--\/Package Count-->/,
"<!--Package Count-->'"$(awk 'END {print NR}' "$of")"'<!--/Package Count-->");
print;
}
/<!--Language Packs-->/ {
suppress = 1;
while ( ( getline line < "'"$of"'" ) > 0 ) {
print line;
}
}
/<!--\/Language Packs-->/ {
suppress = 0;
print;
}' "README.md" >"$tf"
mv "$tf" "README.md"
}
PACKS="
acpiasl:martinlroth/vim-acpi-asl
ansible:pearofducks/ansible-vim
apiblueprint:sheerun/apiblueprint.vim
applescript:mityu/vim-applescript:_SYNTAX
arduino:sudar/vim-arduino-syntax
asciidoc:asciidoc/vim-asciidoc
autohotkey:hnamikaw/vim-autohotkey
blade:jwalton512/vim-blade
brewfile:bfontaine/Brewfile.vim
c++11:octol/vim-cpp-enhanced-highlight
c/c++:vim-jp/vim-cpp
caddyfile:isobit/vim-caddyfile
carp:hellerve/carp-vim
cjsx:mtscout6/vim-cjsx
clojure:guns/vim-clojure-static
cmake:pboettch/vim-cmake-syntax
coffee-script:kchmck/vim-coffee-script:_NOAFTER
cql:elubow/cql-vim
cryptol:victoredwardocallaghan/cryptol.vim
crystal:rhysd/vim-crystal
csv:chrisbra/csv.vim
cucumber:tpope/vim-cucumber
cue:mgrabovsky/vim-cuesheet
dart:dart-lang/dart-vim-plugin
dhall:vmchale/dhall-vim
dlang:JesseKPhillips/d.vim
dockerfile:ekalinin/Dockerfile.vim
elixir:elixir-lang/vim-elixir
elm:andys8/vim-elm-syntax
emberscript:yalesov/vim-ember-script
emblem:yalesov/vim-emblem
erlang:vim-erlang/vim-erlang-runtime
fennel:bakpakin/fennel.vim
ferm:vim-scripts/ferm.vim
fish:georgewitteman/vim-fish
flatbuffers:dcharbon/vim-flatbuffers
fsharp:ionide/Ionide-vim:_BASIC
gdscript:calviken/vim-gdscript3:_SYNTAX
git:tpope/vim-git
glsl:tikhomirov/vim-glsl:_NOAFTER
gmpl:maelvalais/gmpl.vim
gnuplot:vim-scripts/gnuplot-syntax-highlighting
go:fatih/vim-go:_BASIC
graphql:jparise/vim-graphql:_ALL
gradle:tfnico/vim-gradle
haml:sheerun/vim-haml
handlebars:sheerun/vim-mustache-handlebars
haproxy:CH-DanReif/haproxy.vim
haskell:neovimhaskell/haskell-vim
haxe:yaymukund/vim-haxe
hcl:b4b4r07/vim-hcl
helm:towolf/vim-helm
hive:zebradil/hive.vim
html5:othree/html5.vim
i3:mboughaba/i3config.vim
icalenadr:chutzpah/icalendar.vim
idris:idris-hackers/idris-vim
ion:vmchale/ion-vim
javascript:pangloss/vim-javascript:_JAVASCRIPT
jenkins:martinda/Jenkinsfile-vim-syntax
jinja:lepture/vim-jinja
jq:vito-c/jq.vim
json5:GutenYe/json5.vim
json:elzr/vim-json
jsonnet:google/vim-jsonnet
jst:briancollins/vim-jst
jsx:MaxMEllon/vim-jsx-pretty:_ALL
julia:JuliaEditorSupport/julia-vim
kotlin:udalov/kotlin-vim
ledger:ledger/vim-ledger:_BASIC
less:groenewege/vim-less:_NOAFTER
lilypond:anowlcalledjosh/vim-lilypond
livescript:gkz/vim-ls
llvm:rhysd/vim-llvm
log:MTDL9/vim-log-highlighting
lua:tbastos/vim-lua
mako:sophacles/vim-bundle-mako
markdown:plasticboy/vim-markdown:_NOAFTER
mathematica:voldikss/vim-mma
mdx:jxnblk/vim-mdx-js
meson:mesonbuild/meson:_ALL:/data/syntax-highlighting/vim/
moonscript:leafo/moonscript-vim
nginx:chr4/nginx.vim
nim:zah/nim.vim:_BASIC
nix:LnL7/vim-nix
objc:b4winckler/vim-objc
ocaml:rgrinberg/vim-ocaml
octave:McSinyx/vim-octave
opencl:petRUShka/vim-opencl
perl:vim-perl/vim-perl
pgsql:lifepillar/pgsql.vim
php:StanAngeloff/php.vim
plantuml:aklt/plantuml-syntax
pony:jakwings/vim-pony
powershell:PProvost/vim-ps1
protobuf:uarun/vim-protobuf
pug:digitaltoad/vim-pug
puppet:rodjek/vim-puppet
purescript:purescript-contrib/purescript-vim
python-compiler:aliev/vim-compiler-python
python-indent:Vimjas/vim-python-pep8-indent
python:vim-python/python-syntax
qmake:artoj/qmake-syntax-vim
qml:peterhoeg/vim-qml
r-lang:vim-scripts/R.vim:_BASIC
racket:wlangstroth/vim-racket
ragel:jneen/ragel.vim
raku:Raku/vim-raku
raml:IN3D/vim-raml
razor:adamclerk/vim-razor
reason:reasonml-editor/vim-reason-plus
requirements:raimon49/requirements.txt.vim
rspec:keith/rspec.vim
rst:marshallward/vim-restructuredtext
ruby:vim-ruby/vim-ruby
rust:rust-lang/rust.vim
sbt:derekwyatt/vim-sbt
scala:derekwyatt/vim-scala
scss:cakebaker/scss-syntax.vim
sh:arzg/vim-sh
slim:slim-template/vim-slim
slime:slime-lang/vim-slime-syntax
smt2:bohlender/vim-smt2
solidity:tomlion/vim-solidity
sql:shmup/vim-sql-syntax
stylus:wavded/vim-stylus
svelte:evanleck/vim-svelte#main
svg-indent:jasonshell/vim-svg-indent
svg:vim-scripts/svg.vim
swift:keith/swift.vim
sxhkd:baskerville/vim-sxhkdrc
systemd:wgwoods/vim-systemd-syntax
terraform:hashivim/vim-terraform
textile:timcharper/textile.vim
thrift:solarnz/thrift.vim
tmux:ericpruitt/tmux.vim:_ALL:/vim/
tomdoc:wellbredgrapefruit/tomdoc.vim
toml:cespare/vim-toml
tptp:c-cube/vim-tptp
twig:lumiliet/vim-twig
typescript:HerringtonDarkholme/yats.vim
unison:unisonweb/unison#trunk:_ALL:/editor-support/vim/
v:ollykel/v-vim
vala:arrufat/vala.vim
vbnet:vim-scripts/vbnet.vim
vcl:smerrill/vcl-vim-plugin
vifm:vifm/vifm.vim
vm:lepture/vim-velocity
vue:posva/vim-vue
xdc:amal-khailtash/vim-xdc-syntax
xml:amadeus/vim-xml
xls:vim-scripts/XSLT-syntax
yaml:stephpy/vim-yaml
yard:sheerun/vim-yardoc
zephir:xwsoul/vim-zephir
zig:ziglang/zig.vim
zinit:zinit-zsh/zplugin-vim-syntax
"
python3 build.py
rm -rf tmp
mkdir tmp
printf "Downloading packs..."
download "$(sed '/^#/d' <<<"$PACKS")"
rm -rf "${DIRS_RM[@]}"
extract "$(sed '/^#/d' <<<"$PACKS")"
update_readme
rm -rf tmp

269
build.py
View File

@@ -1,269 +0,0 @@
#!/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,
syntax=None,
outer_filetype=None,
custom_set=None,
compound=False,
extra_extensions=[],
extra_filenames=[],
ignored_extensions=[]
):
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")
if syntax != None:
syntax = " syntax=" + syntax
else:
syntax = ""
if extensions == None:
extensions = language.get("extensions", [])
if filenames == None:
filenames = language.get("filenames", [])
if custom_set == None:
custom_set = f"set ft={filetype_name}{syntax}"
for ext in sorted(list(set(extensions + extra_extensions) - set(ignored_extensions))):
if outer_filetype != None:
lines.append(f" au BufNewFile *.*{ext} execute \"do BufNewFile filetypedetect \" . expand(\"<afile>:r\") | {outer_filetype}")
lines.append(f" au BufReadPre *.*{ext} execute \"do BufRead filetypedetect \" . expand(\"<afile>:r\") | {outer_filetype}")
lines.append(f" au BufNewFile,BufRead *{ext} {custom_set}")
for fn in sorted(filenames + extra_filenames):
if fn[0] == ".":
fn = "{.,}" + fn[1:]
lines.append(f" au BufNewFile,BufRead {fn} {custom_set}")
lines.append("endif")
lines.append("")
lines.append("""" don't spam the user when Vim is started in Vi compatibility mode
let s:cpo_save = &cpo
set cpo&vim
if !exists('g:polyglot_disabled')
let g:polyglot_disabled = []
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)
" 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
""")
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", polyglot="coffee-script", filetype="coffee", extra_extensions=[".coffeekup", '.ck'])
language("Literate CoffeeScript", polyglot="coffee-script", filetype="litcoffee", extra_extensions=[".coffee.md"])
language("Clojure")
language("CQL", extensions=[".cql"])
language("Cryptol", extensions=[".cry", ".cyl", ".lcry", ".lcyl"])
language("Crystal", extra_filenames=["Projectfile"])
language("HTML+ECR", polyglot="crystal", filetype="ecrystal")
language("CSV", extra_extensions=[".tsv", ".dat", ".tab"])
language("Gherkin", filetype="cucumber", extra_extensions=[".story"])
language("Cue", filetype="cuesheet", extensions=[".cue"], polyglot="cue")
language("Dart")
language("Dhall")
language("D", polyglot="dlang")
language("D", polyglot="dlang", filetype="dcov", extensions=[".lst"])
language("D", polyglot="dlang", filetype="dd", extensions=[".dd"])
language("D", polyglot="dlang", filetype="ddoc", extensions=[".ddoc"])
language("D", polyglot="dlang", filetype="dsdl", extensions=[".sdl"])
language("Dockerfile", extra_extensions=[".dock", ".Dockerfile"], extra_filenames=["dockerfile", "Dockerfile*"], filetype="Dockerfile", polyglot="dockerfile")
language("Dockerfile", extensions=[], filenames=["docker-compose*.yaml", "docker-compose*.yml"], filetype="yaml.docker-compose", polyglot="dockerfile")
language("Elixir")
language("HTML+EEX", polyglot="elixir", filetype="elixir", extra_extensions=[".leex"])
language("Elm")
language("EmberScript", filetype="ember-script", polyglot="emberscript")
language("Emblem", extensions=[".emblem"], filetype="emblem")
language("Erlang", extra_extensions=[".app", ".yaws"])
language("Ferm", extensions=[".ferm"], filenames=["ferm.conf"], filetype="ferm")
language("fish")
language("YAML", extra_filenames=["fish_history", "fish_read_history"])
language("Flatbuffers", extensions=[".fbs"], filetype="fbs", polyglot="flatbuffers")
language("GDScript", filetype="gdscript3", polyglot="gdscript")
language("GLSL", extra_extensions=[".comp"])
language("F#", polyglot="fsharp", filetype="fsharp")
language("Git Config", polyglot="git", filetype="gitconfig", extra_filenames=["*.git/config", "*/.config/git/config", "*.git/modules/**/config", "gitconfig"])
language("Git Rebase", polyglot="git", filetype="gitrebase", filenames=["git-rebase-todo"])
language("Git Send Email", polyglot="git", filetype="gitsendemail", filenames=[".gitsendemail.*"])
language("Git Commit", polyglot="git", filetype="gitcommit", filenames=["COMMIT_EDIT_MSG", "TAG_EDIT_MSG", "MERGE_MSG", "MSG"])
language("Gnu MathProg", polyglot="gmpl", filetype="gmpl", extensions=[".mod"])
language("Go")
language("Go Mod", filetype="gomod", filenames=["go.mod"], polyglot="go")
language("Go Template", filetype="gohtmltmpl", extensions=[".tmpl"], polyglot="go")
language("Assembly", filetype="asm", polyglot="assembly")
language("GraphQL")
language("Gradle", filetype="groovy", polyglot="gradle")
language("Haml", extra_extensions=[".hamlc", ".hamlbars"])
language("Handlebars", filetype="mustache", polyglot="handlebars", extra_extensions=[".hulk", ".hjs", ".mustache", ".njk"])
language("HTML+Django", polyglot="jinja", filetype="jinja.html", ignored_extensions=[".mustache", ".njk"], extra_extensions=[".j2"])
language("HAProxy")
language("Haskell", extra_extensions=[".bpk", ".hsig"])
language("Haxe")
language("HCL", extra_extensions=[".nomad"], extra_filenames=["Appfile"])
language("Helm", extra_filenames=["*/templates/*.yaml", "*/templates/*.tpl"])
language("HiveQL", polyglot="hive", filetype="hive")
language("I3", extensions=[".i3.config"], filenames=["i3.config"], filetype="i3config", polyglot="i3")
language("HiveQL", polyglot="hive", filetype="hive")
language("iCalendar", polyglot="icalendar", filetype="icalendar", extensions=[".ics"])
language("Idris", extra_filenames=["idris-response"])
language("Ion", extensions=[".ion"], filenames=["~/.config/ion/initrc"])
language("JavaScript")
language("Flow", polyglot="javascript", filetype="flow", extensions=[".flow"])
language("Jenkinsfile", polyglot="jenkins", extensions=[".jenkinsfile", ".Jenkinsfile"], filenames=["Jenkinsfile*"], filetype="Jenkinsfile")
language("JSON5")
language("JSON", extra_extensions=[".jsonp", ".template"])
language("EJS", filetype="jst", extra_extensions=[".jst", ".djs", ".hamljs", ".ect"])
language("JSX", filetype="javascriptreact", polyglot="jsx")
language("Julia")
language("Kotlin")
language("Ledger", extensions=[".ldg", ".ledger", ".journal"])
language("Less")
language("LilyPond")
language("LiveScript")
language("LLVM")
language("Tablegen", polyglot="llvm", extensions=[".td"], filetype="tablegen")
language("Mako", outer_filetype="let b:mako_outer_lang = &filetype")
language("Log", extensions=[".log"], filenames=["*_log"])
language("Markdown", ignored_extensions=[".mdx"])
language("Mdx", extensions=[".mdx"], polyglot="mdx", filetype="markdown.mdx")
language("Mathematica", filetype="mma")
language("Meson")
language("Dosini", extensions=[".wrap"], filetype="dosini", polyglot="meson")
language("MoonScript", filetype="moon", polyglot="moon")
language("Nginx", extra_extensions=[".nginx"], extra_filenames=["*/etc/nginx/*", "*/usr/local/nginx/conf/*", "*/nginx/*.conf", "nginx*.conf", "*nginx.conf"])
language("Nim")
language("Nix")
language("OCaml", extra_extensions=[".mlt", ".mlp", ".mlip", ".mli.cppo", ".ml.cppo"])
language("OMake", extensions=[".om"], filenames=["OMakefile", "OMakeroot", "Omakeroot.in"], polyglot="ocaml", filetype="omake")
language("OPam", extensions=[".opam", ".opam.template"], filenames=["opam"], filetype="opam", polyglot="ocaml")
language("Oasis", filenames=["_oasis"], polyglot="ocaml", filetype="oasis")
language("OpenCL")
language("Perl")
language("PLpgSQL", filetype="sql", ignored_extensions=[".sql"], custom_set="let b:sql_type_override='pgsql' | set ft=sql", polyglot="pgsql")
language("PlantUML", extra_extensions=[".uml", ".pu"])
language("Pony")
language("PowerShell", extra_extensions=[".pssc"])
language("Ps1XML", extensions=[".ps1xml"], polyglot="powershell", filetype="ps1xml")
language("Protocol Buffer", polyglot="protobuf", filetype="proto")
language("Pug")
language("Puppet")
language("Embedded Puppet", polyglot="puppet", filetype="embeddedpuppet", extensions=[".epp"])
language("PureScript")
language("QMake")
language("QML")
language("Racket")
language("Raku", extra_extensions=[".rakudoc", ".rakutest", ".raku", ".rakumod", ".pod6", ".t6"])
language("RAML")
language("HTML+Razor", filetype="razor", polyglot="razor")
language("Reason")
language("Merlin", filetype="merlin", polyglot="razor", filenames=[".merlin"])
language("Ruby", extra_extensions=[".rxml", ".rjs", ".rant", ".axlsx", ".cap", ".opal"], extra_filenames=["Rantfile", ".autotest", "Cheffile", "KitchenSink", "Routefile"])
language("HTML+ERB", polyglot="ruby", filetype="eruby", extra_extensions=[".rhtml"])
# Needs to be after ruby
language("RSpec", filenames=["*_spec.rb"], polyglot="rspec", filetype="ruby", syntax="rspec")
language("Rust")
language("Scala", ignored_extensions=[".sbt"])
language("Scala SBT", filetype="sbt.scala", extensions=[".sbt"], polyglot="scala")
language("SCSS")
language("Slim")
language("Slime", extensions=[".slime"])
language("SMT", filetype="smt2")
language("Solidity", extra_extensions=[".sol"])
language("Stylus", extra_extensions=[".stylus"])
language("Svelte")
language("Swift")
language("Sxhkd", extensions=[".sxhkdrc"], filetype="sxhkdrc", polyglot="sxhkd")
language("Systemd", extensions=[".automount", ".mount", ".path", ".service", ".socket", ".swap", ".target", ".timer"])
language("HCL", filetype="terraform", polyglot="terraform")
language("Textile")
language("Thrift")
language("Tmux", filenames=[".tmux.conf"])
language("TOML", extra_filenames=["Pipfile", "*/.cargo/config", "*/.cargo/credentials"])
language("TPTP", extensions=[".p", ".tptp", ".ax"])
language("Twig", ignored_extensions=[".xml.twig"], filetype="html.twig", polyglot="twig")
language("Twig XML", extensions=[".xml.twig"], filetype="xml.twig", polyglot="twig")
language("TypeScript")
language("TSX", filetype="typescriptreact", polyglot="typescript")
language("XML", extra_extensions=[".cdxml"], ignored_extensions=[".ts", ".tsx"])
language("V")
language("Vala", extra_extensions=[".valadoc"])
language("Visual Basic .NET", filetype="vbnet", polyglot="vbnet")
language("VCL")
language("Vifm", extensions=[".vifm"], filenames=["vifmrc", "*vifm/colors/*"])
language("Vifm Rename", filetype="vifm-rename", filenames=["vifm.rename*"], polyglot="vifm")
language("Velocity", extensions=[".vm"], filetype="velocity")
language("Vue", extra_extensions=[".wpy"])
language("XDC", extensions=[".xdc"])
language("Zig", extra_extensions=[".zir"])
language("Zir", extensions=[".zir"], polyglot="zig", filetype="zir")
language("Jsonnet")
language("Fennel", extensions=[".fnl"])
language("mcfunction")
language("JSONiq", extra_filenames=[".jqrc"], filetype="jq", polyglot="jq")
language("Requirements", extensions=[".pip"], filenames=["*requirements.{txt,in}", "*require.{txt,in}", "constraints.{txt,in}"])
lines.append('" restore Vi compatibility settings')
lines.append('let &cpo = s:cpo_save')
lines.append('unlet s:cpo_save')
f = open("ftdetect/polyglot.vim", "w")
f.write("\n".join(lines))
f.close()

View File

@@ -1,20 +0,0 @@
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'javascript') == -1
" Vim compiler plugin
" Language: JavaScript
" Maintainer: vim-javascript community
" URL: https://github.com/pangloss/vim-javascript
if exists("current_compiler")
finish
endif
let current_compiler = "eslint"
if exists(":CompilerSet") != 2
command! -nargs=* CompilerSet setlocal <args>
endif
CompilerSet makeprg=eslint\ -f\ compact\ %
CompilerSet errorformat=%f:\ line\ %l\\,\ col\ %c\\,\ %m
endif

File diff suppressed because it is too large Load Diff

View File

@@ -38,7 +38,8 @@ nnoremap <buffer><Plug>(crystal-spec-run-current) :<C-u>CrystalSpecRunCurrent<
nnoremap <buffer><Plug>(crystal-format) :<C-u>CrystalFormat<CR>
augroup plugin-ft-crystal
autocmd BufWritePre <buffer> if g:crystal_auto_format | call crystal_lang#format('', 1) | endif
autocmd!
autocmd BufWritePre <buffer> if g:crystal_auto_format && &filetype ==# 'crystal' | call crystal_lang#format('', 1) | endif
augroup END
if get(g:, 'crystal_define_mappings', 1)

View File

@@ -1,5 +1,6 @@
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'crystal') == -1
" Filetype plugin for https://crystal-lang.org/api/0.35.1/ECR.html
if exists('b:did_ftplugin')
finish
endif

View File

@@ -11,6 +11,9 @@ if exists("b:did_ftplugin")
endif
let b:did_ftplugin = 1
let b:undo_ftplugin = "setlocal comments< commentstring<"
setlocal comments=:#
setlocal commentstring=#\ %s
endif

View File

@@ -843,12 +843,11 @@ func! HtmlIndent_FindTagStart(lnum)
" - a flag indicating whether we found the end of a tag.
" This method is global so that HTML-like indenters can use it.
" To avoid matching " > " or " < " inside a string require that the opening
" "<" is followed by a word character and the closing ">" comes after a
" non-white character.
" "<" is followed by a word character
let idx = match(getline(a:lnum), '\S>\s*$')
if idx > 0
call cursor(a:lnum, idx)
let lnum = searchpair('<\w', '' , '\S>', 'bW', '', max([a:lnum - b:html_indent_line_limit, 0]))
let lnum = searchpair('<\w', '' , '>', 'bW', '', max([a:lnum - b:html_indent_line_limit, 0]))
if lnum > 0
return [lnum, 1]
endif

View File

@@ -1,4 +1,4 @@
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'vm') == -1
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'velocity') == -1
if exists("b:did_indent")
finish

1307
packages.yaml Normal file

File diff suppressed because it is too large Load Diff

317
scripts/build Executable file
View File

@@ -0,0 +1,317 @@
#!/usr/bin/env ruby
require 'open-uri'
require 'open3'
require 'yaml'
require 'fileutils'
require 'set'
Dir.chdir(File.dirname(__dir__))
PACKAGES = YAML.load_stream(File.read('packages.yaml'))
BASE_URL = 'https://raw.githubusercontent.com/github/linguist/master'
DIRS = {
default: %w(syntax indent compiler autoload ftplugin ctags after/syntax after/indent after/ftplugin),
all: %w(syntax indent compiler autoload ftplugin after extras ctags),
basic: %w(syntax compiler indent after/syntax after/indent),
syntax: %w(syntax indent after/syntax after/indent),
noafter: %w(syntax compiler indent autoload ftplugin),
javascript: %w(syntax indent compiler autoload ftplugin ctags after/syntax after/indent after/ftplugin extras),
go: %w(autoload/go/config.vim syntax compiler indent after/syntax after/indent)
}
def parallel(*procs)
threads = procs.map { |p| Thread.new { method(p).call } }
threads.map(&:join).map(&:value)
end
def read_strings(data, keys, print=false)
if data.is_a?(Hash)
data.flat_map do |key, val|
read_strings(val, keys, keys.include?(key))
end
elsif data.is_a?(Array)
data.flat_map { |d| read_strings(d, keys, print) }
elsif data.is_a?(String)
print ? [data] : []
else
[]
end
end
def transform_with(data, keys, transfrom=false, &block)
if data.is_a?(Hash)
Hash[data.map do |key, val|
[key, transform_with(val, keys, keys.include?(key), &block)]
end]
elsif data.is_a?(Array)
data.map { |d| transform_with(d, keys, transfrom, &block) }
elsif data.is_a?(String)
transfrom ? yield(data) : data
else
data
end
end
def each_hash(data, &block)
if data.is_a?(Hash)
yield data
data.each do |key, val|
each_hash(val, &block)
end
elsif data.is_a?(Array)
data.map { |d| each_hash(d, &block) }
end
end
def patterns_to_vim_patterns(patterns)
stdin, stdout, stderr = Open3.popen3('vim', '-V', '--clean', '/dev/stdin', '-es', '-c', "echo expand('%:p:h') | source #{__dir__}/scripts/eregex.vim", '-c', "for line in range(0, line('$')) | call setline(line, ExtendedRegex2VimRegex(getline(line))) | endfor", '-c', ':wq! /dev/stdout', chdir: __dir__)
stdin.write(patterns.join("\n"))
stdin.close
stdout.readlines
end
def transform_patterns(data)
patterns = read_strings(data, ["pattern", "patterns"])
patterns_mapping = Hash[patterns.zip(patterns_to_vim_patterns(patterns))]
transform_with(data, ["pattern", "patterns"]) { |a| patterns_mapping[a] }
end
def load_heuristics
url = "#{BASE_URL}/lib/linguist/heuristics.yml"
data = URI.open(url) { |io| YAML.load(io.read) }
each_hash(data["disambiguations"]) do |h|
if h.has_key?("named_pattern")
h["pattern"] = data["named_patterns"].fetch(h["named_pattern"])
h.delete("named_pattern")
end
end
transform_patterns(data["disambiguations"])
end
def load_languages
url = "#{BASE_URL}/lib/linguist/languages.yml"
data = URI.open(url) { |io| YAML.load(io.read) }
end
def parse_remote(remote)
match = remote.match(/(?<repo>[^@:]+)(?:@(?<branch>[^:]+))?(?::(?<path>.*))?/)
[match[:repo], match[:branch] || "master", match[:path]]
end
def copy_file(package, src, dest)
return unless [".vim", ".ctags", ".vital"].include?(File.extname(src))
FileUtils.mkdir_p(File.dirname(dest))
name = package.fetch("name")
open(src, "r") do |input|
open(dest, "a+") do |output|
if name == "jsx"
output << "if !exists('g:polyglot_disabled') || !(index(g:polyglot_disabled, 'typescript') != -1 || index(g:polyglot_disabled, 'typescript') != -1 || index(g:polyglot_disabled, 'jsx') != -1)\n\n"
else
output << "if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, '#{name}') == -1\n\n"
end
IO.copy_stream(input, output)
output << "\nendif\n"
end
end
end
def download
FileUtils.rm_rf('tmp')
PACKAGES.each_slice(20) do |batch|
batch.map do |package|
Thread.new do
repo, branch, path = parse_remote(package.fetch("remote"))
dir = "tmp/" + repo.split('/')[1]
FileUtils.mkdir_p(dir)
url = "https://codeload.github.com/#{repo}/tar.gz/#{branch}"
`curl --silent -fL #{url} | tar -zx -C "#{dir}" --strip 1`
progress
end
end.map(&:join)
end
end
$i = 0
LYRICS = "Never gonna give you up. Never gonna let you down. " +
"Never gonna run around and desert you. " +
"Never gonna make you cry. Never gonna say goodbye. " +
"Never gonna tell a lie and hurt you."
$mutex = Mutex.new
def progress
$mutex.synchronize do
$stdout.write(LYRICS[$i] || ".")
$i += 1
end
end
def extract
FileUtils.rm_rf(DIRS[:all])
output = []
PACKAGES.map do |package|
repo, branch, path = parse_remote(package["remote"])
dir = "tmp/" + repo.split('/')[1]
subdirs = []
dirs = DIRS.fetch(package.fetch("dirs", "default").to_sym)
dirs -= package.fetch("ignored_dirs", [])
dirs |= package.fetch("extra_dirs", [])
for subdir in dirs
subtree = "#{dir}/#{path ? path + "/" : ""}"
subpath = "#{subtree}#{subdir}"
if FileTest.directory?(subpath)
Dir.glob("#{subdir}/**/*", base: subtree).each do |p|
next unless File.file?("#{subtree}/#{p}")
copy_file(package, "#{subtree}/#{p}", p)
end
subdirs << subdir.split("/").last
elsif File.exist?(subpath)
copy_file(package, subpath, subdir)
end
end
output << "- [#{package["name"]}](https://github.com/#{repo}) (#{subdirs.uniq.join(", ")})"
progress
end
readme = File.read('README.md')
readme.gsub!(
%r{(?<=<!--Package Count-->).*?(?=<!--/Package Count-->)},
output.size.to_s
)
readme.gsub!(
%r{(?<=<!--Language Packs-->).*?(?=<!--/Language Packs-->)}m,
"\n" + output.sort.join("\n") + "\n"
)
File.write('README.md', readme)
end
def generate_ftdetect
heuristics, languages = parallel(:load_heuristics, :load_languages)
output = <<~EOS
" don't spam the user when Vim is started in Vi compatibility mode
let s:cpo_save = &cpo
set cpo&vim
if !exists('g:polyglot_disabled')
let g:polyglot_disabled = []
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)
" 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
ambiguous_extensions = languages.flat_map { |_, v| v["extensions"] || [] }
.group_by(&:itself).transform_values(&:count)
.select { |a, b| b > 1 }.keys.map { |a| a[1..] }.to_set
for package in PACKAGES
name = package.fetch("name")
output << if name == "jsx"
"if !(index(g:polyglot_disabled, 'typescript') != -1 || index(g:polyglot_disabled, 'typescript') != -1 || index(g:polyglot_disabled, 'jsx') != -1)\n"
else
"if index(g:polyglot_disabled, '#{name}') == -1\n"
end
filetypes = package["filetypes"] or raise "Unknown filetype for: #{package["name"]}"
for filetype in filetypes
syntax = filetype["syntax"] ? " syntax=#{filetype["syntax"]}" : ""
set_command = package.fetch("custom_set", "set ft=#{filetype.fetch("name")}#{syntax}")
linguist = filetype["linguist"] ? languages.fetch(filetype["linguist"]) : {}
extensions = filetype["extensions"] || linguist.fetch("extensions", []).map { |e| e[1..] }
extensions = (extensions | filetype.fetch("extra_extensions", [])) - filetype.fetch("ignored_extensions", [])
filenames = filetype["filenames"] || linguist.fetch("filenames", [])
filenames = (filenames | filetype.fetch("extra_filenames", [])) - filetype.fetch("ignored_filenames", [])
for extension in extensions.sort
outer_filetype = filetype["outer_filetype"]
if outer_filetype
output << " au BufNewFile *.*.#{extension} execute \"do BufNewFile filetypedetect \" . expand(\"<afile>:r\") | #{outer_filetype}"
output << " au BufReadPre *.*#{extension} execute \"do BufRead filetypedetect \" . expand(\"<afile>:r\") | #{outer_filetype}"
end
if ambiguous_extensions.include?(extension)
output << " au BufNewFile,BufRead *.#{extension} setf #{filetype["name"]}\n"
else
output << " au BufNewFile,BufRead *.#{extension} #{set_command}\n"
end
end
for filename in filenames.sort
if filename[0] == "."
filename = "{.,}" + filename[1..]
end
output << " au BufNewFile,BufRead #{filename} #{set_command}\n"
end
end
output << "endif\n\n"
end
output << <<~EOS
" restore Vi compatibility settings
let &cpo = s:cpo_save
unlet s:cpo_save
EOS
File.write('ftdetect/polyglot.vim', output)
end
download
extract
generate_ftdetect
puts(" Bye! Have a wonderful time!")
FileUtils.rm_rf("tmp")

1102
scripts/eregex.vim Normal file

File diff suppressed because it is too large Load Diff

View File

View File

@@ -1,4 +1,4 @@
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'icalenadr') == -1
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'icalendar') == -1
" Vim syntax file
" Language: icalendar <http://www.ietf.org/rfc/rfc2445.txt>

View File

@@ -3,7 +3,7 @@ if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'log') == -1
" Vim syntax file
" Language: Generic log file
" Maintainer: MTDL9 <https://github.com/MTDL9>
" Latest Revision: 2019-11-24
" Latest Revision: 2020-08-23
if exists('b:current_syntax')
finish
@@ -15,7 +15,7 @@ set cpoptions&vim
" Operators
"---------------------------------------------------------------------------
syn match logOperator display '[;,\?\:\.\<=\>\~\/\@\&\!$\%\&\+\-\|\^(){}\*#]'
syn match logOperator display '[;,\?\:\.\<=\>\~\/\@\!$\%&\+\-\|\^(){}\*#]'
syn match logBrackets display '[\[\]]'
syn match logEmptyLines display '-\{3,}'
syn match logEmptyLines display '\*\{3,}'
@@ -87,7 +87,7 @@ syn match logXmlAttribute contained "\(\n\|\s\)\(\(\w\|-\)\+:\)\?\(\w\|-\)\+\
syn match logXmlNamespace contained "\(\w\|-\)\+:" contains=logOperator
syn region logXmlComment start=/<!--/ end=/-->/
syn match logXmlCData /<!\[CDATA\[.*\]\]>/
syn match logXmlEntity /\&\w\+;/
syn match logXmlEntity /&#\?\w\+;/
" Levels

View File

@@ -67,7 +67,7 @@ endfunction
com! -nargs=* SynFold call s:run_syntax_fold(<q-args>)
" Not-Top Cluster {{{1
syn cluster rubyNotTop contains=@rubyCommentNotTop,@rubyStringNotTop,@rubyRegexpSpecial,@rubyDeclaration,@rubyExceptionHandler,@rubyClassOperator,rubyConditional,rubyModuleName,rubyClassName,rubySymbolDelimiter,rubyParentheses
syn cluster rubyNotTop contains=@rubyCommentNotTop,@rubyStringNotTop,@rubyRegexpSpecial,@rubyDeclaration,@rubyExceptionHandler,@rubyClassOperator,rubyConditional,rubyModuleName,rubyClassName,rubySymbolDelimiter,rubyParentheses,@Spell
" Whitespace Errors {{{1
if exists("ruby_space_errors")

View File

@@ -1,7 +1,7 @@
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'tmux') == -1
" Language: tmux(1) configuration file
" Version: before-OpenBSD-lock (git-53c84fd4)
" Version: 3.1b (git-769ae106)
" URL: https://github.com/ericpruitt/tmux.vim/
" Maintainer: Eric Pruitt <eric.pruitt@gmail.com>
" License: 2-Clause BSD (http://opensource.org/licenses/BSD-2-Clause)
@@ -32,10 +32,10 @@ syn match tmuxVariable /\w\+=/ display
syn match tmuxVariableExpansion /\${\=\w\+}\=/ display
syn match tmuxControl /%\(if\|elif\|else\|endif\)/
syn region tmuxComment start=/#/ skip=/\\\@<!\\$/ end=/$/ contains=tmuxTodo
syn region tmuxComment start=/#/ skip=/\\\@<!\\$/ end=/$/ contains=tmuxTodo,@Spell
syn region tmuxString start=+"+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"+ end='$' contains=tmuxFormatString
syn region tmuxString start=+'+ skip=+\\\\\|\\'\|\\$+ excludenl end=+'+ end='$' contains=tmuxFormatString
syn region tmuxString start=+"+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"+ end='$' contains=tmuxFormatString,@Spell
syn region tmuxString start=+'+ skip=+\\\\\|\\'\|\\$+ excludenl end=+'+ end='$' contains=tmuxFormatString,@Spell
" TODO: Figure out how escaping works inside of #(...) and #{...} blocks.
syn region tmuxFormatString start=/#[#DFhHIPSTW]/ end=// contained keepend

View File

@@ -1,22 +0,0 @@
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'tomdoc') == -1
syn keyword tomdocKeywords
\ Returns Yields Raises Examples Signature
\ containedin=.*Comment
\ contained
syn match tomdocDescriptions
\ +\s*\(Public\|Internal\|Deprecated\):+he=e-1
\ containedin=.*Comment
\ contained
syn match tomdocArguments
\ +\s*[A-Za-z0-9_\-&\*:]*\(\s*- \)+he=e-3
\ containedin=.*Comment
\ contained
hi default link tomdocDescriptions String
hi default link tomdocKeywords String
hi default link tomdocArguments HELP
endif

View File

@@ -1,4 +1,4 @@
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'vm') == -1
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'velocity') == -1
" Vim syntax file
" Language: Velocity HTML template

View File

@@ -1,4 +1,4 @@
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'xls') == -1
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'xsl') == -1
" Vim syntax file
" Language: XSLT 1.0