Compare commits

...

11 Commits

Author SHA1 Message Date
Adam Stankiewicz
262960fa22 Synchronize shiftwidth with tabstop by default 2020-09-04 18:29:53 +02:00
Adam Stankiewicz
b2640b5b76 Fix detection of indentation, #537 2020-09-04 17:31:22 +02:00
Adam Stankiewicz
c30ba66d22 Let user select tabstop, by not changing it 2020-09-04 14:23:18 +02:00
Adam Stankiewicz
4df00e6574 Allow to disable autoindent with g:polyglot_disabled 2020-09-04 14:18:37 +02:00
Adam Stankiewicz
48f59577c8 Switch to neovim version of help filetype, fixes #536 2020-09-04 12:11:55 +02:00
Adam Stankiewicz
96179c95ba Update contribution info 2020-09-03 17:16:08 +02:00
Adam Stankiewicz
520389bbfd Add test for terraform 2020-09-03 05:38:07 +02:00
Adam Stankiewicz
7123e97498 Disable native autocommands when appropriate, fixes #533 2020-09-03 05:36:55 +02:00
Adam Stankiewicz
63119f09d1 Automatically detect indentation, closes #529 2020-09-01 23:38:17 +02:00
Adam Stankiewicz
f2ef4cedec Fix reason filetype detection, closes #532 2020-09-01 23:02:36 +02:00
Adam Stankiewicz
45c1923f43 Add sql support for javascript 2020-09-01 16:02:38 +02:00
15 changed files with 926 additions and 214 deletions

View File

