Fix detection of conf files, closes #569

This commit is contained in:
Adam Stankiewicz
2020-09-29 19:11:11 +02:00
parent 46b09b0d5b
commit 1872af2d5e
9 changed files with 201 additions and 71 deletions

View File

@@ -7,7 +7,7 @@ A collection of language packs for Vim.
> One to rule them all, one to find them, one to bring them all and in the darkness bind them. > 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-->202<!--/Package Count--> packages it consists of. - It **installs and updates 120+ times faster** than the <!--Package Count-->203<!--/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).
@@ -89,6 +89,7 @@ If you need full functionality of any plugin, please use it directly with your p
- [clojure](https://github.com/guns/vim-clojure-static) - [clojure](https://github.com/guns/vim-clojure-static)
- [cmake](https://github.com/pboettch/vim-cmake-syntax) - [cmake](https://github.com/pboettch/vim-cmake-syntax)
- [coffee-script](https://github.com/kchmck/vim-coffee-script) - [coffee-script](https://github.com/kchmck/vim-coffee-script)
- [conf](https://github.com/vim/vim/tree/master/runtime)
- [cpp-modern](https://github.com/bfrg/vim-cpp-modern) - [cpp-modern](https://github.com/bfrg/vim-cpp-modern)
- [cql](https://github.com/elubow/cql-vim) - [cql](https://github.com/elubow/cql-vim)
- [cryptol](https://github.com/victoredwardocallaghan/cryptol.vim) - [cryptol](https://github.com/victoredwardocallaghan/cryptol.vim)

View File

@@ -45,6 +45,7 @@ let s:globs = {
\ 'clojure': '*.clj,*.boot,*.cl2,*.cljc,*.cljs,*.cljs.hl,*.cljscm,*.cljx,*.hic,*.edn,riemann.config,build.boot,profile.boot', \ 'clojure': '*.clj,*.boot,*.cl2,*.cljc,*.cljs,*.cljs.hl,*.cljscm,*.cljx,*.hic,*.edn,riemann.config,build.boot,profile.boot',
\ 'cmake': '*.cmake,*.cmake.in,CMakeLists.txt', \ 'cmake': '*.cmake,*.cmake.in,CMakeLists.txt',
\ 'coffee': '*.coffee,*._coffee,*.cake,*.cjsx,*.iced,*.coffeekup,Cakefile', \ 'coffee': '*.coffee,*._coffee,*.cake,*.cjsx,*.iced,*.coffeekup,Cakefile',
\ 'conf': '*.conf,auto.master,config',
\ 'cpp': '*.cpp,*.c++,*.cc,*.cp,*.cxx,*.h,*.h++,*.hh,*.hpp,*.hxx,*.inc,*.inl,*.ipp,*.tcc,*.tpp,*.moc,*.tlh', \ 'cpp': '*.cpp,*.c++,*.cc,*.cp,*.cxx,*.h,*.h++,*.hh,*.hpp,*.hxx,*.inc,*.inl,*.ipp,*.tcc,*.tpp,*.moc,*.tlh',
\ 'cql': '*.cql', \ 'cql': '*.cql',
\ 'cryptol': '*.cry,*.cyl,*.lcry,*.lcyl', \ 'cryptol': '*.cry,*.cyl,*.lcry,*.lcyl',
@@ -94,7 +95,7 @@ let s:globs = {
\ 'groovy': '*.groovy,*.grt,*.gtpl,*.gvy,*.gradle,Jenkinsfile', \ 'groovy': '*.groovy,*.grt,*.gtpl,*.gvy,*.gradle,Jenkinsfile',
\ 'grub': '', \ 'grub': '',
\ 'haml': '*.haml,*.haml.deface,*.hamlc,*.hamlbars', \ 'haml': '*.haml,*.haml.deface,*.hamlc,*.hamlbars',
\ 'haproxy': '*.cfg,haproxy.cfg,haproxy*.c*', \ 'haproxy': '*.cfg,haproxy.cfg,haproxy*.conf*',
\ 'haskell': '*.hs,*.hs-boot,*.hsc,*.bpk,*.hsig', \ 'haskell': '*.hs,*.hs-boot,*.hsc,*.bpk,*.hsig',
\ 'haxe': '*.hx,*.hxsl', \ 'haxe': '*.hx,*.hxsl',
\ 'hcl': '*.hcl,*.nomad,*.workflow,Appfile', \ 'hcl': '*.hcl,*.nomad,*.workflow,Appfile',

View File

@@ -102,6 +102,10 @@ if !has_key(s:disabled_packages, '8th')
au! BufRead,BufNewFile *.8th au! BufRead,BufNewFile *.8th
endif endif
if !has_key(s:disabled_packages, 'conf')
au! BufRead,BufNewFile auto.master
endif
if !has_key(s:disabled_packages, 'haproxy') if !has_key(s:disabled_packages, 'haproxy')
au! BufRead,BufNewFile *.cfg au! BufRead,BufNewFile *.cfg
endif endif
@@ -254,6 +258,10 @@ if !has_key(s:disabled_packages, 'dlang')
au! BufRead,BufNewFile *.sdl au! BufRead,BufNewFile *.sdl
endif endif
if !has_key(s:disabled_packages, 'yaml')
au! BufRead,BufNewFile *.yml,*.yaml
endif
if !has_key(s:disabled_packages, 'dockerfile') if !has_key(s:disabled_packages, 'dockerfile')
au! BufRead,BufNewFile *.Dockerfile,Dockerfile au! BufRead,BufNewFile *.Dockerfile,Dockerfile
endif endif
@@ -270,10 +278,6 @@ if !has_key(s:disabled_packages, 'forth')
au! BufRead,BufNewFile *.fs,*.ft,*.fth au! BufRead,BufNewFile *.fs,*.ft,*.fth
endif endif
if !has_key(s:disabled_packages, 'glsl')
au! BufRead,BufNewFile *.fs,*.gs,*.comp
endif
if !has_key(s:disabled_packages, 'fsharp') if !has_key(s:disabled_packages, 'fsharp')
au! BufRead,BufNewFile *.fs au! BufRead,BufNewFile *.fs
endif endif
@@ -282,6 +286,10 @@ if !has_key(s:disabled_packages, 'git')
au! BufRead,BufNewFile .gitconfig,.gitmodules,*.git/config,*/.config/git/config,*.git/modules/*/config,git-rebase-todo au! BufRead,BufNewFile .gitconfig,.gitmodules,*.git/config,*/.config/git/config,*.git/modules/*/config,git-rebase-todo
endif endif
if !has_key(s:disabled_packages, 'glsl')
au! BufRead,BufNewFile *.fs,*.gs,*.comp
endif
if !has_key(s:disabled_packages, 'gnuplot') if !has_key(s:disabled_packages, 'gnuplot')
au! BufRead,BufNewFile *.gp,*.gpi au! BufRead,BufNewFile *.gp,*.gpi
endif endif
@@ -482,10 +490,6 @@ if !has_key(s:disabled_packages, 'xsl')
au! BufRead,BufNewFile *.xslt,*.xsl au! BufRead,BufNewFile *.xslt,*.xsl
endif endif
if !has_key(s:disabled_packages, 'yaml')
au! BufRead,BufNewFile *.yml,*.yaml
endif
if !has_key(s:disabled_packages, 'help') if !has_key(s:disabled_packages, 'help')
au! BufRead,BufNewFile $VIMRUNTIME/doc/*.txt au! BufRead,BufNewFile $VIMRUNTIME/doc/*.txt
endif endif
@@ -518,9 +522,13 @@ if !has_key(s:disabled_packages, '8th')
au BufNewFile,BufRead *.8th set ft=8th au BufNewFile,BufRead *.8th set ft=8th
endif endif
if !has_key(s:disabled_packages, 'conf')
au BufNewFile,BufRead *.conf,auto.master,config set ft=conf
endif
if !has_key(s:disabled_packages, 'haproxy') if !has_key(s:disabled_packages, 'haproxy')
au BufNewFile,BufRead *.cfg,haproxy.cfg set ft=haproxy au BufNewFile,BufRead *.cfg,haproxy.cfg set ft=haproxy
au BufNewFile,BufRead haproxy*.c* call s:StarSetf('haproxy') au BufNewFile,BufRead haproxy*.conf* call s:StarSetf('haproxy')
endif endif
if !has_key(s:disabled_packages, 'a2ps') if !has_key(s:disabled_packages, 'a2ps')
@@ -583,6 +591,10 @@ if !has_key(s:disabled_packages, 'ampl')
au BufNewFile,BufRead *.run set ft=ampl au BufNewFile,BufRead *.run set ft=ampl
endif endif
if !has_key(s:disabled_packages, 'csv')
au BufNewFile,BufRead *.csv,*.tab,*.tsv set ft=csv
endif
if !has_key(s:disabled_packages, 'xml') if !has_key(s:disabled_packages, 'xml')
au BufNewFile,BufRead *.adml,*.admx,*.ant,*.axml,*.builds,*.ccproj,*.ccxml,*.cdxml,*.clixml,*.cproject,*.cscfg,*.csdef,*.csl,*.csproj,*.csproj.user,*.ct,*.depproj,*.dita,*.ditamap,*.ditaval,*.dll.config,*.dotsettings,*.filters,*.fsproj,*.fxml,*.glade,*.gml,*.gmx,*.grxml,*.gst,*.iml,*.ivy,*.jelly,*.jsproj,*.kml,*.launch,*.mdpolicy,*.mjml,*.mm,*.mod,*.mxml,*.natvis,*.ncl,*.ndproj,*.nproj,*.nuspec,*.odd,*.osm,*.pkgproj,*.pluginspec,*.proj,*.props,*.ps1xml,*.psc1,*.pt,*.rdf,*.resx,*.rss,*.sch,*.scxml,*.sfproj,*.shproj,*.srdf,*.storyboard,*.sublime-snippet,*.targets,*.tml,*.tpm,*.ui,*.urdf,*.ux,*.vbproj,*.vcxproj,*.vsixmanifest,*.vssettings,*.vstemplate,*.vxml,*.wixproj,*.workflow,*.wpl,*.wsdl,*.wsf,*.wxi,*.wxl,*.wxs,*.x3d,*.xacro,*.xaml,*.xib,*.xlf,*.xliff,*.xmi,*.xml,*.xml.dist,*.xproj,*.xsd,*.xspec,*.xul,*.zcml,*/etc/blkid.tab,*/etc/blkid.tab.old,*/etc/xdg/menus/*.menu,*fglrxrc,{.,}classpath,{.,}cproject,{.,}project,App.config,NuGet.config,Settings.StyleCop,Web.Debug.config,Web.Release.config,Web.config,packages.config set ft=xml au BufNewFile,BufRead *.adml,*.admx,*.ant,*.axml,*.builds,*.ccproj,*.ccxml,*.cdxml,*.clixml,*.cproject,*.cscfg,*.csdef,*.csl,*.csproj,*.csproj.user,*.ct,*.depproj,*.dita,*.ditamap,*.ditaval,*.dll.config,*.dotsettings,*.filters,*.fsproj,*.fxml,*.glade,*.gml,*.gmx,*.grxml,*.gst,*.iml,*.ivy,*.jelly,*.jsproj,*.kml,*.launch,*.mdpolicy,*.mjml,*.mm,*.mod,*.mxml,*.natvis,*.ncl,*.ndproj,*.nproj,*.nuspec,*.odd,*.osm,*.pkgproj,*.pluginspec,*.proj,*.props,*.ps1xml,*.psc1,*.pt,*.rdf,*.resx,*.rss,*.sch,*.scxml,*.sfproj,*.shproj,*.srdf,*.storyboard,*.sublime-snippet,*.targets,*.tml,*.tpm,*.ui,*.urdf,*.ux,*.vbproj,*.vcxproj,*.vsixmanifest,*.vssettings,*.vstemplate,*.vxml,*.wixproj,*.workflow,*.wpl,*.wsdl,*.wsf,*.wxi,*.wxl,*.wxs,*.x3d,*.xacro,*.xaml,*.xib,*.xlf,*.xliff,*.xmi,*.xml,*.xml.dist,*.xproj,*.xsd,*.xspec,*.xul,*.zcml,*/etc/blkid.tab,*/etc/blkid.tab.old,*/etc/xdg/menus/*.menu,*fglrxrc,{.,}classpath,{.,}cproject,{.,}project,App.config,NuGet.config,Settings.StyleCop,Web.Debug.config,Web.Release.config,Web.config,packages.config set ft=xml
endif endif
@@ -717,10 +729,6 @@ if !has_key(s:disabled_packages, 'crystal')
au BufNewFile,BufRead *.cr,Projectfile set ft=crystal au BufNewFile,BufRead *.cr,Projectfile set ft=crystal
endif endif
if !has_key(s:disabled_packages, 'csv')
au BufNewFile,BufRead *.csv,*.tab,*.tsv set ft=csv
endif
if !has_key(s:disabled_packages, 'cucumber') if !has_key(s:disabled_packages, 'cucumber')
au BufNewFile,BufRead *.feature,*.story set ft=cucumber au BufNewFile,BufRead *.feature,*.story set ft=cucumber
endif endif
@@ -745,6 +753,10 @@ if !has_key(s:disabled_packages, 'dlang')
au BufNewFile,BufRead *.d,*.di set ft=d au BufNewFile,BufRead *.d,*.di set ft=d
endif endif
if !has_key(s:disabled_packages, 'yaml')
au BufNewFile,BufRead *.mir,*.reek,*.rviz,*.sublime-syntax,*.syntax,*.yaml,*.yaml-tmlanguage,*.yaml.sed,*.yml,*.yml.mysql,{.,}clang-format,{.,}clang-tidy,{.,}gemrc,fish_history,fish_read_history,glide.lock,yarn.lock set ft=yaml
endif
if !has_key(s:disabled_packages, 'dockerfile') if !has_key(s:disabled_packages, 'dockerfile')
au BufNewFile,BufRead docker-compose*.yaml,docker-compose*.yml set ft=yaml.docker-compose au BufNewFile,BufRead docker-compose*.yaml,docker-compose*.yml set ft=yaml.docker-compose
au BufNewFile,BufRead *.Dockerfile,*.dock,*.dockerfile,Dockerfile,dockerfile set ft=Dockerfile au BufNewFile,BufRead *.Dockerfile,*.dock,*.dockerfile,Dockerfile,dockerfile set ft=Dockerfile
@@ -793,11 +805,6 @@ if !has_key(s:disabled_packages, 'forth')
au BufNewFile,BufRead *.ft,*.fth set ft=forth au BufNewFile,BufRead *.ft,*.fth set ft=forth
endif endif
if !has_key(s:disabled_packages, 'glsl')
au! BufNewFile,BufRead *.fs call polyglot#DetectFsFiletype()
au BufNewFile,BufRead *.comp,*.fp,*.frag,*.frg,*.fsh,*.fshader,*.geo,*.geom,*.glsl,*.glslf,*.glslv,*.gs,*.gshader,*.shader,*.tesc,*.tese,*.vert,*.vrx,*.vsh,*.vshader set ft=glsl
endif
if !has_key(s:disabled_packages, 'fsharp') if !has_key(s:disabled_packages, 'fsharp')
au! BufNewFile,BufRead *.fs call polyglot#DetectFsFiletype() au! BufNewFile,BufRead *.fs call polyglot#DetectFsFiletype()
au BufNewFile,BufRead *.fsi,*.fsx set ft=fsharp au BufNewFile,BufRead *.fsi,*.fsx set ft=fsharp
@@ -815,6 +822,11 @@ if !has_key(s:disabled_packages, 'git')
au BufNewFile,BufRead */{.,}gitconfig.d/* call s:StarSetf('gitconfig') au BufNewFile,BufRead */{.,}gitconfig.d/* call s:StarSetf('gitconfig')
endif endif
if !has_key(s:disabled_packages, 'glsl')
au! BufNewFile,BufRead *.fs call polyglot#DetectFsFiletype()
au BufNewFile,BufRead *.comp,*.fp,*.frag,*.frg,*.fsh,*.fshader,*.geo,*.geom,*.glsl,*.glslf,*.glslv,*.gs,*.gshader,*.shader,*.tesc,*.tese,*.vert,*.vrx,*.vsh,*.vshader set ft=glsl
endif
if !has_key(s:disabled_packages, 'gmpl') if !has_key(s:disabled_packages, 'gmpl')
au BufNewFile,BufRead *.mod set ft=gmpl au BufNewFile,BufRead *.mod set ft=gmpl
endif endif
@@ -1333,10 +1345,6 @@ if !has_key(s:disabled_packages, 'xsl')
au BufNewFile,BufRead *.xsl,*.xslt set ft=xsl au BufNewFile,BufRead *.xsl,*.xslt set ft=xsl
endif endif
if !has_key(s:disabled_packages, 'yaml')
au BufNewFile,BufRead *.mir,*.reek,*.rviz,*.sublime-syntax,*.syntax,*.yaml,*.yaml-tmlanguage,*.yaml.sed,*.yml,*.yml.mysql,{.,}clang-format,{.,}clang-tidy,{.,}gemrc,fish_history,fish_read_history,glide.lock,yarn.lock set ft=yaml
endif
if !has_key(s:disabled_packages, 'ansible') if !has_key(s:disabled_packages, 'ansible')
au BufNewFile,BufRead handlers.*.y{a,}ml,local.y{a,}ml,main.y{a,}ml,playbook.y{a,}ml,requirements.y{a,}ml,roles.*.y{a,}ml,site.y{a,}ml,tasks.*.y{a,}ml set ft=yaml.ansible au BufNewFile,BufRead handlers.*.y{a,}ml,local.y{a,}ml,main.y{a,}ml,playbook.y{a,}ml,requirements.y{a,}ml,roles.*.y{a,}ml,site.y{a,}ml,tasks.*.y{a,}ml set ft=yaml.ansible
au BufNewFile,BufRead host_vars/* call s:StarSetf('yaml.ansible') au BufNewFile,BufRead host_vars/* call s:StarSetf('yaml.ansible')

23
ftplugin/conf.vim Normal file
View File

@@ -0,0 +1,23 @@
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'conf') == -1
" Vim filetype plugin file
" Language: generic configuration file
" Previous Maintainer: Nikolai Weibull <now@bitwi.se>
" Latest Revision: 2008-07-09
if exists("b:did_ftplugin")
finish
endif
let b:did_ftplugin = 1
let s:cpo_save = &cpo
set cpo&vim
let b:undo_ftplugin = "setl com< cms< fo<"
setlocal comments=:# commentstring=#\ %s formatoptions-=t formatoptions+=croql
let &cpo = s:cpo_save
unlet s:cpo_save
endif

View File

@@ -10,8 +10,6 @@ filetypes:
name: a2ps name: a2ps
remote: vim/vim:runtime remote: vim/vim:runtime
glob: '**/a2ps.vim' glob: '**/a2ps.vim'
after:
- haproxy
filetypes: filetypes:
- name: a2ps - name: a2ps
filenames: filenames:
@@ -142,7 +140,6 @@ filetypes:
name: ant name: ant
remote: vim/vim:runtime remote: vim/vim:runtime
glob: '**/ant.vim' glob: '**/ant.vim'
after: xml
filetypes: filetypes:
- name: ant - name: ant
filenames: filenames:
@@ -210,7 +207,7 @@ filetypes:
--- ---
name: arduino name: arduino
remote: sudar/vim-arduino-syntax remote: sudar/vim-arduino-syntax
after: c/c++ dependencies: c/c++
filetypes: filetypes:
- name: arduino - name: arduino
linguist: Processing linguist: Processing
@@ -240,7 +237,6 @@ filetypes:
name: automake name: automake
remote: vim/vim:runtime remote: vim/vim:runtime
glob: '**/automake.vim' glob: '**/automake.vim'
after: elf
filetypes: filetypes:
- name: automake - name: automake
filenames: filenames:
@@ -260,7 +256,6 @@ name: aspvbs
remote: vim/vim:runtime remote: vim/vim:runtime
globs: globs:
- '**/aspvbs.vim' - '**/aspvbs.vim'
dependencies:
filetypes: filetypes:
- name: aspvbs - name: aspvbs
extensions: extensions:
@@ -271,7 +266,6 @@ name: aspperl
remote: vim/vim:runtime remote: vim/vim:runtime
globs: globs:
- '**/aspperl.vim' - '**/aspperl.vim'
dependencies:
filetypes: filetypes:
- name: aspperl - name: aspperl
extensions: extensions:
@@ -347,7 +341,7 @@ filetypes:
--- ---
name: cpp-modern name: cpp-modern
remote: bfrg/vim-cpp-modern remote: bfrg/vim-cpp-modern
after: c/c++ dependencies: c/c++
filetypes: [] filetypes: []
--- ---
name: carp name: carp
@@ -590,7 +584,6 @@ name: fsharp
remote: ionide/Ionide-vim remote: ionide/Ionide-vim
ignored_dirs: ignored_dirs:
- ftplugin - ftplugin
after: glsl
filetypes: filetypes:
- name: fsharp - name: fsharp
linguist: F# linguist: F#
@@ -681,7 +674,8 @@ filetypes:
--- ---
name: graphql name: graphql
remote: jparise/vim-graphql remote: jparise/vim-graphql
after: [javascript, jsx] dependencies: javascript
after: jsx
ignored_dirs: ignored_dirs:
# TODO: remove after bug is fixed: # TODO: remove after bug is fixed:
# https://github.com/jparise/vim-graphql/issues/62 # https://github.com/jparise/vim-graphql/issues/62
@@ -692,7 +686,7 @@ filetypes:
--- ---
name: gradle name: gradle
remote: tfnico/vim-gradle remote: tfnico/vim-gradle
after: groovy dependencies: groovy
# Just adds compiler # Just adds compiler
filetypes: [] filetypes: []
--- ---
@@ -708,7 +702,6 @@ filetypes:
name: grub name: grub
remote: vim/vim:runtime remote: vim/vim:runtime
glob: '**/grub.vim' glob: '**/grub.vim'
after: dlang
filetypes: filetypes:
- name: grub - name: grub
filenames: filenames:
@@ -747,6 +740,8 @@ filetypes:
- name: haproxy - name: haproxy
linguist: HAProxy linguist: HAProxy
extra_filenames: extra_filenames:
- 'haproxy*.conf*'
ignored_warnings:
- 'haproxy*.c*' - 'haproxy*.c*'
--- ---
name: haskell name: haskell
@@ -858,7 +853,7 @@ filetypes:
--- ---
name: javascript-sql name: javascript-sql
remote: statico/vim-javascript-sql remote: statico/vim-javascript-sql
after: javascript dependencies: javascript
filetypes: [] filetypes: []
--- ---
name: jenkins name: jenkins
@@ -931,7 +926,7 @@ filetypes:
--- ---
name: jsx name: jsx
remote: MaxMEllon/vim-jsx-pretty remote: MaxMEllon/vim-jsx-pretty
after: javascript dependencies: javascript
filetypes: filetypes:
- name: javascriptreact - name: javascriptreact
linguist: JSX linguist: JSX
@@ -1158,7 +1153,7 @@ filetypes:
--- ---
name: octave name: octave
remote: McSinyx/vim-octave remote: McSinyx/vim-octave
after: mathematica dependencies: mathematica
filetypes: filetypes:
- name: octave - name: octave
extensions: extensions:
@@ -1223,7 +1218,7 @@ filetypes:
--- ---
name: blade name: blade
remote: jwalton512/vim-blade remote: jwalton512/vim-blade
after: php dependencies: php
filetypes: filetypes:
- name: blade - name: blade
linguist: Blade linguist: Blade
@@ -1245,7 +1240,6 @@ filetypes:
--- ---
name: powershell name: powershell
remote: PProvost/vim-ps1 remote: PProvost/vim-ps1
after: xml
filetypes: filetypes:
- name: ps1 - name: ps1
linguist: PowerShell linguist: PowerShell
@@ -1388,7 +1382,6 @@ 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
@@ -1780,7 +1773,7 @@ filetypes:
--- ---
name: ansible name: ansible
remote: pearofducks/ansible-vim remote: pearofducks/ansible-vim
after: yaml dependencies: yaml
filetypes: filetypes:
- name: yaml.ansible - name: yaml.ansible
filenames: filenames:
@@ -1928,3 +1921,14 @@ filetypes:
- tyb - tyb
- typ - typ
- tyc - tyc
---
name: conf
remote: vim/vim:runtime
glob: '**/conf.vim'
filetypes:
- name: conf
extensions:
- conf
filenames:
- auto.master
- config

View File

@@ -27,23 +27,81 @@ def except(hash, *keys)
h h
end end
def load_data() def verify(packages, heuristics)
packages = Hash[YAML.load_stream(File.read('packages.yaml')) extensions_with_heuristics = Set.new(heuristics.flat_map { |e| e["extensions"] })
.group_by { |a| a.fetch("name") } no_heuristics = Hash.new { |a, b| a[b] = [] }
.map { |a, b| [a, b.first] }]
deps = Hash.new { |h, k| h[k] = [] } for p in packages
for f in p["filetypes"]
for e in f["extensions"]
if !extensions_with_heuristics.include?(e)
no_heuristics[e] << p["name"]
end
end
end
end
no_heuristics.select! { |a, b| b.size > 1}
for e, names in no_heuristics
if ENV["DEV"]
puts "No heuristics for .#{e} extension (#{names.join(", ")})"
end
end
end
def sort_packages(packages)
implicit_dependencies = Hash.new { |h, k| h[k] = [] }
by_extension = Hash.new { |h, k| h[k] = [] }
for p in packages
for f in p["filetypes"]
for e in f["extensions"]
by_extension[e] << p["name"]
end
end
end
for p in packages
for f in p["filetypes"]
for t in f["filenames"]
filename = t.split('/').last
if filename.include?(".")
ext = filename.split(".").last.gsub('*', '')
if by_extension[ext]
for name in by_extension[ext]
if p["name"] != name
implicit_dependencies[p["name"]] |= [name]
end
end
end
end
end
end
end
packages = Hash[packages.group_by { |a| a.fetch("name") }.map { |a, b| [a, b.first] }]
each_node = lambda { |&b| packages.keys.each(&b) } each_node = lambda { |&b| packages.keys.each(&b) }
each_child = lambda {|n, &b| [packages[n]["after"] || []].flatten.each(&b) } each_child = lambda { |n, &b|
[
implicit_dependencies[n] || [],
packages[n]["dependencies"] || [],
packages[n]["after"] || []
].flatten.each(&b)
}
TSort.tsort(each_node, each_child).map { |a| packages[a] }
end
def load_data()
packages = load_packages
languages = load_languages languages = load_languages
heuristics = load_heuristics
# Reason can have ocaml as interpreter but let's not depend on it... # Reason can have ocaml as interpreter but let's not depend on it...
languages["Reason"]["interpreters"] -= ["ocaml"] languages["Reason"]["interpreters"] -= ["ocaml"]
packages = TSort.tsort(each_node, each_child).map { |a| packages[a] }
for package in packages for package in packages
for filetype in package["filetypes"] for filetype in package["filetypes"]
if filetype["linguist"] if filetype["linguist"]
@@ -90,7 +148,9 @@ def load_data()
end end
end end
heuristics = YAML.load_stream(File.read('heuristics.yaml')) verify(packages, heuristics)
packages = sort_packages(packages)
[packages, transform_patterns(heuristics)] [packages, transform_patterns(heuristics)]
end end
@@ -144,6 +204,14 @@ def load_languages
YAML.load(File.read(file)) YAML.load(File.read(file))
end end
def load_packages
YAML.load_stream(File.read('packages.yaml'))
end
def load_heuristics
YAML.load_stream(File.read('heuristics.yaml'))
end
def parse_remote(remote) def parse_remote(remote)
match = remote.match(/(?<repo>[^@:]+)(?:@(?<branch>[^:]+))?(?::(?<path>.*))?/) match = remote.match(/(?<repo>[^@:]+)(?:@(?<branch>[^:]+))?(?::(?<path>.*))?/)
dir = "tmp/" + match[:repo] + (match[:branch] ? "-#{match[:branch]}" : "") dir = "tmp/" + match[:repo] + (match[:branch] ? "-#{match[:branch]}" : "")
@@ -423,16 +491,6 @@ end
def generate_ftdetect(packages, heuristics) def generate_ftdetect(packages, heuristics)
output = "\n" output = "\n"
extensions = Hash.new { |h, k| h[k] = [] }
for package in packages
for filetype in package["filetypes"]
for ext in filetype["extensions"]
extensions[ext] << filetype["name"]
end
end
end
all_filetypes = packages.flat_map { |f| f["filetypes"] || [] } all_filetypes = packages.flat_map { |f| f["filetypes"] || [] }
filetype_names = Set.new(all_filetypes.map { |f| f["name"] }) filetype_names = Set.new(all_filetypes.map { |f| f["name"] })
@@ -738,8 +796,8 @@ def show_warnings(all_filetypes, expected_filetypes)
all_handled = process_list(all_filetypes, all_expected) do |f| all_handled = process_list(all_filetypes, all_expected) do |f|
[f["filenames"], f["ignored_filenames"], f["ignored_warnings"]].compact.flatten + [f["filenames"], f["ignored_filenames"], f["ignored_warnings"], f["extra_filenames"]].compact.flatten +
[f["extensions"], f["ignored_extensions"]].compact.flatten.map { |e| "*." + e } [f["extensions"], f["ignored_extensions"], f["extra_extensions"]].compact.flatten.map { |e| "*." + e }
end end
all_handled_regexps = Hash[all_handled.group_by { |a, b| a }.map do |a, b| all_handled_regexps = Hash[all_handled.group_by { |a, b| a }.map do |a, b|

30
syntax/conf.vim Normal file
View File

@@ -0,0 +1,30 @@
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'conf') == -1
" Vim syntax file
" Language: generic configure file
" Maintainer: Bram Moolenaar <Bram@vim.org>
" Last Change: 2005 Jun 20
" Quit when a (custom) syntax file was already loaded
if exists("b:current_syntax")
finish
endif
syn keyword confTodo contained TODO FIXME XXX
" Avoid matching "text#text", used in /etc/disktab and /etc/gettytab
syn match confComment "^#.*" contains=confTodo
syn match confComment "\s#.*"ms=s+1 contains=confTodo
syn region confString start=+"+ skip=+\\\\\|\\"+ end=+"+ oneline
syn region confString start=+'+ skip=+\\\\\|\\'+ end=+'+ oneline
" Define the default highlighting.
" Only used when an item doesn't have highlighting yet
hi def link confComment Comment
hi def link confTodo Todo
hi def link confString String
let b:current_syntax = "conf"
" vim: ts=8 sw=2
endif

View File

@@ -376,6 +376,10 @@ call TestExtension("html", "template.html", "{{ item.href }}")
call TestExtension("gitignore", ".gitignore", "") call TestExtension("gitignore", ".gitignore", "")
" .xml " .xml
call TestExtension("xml", ".fglrxrc", "") call TestExtension("xml", ".fglrxrc", "")
call TestExtension("xml", "fglrxrc", "") call TestExtension("xml", "fglrxrc", "")
" .conf
call TestExtension("conf", "foo.conf", "")
call TestExtension("conf", "config", "")
call TestExtension("conf", "auto.master", "")

View File

@@ -6,6 +6,7 @@ function! TestFiletype(filetype)
endfunction endfunction
call TestFiletype('8th') call TestFiletype('8th')
call TestFiletype('conf')
call TestFiletype('haproxy') call TestFiletype('haproxy')
call TestFiletype('a2ps') call TestFiletype('a2ps')
call TestFiletype('a65') call TestFiletype('a65')
@@ -22,6 +23,7 @@ call TestFiletype('aidl')
call TestFiletype('alsaconf') call TestFiletype('alsaconf')
call TestFiletype('aml') call TestFiletype('aml')
call TestFiletype('ampl') call TestFiletype('ampl')
call TestFiletype('csv')
call TestFiletype('xml') call TestFiletype('xml')
call TestFiletype('ant') call TestFiletype('ant')
call TestFiletype('apache') call TestFiletype('apache')
@@ -53,7 +55,6 @@ call TestFiletype('litcoffee')
call TestFiletype('cryptol') call TestFiletype('cryptol')
call TestFiletype('crystal') call TestFiletype('crystal')
call TestFiletype('ecrystal') call TestFiletype('ecrystal')
call TestFiletype('csv')
call TestFiletype('cucumber') call TestFiletype('cucumber')
call TestFiletype('cuesheet') call TestFiletype('cuesheet')
call TestFiletype('dart') call TestFiletype('dart')
@@ -63,6 +64,7 @@ call TestFiletype('dcov')
call TestFiletype('dd') call TestFiletype('dd')
call TestFiletype('ddoc') call TestFiletype('ddoc')
call TestFiletype('dsdl') call TestFiletype('dsdl')
call TestFiletype('yaml')
call TestFiletype('Dockerfile') call TestFiletype('Dockerfile')
call TestFiletype('yaml.docker-compose') call TestFiletype('yaml.docker-compose')
call TestFiletype('elixir') call TestFiletype('elixir')
@@ -76,13 +78,13 @@ call TestFiletype('ferm')
call TestFiletype('fish') call TestFiletype('fish')
call TestFiletype('fbs') call TestFiletype('fbs')
call TestFiletype('forth') call TestFiletype('forth')
call TestFiletype('glsl')
call TestFiletype('fsharp') call TestFiletype('fsharp')
call TestFiletype('gdscript3') call TestFiletype('gdscript3')
call TestFiletype('gitconfig') call TestFiletype('gitconfig')
call TestFiletype('gitrebase') call TestFiletype('gitrebase')
call TestFiletype('gitsendemail') call TestFiletype('gitsendemail')
call TestFiletype('gitcommit') call TestFiletype('gitcommit')
call TestFiletype('glsl')
call TestFiletype('gmpl') call TestFiletype('gmpl')
call TestFiletype('gnuplot') call TestFiletype('gnuplot')
call TestFiletype('go') call TestFiletype('go')
@@ -221,7 +223,6 @@ call TestFiletype('vmasm')
call TestFiletype('vue') call TestFiletype('vue')
call TestFiletype('xdc') call TestFiletype('xdc')
call TestFiletype('xsl') call TestFiletype('xsl')
call TestFiletype('yaml')
call TestFiletype('yaml.ansible') call TestFiletype('yaml.ansible')
call TestFiletype('helm') call TestFiletype('helm')
call TestFiletype('help') call TestFiletype('help')