mirror of
https://github.com/vim/vim.git
synced 2025-10-04 05:25:06 -04:00
patch 9.0.1539: typst filetype is not recognized
Problem: Typst filetype is not recognized. Solution: Distinguish between sql and typst. (Gaetan Lepage, closes #12363)
This commit is contained in:
committed by
Bram Moolenaar
parent
411da64e77
commit
4ce1bda869
25
runtime/autoload/dist/ft.vim
vendored
25
runtime/autoload/dist/ft.vim
vendored
@@ -1106,6 +1106,31 @@ export def FTlsl()
|
|||||||
endif
|
endif
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
|
export def FTtyp()
|
||||||
|
if exists("g:filetype_typ")
|
||||||
|
exe "setf " .. g:filetype_typ
|
||||||
|
return
|
||||||
|
endif
|
||||||
|
|
||||||
|
# Look for SQL type definition syntax
|
||||||
|
for line in getline(1, 200)
|
||||||
|
# SQL type files may define the casing
|
||||||
|
if line =~ '^CASE\s\==\s\=\(SAME\|LOWER\|UPPER\|OPPOSITE\)$'
|
||||||
|
setf sql
|
||||||
|
return
|
||||||
|
endif
|
||||||
|
|
||||||
|
# SQL type files may define some types as follows
|
||||||
|
if line =~ '^TYPE\s.*$'
|
||||||
|
setf sql
|
||||||
|
return
|
||||||
|
endif
|
||||||
|
endfor
|
||||||
|
|
||||||
|
# Otherwise, affect the typst filetype
|
||||||
|
setf typst
|
||||||
|
enddef
|
||||||
|
|
||||||
# Set the filetype of a *.v file to Verilog, V or Cog based on the first 200
|
# Set the filetype of a *.v file to Verilog, V or Cog based on the first 200
|
||||||
# lines.
|
# lines.
|
||||||
export def FTv()
|
export def FTv()
|
||||||
|
@@ -164,6 +164,7 @@ variables can be used to overrule the filetype used for certain extensions:
|
|||||||
*.sys g:filetype_sys
|
*.sys g:filetype_sys
|
||||||
*.sh g:bash_is_sh |ft-sh-syntax|
|
*.sh g:bash_is_sh |ft-sh-syntax|
|
||||||
*.tex g:tex_flavor |ft-tex-plugin|
|
*.tex g:tex_flavor |ft-tex-plugin|
|
||||||
|
*.typ g:filetype_typ
|
||||||
*.w g:filetype_w |ft-cweb-syntax|
|
*.w g:filetype_w |ft-cweb-syntax|
|
||||||
|
|
||||||
For a few filetypes the global variable is used only when the filetype could
|
For a few filetypes the global variable is used only when the filetype could
|
||||||
|
@@ -2058,7 +2058,10 @@ au BufNewFile,BufRead *.spy,*.spi setf spyce
|
|||||||
au BufNewFile,BufRead squid.conf setf squid
|
au BufNewFile,BufRead squid.conf setf squid
|
||||||
|
|
||||||
" SQL for Oracle Designer
|
" SQL for Oracle Designer
|
||||||
au BufNewFile,BufRead *.tyb,*.typ,*.tyc,*.pkb,*.pks setf sql
|
au BufNewFile,BufRead *.tyb,*.tyc,*.pkb,*.pks setf sql
|
||||||
|
|
||||||
|
" *.typ can be either SQL or Typst files
|
||||||
|
au BufNewFile,BufRead *.typ call dist#ft#FTtyp()
|
||||||
|
|
||||||
" SQL
|
" SQL
|
||||||
au BufNewFile,BufRead *.sql call dist#ft#SQL()
|
au BufNewFile,BufRead *.sql call dist#ft#SQL()
|
||||||
|
@@ -564,7 +564,7 @@ let s:filename_checks = {
|
|||||||
\ 'spice': ['file.sp', 'file.spice'],
|
\ 'spice': ['file.sp', 'file.spice'],
|
||||||
\ 'spup': ['file.speedup', 'file.spdata', 'file.spd'],
|
\ 'spup': ['file.speedup', 'file.spdata', 'file.spd'],
|
||||||
\ 'spyce': ['file.spy', 'file.spi'],
|
\ 'spyce': ['file.spy', 'file.spi'],
|
||||||
\ 'sql': ['file.tyb', 'file.typ', 'file.tyc', 'file.pkb', 'file.pks'],
|
\ 'sql': ['file.tyb', 'file.tyc', 'file.pkb', 'file.pks'],
|
||||||
\ 'sqlj': ['file.sqlj'],
|
\ 'sqlj': ['file.sqlj'],
|
||||||
\ 'prql': ['file.prql'],
|
\ 'prql': ['file.prql'],
|
||||||
\ 'sqr': ['file.sqr', 'file.sqi'],
|
\ 'sqr': ['file.sqr', 'file.sqi'],
|
||||||
@@ -2047,4 +2047,35 @@ func Test_lsl_file()
|
|||||||
filetype off
|
filetype off
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
func Test_typ_file()
|
||||||
|
filetype on
|
||||||
|
|
||||||
|
" SQL type file
|
||||||
|
|
||||||
|
call writefile(['CASE = LOWER'], 'Xfile.typ', 'D')
|
||||||
|
split Xfile.typ
|
||||||
|
call assert_equal('sql', &filetype)
|
||||||
|
bwipe!
|
||||||
|
|
||||||
|
call writefile(['TYPE foo'], 'Xfile.typ')
|
||||||
|
split Xfile.typ
|
||||||
|
call assert_equal('sql', &filetype)
|
||||||
|
bwipe!
|
||||||
|
|
||||||
|
" typst document
|
||||||
|
|
||||||
|
call writefile(['this is a fallback'], 'Xfile.typ')
|
||||||
|
split Xfile.typ
|
||||||
|
call assert_equal('typst', &filetype)
|
||||||
|
bwipe!
|
||||||
|
|
||||||
|
let g:filetype_typ = 'typst'
|
||||||
|
split test.typ
|
||||||
|
call assert_equal('typst', &filetype)
|
||||||
|
bwipe!
|
||||||
|
unlet g:filetype_typ
|
||||||
|
|
||||||
|
filetype off
|
||||||
|
endfunc
|
||||||
|
|
||||||
" vim: shiftwidth=2 sts=2 expandtab
|
" vim: shiftwidth=2 sts=2 expandtab
|
||||||
|
@@ -695,6 +695,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
1539,
|
||||||
/**/
|
/**/
|
||||||
1538,
|
1538,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user