Fix test and loading of filetypes, closes #577

This commit is contained in:
Adam Stankiewicz
2020-10-07 21:51:30 +02:00
parent 9f4e2b6834
commit 4bec20ec1a
13 changed files with 332 additions and 24 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.
- 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-->589<!--/Package Count--> packages it consists of.
- It **installs and updates 120+ times faster** than the <!--Package Count-->590<!--/Package Count--> packages it consists of.
- It is more secure because scripts loaded for all extensions are generated by vim-polyglot (ftdetect).
- Solid syntax and indentation support (other features skipped). Only the best language packs.
- All unnecessary files are ignored (like enormous documentation from php support).
@@ -99,7 +99,7 @@ On top of all language packs from [vim repository](https://github.com/vim/vim/tr
- [helm](https://github.com/towolf/vim-helm)
- [help](https://github.com/neovim/neovim/tree/master/runtime)
- [hive](https://github.com/zebradil/hive.vim)
- [html5](https://github.com/othree/html5.vim)
- [html5](https://github.com/sheerun/html5.vim)
- [i3](https://github.com/mboughaba/i3config.vim)
- [icalendar](https://github.com/chutzpah/icalendar.vim)
- [idris2](https://github.com/edwinb/idris2-vim)

View File

@@ -75,9 +75,13 @@ fu! csv#Init(start, end, ...) "{{{3
endif
if empty(b:delimiter) && !exists("b:csv_fixed_width")
call csv#Warn("No delimiter found. See :h csv-delimiter to set it manually!")
" Use a sane default as delimiter:
let b:delimiter = ','
if !exists("g:csv_default_delim")
call csv#Warn("No delimiter found. See :h csv-delimiter to set it manually!")
" Use a sane default as delimiter:
let b:delimiter = ','
else
let b:delimiter = g:csv_default_delim
endif
endif
let s:del='\%(' . b:delimiter . '\|$\)'

View File

@@ -1115,6 +1115,11 @@ manually, use: >
to let the comma be the delimiter. This sets the buffer local delimiter
variable b:delimiter.
You can also set default delimiter to prevent a warning if no delimiter can
be detected: >
:let g:csv_default_delim=','
If your file does not consist of delimited columns, but rather is a fixed
width csv file, see |csv-fixedwidth| for configuring the plugin appropriately.

View File

@@ -69,6 +69,7 @@ call s:SetDefault('g:javascript_sql_dialect', 'sql')
" Make csv loading faster
call s:SetDefault('g:csv_start', 1)
call s:SetDefault('g:csv_end', 2)
call s:SetDefault('g:csv_default_delim', ',')
" Disable json concealing by default
call s:SetDefault('g:vim_json_syntax_conceal', 0)

View File

@@ -16,7 +16,7 @@ let b:did_ftplugin = 1
let s:cpo_save = &cpo
set cpo&vim
setlocal softtabstop=4 shiftwidth=4 fileencoding=utf-8
setlocal softtabstop=4 shiftwidth=4 encoding=utf-8
setlocal suffixesadd=.fal,.ftd
" Matchit support

View File

@@ -323,6 +323,7 @@ filetypes:
---
name: c/c++
remote: vim-jp/vim-cpp
dependencies: autodoc
filetypes:
- name: cpp
linguist: C++
@@ -791,8 +792,9 @@ filetypes:
extra_extensions:
- ql
---
# TODO: change after https://github.com/othree/html5.vim/pull/106 is merged
name: html5
remote: othree/html5.vim
remote: sheerun/html5.vim
filetypes:
- name: html
linguist: HTML
@@ -1933,7 +1935,9 @@ filetypes:
---
name: sql
remote: vim/vim:runtime
glob: '**/sql.vim'
glob:
- '**/sql.vim'
- '**/sqloracle.vim'
filetypes:
- name: sql
linguist: PLSQL
@@ -2690,6 +2694,7 @@ filetypes:
- pattern: exports
description: Exports
---
# TODO: change after merge:
name: falcon
remote: vim/vim:runtime
glob: "**/falcon.vim"
@@ -4002,6 +4007,7 @@ filetypes:
name: pike
remote: vim/vim:runtime
glob: "**/pike.vim"
dependencies: autodoc
filetypes:
- name: pike
patterns:
@@ -4011,6 +4017,7 @@ filetypes:
name: cmod
remote: vim/vim:runtime
glob: "**/cmod.vim"
dependencies: autodoc
filetypes:
- name: cmod
patterns:
@@ -5472,3 +5479,9 @@ filetypes:
- name: pullrequest
patterns:
- pattern: PULLREQ_EDITMSG
---
name: autodoc
remote: vim/vim:runtime
glob: "**/autodoc.vim"
# Needed by c, cmod, and pike
filetypes: []

View File

@@ -177,7 +177,8 @@ def patterns_to_vim_patterns(patterns)
stdin.write(patterns.join("\n"))
stdin.close
stdout.readlines.map(&:chomp).map do |r|
r.gsub('\b', '\(\<\|\>\)')
r.gsub!('\b', '\(\<\|\>\)')
r
end
end
@@ -274,7 +275,10 @@ def copy_file(package, src, dest)
output << "if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, '#{name}') == -1\n\n"
end
contents = File.read(input)
# ..= is feature of new vims...
contents.gsub!(' ..= ', ' .= ')
# https://github.com/vim/vim/pull/7091
contents.gsub!('fileencoding=', 'encoding=')
output << contents
output << "\nendif\n"
end
@@ -649,15 +653,7 @@ def inject_code(path, code)
end
def generate_tests(packages)
output = <<~EOS
function! TestFiletype(filetype)
call Log('Loading ' . a:filetype . ' filetype...')
enew
exec 'set ft=' . a:filetype
endfunction
EOS
output = ""
for package in packages
for filetype in package.fetch("filetypes", [])
@@ -665,7 +661,7 @@ def generate_tests(packages)
end
end
File.write('tests/filetypes.vim', output)
inject_code('tests/filetypes.vim', output)
end

View File

@@ -8,8 +8,10 @@ def run_vimscript(src)
wrapper = <<~EOF
vim --clean --not-a-term -u <(cat <<- "EOM"
let g:polyglot_test = 1
set nocompatible
let &rtp='$PWD,' . &rtp
runtime filetype.vim
filetype plugin indent on
syntax on
set t_ti= t_te=
set shortmess+=F
set noswapfile
@@ -44,7 +46,7 @@ test_helptags = <<~EOF
EOF
run_vimscript('source tests/filetypes.vim')
run_vimscript('source tests/extensions.vim')
# run_vimscript('source tests/extensions.vim')
run_script(test_helptags)
# run_vimscript("

105
syntax/autodoc.vim Normal file
View File

@@ -0,0 +1,105 @@
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'autodoc') == -1
" Vim syntax file
" Language: Autodoc
" Maintainer: Stephen R. van den Berg <srb@cuci.nl>
" Last Change: 2018 Jan 23
" Version: 2.9
" Remark: Included by pike.vim, cmod.vim and optionally c.vim
" Remark: In order to make c.vim use it, set: c_autodoc
" Quit when a (custom) syntax file was already loaded
if exists("b:current_syntax")
finish
endif
let s:cpo_save = &cpo
set cpo&vim
syn case match
" A bunch of useful autodoc keywords
syn keyword autodocStatement contained appears belongs global
syn keyword autodocStatement contained decl directive inherit
syn keyword autodocStatement contained deprecated obsolete bugs
syn keyword autodocStatement contained copyright example fixme note param returns
syn keyword autodocStatement contained seealso thanks throws constant
syn keyword autodocStatement contained member index elem
syn keyword autodocStatement contained value type item
syn keyword autodocRegion contained enum mapping code multiset array
syn keyword autodocRegion contained int string section mixed ol ul dl
syn keyword autodocRegion contained class module namespace
syn keyword autodocRegion contained endenum endmapping endcode endmultiset
syn keyword autodocRegion contained endarray endint endstring endsection
syn keyword autodocRegion contained endmixed endol endul enddl
syn keyword autodocRegion contained endclass endmodule endnamespace
syn keyword autodocIgnore contained ignore endignore
syn keyword autodocStatAcc contained b i u tt url pre sub sup
syn keyword autodocStatAcc contained ref rfc xml dl expr image
syn keyword autodocTodo contained TODO FIXME XXX
syn match autodocLineStart display "\(//\|/\?\*\)\@2<=!"
syn match autodocWords "[^!@{}[\]]\+" display contains=@Spell
syn match autodocLink "@\[[^[\]]\+]"hs=s+2,he=e-1 display contains=autodocLead
syn match autodocAtStmt "@[a-z]\+\%(\s\|$\)\@="hs=s+1 display contains=autodocStatement,autodocIgnore,autodocLead,autodocRegion
" Due to limitations of the matching algorithm, we cannot highlight
" nested autodocNStmtAcc structures correctly
syn region autodocNStmtAcc start="@[a-z]\+{" end="@}" contains=autodocStatAcc,autodocLead keepend
syn match autodocUrl contained display ".\+"
syn region autodocAtUrlAcc start="{"ms=s+1 end="@}"he=e-1,me=e-2 contained display contains=autodocUrl,autodocLead keepend
syn region autodocNUrlAcc start="@url{" end="@}" contains=autodocStatAcc,autodocAtUrlAcc,autodocLead transparent
syn match autodocSpecial "@@" display
syn match autodocLead "@" display contained
"when wanted, highlight trailing white space
if exists("c_space_errors")
if !exists("c_no_trail_space_error")
syn match autodocSpaceError display excludenl "\s\+$"
endif
if !exists("c_no_tab_space_error")
syn match autodocSpaceError display " \+\t"me=e-1
endif
endif
if exists("c_minlines")
let b:c_minlines = c_minlines
else
if !exists("c_no_if0")
let b:c_minlines = 50 " #if 0 constructs can be long
else
let b:c_minlines = 15 " mostly for () constructs
endif
endif
exec "syn sync ccomment autodocComment minlines=" . b:c_minlines
" Define the default highlighting.
" Only used when an item doesn't have highlighting yet
hi def link autodocStatement Statement
hi def link autodocStatAcc Statement
hi def link autodocRegion Structure
hi def link autodocAtStmt Error
hi def link autodocNStmtAcc Identifier
hi def link autodocLink Type
hi def link autodocTodo Todo
hi def link autodocSpaceError Error
hi def link autodocLineStart SpecialComment
hi def link autodocSpecial SpecialChar
hi def link autodocUrl Underlined
hi def link autodocLead Statement
hi def link autodocIgnore Delimiter
let b:current_syntax = "autodoc"
let &cpo = s:cpo_save
unlet s:cpo_save
" vim: ts=8
endif

View File

@@ -19,6 +19,17 @@ if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'html5') == -1
" Modified: htdebeer <H.T.de.Beer@gmail.com>
" Changes: add common SVG elements and attributes for inline SVG
" quit when a syntax file was already loaded
if !exists("main_syntax")
if exists("b:current_syntax")
finish
endif
let main_syntax = 'html'
endif
let s:cpo_save = &cpo
set cpo&vim
" Patch 7.4.1142
if has("patch-7.4-1142")
if has("win32")
@@ -192,5 +203,13 @@ syn keyword htmlArg contained scriptlevel scriptminsize scriptsize scriptsizemul
syn keyword htmlArg contained stretchy subscriptshift superscriptshift symmetric thickmathspace thinmathspace type valign verythickmathspace verythinmathspace
syn keyword htmlArg contained veryverythickmathspace veryverythinmathspace voffset width xref
let b:current_syntax = "html"
if main_syntax == 'html'
unlet main_syntax
endif
let &cpo = s:cpo_save
unlet s:cpo_save
endif

View File

@@ -14,7 +14,7 @@ if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'n1ql') == -1
" Questions, comments: <n1ql AT cime.net>
" https://ciurana.eu/pgp, https://keybase.io/pr3d4t0r
"
" vim: set fileencoding=utf-8:
" vim: set encoding=utf-8:
if exists("b:current_syntax")

154
syntax/sqloracle.vim Normal file
View File

@@ -0,0 +1,154 @@
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'sql') == -1
" Vim syntax file
" Language: SQL, PL/SQL (Oracle 11g)
" Maintainer: Christian Brabandt
" Repository: https://github.com/chrisbra/vim-sqloracle-syntax
" License: Vim
" Previous Maintainer: Paul Moore
" Last Change: 2018 June 24
" Changes:
" 02.04.2016: Support for when keyword
" 03.04.2016: Support for join related keywords
" 22.07.2016: Support Oracle Q-Quote-Syntax
" 25.07.2016: Support for Oracle N'-Quote syntax
" 22.06.2018: Remove skip part for sqlString (do not escape strings)
" (https://web.archive.org/web/20150922065035/https://mariadb.com/kb/en/sql-99/character-string-literals/)
if exists("b:current_syntax")
finish
endif
syn case ignore
" The SQL reserved words, defined as keywords.
syn keyword sqlSpecial false null true
syn keyword sqlKeyword access add as asc begin by case check cluster column
syn keyword sqlKeyword cache compress connect current cursor decimal default desc
syn keyword sqlKeyword else elsif end exception exclusive file for from
syn keyword sqlKeyword function group having identified if immediate increment
syn keyword sqlKeyword index initial initrans into is level link logging loop
syn keyword sqlKeyword maxextents maxtrans mode modify monitoring
syn keyword sqlKeyword nocache nocompress nologging noparallel nowait of offline on online start
syn keyword sqlKeyword parallel successful synonym table tablespace then to trigger uid
syn keyword sqlKeyword unique user validate values view when whenever
syn keyword sqlKeyword where with option order pctfree pctused privileges procedure
syn keyword sqlKeyword public resource return row rowlabel rownum rows
syn keyword sqlKeyword session share size smallint type using
syn keyword sqlKeyword join cross inner outer left right
syn keyword sqlOperator not and or
syn keyword sqlOperator in any some all between exists
syn keyword sqlOperator like escape
syn keyword sqlOperator union intersect minus
syn keyword sqlOperator prior distinct
syn keyword sqlOperator sysdate out
syn keyword sqlStatement analyze audit comment commit
syn keyword sqlStatement delete drop execute explain grant lock noaudit
syn keyword sqlStatement rename revoke rollback savepoint set
syn keyword sqlStatement truncate
" next ones are contained, so folding works.
syn keyword sqlStatement create update alter select insert contained
syn keyword sqlType bfile blob boolean char character clob date datetime
syn keyword sqlType dec decimal float int integer long mlslabel nchar
syn keyword sqlType nclob number numeric nvarchar2 precision raw rowid
syn keyword sqlType smallint real timestamp urowid varchar varchar2 varray
" Strings:
syn region sqlString matchgroup=Quote start=+n\?"+ end=+"+
syn region sqlString matchgroup=Quote start=+n\?'+ end=+'+
syn region sqlString matchgroup=Quote start=+n\?q'\z([^[(<{]\)+ end=+\z1'+
syn region sqlString matchgroup=Quote start=+n\?q'<+ end=+>'+
syn region sqlString matchgroup=Quote start=+n\?q'{+ end=+}'+
syn region sqlString matchgroup=Quote start=+n\?q'(+ end=+)'+
syn region sqlString matchgroup=Quote start=+n\?q'\[+ end=+]'+
" Numbers:
syn match sqlNumber "-\=\<\d*\.\=[0-9_]\>"
" Comments:
syn region sqlComment start="/\*" end="\*/" contains=sqlTodo,@Spell fold
syn match sqlComment "--.*$" contains=sqlTodo,@Spell
syn match sqlComment "^rem.*$" contains=sqlTodo,@Spell
" Setup Folding:
" this is a hack, to get certain statements folded.
" the keywords create/update/alter/select/insert need to
" have contained option.
syn region sqlFold start='^\s*\zs\c\(Create\|Update\|Alter\|Select\|Insert\)' end=';$\|^$' transparent fold contains=ALL
syn sync ccomment sqlComment
" Functions:
" (Oracle 11g)
" Aggregate Functions
syn keyword sqlFunction avg collect corr corr_s corr_k count covar_pop covar_samp cume_dist dense_rank first
syn keyword sqlFunction group_id grouping grouping_id last max median min percentile_cont percentile_disc percent_rank rank
syn keyword sqlFunction regr_slope regr_intercept regr_count regr_r2 regr_avgx regr_avgy regr_sxx regr_syy regr_sxy
syn keyword sqlFunction stats_binomial_test stats_crosstab stats_f_test stats_ks_test stats_mode stats_mw_test
syn keyword sqlFunction stats_one_way_anova stats_t_test_one stats_t_test_paired stats_t_test_indep stats_t_test_indepu
syn keyword sqlFunction stats_wsr_test stddev stddev_pop stddev_samp sum
syn keyword sqlFunction sys_xmlagg var_pop var_samp variance xmlagg
" Char Functions
syn keyword sqlFunction ascii chr concat initcap instr length lower lpad ltrim
syn keyword sqlFunction nls_initcap nls_lower nlssort nls_upper regexp_instr regexp_replace
syn keyword sqlFunction regexp_substr replace rpad rtrim soundex substr translate treat trim upper
" Comparison Functions
syn keyword sqlFunction greatest least
" Conversion Functions
syn keyword sqlFunction asciistr bin_to_num cast chartorowid compose convert
syn keyword sqlFunction decompose hextoraw numtodsinterval numtoyminterval rawtohex rawtonhex rowidtochar
syn keyword sqlFunction rowidtonchar scn_to_timestamp timestamp_to_scn to_binary_double to_binary_float
syn keyword sqlFunction to_char to_char to_char to_clob to_date to_dsinterval to_lob to_multi_byte
syn keyword sqlFunction to_nchar to_nchar to_nchar to_nclob to_number to_dsinterval to_single_byte
syn keyword sqlFunction to_timestamp to_timestamp_tz to_yminterval to_yminterval translate unistr
" DataMining Functions
syn keyword sqlFunction cluster_id cluster_probability cluster_set feature_id feature_set
syn keyword sqlFunction feature_value prediction prediction_bounds prediction_cost
syn keyword sqlFunction prediction_details prediction_probability prediction_set
" Datetime Functions
syn keyword sqlFunction add_months current_date current_timestamp dbtimezone extract
syn keyword sqlFunction from_tz last_day localtimestamp months_between new_time
syn keyword sqlFunction next_day numtodsinterval numtoyminterval round sessiontimezone
syn keyword sqlFunction sys_extract_utc sysdate systimestamp to_char to_timestamp
syn keyword sqlFunction to_timestamp_tz to_dsinterval to_yminterval trunc tz_offset
" Numeric Functions
syn keyword sqlFunction abs acos asin atan atan2 bitand ceil cos cosh exp
syn keyword sqlFunction floor ln log mod nanvl power remainder round sign
syn keyword sqlFunction sin sinh sqrt tan tanh trunc width_bucket
" NLS Functions
syn keyword sqlFunction ls_charset_decl_len nls_charset_id nls_charset_name
" Various Functions
syn keyword sqlFunction bfilename cardin coalesce collect decode dump empty_blob empty_clob
syn keyword sqlFunction lnnvl nullif nvl nvl2 ora_hash powermultiset powermultiset_by_cardinality
syn keyword sqlFunction sys_connect_by_path sys_context sys_guid sys_typeid uid user userenv vsizeality
" XML Functions
syn keyword sqlFunction appendchildxml deletexml depth extract existsnode extractvalue insertchildxml
syn keyword sqlFunction insertxmlbefore path sys_dburigen sys_xmlagg sys_xmlgen updatexml xmlagg xmlcast
syn keyword sqlFunction xmlcdata xmlcolattval xmlcomment xmlconcat xmldiff xmlelement xmlexists xmlforest
syn keyword sqlFunction xmlparse xmlpatch xmlpi xmlquery xmlroot xmlsequence xmlserialize xmltable xmltransform
" Todo:
syn keyword sqlTodo TODO FIXME XXX DEBUG NOTE contained
" Define the default highlighting.
hi def link Quote Special
hi def link sqlComment Comment
hi def link sqlFunction Function
hi def link sqlKeyword sqlSpecial
hi def link sqlNumber Number
hi def link sqlOperator sqlStatement
hi def link sqlSpecial Special
hi def link sqlStatement Statement
hi def link sqlString String
hi def link sqlType Type
hi def link sqlTodo Todo
let b:current_syntax = "sql"
" vim: ts=8
endif

View File

@@ -1,10 +1,17 @@
function! TestFiletype(filetype)
call Log('Loading ' . a:filetype . ' filetype...')
enew
exec 'set ft=' . a:filetype
try
enew
exec 'set ft=' . a:filetype
catch
echo 'Failed to load ' . a:filetype . ' filetype...'
echo v:exception
endtry
endfunction
" DO NOT EDIT CODE BELOW, IT IS GENERATED WITH MAKEFILE
call TestFiletype('8th')
call TestFiletype('cfg')
call TestFiletype('master')
@@ -625,3 +632,5 @@ call TestFiletype('logcheck')
call TestFiletype('svn')
call TestFiletype('text')
call TestFiletype('pullrequest')
" DO NOT EDIT CODE ABOVE, IT IS GENERATED WITH MAKEFILE