made the pack completely portable and wrote relevent bat files to go with it

This commit is contained in:
Draqoken
2025-04-09 17:04:56 +03:00
parent 5e77d7e9cf
commit 5e4144c3c0
7417 changed files with 2181044 additions and 19 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,182 @@
vim9script
# Maintainer: Maxim Kim <habamax@gmail.com>
# Last update: 2023-12-10
#
# Set of functions to format/beautify JSON data structures.
#
# Could be used to reformat a minified json in a buffer (put it into ~/.vim/ftplugin/json.vim):
# import autoload 'dist/json.vim'
# setl formatexpr=json.FormatExpr()
#
# Or to get a formatted string out of vim's dict/list/string:
# vim9script
# import autoload 'dist/json.vim'
# echo json.Format({
# "widget": { "debug": "on", "window": { "title": "Sample \"Konfabulator\" Widget",
# "name": "main_window", "width": 500, "height": 500
# },
# "image": { "src": "Images/Sun.png", "name": "sun1", "hOffset": 250,
# "vOffset": 250, "alignment": "center" },
# "text": { "data": "Click Here", "size": 36, "style": "bold", "name": "text1",
# "hOffset": 250, "vOffset": 100, "alignment": "center",
# "onMouseUp": "sun1.opacity = (sun1.opacity / 100) * 90;" } }
# })
#
# Should output:
# {
# "widget": {
# "debug": "on",
# "window": {
# "title": "Sample \"Konfabulator\" Widget",
# "name": "main_window",
# "width": 500,
# "height": 500
# },
# "image": {
# "src": "Images/Sun.png",
# "name": "sun1",
# "hOffset": 250,
# "vOffset": 250,
# "alignment": "center"
# },
# "text": {
# "data": "Click Here",
# "size": 36,
# "style": "bold",
# "name": "text1",
# "hOffset": 250,
# "vOffset": 100,
# "alignment": "center",
# "onMouseUp": "sun1.opacity = (sun1.opacity / 100) * 90;"
# }
# }
# }
#
# NOTE: order of `key: value` pairs is not kept.
#
# You can also use a JSON string instead of vim's dict/list to maintain order:
# echo json.Format('{"hello": 1, "world": 2}')
# {
# "hello": 1,
# "world": 2
# }
# To be able to reformat with `gq` add following to `~/.vim/ftplugin/json.vim`:
# import autoload 'dist/json.vim'
# setl formatexpr=json.FormatExpr()
export def FormatExpr(): number
FormatRange(v:lnum, v:lnum + v:count - 1)
return 0
enddef
# import autoload 'dist/json.vim'
# command -range=% JSONFormat json.FormatRange(<line1>, <line2>)
export def FormatRange(line1: number, line2: number)
var indent_base = matchstr(getline(line1), '^\s*')
var indent = &expandtab ? repeat(' ', &shiftwidth) : "\t"
var [l1, l2] = line1 > line2 ? [line2, line1] : [line1, line2]
var json_src = getline(l1, l2)->join()
var json_fmt = Format(json_src, {use_tabs: !&et, indent: &sw, indent_base: indent_base})->split("\n")
exe $":{l1},{l2}d"
if line('$') == 1 && getline(1) == ''
setline(l1, json_fmt[0])
append(l1, json_fmt[1 : ])
else
append(l1 - 1, json_fmt)
endif
enddef
# Format JSON string or dict/list as JSON
# import autoload 'dist/json.vim'
# echo json.Format('{"hello": "world"}', {use_tabs: false, indent: 2, indent_base: 0})
# {
# "hello": "world"
# }
# echo json.Format({'hello': 'world'}, {use_tabs: false, indent: 2, indent_base: 0})
# {
# "hello": "world"
# }
#
# Note, when `obj` is dict, order of the `key: value` pairs might be different:
# echo json.Format({'hello': 1, 'world': 2})
# {
# "world": 2,
# "hello": 1
# }
export def Format(obj: any, params: dict<any> = {}): string
var obj_str = ''
if type(obj) == v:t_string
obj_str = obj
else
obj_str = json_encode(obj)
endif
var indent_lvl = 0
var indent_base = get(params, "indent_base", "")
var indent = get(params, "use_tabs", false) ? "\t" : repeat(' ', get(params, "indent", 2))
var json_line = indent_base
var json = ""
var state = ""
for char in obj_str
if state == ""
if char =~ '[{\[]'
json_line ..= char
json ..= json_line .. "\n"
indent_lvl += 1
json_line = indent_base .. repeat(indent, indent_lvl)
elseif char =~ '[}\]]'
if json_line !~ '^\s*$'
json ..= json_line .. "\n"
indent_lvl -= 1
if indent_lvl < 0
json_line = strpart(indent_base, -indent_lvl * len(indent))
else
json_line = indent_base .. repeat(indent, indent_lvl)
endif
elseif json =~ '[{\[]\n$'
json = json[ : -2]
json_line = substitute(json_line, '^\s*', '', '')
indent_lvl -= 1
endif
json_line ..= char
elseif char == ':'
json_line ..= char .. ' '
elseif char == '"'
json_line ..= char
state = 'QUOTE'
elseif char == ','
json_line ..= char
json ..= json_line .. "\n"
json_line = indent_base .. repeat(indent, indent_lvl)
elseif char !~ '\s'
json_line ..= char
endif
elseif state == "QUOTE"
json_line ..= char
if char == '\'
state = "ESCAPE"
elseif char == '"'
state = ""
endif
elseif state == "ESCAPE"
state = "QUOTE"
json_line ..= char
else
json_line ..= char
endif
endfor
if json_line !~ '^\s*$'
json ..= json_line .. "\n"
endif
return json
enddef

