mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
Merge pull request #13750 from janlazo/vim-8.2.2329
vim-patch:8.2.{2329,2334}
This commit is contained in:
commit
0fad952a2b
23
runtime/autoload/dist/ft.vim
vendored
23
runtime/autoload/dist/ft.vim
vendored
@ -362,6 +362,10 @@ func dist#ft#FTinc()
|
||||
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,6 +412,9 @@ func dist#ft#FTprogress_asm()
|
||||
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,8 +426,7 @@ func dist#ft#FTprogress_pascal()
|
||||
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*(\*'
|
||||
if line =~ s:ft_pascal_comments || line =~? s:ft_pascal_keywords
|
||||
setf pascal
|
||||
return
|
||||
elseif line !~ '^\s*$' || line =~ '^/\*'
|
||||
@ -433,6 +439,19 @@ func dist#ft#FTprogress_pascal()
|
||||
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("$")
|
||||
|
||||
|
@ -1170,7 +1170,9 @@ au BufNewFile,BufRead *.papp,*.pxml,*.pxsl setf papp
|
||||
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
|
||||
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
|
||||
|
@ -182,6 +182,10 @@ if s:line1 =~# "^#!"
|
||||
elseif s:name =~# 'clojure'
|
||||
set ft=clojure
|
||||
|
||||
" Free Pascal
|
||||
elseif s:name =~# 'instantfpc\>'
|
||||
set ft=pascal
|
||||
|
||||
endif
|
||||
unlet s:name
|
||||
|
||||
|
@ -332,7 +332,7 @@ let s:filename_checks = {
|
||||
\ 'pamconf': ['/etc/pam.conf'],
|
||||
\ 'pamenv': ['/etc/security/pam_env.conf', '/home/user/.pam_environment'],
|
||||
\ 'papp': ['file.papp', 'file.pxml', 'file.pxsl'],
|
||||
\ 'pascal': ['file.pas', 'file.pp', 'file.dpr', 'file.lpr'],
|
||||
\ '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'],
|
||||
\ 'pbtxt': ['file.pbtxt'],
|
||||
\ 'pccts': ['file.g'],
|
||||
@ -368,6 +368,7 @@ let s:filename_checks = {
|
||||
\ 'proto': ['file.proto'],
|
||||
\ 'protocols': ['/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'],
|
||||
@ -619,6 +620,7 @@ let s:script_checks = {
|
||||
\ 'cpp': [['// Standard iostream objects -*- C++ -*-'],
|
||||
\ ['// -*- C++ -*-']],
|
||||
\ 'yaml': [['%YAML 1.2']],
|
||||
\ 'pascal': [['#!/path/instantfpc']],
|
||||
\ }
|
||||
|
||||
" Various forms of "env" optional arguments.
|
||||
@ -689,5 +691,33 @@ func Test_ts_file()
|
||||
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: shiftwidth=2 sts=2 expandtab
|
||||
|
@ -735,4 +735,82 @@ func Test_x_arg()
|
||||
call delete('Xtest_x_arg')
|
||||
endfunc
|
||||
|
||||
" Test starting vim with various names: vim, ex, view, evim, etc.
|
||||
func Test_progname()
|
||||
CheckUnix
|
||||
|
||||
call mkdir('Xprogname', 'p')
|
||||
call writefile(['silent !date',
|
||||
\ 'call writefile([mode(1), '
|
||||
\ .. '&insertmode, &diff, &readonly, &updatecount, '
|
||||
\ .. 'join(split(execute("message"), "\n")[1:])], "Xprogname_out")',
|
||||
\ 'qall'], 'Xprogname_after')
|
||||
|
||||
" +---------------------------------------------- progname
|
||||
" | +--------------------------------- mode(1)
|
||||
" | | +--------------------------- &insertmode
|
||||
" | | | +---------------------- &diff
|
||||
" | | | | +----------------- &readonly
|
||||
" | | | | | +-------- &updatecount
|
||||
" | | | | | | +--- :messages
|
||||
" | | | | | | |
|
||||
" let expectations = {
|
||||
" \ 'vim': ['n', '0', '0', '0', '200', ''],
|
||||
" \ 'gvim': ['n', '0', '0', '0', '200', ''],
|
||||
" \ 'ex': ['ce', '0', '0', '0', '200', ''],
|
||||
" \ 'exim': ['cv', '0', '0', '0', '200', ''],
|
||||
" \ 'view': ['n', '0', '0', '1', '10000', ''],
|
||||
" \ 'gview': ['n', '0', '0', '1', '10000', ''],
|
||||
" \ 'evim': ['n', '1', '0', '0', '200', ''],
|
||||
" \ 'eview': ['n', '1', '0', '1', '10000', ''],
|
||||
" \ 'rvim': ['n', '0', '0', '0', '200', 'line 1: E145: Shell commands and some functionality not allowed in rvim'],
|
||||
" \ 'rgvim': ['n', '0', '0', '0', '200', 'line 1: E145: Shell commands and some functionality not allowed in rvim'],
|
||||
" \ 'rview': ['n', '0', '0', '1', '10000', 'line 1: E145: Shell commands and some functionality not allowed in rvim'],
|
||||
" \ 'rgview': ['n', '0', '0', '1', '10000', 'line 1: E145: Shell commands and some functionality not allowed in rvim'],
|
||||
" \ 'vimdiff': ['n', '0', '1', '0', '200', ''],
|
||||
" \ 'gvimdiff': ['n', '0', '1', '0', '200', '']}
|
||||
let expectations = {'nvim': ['n', '0', '0', '0', '200', '']}
|
||||
|
||||
" let prognames = ['vim', 'gvim', 'ex', 'exim', 'view', 'gview',
|
||||
" \ 'evim', 'eview', 'rvim', 'rgvim', 'rview', 'rgview',
|
||||
" \ 'vimdiff', 'gvimdiff']
|
||||
let prognames = ['nvim']
|
||||
|
||||
for progname in prognames
|
||||
if empty($DISPLAY)
|
||||
if progname =~# 'g'
|
||||
" Can't run gvim, gview (etc.) if $DISPLAY is not setup.
|
||||
continue
|
||||
endif
|
||||
if has('gui') && (progname ==# 'evim' || progname ==# 'eview')
|
||||
" evim or eview will start the GUI if there is gui support.
|
||||
" So don't try to start them either if $DISPLAY is not setup.
|
||||
continue
|
||||
endif
|
||||
endif
|
||||
|
||||
exe 'silent !ln -s -f ' ..exepath(GetVimProg()) .. ' Xprogname/' .. progname
|
||||
|
||||
let stdout_stderr = ''
|
||||
if progname =~# 'g'
|
||||
let stdout_stderr = system('Xprogname/'..progname..' -f --clean --not-a-term -S Xprogname_after')
|
||||
else
|
||||
exe 'sil !Xprogname/'..progname..' -f --clean -S Xprogname_after'
|
||||
endif
|
||||
|
||||
if progname =~# 'g' && !has('gui')
|
||||
call assert_equal("E25: GUI cannot be used: Not enabled at compile time\n", stdout_stderr, progname)
|
||||
else
|
||||
call assert_equal('', stdout_stderr, progname)
|
||||
call assert_equal(expectations[progname], readfile('Xprogname_out'), progname)
|
||||
endif
|
||||
|
||||
call delete('Xprogname/' .. progname)
|
||||
call delete('Xprogname_out')
|
||||
endfor
|
||||
|
||||
call delete('Xprogname_after')
|
||||
call delete('Xprogname', 'd')
|
||||
endfunc
|
||||
|
||||
" vim: shiftwidth=2 sts=2 expandtab
|
||||
|
Loading…
Reference in New Issue
Block a user