summaryrefslogtreecommitdiffstats
path: root/runtime/autoload/dist
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-09-19 04:05:15 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-09-19 04:05:15 +0000
commit6e9cd6b491267e6dff3e3f3f37d8af5f28e40672 (patch)
tree35661af16c4a0ef2a9a8e225d2d5cc82605ea289 /runtime/autoload/dist
parentAdding upstream version 2:9.1.0496. (diff)
downloadvim-6e9cd6b491267e6dff3e3f3f37d8af5f28e40672.tar.xz
vim-6e9cd6b491267e6dff3e3f3f37d8af5f28e40672.zip
Adding upstream version 2:9.1.0698.upstream/2%9.1.0698
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'runtime/autoload/dist')
-rw-r--r--runtime/autoload/dist/ft.vim101
-rw-r--r--runtime/autoload/dist/man.vim7
-rw-r--r--runtime/autoload/dist/vim.vim4
-rw-r--r--runtime/autoload/dist/vim9.vim4
4 files changed, 109 insertions, 7 deletions
diff --git a/runtime/autoload/dist/ft.vim b/runtime/autoload/dist/ft.vim
index bf9e32e..c8942eb 100644
--- a/runtime/autoload/dist/ft.vim
+++ b/runtime/autoload/dist/ft.vim
@@ -9,6 +9,8 @@ vim9script
# These functions are moved here from runtime/filetype.vim to make startup
# faster.
+var prolog_pattern = '^\s*\(:-\|%\+\(\s\|$\)\|\/\*\)\|\.\s*$'
+
export def Check_inp()
if getline(1) =~ '%%'
setf tex
@@ -402,18 +404,38 @@ export def FTharedoc()
endif
enddef
-# Distinguish between HTML, XHTML and Django
+# Distinguish between HTML, XHTML, Django and Angular
export def FThtml()
var n = 1
- while n < 10 && n <= line("$")
+
+ # Test if the filename follows the Angular component template convention
+ # Disabled for the reasons mentioned here: #13594
+ # if expand('%:t') =~ '^.*\.component\.html$'
+ # setf htmlangular
+ # return
+ # endif
+
+ while n < 40 && n <= line("$")
+ # Check for Angular
+ if getline(n) =~ '@\(if\|for\|defer\|switch\)\|\*\(ngIf\|ngFor\|ngSwitch\|ngTemplateOutlet\)\|ng-template\|ng-content\|{{.*}}'
+ setf htmlangular
+ return
+ endif
+ # Check for XHTML
if getline(n) =~ '\<DTD\s\+XHTML\s'
setf xhtml
return
endif
- if getline(n) =~ '{%\s*\(extends\|block\|load\)\>\|{#\s\+'
+ # Check for Django
+ if getline(n) =~ '{%\s*\(autoescape\|block\|comment\|csrf_token\|cycle\|debug\|extends\|filter\|firstof\|for\|if\|ifchanged\|include\|load\|lorem\|now\|query_string\|regroup\|resetcycle\|spaceless\|templatetag\|url\|verbatim\|widthratio\|with\)\>\|{#\s\+'
setf htmldjango
return
endif
+ # Check for SuperHTML
+ if getline(n) =~ '<extend\|<super>'
+ setf superhtml
+ return
+ endif
n += 1
endwhile
setf FALLBACK html
@@ -449,7 +471,7 @@ export def ProtoCheck(default: string)
# recognize Prolog by specific text in the first non-empty line
# require a blank after the '%' because Perl uses "%list" and "%translate"
var lnum = getline(nextnonblank(1))
- if lnum =~ '\<prolog\>' || lnum =~ '^\s*\(%\+\(\s\|$\)\|/\*\)' || lnum =~ ':-'
+ if lnum =~ '\<prolog\>' || lnum =~ prolog_pattern
setf prolog
else
exe 'setf ' .. default
@@ -514,6 +536,25 @@ export def FTm()
endif
enddef
+export def FTmake()
+ # Check if it is a Microsoft Makefile
+ unlet! b:make_microsoft
+ var n = 1
+ while n < 1000 && n <= line('$')
+ var line = getline(n)
+ if line =~? '^\s*!\s*\(ifn\=\(def\)\=\|include\|message\|error\)\>'
+ b:make_microsoft = 1
+ break
+ elseif line =~ '^ *ifn\=\(eq\|def\)\>' || line =~ '^ *[-s]\=include\s'
+ break
+ elseif line =~ '^ *\w\+\s*[!?:+]='
+ break
+ endif
+ n += 1
+ endwhile
+ setf make
+enddef
+
export def FTmms()
var n = 1
while n < 20
@@ -628,7 +669,7 @@ export def FTpl()
# recognize Prolog by specific text in the first non-empty line
# require a blank after the '%' because Perl uses "%list" and "%translate"
var line = getline(nextnonblank(1))
- if line =~ '\<prolog\>' || line =~ '^\s*\(%\+\(\s\|$\)\|/\*\)' || line =~ ':-'
+ if line =~ '\<prolog\>' || line =~ prolog_pattern
setf prolog
else
setf perl
@@ -1265,6 +1306,56 @@ export def FTtyp()
setf typst
enddef
+# Detect Microsoft Developer Studio Project files (Makefile) or Faust DSP
+# files.
+export def FTdsp()
+ if exists("g:filetype_dsp")
+ exe "setf " .. g:filetype_dsp
+ return
+ endif
+
+ # Test the filename
+ if expand('%:t') =~ '^[mM]akefile.*$'
+ setf make
+ return
+ endif
+
+ # Test the file contents
+ for line in getline(1, 200)
+ # Chech for comment style
+ if line =~ '^#.*'
+ setf make
+ return
+ endif
+
+ # Check for common lines
+ if line =~ '^.*Microsoft Developer Studio Project File.*$'
+ setf make
+ return
+ endif
+
+ if line =~ '^!MESSAGE This is not a valid makefile\..+$'
+ setf make
+ return
+ endif
+
+ # Check for keywords
+ if line =~ '^!(IF,ELSEIF,ENDIF).*$'
+ setf make
+ return
+ endif
+
+ # Check for common assignments
+ if line =~ '^SOURCE=.*$'
+ setf make
+ return
+ endif
+ endfor
+
+ # Otherwise, assume we have a Faust file
+ setf faust
+enddef
+
# Set the filetype of a *.v file to Verilog, V or Cog based on the first 200
# lines.
export def FTv()
diff --git a/runtime/autoload/dist/man.vim b/runtime/autoload/dist/man.vim
index 708e106..d9dbaf4 100644
--- a/runtime/autoload/dist/man.vim
+++ b/runtime/autoload/dist/man.vim
@@ -4,6 +4,7 @@
" Maintainer: SungHyun Nam <goweol@gmail.com>
" Autoload Split: Bram Moolenaar
" Last Change: 2024 Jan 17 (make it work on AIX, see #13847)
+" 2024 Jul 06 (honor command modifiers, #15117)
let s:cpo_save = &cpo
set cpo-=C
@@ -165,7 +166,9 @@ func dist#man#GetPage(cmdmods, ...)
endwhile
endif
if &filetype != "man"
- if exists("g:ft_man_open_mode")
+ if a:cmdmods =~ '\<\(tab\|vertical\|horizontal\)\>'
+ let open_cmd = a:cmdmods . ' split'
+ elseif exists("g:ft_man_open_mode")
if g:ft_man_open_mode == 'vert'
let open_cmd = 'vsplit'
elseif g:ft_man_open_mode == 'tab'
@@ -174,7 +177,7 @@ func dist#man#GetPage(cmdmods, ...)
let open_cmd = 'split'
endif
else
- let open_cmd = a:cmdmods . ' split'
+ let open_cmd = 'split'
endif
endif
endif
diff --git a/runtime/autoload/dist/vim.vim b/runtime/autoload/dist/vim.vim
index 021244c..d519406 100644
--- a/runtime/autoload/dist/vim.vim
+++ b/runtime/autoload/dist/vim.vim
@@ -18,6 +18,10 @@ endif
if !has('vim9script')
function dist#vim#IsSafeExecutable(filetype, executable)
let cwd = getcwd()
+ if empty(exepath(a:executable))
+ echomsg a:executable .. " not found in $PATH"
+ return v:false
+ endif
return get(g:, a:filetype .. '_exec', get(g:, 'plugin_exec', 0)) &&
\ (fnamemodify(exepath(a:executable), ':p:h') !=# cwd
\ || (split($PATH, has('win32') ? ';' : ':')->index(cwd) != -1 &&
diff --git a/runtime/autoload/dist/vim9.vim b/runtime/autoload/dist/vim9.vim
index 807140d..8fa9380 100644
--- a/runtime/autoload/dist/vim9.vim
+++ b/runtime/autoload/dist/vim9.vim
@@ -6,6 +6,10 @@ vim9script
# Last Change: 2023 Oct 25
export def IsSafeExecutable(filetype: string, executable: string): bool
+ if empty(exepath(executable))
+ echomsg executable .. " not found in $PATH"
+ return v:false
+ endif
var cwd = getcwd()
return get(g:, filetype .. '_exec', get(g:, 'plugin_exec', 0))
&& (fnamemodify(exepath(executable), ':p:h') !=# cwd