Patch 8.2.2334
Problem: Pascal-like filetypes not always detected.
Solution: Improved Puppet, InstantFPC and Pascal detection. (Doug Kearns,
closes #7662)
Files: runtime/autoload/dist/ft.vim, runtime/filetype.vim,
runtime/scripts.vim, src/testdir/test_filetype.vim
*** ../vim-8.2.2333/runtime/autoload/dist/ft.vim 2020-08-17
21:57:04.710167546 +0200
--- runtime/autoload/dist/ft.vim 2021-01-12 17:26:12.112498783 +0100
***************
*** 362,367 ****
--- 362,371 ----
setf aspvbs
elseif lines =~ "<?"
setf php
+ " Pascal supports // comments but they're vary rarely used for file
+ " headers so assume POV-Ray
+ elseif lines =~ '^\s*\%({\|(\*\)' || lines =~? s:ft_pascal_keywords
+ setf pascal
else
call dist#ft#FTasmsyntax()
if exists("b:asmsyntax")
***************
*** 408,413 ****
--- 412,420 ----
setf progress
endfunc
+ let s:ft_pascal_comments = '^\s*\%({\|(\*\|//\)'
+ let s:ft_pascal_keywords =
'^\s*\%(program\|unit\|library\|uses\|begin\|procedure\|function\|const\|type\|var\)\>'
+
func dist#ft#FTprogress_pascal()
if exists("g:filetype_p")
exe "setf " . g:filetype_p
***************
*** 419,426 ****
let lnum = 1
while lnum <= 10 && lnum < line('$')
let line = getline(lnum)
! if line =~
'^\s*\(program\|unit\|procedure\|function\|const\|type\|var\)\>'
! \ || line =~ '^\s*{' || line =~ '^\s*(\*'
setf pascal
return
elseif line !~ '^\s*$' || line =~ '^/\*'
--- 426,432 ----
let lnum = 1
while lnum <= 10 && lnum < line('$')
let line = getline(lnum)
! if line =~ s:ft_pascal_comments || line =~? s:ft_pascal_keywords
setf pascal
return
elseif line !~ '^\s*$' || line =~ '^/\*'
***************
*** 433,438 ****
--- 439,457 ----
setf progress
endfunc
+ func dist#ft#FTpp()
+ if exists("g:filetype_pp")
+ exe "setf " . g:filetype_pp
+ else
+ let line = getline(nextnonblank(1))
+ if line =~ s:ft_pascal_comments || line =~? s:ft_pascal_keywords
+ setf pascal
+ else
+ setf puppet
+ endif
+ endif
+ endfunc
+
func dist#ft#FTr()
let max = line("$") > 50 ? 50 : line("$")
*** ../vim-8.2.2333/runtime/filetype.vim 2021-01-01 13:53:56.929340268
+0100
--- runtime/filetype.vim 2021-01-12 17:26:12.124498752 +0100
***************
*** 1174,1180 ****
au BufNewFile,BufRead
*/etc/passwd,*/etc/passwd-,*/etc/passwd.edit,*/etc/shadow,*/etc/shadow-,*/etc/shadow.edit,*/var/backups/passwd.bak,*/var/backups/shadow.bak
setf passwd
" Pascal (also *.p)
! au BufNewFile,BufRead *.pas,*.pp setf pascal
" Delphi or Lazarus program file
au BufNewFile,BufRead *.dpr,*.lpr setf pascal
--- 1174,1182 ----
au BufNewFile,BufRead
*/etc/passwd,*/etc/passwd-,*/etc/passwd.edit,*/etc/shadow,*/etc/shadow-,*/etc/shadow.edit,*/var/backups/passwd.bak,*/var/backups/shadow.bak
setf passwd
" Pascal (also *.p)
! au BufNewFile,BufRead *.pas setf pascal
!
! au BufNewFile,BufRead *.pp call dist#ft#FTpp()
" Delphi or Lazarus program file
au BufNewFile,BufRead *.dpr,*.lpr setf pascal
*** ../vim-8.2.2333/runtime/scripts.vim 2020-06-07 21:58:09.872657559 +0200
--- runtime/scripts.vim 2021-01-12 17:26:12.124498752 +0100
***************
*** 182,187 ****
--- 182,191 ----
elseif s:name =~# 'clojure'
set ft=clojure
+ " Free Pascal
+ elseif s:name =~# 'instantfpc\>'
+ set ft=pascal
+
endif
unlet s:name
*** ../vim-8.2.2333/src/testdir/test_filetype.vim 2021-01-01
13:53:56.929340268 +0100
--- src/testdir/test_filetype.vim 2021-01-12 17:40:54.982009003 +0100
***************
*** 348,354 ****
\ 'pamconf': ['/etc/pam.conf', '/etc/pam.d/file', 'any/etc/pam.conf',
'any/etc/pam.d/file'],
\ 'pamenv': ['/etc/security/pam_env.conf', '/home/user/.pam_environment',
'.pam_environment', 'pam_env.conf'],
\ 'papp': ['file.papp', 'file.pxml', 'file.pxsl'],
! \ 'pascal': ['file.pas', 'file.pp', 'file.dpr', 'file.lpr'],
\ 'passwd': ['any/etc/passwd', 'any/etc/passwd-', 'any/etc/passwd.edit',
'any/etc/shadow', 'any/etc/shadow-', 'any/etc/shadow.edit',
'any/var/backups/passwd.bak', 'any/var/backups/shadow.bak', '/etc/passwd',
'/etc/passwd-', '/etc/passwd.edit', '/etc/shadow', '/etc/shadow-',
'/etc/shadow.edit', '/var/backups/passwd.bak', '/var/backups/shadow.bak'],
\ 'pbtxt': ['file.pbtxt'],
\ 'pccts': ['file.g'],
--- 348,354 ----
\ 'pamconf': ['/etc/pam.conf', '/etc/pam.d/file', 'any/etc/pam.conf',
'any/etc/pam.d/file'],
\ 'pamenv': ['/etc/security/pam_env.conf', '/home/user/.pam_environment',
'.pam_environment', 'pam_env.conf'],
\ 'papp': ['file.papp', 'file.pxml', 'file.pxsl'],
! \ 'pascal': ['file.pas', 'file.dpr', 'file.lpr'],
\ 'passwd': ['any/etc/passwd', 'any/etc/passwd-', 'any/etc/passwd.edit',
'any/etc/shadow', 'any/etc/shadow-', 'any/etc/shadow.edit',
'any/var/backups/passwd.bak', 'any/var/backups/shadow.bak', '/etc/passwd',
'/etc/passwd-', '/etc/passwd.edit', '/etc/shadow', '/etc/shadow-',
'/etc/shadow.edit', '/var/backups/passwd.bak', '/var/backups/shadow.bak'],
\ 'pbtxt': ['file.pbtxt'],
\ 'pccts': ['file.g'],
***************
*** 384,389 ****
--- 384,390 ----
\ 'proto': ['file.proto'],
\ 'protocols': ['/etc/protocols', 'any/etc/protocols'],
\ 'psf': ['file.psf'],
+ \ 'puppet': ['file.pp'],
\ 'pyrex': ['file.pyx', 'file.pxd'],
\ 'python': ['file.py', 'file.pyw', '.pythonstartup', '.pythonrc',
'file.ptl', 'file.pyi', 'SConstruct'],
\ 'quake': ['anybaseq2/file.cfg', 'anyid1/file.cfg', 'quake3/file.cfg',
'baseq2/file.cfg', 'id1/file.cfg', 'quake1/file.cfg', 'some-baseq2/file.cfg',
'some-id1/file.cfg', 'some-quake1/file.cfg'],
***************
*** 636,641 ****
--- 637,643 ----
\ 'cpp': [['// Standard iostream objects -*- C++ -*-'],
\ ['// -*- C++ -*-']],
\ 'yaml': [['%YAML 1.2']],
+ \ 'pascal': [['#!/path/instantfpc']],
\ }
" Various forms of "env" optional arguments.
***************
*** 727,732 ****
--- 729,762 ----
bwipe!
call delete('Xfile.ts')
+ filetype off
+ endfunc
+
+ func Test_pp_file()
+ filetype on
+
+ call writefile(['looks like puppet'], 'Xfile.pp')
+ split Xfile.pp
+ call assert_equal('puppet', &filetype)
+ bwipe!
+
+ let g:filetype_pp = 'pascal'
+ split Xfile.pp
+ call assert_equal('pascal', &filetype)
+ bwipe!
+
+ " Test dist#ft#FTpp()
+ call writefile(['{ pascal comment'], 'Xfile.pp')
+ split Xfile.pp
+ call assert_equal('pascal', &filetype)
+ bwipe!
+
+ call writefile(['procedure pascal'], 'Xfile.pp')
+ split Xfile.pp
+ call assert_equal('pascal', &filetype)
+ bwipe!
+
+ call delete('Xfile.ts')
filetype off
endfunc
*** ../vim-8.2.2333/src/version.c 2021-01-12 17:16:58.101985157 +0100
--- src/version.c 2021-01-12 17:27:34.980268816 +0100
***************
*** 752,753 ****
--- 752,755 ----
{ /* Add new patch number below this line */
+ /**/
+ 2334,
/**/
--
Why is it called "Windows"? "Gates" would be more appropriate...
/// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/vim_dev/202101121642.10CGgquq1001344%40masaka.moolenaar.net.