View File

@@ -0,0 +1,253 @@
" Vim filetype plugin autoload file
" Language: man
" Maintainer: Jason Franklin <jason@oneway.dev>
" 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
let s:man_tag_depth = 0
let s:man_sect_arg = ""
let s:man_find_arg = "-w"
try
if !has("win32") && $OSTYPE !~ 'cygwin\|linux'
" cache the value
let uname_s = system('uname -s')
if uname_s =~ "SunOS" && system('uname -r') =~ "^5"
" Special Case for Man on SunOS
let s:man_sect_arg = "-s"
let s:man_find_arg = "-l"
elseif uname_s =~? 'AIX'
" Special Case for Man on AIX
let s:man_sect_arg = ""
let s:man_find_arg = ""
endif
endif
catch /E145:/
" Ignore the error in restricted mode
endtry
unlet! uname_s
func s:ParseIntoPageAndSection()
" Accommodate a reference that terminates in a hyphen.
"
" See init_charset_table() at
" https://git.savannah.gnu.org/cgit/groff.git/tree/src/roff/troff/input.cpp?h=1.22.4#n6794
"
" See can_break_after() at
" https://git.savannah.gnu.org/cgit/groff.git/tree/src/roff/troff/charinfo.h?h=1.22.4#n140
"
" Assumptions and limitations:
" 1) Manual-page references (in consequence of command-related filenames)
" do not contain non-ASCII HYPHENs (0x2010), any terminating HYPHEN
" must have been introduced to mark division of a word at the end of
" a line and can be discarded; whereas similar references may contain
" ASCII HYPHEN-MINUSes (0x002d) and any terminating HYPHEN-MINUS forms
" a compound word in addition to marking word division.
" 2) Well-formed manual-page references always have a section suffix, e.g.
" "git-commit(1)", therefore suspended hyphenated compounds are not
" determined, e.g. [V] (With cursor at _git-merge-_ below...)
" ".................... git-merge- and git-merge-base. (See git-cherry-
" pick(1) and git-cherry(1).)" (... look up "git-merge-pick(1)".)
"
" Note that EM DASH (0x2014), a third stooge from init_charset_table(),
" neither connects nor divides parts of a word.
let str = expand("<cWORD>")
if str =~ '\%u2010$' " HYPHEN (-1).
let str = strpart(str, 0, strridx(str, "\u2010"))
" Append the leftmost WORD (or an empty string) from the line below.
let str .= get(split(get(getbufline(bufnr('%'), line('.') + 1), 0, '')), 0, '')
elseif str =~ '-$' " HYPHEN-MINUS.
" Append the leftmost WORD (or an empty string) from the line below.
let str .= get(split(get(getbufline(bufnr('%'), line('.') + 1), 0, '')), 0, '')
endif
" According to man(1), section name formats vary (MANSECT):
" 1 n l 8 3 2 3posix 3pm 3perl 3am 5 4 9 6 7
let parts = matchlist(str, '\(\k\+\)(\(\k\+\))')
return (len(parts) > 2)
\ ? {'page': parts[1], 'section': parts[2]}
\ : {'page': matchstr(str, '\k\+'), 'section': ''}
endfunc
func dist#man#PreGetPage(cnt)
if a:cnt == 0
let what = s:ParseIntoPageAndSection()
let sect = what.section
let page = what.page
else
let what = s:ParseIntoPageAndSection()
let sect = a:cnt
let page = what.page
endif
call dist#man#GetPage('', sect, page)
endfunc
func s:GetCmdArg(sect, page)
if empty(a:sect)
return shellescape(a:page)
endif
return s:man_sect_arg . ' ' . shellescape(a:sect) . ' ' . shellescape(a:page)
endfunc
func s:FindPage(sect, page)
let l:cmd = printf('man %s %s', s:man_find_arg, s:GetCmdArg(a:sect, a:page))
call system(l:cmd)
if v:shell_error
return 0
endif
return 1
endfunc
func dist#man#GetPage(cmdmods, ...)
if a:0 >= 2
let sect = a:1
let page = a:2
elseif a:0 >= 1
let sect = ""
let page = a:1
else
return
endif
" To support: nmap K :Man <cWORD><CR>
if page ==? '<cword>'
let what = s:ParseIntoPageAndSection()
let sect = what.section
let page = what.page
endif
if !exists('g:ft_man_no_sect_fallback') || (g:ft_man_no_sect_fallback == 0)
if sect != "" && s:FindPage(sect, page) == 0
let sect = ""
endif
endif
if s:FindPage(sect, page) == 0
let msg = 'man.vim: no manual entry for "' . page . '"'
if !empty(sect)
let msg .= ' in section ' . sect
endif
echomsg msg
return
endif
exec "let s:man_tag_buf_".s:man_tag_depth." = ".bufnr("%")
exec "let s:man_tag_lin_".s:man_tag_depth." = ".line(".")
exec "let s:man_tag_col_".s:man_tag_depth." = ".col(".")
let s:man_tag_depth = s:man_tag_depth + 1
let open_cmd = 'edit'
" Use an existing "man" window if it exists, otherwise open a new one.
if &filetype != "man"
let thiswin = winnr()
exe "norm! \<C-W>b"
if winnr() > 1
exe "norm! " . thiswin . "\<C-W>w"
while 1
if &filetype == "man"
break
endif
exe "norm! \<C-W>w"
if thiswin == winnr()
break
endif
endwhile
endif
if &filetype != "man"
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'
let open_cmd = 'tabedit'
else
let open_cmd = 'split'
endif
else
let open_cmd = 'split'
endif
endif
endif
silent execute open_cmd . " $HOME/" . page . '.' . sect . '~'
" Avoid warning for editing the dummy file twice
setl buftype=nofile noswapfile
setl fdc=0 ma nofen nonu nornu
%delete _
let unsetwidth = 0
if empty($MANWIDTH)
let $MANWIDTH = winwidth(0)
let unsetwidth = 1
endif
" Ensure Vim is not recursively invoked (man-db does this) when doing ctrl-[
" on a man page reference by unsetting MANPAGER.
" Some versions of env(1) do not support the '-u' option, and in such case
" we set MANPAGER=cat.
if !exists('s:env_has_u')
call system('env -u x true')
let s:env_has_u = (v:shell_error == 0)
endif
let env_cmd = s:env_has_u ? 'env -u MANPAGER' : 'env MANPAGER=cat'
let env_cmd .= ' GROFF_NO_SGR=1'
let man_cmd = env_cmd . ' man ' . s:GetCmdArg(sect, page)
silent exec "r !" . man_cmd
" Emulate piping the buffer through the "col -b" command.
" Ref: https://github.com/vim/vim/issues/12301
exe 'silent! keepjumps keeppatterns %s/\v(.)\b\ze\1?//e' .. (&gdefault ? '' : 'g')
if unsetwidth
let $MANWIDTH = ''
endif
" Remove blank lines from top and bottom.
while line('$') > 1 && getline(1) =~ '^\s*$'
1delete _
endwhile
while line('$') > 1 && getline('$') =~ '^\s*$'
$delete _
endwhile
1
setl ft=man nomod
setl bufhidden=hide
setl nobuflisted
setl noma
endfunc
func dist#man#PopPage()
if s:man_tag_depth > 0
let s:man_tag_depth = s:man_tag_depth - 1
exec "let s:man_tag_buf=s:man_tag_buf_".s:man_tag_depth
exec "let s:man_tag_lin=s:man_tag_lin_".s:man_tag_depth
exec "let s:man_tag_col=s:man_tag_col_".s:man_tag_depth
exec s:man_tag_buf."b"
call cursor(s:man_tag_lin, s:man_tag_col)
exec "unlet s:man_tag_buf_".s:man_tag_depth
exec "unlet s:man_tag_lin_".s:man_tag_depth
exec "unlet s:man_tag_col_".s:man_tag_depth
unlet s:man_tag_buf s:man_tag_lin s:man_tag_col
endif
endfunc
let &cpo = s:cpo_save
unlet s:cpo_save
" vim: set sw=2 ts=8 noet:

View File

@@ -0,0 +1,474 @@
vim9script
# Vim function for detecting a filetype from the file contents.
# Invoked from "scripts.vim" in 'runtimepath'
#
# Maintainer: The Vim Project <https://github.com/vim/vim>
# Last Change: 2023 Aug 10
# Former Maintainer: Bram Moolenaar <Bram@vim.org>
export def DetectFiletype()
var line1 = getline(1)
if line1[0] == '#' && line1[1] == '!'
# File that starts with "#!".
DetectFromHashBang(line1)
else
# File does not start with "#!".
DetectFromText(line1)
endif
enddef
# Called for a script that has "#!" in the first line.
def DetectFromHashBang(firstline: string)
var line1 = firstline
# Check for a line like "#!/usr/bin/env {options} bash". Turn it into
# "#!/usr/bin/bash" to make matching easier.
# Recognize only a few {options} that are commonly used.
if line1 =~ '^#!\s*\S*\<env\s'
line1 = substitute(line1, '\S\+=\S\+', '', 'g')
line1 = substitute(line1, '\(-[iS]\|--ignore-environment\|--split-string\)', '', '')
line1 = substitute(line1, '\<env\s\+', '', '')
endif
# Get the program name.
# Only accept spaces in PC style paths: "#!c:/program files/perl [args]".
# If the word env is used, use the first word after the space:
# "#!/usr/bin/env perl [path/args]"
# If there is no path use the first word: "#!perl [path/args]".
# Otherwise get the last word after a slash: "#!/usr/bin/perl [path/args]".
var name: string
if line1 =~ '^#!\s*\a:[/\\]'
name = substitute(line1, '^#!.*[/\\]\(\i\+\).*', '\1', '')
elseif line1 =~ '^#!.*\<env\>'
name = substitute(line1, '^#!.*\<env\>\s\+\(\i\+\).*', '\1', '')
elseif line1 =~ '^#!\s*[^/\\ ]*\>\([^/\\]\|$\)'
name = substitute(line1, '^#!\s*\([^/\\ ]*\>\).*', '\1', '')
else
name = substitute(line1, '^#!\s*\S*[/\\]\(\f\+\).*', '\1', '')
endif
# tcl scripts may have #!/bin/sh in the first line and "exec wish" in the
# third line. Suggested by Steven Atkinson.
if getline(3) =~ '^exec wish'
name = 'wish'
endif
var ft = Exe2filetype(name, line1)
if ft != ''
exe 'setl ft=' .. ft
endif
enddef
# Returns the filetype name associated with program "name".
# "line1" is the #! line at the top of the file. Use the same as "name" if
# not available.
# Returns an empty string when not recognized.
export def Exe2filetype(name: string, line1: string): string
# Bourne-like shell scripts: bash bash2 dash ksh ksh93 sh
if name =~ '^\(bash\d*\|dash\|ksh\d*\|sh\)\>'
return dist#ft#SetFileTypeSH(line1, false)
# csh scripts
elseif name =~ '^csh\>'
return dist#ft#SetFileTypeShell(exists("g:filetype_csh") ? g:filetype_csh : 'csh', false)
# tcsh scripts
elseif name =~ '^tcsh\>'
return dist#ft#SetFileTypeShell("tcsh", false)
# Z shell scripts
elseif name =~ '^zsh\>'
return 'zsh'
# TCL scripts
elseif name =~ '^\(tclsh\|wish\|expectk\|itclsh\|itkwish\)\>'
return 'tcl'
# Expect scripts
elseif name =~ '^expect\>'
return 'expect'
# Gnuplot scripts
elseif name =~ '^gnuplot\>'
return 'gnuplot'
# Makefiles
elseif name =~ 'make\>'
return 'make'
# Pike
elseif name =~ '^pike\%(\>\|[0-9]\)'
return 'pike'
# Lua
elseif name =~ 'lua'
return 'lua'
# Perl
elseif name =~ 'perl'
return 'perl'
# PHP
elseif name =~ 'php'
return 'php'
# Python
elseif name =~ 'python'
return 'python'
# Groovy
elseif name =~ '^groovy\>'
return 'groovy'
# Raku
elseif name =~ 'raku'
return 'raku'
# Ruby
elseif name =~ 'ruby'
return 'ruby'
# JavaScript
elseif name =~ 'node\(js\)\=\>\|js\>' || name =~ 'rhino\>'
return 'javascript'
# BC calculator
elseif name =~ '^bc\>'
return 'bc'
# sed
elseif name =~ 'sed\>'
return 'sed'
# OCaml-scripts
elseif name =~ 'ocaml'
return 'ocaml'
# Awk scripts; also finds "gawk"
elseif name =~ 'awk\>'
return 'awk'
# Website MetaLanguage
elseif name =~ 'wml'
return 'wml'
# Scheme scripts
elseif name =~ 'scheme'
return 'scheme'
# CFEngine scripts
elseif name =~ 'cfengine'
return 'cfengine'
# Erlang scripts
elseif name =~ 'escript'
return 'erlang'
# Haskell
elseif name =~ 'haskell'
return 'haskell'
# Scala
elseif name =~ 'scala\>'
return 'scala'
# Clojure
elseif name =~ 'clojure'
return 'clojure'
# Free Pascal
elseif name =~ 'instantfpc\>'
return 'pascal'
# Fennel
elseif name =~ 'fennel\>'
return 'fennel'
# MikroTik RouterOS script
elseif name =~ 'rsc\>'
return 'routeros'
# Fish shell
elseif name =~ 'fish\>'
return 'fish'
# Gforth
elseif name =~ 'gforth\>'
return 'forth'
# Icon
elseif name =~ 'icon\>'
return 'icon'
# Guile
elseif name =~ 'guile'
return 'scheme'
# Nix
elseif name =~ 'nix-shell'
return 'nix'
# Crystal
elseif name =~ '^crystal\>'
return 'crystal'
# Rexx
elseif name =~ '^\%(rexx\|regina\)\>'
return 'rexx'
# Janet
elseif name =~ '^janet\>'
return 'janet'
# Dart
elseif name =~ '^dart\>'
return 'dart'
# Execline (s6)
elseif name =~ '^execlineb\>'
return 'execline'
# Vim
elseif name =~ '^vim\>'
return 'vim'
endif
return ''
enddef
# Called for a script that does not have "#!" in the first line.
def DetectFromText(line1: string)
var line2 = getline(2)
var line3 = getline(3)
var line4 = getline(4)
var line5 = getline(5)
# Bourne-like shell scripts: sh ksh bash bash2
if line1 =~ '^:$'
call dist#ft#SetFileTypeSH(line1)
# Z shell scripts
elseif line1 =~ '^#compdef\>'
|| line1 =~ '^#autoload\>'
|| "\n" .. line1 .. "\n" .. line2 .. "\n" .. line3 ..
"\n" .. line4 .. "\n" .. line5
=~ '\n\s*emulate\s\+\%(-[LR]\s\+\)\=[ckz]\=sh\>'
setl ft=zsh
# ELM Mail files
elseif line1 =~ '^From \([a-zA-Z][a-zA-Z_0-9\.=-]*\(@[^ ]*\)\=\|-\) .* \(19\|20\)\d\d$'
setl ft=mail
# Mason
elseif line1 =~ '^<[%&].*>'
setl ft=mason
# Vim scripts (must have '" vim' as the first line to trigger this)
elseif line1 =~ '^" *[vV]im$'
setl ft=vim
# libcxx and libstdc++ standard library headers like "iostream" do not have
# an extension, recognize the Emacs file mode.
elseif line1 =~? '-\*-.*C++.*-\*-'
setl ft=cpp
# MOO
elseif line1 =~ '^\*\* LambdaMOO Database, Format Version \%([1-3]\>\)\@!\d\+ \*\*$'
setl ft=moo
# Diff file:
# - "diff" in first line (context diff)
# - "Only in " in first line
# - "--- " in first line and "+++ " in second line (unified diff).
# - "*** " in first line and "--- " in second line (context diff).
# - "# It was generated by makepatch " in the second line (makepatch diff).
# - "Index: <filename>" in the first line (CVS file)
# - "=== ", line of "=", "---", "+++ " (SVK diff)
# - "=== ", "--- ", "+++ " (bzr diff, common case)
# - "=== (removed|added|renamed|modified)" (bzr diff, alternative)
# - "# HG changeset patch" in first line (Mercurial export format)
elseif line1 =~ '^\(diff\>\|Only in \|\d\+\(,\d\+\)\=[cda]\d\+\>\|# It was generated by makepatch \|Index:\s\+\f\+\r\=$\|===== \f\+ \d\+\.\d\+ vs edited\|==== //\f\+#\d\+\|# HG changeset patch\)'
|| (line1 =~ '^--- ' && line2 =~ '^+++ ')
|| (line1 =~ '^\* looking for ' && line2 =~ '^\* comparing to ')
|| (line1 =~ '^\*\*\* ' && line2 =~ '^--- ')
|| (line1 =~ '^=== ' && ((line2 =~ '^=\{66\}' && line3 =~ '^--- ' && line4 =~ '^+++') || (line2 =~ '^--- ' && line3 =~ '^+++ ')))
|| (line1 =~ '^=== \(removed\|added\|renamed\|modified\)')
setl ft=diff
# PostScript Files (must have %!PS as the first line, like a2ps output)
elseif line1 =~ '^%![ \t]*PS'
setl ft=postscr
# M4 scripts: Guess there is a line that starts with "dnl".
elseif line1 =~ '^\s*dnl\>'
|| line2 =~ '^\s*dnl\>'
|| line3 =~ '^\s*dnl\>'
|| line4 =~ '^\s*dnl\>'
|| line5 =~ '^\s*dnl\>'
setl ft=m4
# AmigaDos scripts
elseif $TERM == "amiga" && (line1 =~ "^;" || line1 =~? '^\.bra')
setl ft=amiga
# SiCAD scripts (must have procn or procd as the first line to trigger this)
elseif line1 =~? '^ *proc[nd] *$'
setl ft=sicad
# Purify log files start with "**** Purify"
elseif line1 =~ '^\*\*\*\* Purify'
setl ft=purifylog
# XML
elseif line1 =~ '<?\s*xml.*?>'
setl ft=xml
# XHTML (e.g.: PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN")
elseif line1 =~ '\<DTD\s\+XHTML\s'
setl ft=xhtml
# HTML (e.g.: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN")
# Avoid "doctype html", used by slim.
elseif line1 =~? '<!DOCTYPE\s\+html\>'
setl ft=html
# PDF
elseif line1 =~ '^%PDF-'
setl ft=pdf
# XXD output
elseif line1 =~ '^\x\{7}: \x\{2} \=\x\{2} \=\x\{2} \=\x\{2} '
setl ft=xxd
# RCS/CVS log output
elseif line1 =~ '^RCS file:' || line2 =~ '^RCS file:'
setl ft=rcslog
# CVS commit
elseif line2 =~ '^CVS:' || getline("$") =~ '^CVS: '
setl ft=cvs
# Prescribe
elseif line1 =~ '^!R!'
setl ft=prescribe
# Send-pr
elseif line1 =~ '^SEND-PR:'
setl ft=sendpr
# SNNS files
elseif line1 =~ '^SNNS network definition file'
setl ft=snnsnet
elseif line1 =~ '^SNNS pattern definition file'
setl ft=snnspat
elseif line1 =~ '^SNNS result file'
setl ft=snnsres
# Virata
elseif line1 =~ '^%.\{-}[Vv]irata'
|| line2 =~ '^%.\{-}[Vv]irata'
|| line3 =~ '^%.\{-}[Vv]irata'
|| line4 =~ '^%.\{-}[Vv]irata'
|| line5 =~ '^%.\{-}[Vv]irata'
setl ft=virata
# Strace
# inaccurate fast match first, then use accurate slow match
elseif (line1 =~ 'execve(' && line1 =~ '^[0-9:. ]*execve(')
|| line1 =~ '^__libc_start_main'
setl ft=strace
# VSE JCL
elseif line1 =~ '^\* $$ JOB\>' || line1 =~ '^// *JOB\>'
setl ft=vsejcl
# TAK and SINDA
elseif line4 =~ 'K & K Associates' || line2 =~ 'TAK 2000'
setl ft=takout
elseif line3 =~ 'S Y S T E M S I M P R O V E D '
setl ft=sindaout
elseif getline(6) =~ 'Run Date: '
setl ft=takcmp
elseif getline(9) =~ 'Node File 1'
setl ft=sindacmp
# DNS zone files
elseif line1 .. line2 .. line3 .. line4 =~ '^; <<>> DiG [0-9.]\+.* <<>>\|$ORIGIN\|$TTL\|IN\s\+SOA'
setl ft=bindzone
# BAAN
elseif line1 =~ '|\*\{1,80}' && line2 =~ 'VRC '
|| line2 =~ '|\*\{1,80}' && line3 =~ 'VRC '
setl ft=baan
# Valgrind
elseif line1 =~ '^==\d\+== valgrind' || line3 =~ '^==\d\+== Using valgrind'
setl ft=valgrind
# Go docs
elseif line1 =~ '^PACKAGE DOCUMENTATION$'
setl ft=godoc
# Renderman Interface Bytestream
elseif line1 =~ '^##RenderMan'
setl ft=rib
# Scheme scripts
elseif line1 =~ 'exec\s\+\S*scheme' || line2 =~ 'exec\s\+\S*scheme'
setl ft=scheme
# Git output
elseif line1 =~ '^\(commit\|tree\|object\) \x\{40,\}\>\|^tag \S\+$'
setl ft=git
# Gprof (gnu profiler)
elseif line1 == 'Flat profile:'
&& line2 == ''
&& line3 =~ '^Each sample counts as .* seconds.$'
setl ft=gprof
# Erlang terms
# (See also: http://www.gnu.org/software/emacs/manual/html_node/emacs/Choosing-Modes.html#Choosing-Modes)
elseif line1 =~? '-\*-.*erlang.*-\*-'
setl ft=erlang
# YAML
elseif line1 =~ '^%YAML'
setl ft=yaml
# MikroTik RouterOS script
elseif line1 =~ '^#.*by RouterOS.*$'
setl ft=routeros
# Sed scripts
# #ncomment is allowed but most likely a false positive so require a space
# before any trailing comment text
elseif line1 =~ '^#n\%($\|\s\)'
setl ft=sed
else
var lnum = 1
while getline(lnum) =~ "^? " && lnum < line("$")
lnum += 1
endwhile
if getline(lnum) =~ '^Index:\s\+\f\+$'
# CVS diff
setl ft=diff
# locale input files: Formal Definitions of Cultural Conventions
# filename must be like en_US, fr_FR@euro or en_US.UTF-8
elseif expand("%") =~ '\a\a_\a\a\($\|[.@]\)\|i18n$\|POSIX$\|translit_'
lnum = 1
while lnum < 100 && lnum < line("$")
if getline(lnum) =~ '^LC_\(IDENTIFICATION\|CTYPE\|COLLATE\|MONETARY\|NUMERIC\|TIME\|MESSAGES\|PAPER\|TELEPHONE\|MEASUREMENT\|NAME\|ADDRESS\)$'
setf fdcc
break
endif
lnum += 1
endwhile
endif
endif
enddef

View File

@@ -0,0 +1,35 @@
" Vim runtime support library,
" runs the vim9 script version or legacy script version
" on demand (mostly for Neovim compatability)
"
" Maintainer: The Vim Project <https://github.com/vim/vim>
" Last Change: 2023 Nov 04
" enable the zip and gzip plugin by default, if not set
if !exists('g:zip_exec')
let g:zip_exec = 1
endif
if !exists('g:gzip_exec')
let g:gzip_exec = 1
endif
if !has('vim9script')
function dist#vim#IsSafeExecutable(filetype, executable)
let cwd = getcwd()
if empty(exepath(a:executable))
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 &&
\ cwd != '.'))
endfunction
finish
endif
def dist#vim#IsSafeExecutable(filetype: string, executable: string): bool
return dist#vim9#IsSafeExecutable(filetype, executable)
enddef

View File

@@ -0,0 +1,20 @@
vim9script
# Vim runtime support library
#
# Maintainer: The Vim Project <https://github.com/vim/vim>
# Last Change: 2023 Oct 25
export def IsSafeExecutable(filetype: string, executable: string): bool
if empty(exepath(executable))
return v:false
endif
var cwd = getcwd()
return get(g:, filetype .. '_exec', get(g:, 'plugin_exec', 0))
&& (fnamemodify(exepath(executable), ':p:h') !=# cwd
|| (split($PATH, has('win32') ? ';' : ':')->index(cwd) != -1
&& cwd != '.'))
enddef
# Uncomment this line to check for compilation errors early
# defcompile

File diff suppressed because it is too large Load Diff