Skip to content

Commit

Permalink
Merge remote-tracking branch 'vim/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
ychin committed Jun 20, 2023
2 parents a55fbcb + 7f29122 commit a27b466
Show file tree
Hide file tree
Showing 92 changed files with 2,052 additions and 596 deletions.
5 changes: 5 additions & 0 deletions Filelist
Original file line number Diff line number Diff line change
Expand Up @@ -805,6 +805,11 @@ RT_SCRIPTS = \
runtime/syntax/README.txt \
runtime/syntax/shared/*.vim \
runtime/syntax/shared/README.txt \
runtime/syntax/Makefile \
runtime/syntax/testdir/README.txt \
runtime/syntax/testdir/runtest.vim \
runtime/syntax/testdir/input/*.* \
runtime/syntax/testdir/dumps/*.dump \

# Unix runtime
RT_UNIX = \
Expand Down
17 changes: 13 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,15 @@ all install uninstall tools config configure reconfig proto depend lint tags typ
@echo "Starting make in the src directory."
@echo "If there are problems, cd to the src directory and run make there"
cd src && $(MAKE) $@
@# When the target is "test" also run the indent tests.
@# When the target is "test" also run the indent and syntax tests.
@if test "$@" = "test"; then \
$(MAKE) indenttest; \
$(MAKE) syntaxtest; \
fi
@# When the target is "clean" also clean for the indent tests.
@# When the target is "clean" also clean for the indent and syntax tests.
@if test "$@" = "clean" -o "$@" = "distclean" -o "$@" = "testclean"; then \
cd runtime/indent && \
$(MAKE) clean; \
(cd runtime/indent && $(MAKE) clean); \
(cd runtime/syntax && $(MAKE) clean); \
fi

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

# Executable used for running the syntax tests.
VIM_FOR_SYNTAXTEST = ../../src/vim

syntaxtest:
cd runtime/syntax && \
$(MAKE) clean && \
$(MAKE) test VIMPROG="$(VIM_FOR_SYNTAXTEST)"


#########################################################################
# 2. Creating the various distribution files.
Expand Down
75 changes: 41 additions & 34 deletions runtime/autoload/dist/ft.vim
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ vim9script
# Vim functions for file type detection
#
# Maintainer: Bram Moolenaar <Bram@vim.org>
# Last Change: 2023 Apr 22
# Last Change: 2023 Jun 09

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

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

# Called from filetype.vim and scripts.vim.
export def SetFileTypeSH(name: string)
if did_filetype()
# When "setft" is passed and false then the 'filetype' option is not set.
export def SetFileTypeSH(name: string, setft = true): string
if setft && did_filetype()
# Filetype was already detected
return
return ''
endif
if expand("<amatch>") =~ g:ft_ignore_pat
return
if setft && expand("<amatch>") =~ g:ft_ignore_pat
return ''
endif
if name =~ '\<csh\>'
# Some .sh scripts contain #!/bin/csh.
SetFileTypeShell("csh")
return
return SetFileTypeShell("csh", setft)
elseif name =~ '\<tcsh\>'
# Some .sh scripts contain #!/bin/tcsh.
SetFileTypeShell("tcsh")
return
return SetFileTypeShell("tcsh", setft)
elseif name =~ '\<zsh\>'
# Some .sh scripts contain #!/bin/zsh.
SetFileTypeShell("zsh")
return
return SetFileTypeShell("zsh", setft)
elseif name =~ '\<ksh\>'
b:is_kornshell = 1
if exists("b:is_bash")
Expand All @@ -724,34 +722,43 @@ export def SetFileTypeSH(name: string)
unlet b:is_bash
endif
endif
SetFileTypeShell("sh")

return SetFileTypeShell("sh", setft)
enddef

# For shell-like file types, check for an "exec" command hidden in a comment,
# as used for Tcl.
# When "setft" is passed and false then the 'filetype' option is not set.
# Also called from scripts.vim, thus can't be local to this script.
export def SetFileTypeShell(name: string)
if did_filetype()
export def SetFileTypeShell(name: string, setft = true): string
if setft && did_filetype()
# Filetype was already detected
return
return ''
endif
if expand("<amatch>") =~ g:ft_ignore_pat
return
if setft && expand("<amatch>") =~ g:ft_ignore_pat
return ''
endif
var l = 2
while l < 20 && l < line("$") && getline(l) =~ '^\s*\(#\|$\)'

var lnum = 2
while lnum < 20 && lnum < line("$") && getline(lnum) =~ '^\s*\(#\|$\)'
# Skip empty and comment lines.
l += 1
lnum += 1
endwhile
if l < line("$") && getline(l) =~ '\s*exec\s' && getline(l - 1) =~ '^\s*#.*\\$'
if lnum < line("$") && getline(lnum) =~ '\s*exec\s' && getline(lnum - 1) =~ '^\s*#.*\\$'
# Found an "exec" line after a comment with continuation
var n = substitute(getline(l), '\s*exec\s\+\([^ ]*/\)\=', '', '')
var n = substitute(getline(lnum), '\s*exec\s\+\([^ ]*/\)\=', '', '')
if n =~ '\<tclsh\|\<wish'
setf tcl
return
if setft
setf tcl
endif
return 'tcl'
endif
endif
exe "setf " .. name

if setft
exe "setf " .. name
endif
return name
enddef

export def CSH()
Expand Down
Loading

0 comments on commit a27b466

Please sign in to comment.