@@ -7,11 +7,11 @@ 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. > 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 **won't affect your startup time**, as scripts are loaded only on demand\*.
- It **installs and updates 120+ times faster** than the <!--Package Count-->189<!--/Package Count--> packages it consists of. - It **installs and updates 120+ times faster** than the <!--Package Count-->190<!--/Package Count--> packages it consists of.
- It is more secure because scripts loaded for all extensions are generated by vim-polyglot (ftdetect). - 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. - Solid syntax and indentation support (other features skipped). Only the best language packs.
- All unnecessary files are ignored (like enormous documentation from php support). - 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. - 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. \*To be completely honest, optimized `ftdetect` script takes around `19ms` to load.
@@ -125,13 +125,14 @@ If you need full functionality of any plugin, please use it directly with your p
- [haxe](https://github.com/yaymukund/vim-haxe) - [haxe](https://github.com/yaymukund/vim-haxe)
- [hcl](https://github.com/b4b4r07/vim-hcl) - [hcl](https://github.com/b4b4r07/vim-hcl)
- [helm](https://github.com/towolf/vim-helm) - [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) - [hive](https://github.com/zebradil/hive.vim)
- [html5](https://github.com/othree/html5.vim) - [html5](https://github.com/othree/html5.vim)
- [i3](https://github.com/mboughaba/i3config.vim) - [i3](https://github.com/mboughaba/i3config.vim)
- [icalendar](https://github.com/chutzpah/icalendar.vim) - [icalendar](https://github.com/chutzpah/icalendar.vim)
- [idris](https://github.com/idris-hackers/idris-vim) - [idris](https://github.com/idris-hackers/idris-vim)
- [ion](https://github.com/vmchale/ion-vim) - [ion](https://github.com/vmchale/ion-vim)
- [javascript-sql](https://github.com/statico/vim-javascript-sql)
- [javascript](https://github.com/pangloss/vim-javascript) - [javascript](https://github.com/pangloss/vim-javascript)
- [jenkins](https://github.com/martinda/Jenkinsfile-vim-syntax) - [jenkins](https://github.com/martinda/Jenkinsfile-vim-syntax)
- [jinja](https://github.com/lepture/vim-jinja) - [jinja](https://github.com/lepture/vim-jinja)
@@ -244,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: Individual language packs can be disabled by setting `g:polyglot_disabled` as follows:
```viml ```vim
let g:polyglot_disabled = ['css'] let g:polyglot_disabled = ['css']
``` ```
@@ -252,11 +253,17 @@ 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. 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 ## Contributing
Language packs are periodically updated using automated `scripts/build` script. 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 ## License

View File

@@ -0,0 +1,26 @@
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'javascript-sql') == -1
" Vim plugin
" Language: JavaScript
" Maintainer: Ian Langworth <ian@langworth.com>
if exists('b:current_syntax')
let s:current_syntax = b:current_syntax
unlet b:current_syntax
endif
exec 'syntax include @SQLSyntax syntax/' . g:javascript_sql_dialect . '.vim'
if exists('s:current_syntax')
let b:current_syntax = s:current_syntax
endif
syntax region sqlTemplateString start=+`+ skip=+\\\(`\|$\)+ end=+`+ contains=@SQLSyntax,jsTemplateExpression,jsSpecial extend
exec 'syntax match sqlTaggedTemplate +\%(SQL\)\%(`\)\@=+ nextgroup=sqlTemplateString'
hi def link sqlTemplateString jsTemplateString
hi def link sqlTaggedTemplate jsTaggedTemplate
syn cluster jsExpression add=sqlTaggedTemplate
syn cluster sqlTaggedTemplate add=sqlTemplateString
endif

View File

@@ -1450,7 +1450,7 @@ fu! csv#SumColumn(list) "{{{3
let b:csv_result = '0' let b:csv_result = '0'
return 0 return 0
else else
let sum = has("float") ? 0.0 : 0 let sum = 0.0
for item in a:list for item in a:list
if empty(item) if empty(item)
continue continue
@@ -1460,33 +1460,25 @@ fu! csv#SumColumn(list) "{{{3
let format2 = '\d\+\zs\V' . s:nr_format[1] . '\m\ze\d' let format2 = '\d\+\zs\V' . s:nr_format[1] . '\m\ze\d'
try try
let nr = substitute(nr, format1, '', '') let nr = substitute(nr, format1, '', '')
if has("float") && s:nr_format[1] != '.' if s:nr_format[1] != '.'
let nr = substitute(nr, format2, '.', '') let nr = substitute(nr, format2, '.', '')
endif endif
catch catch
let nr = 0 let nr = '0'
endtry endtry
let sum += (has("float") ? str2float(nr) : (nr + 0)) let sum += str2float(nr)
endfor endfor
if has("float") let b:csv_result = sum
let b:csv_result = string(float2nr(sum)) return printf("%.2f", sum)
if float2nr(sum) == sum
return float2nr(sum)
else
return printf("%.2f", sum)
endif
endif
let b:csv_result = string(sum)
return sum
endif endif
endfu endfu
fu! csv#AvgColumn(list) "{{{3 fu! csv#AvgColumn(list) "{{{3
if empty(a:list) if empty(a:list)
let b:csv_result = '0' let b:csv_result = '0'
return 0 return 0.0
else else
let cnt = 0 let cnt = 0
let sum = has("float") ? 0.0 : 0 let sum = 0.0
for item in a:list for item in a:list
if empty(item) if empty(item)
continue continue
@@ -1496,30 +1488,25 @@ fu! csv#AvgColumn(list) "{{{3
let format2 = '\d\+\zs\V' . s:nr_format[1] . '\m\ze\d' let format2 = '\d\+\zs\V' . s:nr_format[1] . '\m\ze\d'
try try
let nr = substitute(nr, format1, '', '') let nr = substitute(nr, format1, '', '')
if has("float") && s:nr_format[1] != '.' if s:nr_format[1] != '.'
let nr = substitute(nr, format2, '.', '') let nr = substitute(nr, format2, '.', '')
endif endif
catch catch
let nr = 0 let nr ='0'
endtry endtry
let sum += (has("float") ? str2float(nr) : (nr + 0)) let sum += str2float(nr)
let cnt += 1 let cnt += 1
endfor endfor
if has("float") let b:csv_result = printf("%.2f", sum/cnt)
let b:csv_result = printf("%.2f", sum/cnt) return sum/cnt
return str2float(b:csv_result)
else
let b:csv_result = printf("%s", sum/cnt)
return b:csv_result + 0
endif
endif endif
endfu endfu
fu! csv#VarianceColumn(list, is_population) "{{{3 fu! csv#VarianceColumn(list, is_population) "{{{3
if empty(a:list) if empty(a:list)
return 0 return 0.0
else else
let cnt = 0 let cnt = 0
let sum = has("float") ? 0.0 : 0 let sum = 0.0
let avg = csv#AvgColumn(a:list) let avg = csv#AvgColumn(a:list)
for item in a:list for item in a:list
if empty(item) 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' let format2 = '\d\+\zs\V' . s:nr_format[1] . '\m\ze\d'
try try
let nr = substitute(nr, format1, '', '') let nr = substitute(nr, format1, '', '')
if has("float") && s:nr_format[1] != '.' if s:nr_format[1] != '.'
let nr = substitute(nr, format2, '.', '') let nr = substitute(nr, format2, '.', '')
endif endif
catch catch
let nr = 0 let nr = '0'
endtry 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 let cnt += 1
endfor endfor
if(a:is_population == 0) if(a:is_population == 0)
let cnt = cnt-1 let cnt = cnt-1
endif endif
if has("float") let b:csv_result = sum/cnt
let b:csv_result = printf("%." . get(b:, 'csv_accuracy', get(g:, 'csv_accuracy', 2)) . "f", sum/cnt) return b:csv_result
return b:csv_result
else
let b:csv_result = printf("%s", sum/cnt)
return sum/(cnt)
endif
endif endif
endfu endfu
fu! csv#SmplVarianceColumn(list) "{{{2 fu! csv#SmplVarianceColumn(list) "{{{2
unlet! b:csv_result
if empty(a:list) if empty(a:list)
let b:csv_result = '0' let b:csv_result = 0.0
return 0 return 0.0
else else
return csv#VarianceColumn(a:list, 0) return csv#VarianceColumn(a:list, 0)
endif endif
endfu endfu
fu! csv#PopVarianceColumn(list) "{{{2 fu! csv#PopVarianceColumn(list) "{{{2
unlet! b:csv_result
if empty(a:list) if empty(a:list)
let b:csv_result = '0' let b:csv_result = 0.0
return 0 return 0.0
else else
return csv#VarianceColumn(a:list, 1) return csv#VarianceColumn(a:list, 1)
endif endif
endfu endfu
fu! csv#SmplStdDevColumn(list) "{{{2 fu! csv#SmplStdDevColumn(list) "{{{2
unlet! b:csv_result
if empty(a:list) if empty(a:list)
let b:csv_result = '0' let b:csv_result = 0.0
return 0 return 0.0
else else
let result = sqrt(str2float(csv#VarianceColumn(a:list, 0))) let result = sqrt(csv#VarianceColumn(a:list, 0))
let b:csv_result = string(result) let b:csv_result = result
return result return result
endif endif
endfu endfu
fu! csv#PopStdDevColumn(list) "{{{2 fu! csv#PopStdDevColumn(list) "{{{2
unlet! b:csv_result
if empty(a:list) if empty(a:list)
let b:csv_result = '0' let b:csv_result = 0.0
return 0 return 0.0
else else
let result = sqrt(str2float(csv#VarianceColumn(a:list, 1))) let result = sqrt(csv#VarianceColumn(a:list, 1))
let b:csv_result = string(result) let b:csv_result = result
return result return result
endif endif
endfu endfu
@@ -1610,13 +1597,13 @@ fu! csv#MaxColumn(list) "{{{3
let format2 = '\d\+\zs\V' . s:nr_format[1] . '\m\ze\d' let format2 = '\d\+\zs\V' . s:nr_format[1] . '\m\ze\d'
try try
let nr = substitute(nr, format1, '', '') let nr = substitute(nr, format1, '', '')
if has("float") && s:nr_format[1] != '.' if s:nr_format[1] != '.'
let nr = substitute(nr, format2, '.', '') let nr = substitute(nr, format2, '.', '')
endif endif
catch catch
let nr = 0 let nr = '0'
endtry endtry
call add(result, has("float") ? str2float(nr) : nr+0) call add(result, str2float(nr))
endfor endfor
let result = sort(result, s:csv_numeric_sort ? 'n' : 'csv#CSVSortValues') let result = sort(result, s:csv_numeric_sort ? 'n' : 'csv#CSVSortValues')
let ind = len(result) > 9 ? 9 : len(result) let ind = len(result) > 9 ? 9 : len(result)
@@ -1995,10 +1982,7 @@ fu! csv#AnalyzeColumn(...) "{{{3
call filter(res, 'v:val =~ ''^''.join(max_items, ''\|'').''$''') call filter(res, 'v:val =~ ''^''.join(max_items, ''\|'').''$''')
endif endif
if has("float") let title="Nr\tCount\t % \tValue"
let title="Nr\tCount\t % \tValue"
else
let title="Nr\tCount\tValue"
endif endif
echohl Title echohl Title
echo printf("%s", title) echo printf("%s", title)
@@ -2014,12 +1998,8 @@ fu! csv#AnalyzeColumn(...) "{{{3
else else
let k = key let k = key
endif endif
if has("float") echo printf("%02d\t%02d\t%2.0f%%\t%.50s", i, res[key],
echo printf("%02d\t%02d\t%2.0f%%\t%.50s", i, res[key], \ ((res[key] + 0.0)/qty)*100, k)
\ ((res[key] + 0.0)/qty)*100, k)
else
echo printf("%02d\t%02d\t%.50s", i, res[key], k)
endif
call remove(res,key) call remove(res,key)
let i+=1 let i+=1
else else
@@ -2950,6 +2930,11 @@ fu! csv#EvalColumn(nr, func, first, last, ...) range "{{{3
call csv#Warn("File is no CSV file!") call csv#Warn("File is no CSV file!")
return return
endif 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() let save = winsaveview()
call csv#CheckHeaderLine() call csv#CheckHeaderLine()
let nr = matchstr(a:nr, '^\-\?\d\+') let nr = matchstr(a:nr, '^\-\?\d\+')

View File

@@ -202,6 +202,16 @@ func! polyglot#DetectFsFiletype()
setf forth | return setf forth | return
endfunc 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' " Restore 'cpoptions'
let &cpo = s:cpo_save let &cpo = s:cpo_save
unlet s:cpo_save unlet s:cpo_save

221
autoload/sleuth.vim Normal file
View File

@@ -0,0 +1,221 @@
let s:globs = {
\ '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)
return get(s:globs, a:type, '')
endfunc

View File

@@ -969,8 +969,7 @@ The result is also available in the buffer-local variable `b:csv_result`.
See also |csv-aggregate-functions| See also |csv-aggregate-functions|
*MinCol_CSV* 3.27 Maximum/Minimum value of a Column *MaxCol_CSV* *MinCol_CSV*
3.27 Maximum/Minimum value of a Column *MaxCol_CSV*
--------------------------------------- ---------------------------------------
You can let Vim output the 10 maximum/minimum values of a column using the You can let Vim output the 10 maximum/minimum values of a column using the
`:CSVMaxCol` command > `: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 delimiter will be stripped away from each value and also empty values won't be
considered. considered.
*format_number_csv*
By default, Vim uses the a numerical format that uses the '.' as decimal By default, Vim uses the a numerical format that uses the '.' as decimal
separator while there is no thousands separator. If youre file contains 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 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. 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`. The result is also available in the buffer-local variable `b:csv_result`.
3.28 Average value of a Column *AvgCol_CSV* 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 delimiter will be stripped away from each value and also empty values won't be
considered. 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`. The result is also available in the buffer-local variable `b:csv_result`.
See also |csv-aggregate-functions| 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]PopVarCol [nr] [/format/]
:[range]SmplVarCol [nr] [/format/] :[range]SmplVarCol [nr] [/format/]
Calculate the Population or Sample Variance for the specified column.
This outputs the result of the column `<nr>` within the range given. If no range This outputs the result of the column `<nr>` within the range given. If no range
is given, this will calculate the statistical variance of the whole column. If <nr> is not is given, this will calculate the statistical variance of the whole column. If <nr> is not
given, this calculates the variance for the column the cursor is on. Note, that the delimiter 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`. 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]PopStdCol [nr] [/format/]
:[range]SmplStdCol [nr] [/format/] :[range]SmplStdCol [nr] [/format/]
Calculate the Population or Sample Standard Deviation for the specified column.
This outputs the result of the column `<nr>` within the range given. If no range This outputs the result of the column `<nr>` within the range given. If no range
is given, this will calculate the standard deviation of the whole column. If <nr> is not is given, this will calculate the standard deviation of the whole column. If <nr> is not
given, this calculates the standard deviation for the column the cursor is on. Note, that 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`. The result is also available in the buffer-local variable `b:csv_result`.
For the [/format/] part, see |format_number_csv|.
*:CSVDupColumn* *:CSVDupColumn*
3.31 Duplicate columns *DupColumn_CSV* 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 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. 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* 4. CSV Configuration *csv-configuration*

View File

@@ -28,6 +28,9 @@ call s:SetDefault('g:markdown_enable_mappings', 0)
" Enable jsx syntax by default " Enable jsx syntax by default
call s:SetDefault('g:jsx_ext_required', 0) call s:SetDefault('g:jsx_ext_required', 0)
" Needed for sql highlighting
call s:SetDefault('g:javascript_sql_dialect', 'sql')
" Make csv loading faster " Make csv loading faster
call s:SetDefault('g:csv_start', 1) call s:SetDefault('g:csv_start', 1)
call s:SetDefault('g:csv_end', 2) call s:SetDefault('g:csv_end', 2)
@@ -56,6 +59,233 @@ if !exists('g:python_highlight_all')
call s:SetDefault('g:python_highlight_file_headers_as_comments', 1) call s:SetDefault('g:python_highlight_file_headers_as_comments', 1)
call s:SetDefault('g:python_slow_sync', 1) call s:SetDefault('g:python_slow_sync', 1)
endif endif
" filetypes
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') if !has_key(s:disabled_packages, '8th')
au BufNewFile,BufRead *.8th setf 8th au BufNewFile,BufRead *.8th setf 8th
endif endif
@@ -150,7 +380,8 @@ endif
if !has_key(s:disabled_packages, 'aptconf') if !has_key(s:disabled_packages, 'aptconf')
au BufNewFile,BufRead */.aptitude/config setf 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 au BufNewFile,BufRead apt.conf setf aptconf
endif endif
@@ -215,6 +446,11 @@ if !has_key(s:disabled_packages, 'awk')
au BufNewFile,BufRead *.awk setf awk au BufNewFile,BufRead *.awk setf awk
endif 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++') if !has_key(s:disabled_packages, 'c/c++')
au BufNewFile,BufRead *.c setf c au BufNewFile,BufRead *.c setf c
au BufNewFile,BufRead *.cats setf c au BufNewFile,BufRead *.cats setf c
@@ -232,9 +468,7 @@ if !has_key(s:disabled_packages, 'c/c++')
au BufNewFile,BufRead *.hxx setf cpp au BufNewFile,BufRead *.hxx setf cpp
au BufNewFile,BufRead *.inc setf cpp au BufNewFile,BufRead *.inc setf cpp
au BufNewFile,BufRead *.inl setf cpp au BufNewFile,BufRead *.inl setf cpp
au BufNewFile,BufRead *.ino setf cpp
au BufNewFile,BufRead *.ipp setf cpp au BufNewFile,BufRead *.ipp setf cpp
au BufNewFile,BufRead *.re setf cpp
au BufNewFile,BufRead *.tcc setf cpp au BufNewFile,BufRead *.tcc setf cpp
au BufNewFile,BufRead *.tpp setf cpp au BufNewFile,BufRead *.tpp setf cpp
endif endif
@@ -527,8 +761,6 @@ endif
if !has_key(s:disabled_packages, 'hcl') if !has_key(s:disabled_packages, 'hcl')
au BufNewFile,BufRead *.hcl setf hcl au BufNewFile,BufRead *.hcl setf hcl
au BufNewFile,BufRead *.nomad 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 *.workflow setf hcl
au BufNewFile,BufRead Appfile setf hcl au BufNewFile,BufRead Appfile setf hcl
endif endif
@@ -573,6 +805,9 @@ if !has_key(s:disabled_packages, 'ion')
au BufNewFile,BufRead ~/.config/ion/initrc setf ion au BufNewFile,BufRead ~/.config/ion/initrc setf ion
endif endif
if !has_key(s:disabled_packages, 'javascript-sql')
endif
if !has_key(s:disabled_packages, 'javascript') if !has_key(s:disabled_packages, 'javascript')
au BufNewFile,BufRead *._js setf javascript au BufNewFile,BufRead *._js setf javascript
au BufNewFile,BufRead *.bones setf javascript au BufNewFile,BufRead *.bones setf javascript
@@ -610,7 +845,6 @@ if !has_key(s:disabled_packages, 'jinja')
au BufNewFile,BufRead *.j2 setf jinja.html au BufNewFile,BufRead *.j2 setf jinja.html
au BufNewFile,BufRead *.jinja setf jinja.html au BufNewFile,BufRead *.jinja setf jinja.html
au BufNewFile,BufRead *.jinja2 setf jinja.html au BufNewFile,BufRead *.jinja2 setf jinja.html
au BufNewFile,BufRead *.njk setf jinja.html
endif endif
if !has_key(s:disabled_packages, 'jq') if !has_key(s:disabled_packages, 'jq')
@@ -757,7 +991,6 @@ if !has_key(s:disabled_packages, 'markdown')
au BufNewFile,BufRead *.md setf markdown au BufNewFile,BufRead *.md setf markdown
au BufNewFile,BufRead *.mdown setf markdown au BufNewFile,BufRead *.mdown setf markdown
au BufNewFile,BufRead *.mdwn setf markdown au BufNewFile,BufRead *.mdwn setf markdown
au BufNewFile,BufRead *.mdx setf markdown
au BufNewFile,BufRead *.mkd setf markdown au BufNewFile,BufRead *.mkd setf markdown
au BufNewFile,BufRead *.mkdn setf markdown au BufNewFile,BufRead *.mkdn setf markdown
au BufNewFile,BufRead *.mkdown setf markdown au BufNewFile,BufRead *.mkdown setf markdown
@@ -870,7 +1103,6 @@ endif
if !has_key(s:disabled_packages, 'pgsql') if !has_key(s:disabled_packages, 'pgsql')
au BufNewFile,BufRead *.pgsql let b:sql_type_override='pgsql' | set ft=sql 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 endif
if !has_key(s:disabled_packages, 'cql') if !has_key(s:disabled_packages, 'cql')
@@ -991,7 +1223,6 @@ endif
if !has_key(s:disabled_packages, 'r-lang') if !has_key(s:disabled_packages, 'r-lang')
au BufNewFile,BufRead *.S setf r au BufNewFile,BufRead *.S setf r
au BufNewFile,BufRead *.r setf r au BufNewFile,BufRead *.r setf r
au BufNewFile,BufRead *.rd setf r
au BufNewFile,BufRead *.rsx setf r au BufNewFile,BufRead *.rsx setf r
au BufNewFile,BufRead *.s setf r au BufNewFile,BufRead *.s setf r
au BufNewFile,BufRead {.,}Rprofile setf r au BufNewFile,BufRead {.,}Rprofile setf r
@@ -1039,11 +1270,6 @@ if !has_key(s:disabled_packages, 'razor')
au BufNewFile,BufRead *.razor setf razor au BufNewFile,BufRead *.razor setf razor
endif 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') if !has_key(s:disabled_packages, 'rst')
au BufNewFile,BufRead *.rest setf rst au BufNewFile,BufRead *.rest setf rst
au BufNewFile,BufRead *.rest.txt setf rst au BufNewFile,BufRead *.rest.txt setf rst
@@ -1087,7 +1313,6 @@ if !has_key(s:disabled_packages, 'ruby')
au BufNewFile,BufRead {.,}simplecov setf ruby au BufNewFile,BufRead {.,}simplecov setf ruby
au BufNewFile,BufRead Appraisals setf ruby au BufNewFile,BufRead Appraisals setf ruby
au BufNewFile,BufRead Berksfile setf ruby au BufNewFile,BufRead Berksfile setf ruby
au BufNewFile,BufRead Brewfile setf ruby
au BufNewFile,BufRead Buildfile setf ruby au BufNewFile,BufRead Buildfile setf ruby
au BufNewFile,BufRead Capfile setf ruby au BufNewFile,BufRead Capfile setf ruby
au BufNewFile,BufRead Cheffile setf ruby au BufNewFile,BufRead Cheffile setf ruby
@@ -1134,7 +1359,6 @@ endif
if !has_key(s:disabled_packages, 'scala') if !has_key(s:disabled_packages, 'scala')
au BufNewFile,BufRead *.kojo setf scala au BufNewFile,BufRead *.kojo setf scala
au BufNewFile,BufRead *.sbt setf scala
au BufNewFile,BufRead *.sc setf scala au BufNewFile,BufRead *.sc setf scala
au BufNewFile,BufRead *.scala setf scala au BufNewFile,BufRead *.scala setf scala
endif endif
@@ -1159,7 +1383,6 @@ if !has_key(s:disabled_packages, 'sh')
au BufNewFile,BufRead *.sh.in setf sh au BufNewFile,BufRead *.sh.in setf sh
au BufNewFile,BufRead *.tmux setf sh au BufNewFile,BufRead *.tmux setf sh
au BufNewFile,BufRead *.tool 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_aliases setf sh
au BufNewFile,BufRead {.,}bash_history setf sh au BufNewFile,BufRead {.,}bash_history setf sh
au BufNewFile,BufRead {.,}bash_logout setf sh au BufNewFile,BufRead {.,}bash_logout setf sh
@@ -1171,11 +1394,6 @@ if !has_key(s:disabled_packages, 'sh')
au BufNewFile,BufRead {.,}flaskenv setf sh au BufNewFile,BufRead {.,}flaskenv setf sh
au BufNewFile,BufRead {.,}login setf sh au BufNewFile,BufRead {.,}login setf sh
au BufNewFile,BufRead {.,}profile 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 9fs setf sh
au BufNewFile,BufRead PKGBUILD setf sh au BufNewFile,BufRead PKGBUILD setf sh
au BufNewFile,BufRead bash_aliases setf sh au BufNewFile,BufRead bash_aliases setf sh
@@ -1187,11 +1405,6 @@ if !has_key(s:disabled_packages, 'sh')
au BufNewFile,BufRead login setf sh au BufNewFile,BufRead login setf sh
au BufNewFile,BufRead man setf sh au BufNewFile,BufRead man setf sh
au BufNewFile,BufRead profile 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 *.zsh setf zsh
au BufNewFile,BufRead {.,}zlogin setf zsh au BufNewFile,BufRead {.,}zlogin setf zsh
au BufNewFile,BufRead {.,}zlogout setf zsh au BufNewFile,BufRead {.,}zlogout setf zsh
@@ -1410,8 +1623,6 @@ if !has_key(s:disabled_packages, 'xml')
au BufNewFile,BufRead *.sublime-snippet setf xml au BufNewFile,BufRead *.sublime-snippet setf xml
au BufNewFile,BufRead *.targets setf xml au BufNewFile,BufRead *.targets setf xml
au BufNewFile,BufRead *.tml 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 *.ui setf xml
au BufNewFile,BufRead *.urdf setf xml au BufNewFile,BufRead *.urdf setf xml
au BufNewFile,BufRead *.ux setf xml au BufNewFile,BufRead *.ux setf xml
@@ -1515,6 +1726,9 @@ if !has_key(s:disabled_packages, 'trasys')
au! BufNewFile,BufRead *.inp call polyglot#DetectInpFiletype() au! BufNewFile,BufRead *.inp call polyglot#DetectInpFiletype()
endif endif
" end filetypes
au BufNewFile,BufRead,StdinReadPost * au BufNewFile,BufRead,StdinReadPost *
\ if !did_filetype() && expand("<amatch>") !~ g:ft_ignore_pat \ if !did_filetype() && expand("<amatch>") !~ g:ft_ignore_pat
\ | call polyglot#Heuristics() | endif \ | call polyglot#Heuristics() | endif

View File

@@ -15,11 +15,86 @@ set cpo&vim
let b:undo_ftplugin = "setl fo< tw< cole< cocu< keywordprg<" 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") if has("conceal")
setlocal cole=2 cocu=nc setlocal cole=2 cocu=nc
endif 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 <silent><buffer> gO :call <sid>show_toc()<cr>
endif
let &cpo = s:cpo_save let &cpo = s:cpo_save
unlet s:cpo_save unlet s:cpo_save

View File

@@ -55,3 +55,11 @@ rules:
filetype: glsl filetype: glsl
- override: "g:filetype_fs" - override: "g:filetype_fs"
- filetype: forth - 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

View File

@@ -179,7 +179,8 @@ filetypes:
filenames: filenames:
- apt.conf - apt.conf
- '*/.aptitude/config' - '*/.aptitude/config'
- '*/etc/apt/apt.conf.d/{[-_[:alnum:]]\+,[-_.[:alnum:]]\+.conf}' - '*/etc/apt/apt.conf.d/[^.]*'
- '*/etc/apt/apt.conf.d/*.conf'
--- ---
name: arch name: arch
remote: vim/vim:runtime remote: vim/vim:runtime
@@ -302,6 +303,8 @@ filetypes:
ignored_extensions: ignored_extensions:
# conflicts with more popular reason, remove after heuristics work # conflicts with more popular reason, remove after heuristics work
- re - re
# implemented by arduino
- ino
--- ---
name: caddyfile name: caddyfile
remote: isobit/vim-caddyfile remote: isobit/vim-caddyfile
@@ -773,6 +776,11 @@ filetypes:
extensions: extensions:
- flow - flow
--- ---
name: javascript-sql
remote: statico/vim-javascript-sql
after: javascript
filetypes: []
---
name: jenkins name: jenkins
remote: martinda/Jenkinsfile-vim-syntax remote: martinda/Jenkinsfile-vim-syntax
filetypes: filetypes:
@@ -1271,6 +1279,7 @@ filetypes:
--- ---
name: reason name: reason
remote: reasonml-editor/vim-reason-plus remote: reasonml-editor/vim-reason-plus
after: c/c++
filetypes: filetypes:
- name: reason - name: reason
linguist: Reason linguist: Reason
@@ -1664,7 +1673,7 @@ filetypes:
- "*/templates/*.tpl" - "*/templates/*.tpl"
--- ---
name: help name: help
remote: vim/vim:runtime remote: neovim/neovim:runtime
glob: '**/help.vim' glob: '**/help.vim'
filetypes: filetypes:
- name: help - name: help

154
plugin/polyglot.vim Normal file
View File

@@ -0,0 +1,154 @@
" 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 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

View File

@@ -59,17 +59,20 @@ def load_data()
linguist = languages.fetch(filetype["linguist"]) linguist = languages.fetch(filetype["linguist"])
filetype["extensions"] = (linguist["extensions"] || []).map { |e| e[1..-1] } | filetype["extensions"] = ((
filetype.fetch("extra_extensions", []) - (linguist["extensions"] || []).map { |e| e[1..-1] } |
filetype.fetch("ignored_extensions", []).uniq filetype.fetch("extra_extensions", [])
) - filetype.fetch("ignored_extensions", [])).uniq
filetype["filenames"] = (linguist["filenames"] || []) | filetype["filenames"] = ((
filetype.fetch("extra_filenames", []) - (linguist["filenames"] || []) |
filetype.fetch("ignored_filenames", []).uniq filetype.fetch("extra_filenames", [])
) - filetype.fetch("ignored_filenames", [])).uniq
filetype["interpreters"] = (linguist["interpreters"] || []) | filetype["interpreters"] = ((
filetype.fetch("extra_interpreters", []) - (linguist["interpreters"] || []) |
filetype.fetch("ignored_interpreters", []).uniq filetype.fetch("extra_interpreters", [])
) - filetype.fetch("ignored_interpreters", []).uniq)
else else
filetype["extensions"] ||= [] filetype["extensions"] ||= []
filetype["filenames"] ||= [] filetype["filenames"] ||= []
@@ -202,9 +205,17 @@ def indent(str, amount)
end end
def pattern_to_condition(rule) 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"] ? "?" : "#") operator = (rule["negative"] ? "!" : "=") + "~" + (rule["ignore_case"] ? "?" : "#")
"line #{operator} '#{rule["pattern"]}'" return "line #{operator} '#{rule["pattern"]}'"
end end
def rules_to_code(rules) def rules_to_code(rules)
@@ -250,10 +261,10 @@ def rule_to_code(rule)
return rule["rules"].map { |r| indent(rule_to_code(r), 0) }.join("\n") return rule["rules"].map { |r| indent(rule_to_code(r), 0) }.join("\n")
end end
if rule.has_key?("pattern") if rule.has_key?("pattern") || rule.has_key?("or") || rule.has_key?("and")
return <<~EOS return <<~EOS
if #{pattern_to_condition(rule)} 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 endif
EOS EOS
end end
@@ -360,66 +371,7 @@ def extract(packages)
end end
def generate_ftdetect(packages, heuristics) def generate_ftdetect(packages, heuristics)
output = <<~EOS output = "\n"
" 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)
" 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
extensions = Hash.new { |h, k| h[k] = [] } extensions = Hash.new { |h, k| h[k] = [] }
@@ -434,7 +386,29 @@ def generate_ftdetect(packages, heuristics)
ambiguous_extensions = extensions ambiguous_extensions = extensions
.select { |a, b| b.uniq.size > 1 }.keys.sort .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 for package in packages
name = package.fetch("name") name = package.fetch("name")
@@ -507,17 +481,8 @@ def generate_ftdetect(packages, heuristics)
output << "endif\n\n" output << "endif\n\n"
end end
output << <<~EOS ftdetect = File.read('ftdetect/polyglot.vim')
au BufNewFile,BufRead,StdinReadPost * File.write('ftdetect/polyglot.vim', ftdetect.gsub(/(?<=" filetypes\n).*(?=\n" end filetypes)/m, output))
\\ if !did_filetype() && expand("<amatch>") !~ 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)
output = <<~EOS output = <<~EOS
" Line continuation is used here, remove 'C' from 'cpoptions' " Line continuation is used here, remove 'C' from 'cpoptions'
@@ -679,8 +644,8 @@ def expand_all(pattern)
end end
end end
def detect_filetypes def detect_filetypes(glob)
filetypes = Dir['tmp/**/ftdetect/*.vim'].flat_map do |file| filetypes = Dir[glob].flat_map do |file|
contents = File.read(file).gsub(/^\s*au(tocmd)?!?\s*$/, '') contents = File.read(file).gsub(/^\s*au(tocmd)?!?\s*$/, '')
results = contents.scan(/^\s*(?:au!|au|au[^g][^ ]*) +(?:\S+)\s+(\S+)[\s\\]+([^\n]+)/) results = contents.scan(/^\s*(?:au!|au|au[^g][^ ]*) +(?:\S+)\s+(\S+)[\s\\]+([^\n]+)/)
results = results.map do |a, b| results = results.map do |a, b|
@@ -705,6 +670,39 @@ def detect_filetypes
}] }]
end 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(/\*\*|\//) || 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"
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 __FILE__ == $0
if !ENV["DEV"] if !ENV["DEV"]
FileUtils.rm_rf("tmp") FileUtils.rm_rf("tmp")
@@ -714,6 +712,7 @@ if __FILE__ == $0
download(packages) download(packages)
extract(packages) extract(packages)
generate_ftdetect(packages, heuristics) generate_ftdetect(packages, heuristics)
generate_plugins(packages)
generate_tests(packages) generate_tests(packages)
puts(" Bye! Have a wonderful time!") puts(" Bye! Have a wonderful time!")

View File

@@ -188,6 +188,7 @@ call TestExtension('yaml.ansible', 'host_vars/foobar', '')
call TestExtension('yaml.ansible', 'handlers.foobar.yaml', '') call TestExtension('yaml.ansible', 'handlers.foobar.yaml', '')
call TestExtension('yaml.ansible', 'requirements.yaml', '') call TestExtension('yaml.ansible', 'requirements.yaml', '')
call TestExtension('ps1xml', 'foobar.ps1xml', '') call TestExtension('ps1xml', 'foobar.ps1xml', '')
call TestExtension('terraform', 'terraform.tf', '')
" .m extension " .m extension
call TestExtension('octave', 'matlab.m', '') call TestExtension('octave', 'matlab.m', '')
@@ -207,3 +208,10 @@ call TestExtension('fsharp', 'fsharp.fs', "let myInt = 5")
call TestExtension('glsl', 'glsl.fs', "//#version 120\nvoid main() {}") call TestExtension('glsl', 'glsl.fs', "//#version 120\nvoid main() {}")
let g:filetype_fs = 'fizfuz' let g:filetype_fs = 'fizfuz'
call TestExtension('fizfuz', 'fizfuz.fs', '') 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("");')

View File

@@ -44,6 +44,7 @@ call TestFiletype('atlas')
call TestFiletype('autoit') call TestFiletype('autoit')
call TestFiletype('ave') call TestFiletype('ave')
call TestFiletype('awk') call TestFiletype('awk')
call TestFiletype('reason')
call TestFiletype('c') call TestFiletype('c')
call TestFiletype('cpp') call TestFiletype('cpp')
call TestFiletype('caddyfile') call TestFiletype('caddyfile')
@@ -175,7 +176,6 @@ call TestFiletype('ragel')
call TestFiletype('raku') call TestFiletype('raku')
call TestFiletype('raml') call TestFiletype('raml')
call TestFiletype('razor') call TestFiletype('razor')
call TestFiletype('reason')
call TestFiletype('rst') call TestFiletype('rst')
call TestFiletype('ruby') call TestFiletype('ruby')
call TestFiletype('eruby') call TestFiletype('eruby')

View File

@@ -3,7 +3,7 @@ if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'help') == -1
" Vim syntax file " Vim syntax file
" Language: Vim help file " Language: Vim help file
" Maintainer: Bram Moolenaar (Bram@vim.org) " 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 " Quit when a (custom) syntax file was already loaded
if exists("b:current_syntax") if exists("b:current_syntax")
@@ -13,7 +13,7 @@ endif
let s:cpo_save = &cpo let s:cpo_save = &cpo
set cpo&vim 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 "^===.*===$"
syn match helpSectionDelim "^---.*--$" syn match helpSectionDelim "^---.*--$"
if has("conceal") if has("conceal")
@@ -21,15 +21,9 @@ if has("conceal")
else else
syn region helpExample matchgroup=helpIgnore start=" >$" start="^>$" end="^[^ \t]"me=e-1 end="^<" syn region helpExample matchgroup=helpIgnore start=" >$" start="^>$" end="^[^ \t]"me=e-1 end="^<"
endif endif
if has("ebcdic") syn match helpHyperTextJump "\\\@<!|[#-)!+-~]\+|" contains=helpBar
syn match helpHyperTextJump "\\\@<!|[^"*|]\+|" contains=helpBar syn match helpHyperTextEntry "\*[#-)!+-~]\+\*\s"he=e-1 contains=helpStar
syn match helpHyperTextEntry "\*[^"*|]\+\*\s"he=e-1 contains=helpStar syn match helpHyperTextEntry "\*[#-)!+-~]\+\*$" contains=helpStar
syn match helpHyperTextEntry "\*[^"*|]\+\*$" contains=helpStar
else
syn match helpHyperTextJump "\\\@<!|[#-)!+-~]\+|" contains=helpBar
syn match helpHyperTextEntry "\*[#-)!+-~]\+\*\s"he=e-1 contains=helpStar
syn match helpHyperTextEntry "\*[#-)!+-~]\+\*$" contains=helpStar
endif
if has("conceal") if has("conceal")
syn match helpBar contained "|" conceal syn match helpBar contained "|" conceal
syn match helpBacktick contained "`" conceal syn match helpBacktick contained "`" conceal
@@ -44,6 +38,7 @@ syn match helpNormal "|||"
syn match helpNormal ":|vim:|" " for :help modeline syn match helpNormal ":|vim:|" " for :help modeline
syn match helpVim "\<Vim version [0-9][0-9.a-z]*" syn match helpVim "\<Vim version [0-9][0-9.a-z]*"
syn match helpVim "VIM REFERENCE.*" syn match helpVim "VIM REFERENCE.*"
syn match helpVim "NVIM REFERENCE.*"
syn match helpOption "'[a-z]\{2,\}'" syn match helpOption "'[a-z]\{2,\}'"
syn match helpOption "'t_..'" syn match helpOption "'t_..'"
syn match helpCommand "`[^` \t]\+`"hs=s+1,he=e-1 contains=helpBacktick syn match helpCommand "`[^` \t]\+`"hs=s+1,he=e-1 contains=helpBacktick
@@ -68,7 +63,7 @@ syn match helpSpecial "\[N]"
syn match helpSpecial "N N"he=s+1 syn match helpSpecial "N N"he=s+1
syn match helpSpecial "Nth"me=e-2 syn match helpSpecial "Nth"me=e-2
syn match helpSpecial "N-1"me=e-2 syn match helpSpecial "N-1"me=e-2
syn match helpSpecial "{[-a-zA-Z0-9'"*+/:%#=[\]<>.,]\+}" syn match helpSpecial "{[-_a-zA-Z0-9'"*+/:%#=[\]<>.,]\+}"
syn match helpSpecial "\s\[[-a-z^A-Z0-9_]\{2,}]"ms=s+1 syn match helpSpecial "\s\[[-a-z^A-Z0-9_]\{2,}]"ms=s+1
syn match helpSpecial "<[-a-zA-Z0-9_]\+>" syn match helpSpecial "<[-a-zA-Z0-9_]\+>"
syn match helpSpecial "<[SCM]-.>" syn match helpSpecial "<[SCM]-.>"
@@ -92,15 +87,14 @@ syn match helpSpecial "\[group]"
syn match helpNormal "\[\(readonly\|fifo\|socket\|converted\|crypted\)]" syn match helpNormal "\[\(readonly\|fifo\|socket\|converted\|crypted\)]"
syn match helpSpecial "CTRL-." syn match helpSpecial "CTRL-."
syn match helpSpecial "CTRL-SHIFT-."
syn match helpSpecial "CTRL-Break" syn match helpSpecial "CTRL-Break"
syn match helpSpecial "CTRL-PageUp" syn match helpSpecial "CTRL-PageUp"
syn match helpSpecial "CTRL-PageDown" syn match helpSpecial "CTRL-PageDown"
syn match helpSpecial "CTRL-Insert" syn match helpSpecial "CTRL-Insert"
syn match helpSpecial "CTRL-Del" syn match helpSpecial "CTRL-Del"
syn match helpSpecial "CTRL-{char}" syn match helpSpecial "CTRL-{char}"
syn region helpNotVi start="{Vi[: ]" start="{not" start="{only" end="}" contains=helpLeadBlank,helpHyperTextJump syn match helpSpecial "META-."
syn match helpLeadBlank "^\s\+" contained syn match helpSpecial "ALT-."
" Highlight group items in their own color. " Highlight group items in their own color.
syn match helpComment "\t[* ]Comment\t\+[a-z].*" syn match helpComment "\t[* ]Comment\t\+[a-z].*"
@@ -154,7 +148,6 @@ if v:lang =~ '\<IT\>' || v:lang =~ '_IT\>' || v:lang =~? "italian"
syn match helpSpecial "Nmi"me=e-2 syn match helpSpecial "Nmi"me=e-2
syn match helpSpecial "Nmo"me=e-2 syn match helpSpecial "Nmo"me=e-2
syn match helpSpecial "\[interv.]" syn match helpSpecial "\[interv.]"
syn region helpNotVi start="{non" start="{solo" start="{disponibile" end="}" contains=helpLeadBlank,helpHyperTextJump
endif endif
syn sync minlines=40 syn sync minlines=40
@@ -175,7 +168,6 @@ hi def link helpVim Identifier
hi def link helpCommand Comment hi def link helpCommand Comment
hi def link helpExample Comment hi def link helpExample Comment
hi def link helpOption Type hi def link helpOption Type
hi def link helpNotVi Special
hi def link helpSpecial Special hi def link helpSpecial Special
hi def link helpNote Todo hi def link helpNote Todo
hi def link helpWarning Todo hi def link helpWarning Todo