Skip to content

Commit a27b466

Browse files
committed
Merge remote-tracking branch 'vim/master'
2 parents a55fbcb + 7f29122 commit a27b466

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

92 files changed

+2052
-596
lines changed

Filelist

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -805,6 +805,11 @@ RT_SCRIPTS = \
805805
runtime/syntax/README.txt \
806806
runtime/syntax/shared/*.vim \
807807
runtime/syntax/shared/README.txt \
808+
runtime/syntax/Makefile \
809+
runtime/syntax/testdir/README.txt \
810+
runtime/syntax/testdir/runtest.vim \
811+
runtime/syntax/testdir/input/*.* \
812+
runtime/syntax/testdir/dumps/*.dump \
808813

809814
# Unix runtime
810815
RT_UNIX = \

Makefile

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,15 @@ all install uninstall tools config configure reconfig proto depend lint tags typ
3939
@echo "Starting make in the src directory."
4040
@echo "If there are problems, cd to the src directory and run make there"
4141
cd src && $(MAKE) $@
42-
@# When the target is "test" also run the indent tests.
42+
@# When the target is "test" also run the indent and syntax tests.
4343
@if test "$@" = "test"; then \
4444
$(MAKE) indenttest; \
45+
$(MAKE) syntaxtest; \
4546
fi
46-
@# When the target is "clean" also clean for the indent tests.
47+
@# When the target is "clean" also clean for the indent and syntax tests.
4748
@if test "$@" = "clean" -o "$@" = "distclean" -o "$@" = "testclean"; then \
48-
cd runtime/indent && \
49-
$(MAKE) clean; \
49+
(cd runtime/indent && $(MAKE) clean); \
50+
(cd runtime/syntax && $(MAKE) clean); \
5051
fi
5152

5253
# Executable used for running the indent tests.
@@ -57,6 +58,14 @@ indenttest:
5758
$(MAKE) clean && \
5859
$(MAKE) test VIM="$(VIM_FOR_INDENTTEST)"
5960

61+
# Executable used for running the syntax tests.
62+
VIM_FOR_SYNTAXTEST = ../../src/vim
63+
64+
syntaxtest:
65+
cd runtime/syntax && \
66+
$(MAKE) clean && \
67+
$(MAKE) test VIMPROG="$(VIM_FOR_SYNTAXTEST)"
68+
6069

6170
#########################################################################
6271
# 2. Creating the various distribution files.

runtime/autoload/dist/ft.vim

Lines changed: 41 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ vim9script
33
# Vim functions for file type detection
44
#
55
# Maintainer: Bram Moolenaar <[email protected]>
6-
# Last Change: 2023 Apr 22
6+
# Last Change: 2023 Jun 09
77

88
# These functions are moved here from runtime/filetype.vim to make startup
99
# faster.
@@ -362,8 +362,8 @@ export def ProtoCheck(default: string)
362362
else
363363
# recognize Prolog by specific text in the first non-empty line
364364
# require a blank after the '%' because Perl uses "%list" and "%translate"
365-
var l = getline(nextnonblank(1))
366-
if l =~ '\<prolog\>' || l =~ '^\s*\(%\+\(\s\|$\)\|/\*\)' || l =~ ':-'
365+
var lnum = getline(nextnonblank(1))
366+
if lnum =~ '\<prolog\>' || lnum =~ '^\s*\(%\+\(\s\|$\)\|/\*\)' || lnum =~ ':-'
367367
setf prolog
368368
else
369369
exe 'setf ' .. default
@@ -472,12 +472,12 @@ enddef
472472
def IsLProlog(): bool
473473
# skip apparent comments and blank lines, what looks like
474474
# LambdaProlog comment may be RAPID header
475-
var l: number = nextnonblank(1)
476-
while l > 0 && l < line('$') && getline(l) =~ '^\s*%' # LambdaProlog comment
477-
l = nextnonblank(l + 1)
475+
var lnum: number = nextnonblank(1)
476+
while lnum > 0 && lnum < line('$') && getline(lnum) =~ '^\s*%' # LambdaProlog comment
477+
lnum = nextnonblank(lnum + 1)
478478
endwhile
479479
# this pattern must not catch a go.mod file
480-
return getline(l) =~ '\<module\s\+\w\+\s*\.\s*\(%\|$\)'
480+
return getline(lnum) =~ '\<module\s\+\w\+\s*\.\s*\(%\|$\)'
481481
enddef
482482

483483
# Determine if *.mod is ABB RAPID, LambdaProlog, Modula-2, Modsim III or go.mod
@@ -504,8 +504,8 @@ export def FTpl()
504504
else
505505
# recognize Prolog by specific text in the first non-empty line
506506
# require a blank after the '%' because Perl uses "%list" and "%translate"
507-
var l = getline(nextnonblank(1))
508-
if l =~ '\<prolog\>' || l =~ '^\s*\(%\+\(\s\|$\)\|/\*\)' || l =~ ':-'
507+
var line = getline(nextnonblank(1))
508+
if line =~ '\<prolog\>' || line =~ '^\s*\(%\+\(\s\|$\)\|/\*\)' || line =~ ':-'
509509
setf prolog
510510
else
511511
setf perl
@@ -678,26 +678,24 @@ export def McSetf()
678678
enddef
679679

680680
# Called from filetype.vim and scripts.vim.
681-
export def SetFileTypeSH(name: string)
682-
if did_filetype()
681+
# When "setft" is passed and false then the 'filetype' option is not set.
682+
export def SetFileTypeSH(name: string, setft = true): string
683+
if setft && did_filetype()
683684
# Filetype was already detected
684-
return
685+
return ''
685686
endif
686-
if expand("<amatch>") =~ g:ft_ignore_pat
687-
return
687+
if setft && expand("<amatch>") =~ g:ft_ignore_pat
688+
return ''
688689
endif
689690
if name =~ '\<csh\>'
690691
# Some .sh scripts contain #!/bin/csh.
691-
SetFileTypeShell("csh")
692-
return
692+
return SetFileTypeShell("csh", setft)
693693
elseif name =~ '\<tcsh\>'
694694
# Some .sh scripts contain #!/bin/tcsh.
695-
SetFileTypeShell("tcsh")
696-
return
695+
return SetFileTypeShell("tcsh", setft)
697696
elseif name =~ '\<zsh\>'
698697
# Some .sh scripts contain #!/bin/zsh.
699-
SetFileTypeShell("zsh")
700-
return
698+
return SetFileTypeShell("zsh", setft)
701699
elseif name =~ '\<ksh\>'
702700
b:is_kornshell = 1
703701
if exists("b:is_bash")
@@ -724,34 +722,43 @@ export def SetFileTypeSH(name: string)
724722
unlet b:is_bash
725723
endif
726724
endif
727-
SetFileTypeShell("sh")
725+
726+
return SetFileTypeShell("sh", setft)
728727
enddef
729728

730729
# For shell-like file types, check for an "exec" command hidden in a comment,
731730
# as used for Tcl.
731+
# When "setft" is passed and false then the 'filetype' option is not set.
732732
# Also called from scripts.vim, thus can't be local to this script.
733-
export def SetFileTypeShell(name: string)
734-
if did_filetype()
733+
export def SetFileTypeShell(name: string, setft = true): string
734+
if setft && did_filetype()
735735
# Filetype was already detected
736-
return
736+
return ''
737737
endif
738-
if expand("<amatch>") =~ g:ft_ignore_pat
739-
return
738+
if setft && expand("<amatch>") =~ g:ft_ignore_pat
739+
return ''
740740
endif
741-
var l = 2
742-
while l < 20 && l < line("$") && getline(l) =~ '^\s*\(#\|$\)'
741+
742+
var lnum = 2
743+
while lnum < 20 && lnum < line("$") && getline(lnum) =~ '^\s*\(#\|$\)'
743744
# Skip empty and comment lines.
744-
l += 1
745+
lnum += 1
745746
endwhile
746-
if l < line("$") && getline(l) =~ '\s*exec\s' && getline(l - 1) =~ '^\s*#.*\\$'
747+
if lnum < line("$") && getline(lnum) =~ '\s*exec\s' && getline(lnum - 1) =~ '^\s*#.*\\$'
747748
# Found an "exec" line after a comment with continuation
748-
var n = substitute(getline(l), '\s*exec\s\+\([^ ]*/\)\=', '', '')
749+
var n = substitute(getline(lnum), '\s*exec\s\+\([^ ]*/\)\=', '', '')
749750
if n =~ '\<tclsh\|\<wish'
750-
setf tcl
751-
return
751+
if setft
752+
setf tcl
753+
endif
754+
return 'tcl'
752755
endif
753756
endif
754-
exe "setf " .. name
757+
758+
if setft
759+
exe "setf " .. name
760+
endif
761+
return name
755762
enddef
756763

757764
export def CSH()

0 commit comments

Comments
 (0)