fix(runtime): clean up one-off scripts

Problem: Some runtime files no longer spark joy.

Solution: Kondo the place up.

Still sparks _some_ joy (moved to new `runtime/scripts` folder):
* `macros/less.*`
* `mswin.vim`
* `tools/emoji_list.lua`

No longer sparks joy (removed):
* `macmap.vim` (gvimrc file; not useful in Nvim)
* `tools/check_colors.vim` (no longer useful with new default colorscheme and treesitter)
* `macros/editexisting.vim` (throws error on current Nvim)
* `macros/justify.vim` (obsolete shim for `packadd! justify`)
* `macros/matchit.vim` (same)
* `macros/shellmenu.vim` (same)
* `macros/swapmous.vim` (same)
This commit is contained in:
Christian Clason 2024-10-12 11:23:31 +02:00 committed by Christian Clason
parent ea5b748f24
commit 82b02ae2f2
26 changed files with 21 additions and 477 deletions

View File

@ -118,4 +118,4 @@ foreach(D ${RUNTIME_DIRS})
endforeach()
# only foo.sh script in runtime/
install_helper(PROGRAMS ${CMAKE_CURRENT_SOURCE_DIR}/macros/less.sh DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/nvim/runtime/macros/)
install_helper(PROGRAMS ${CMAKE_CURRENT_SOURCE_DIR}/scripts/less.sh DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/nvim/runtime/scripts/)

View File

@ -7,7 +7,7 @@ gzip.vim for editing compressed files
netrw*.vim browsing (remote) directories and editing remote files
tar.vim browsing tar files
zip.vim browsing zip files
paste.vim common code for mswin.vim, menu.vim and macmap.vim
paste.vim common code for mswin.vim and menu.vim
spellfile.vim downloading of a missing spell file
Omni completion files:

View File

@ -4,7 +4,7 @@
" Former Maintainer: Bram Moolenaar <Bram@vim.org>
" Define the string to use for items that are present both in Edit, Popup and
" Toolbar menu. Also used in mswin.vim and macmap.vim.
" Toolbar menu. Also used in mswin.vim.
let paste#paste_cmd = {'n': ":call paste#Paste()<CR>"}
let paste#paste_cmd['v'] = '"-c<Esc>' . paste#paste_cmd['n']

View File

@ -84,9 +84,6 @@ The default color settings can be found in the source file
If you think you have a color scheme that is good enough to be used by others,
please check the following items:
- Source the $VIMRUNTIME/colors/tools/check_colors.vim script to check for
common mistakes.
- Does it work in a color terminal as well as in the GUI? Is it consistent?
- Is "g:colors_name" set to a meaningful value? In case of doubt you can do

View File

@ -8702,7 +8702,7 @@ setcellwidths({list}) *setcellwidths()*
To clear the overrides pass an empty {list}: >vim
call setcellwidths([])
< You can use the script $VIMRUNTIME/tools/emoji_list.lua to see
< You can use the script $VIMRUNTIME/scripts/emoji_list.lua to see
the effect for known emoji characters. Move the cursor
through the text to check if the cell widths of your terminal
match with what Vim knows about each emoji. If it doesn't

View File

@ -548,9 +548,9 @@ gO Show a filetype-specific, navigable "outline" of the
If you use the less or more program to view a file, you don't get syntax
highlighting. Thus you would like to use Vim instead. You can do this by
using the shell script "$VIMRUNTIME/macros/less.sh".
using the shell script "$VIMRUNTIME/scripts/less.sh".
This shell script uses the Vim script "$VIMRUNTIME/macros/less.vim". It sets
This shell script uses the Vim script "$VIMRUNTIME/scripts/less.vim". It sets
up mappings to simulate the commands that less supports. Otherwise, you can
still use the Vim commands.

View File

@ -801,6 +801,10 @@ Plugins:
- logiPat
- rrhelper
- *vimball*
- macmap.vim
- tools/check_colors.vim
- macros/{justify,matchit,shellmenu,swapmous}.vim: use `packadd! justify` etc.
directly
Providers:

View File

@ -103,7 +103,7 @@ endif
if !exists ("b:match_words") &&
\ exists ("loaded_matchit")
"
" The following lines enable the macros/matchit.vim plugin for
" The following lines enable the matchit.vim plugin for
" Ada-specific extended matching with the % key.
"
let s:notend = '\%(\<end\s\+\)\@<!'

View File

@ -97,7 +97,7 @@ if !exists('*ErlangFoldText')
endfunction
endif
" The following lines enable the macros/matchit.vim plugin for extended
" The following lines enable the matchit.vim plugin for extended
" matching with the % key.
let b:match_ignorecase = 0
let b:match_words =

View File

@ -22,7 +22,7 @@ let b:undo_ftplugin .= "| unlet! b:match_ignorecase b:match_skip b:match_words"
let &l:define .= '\|\\new\(count\|dimen\|skip\|muskip\|box\|toks\|read\|write'
\ . '\|fam\|insert\)'
" The following lines enable the macros/matchit.vim plugin for
" The following lines enable the matchit.vim plugin for
" extended matching with the % key.
" There is no default meaning for \(...\) etc., but many users define one.
if exists("loaded_matchit")

View File

@ -210,7 +210,7 @@ if !exists("*s:ParseRpmVars")
endfunction
endif
" The following lines, along with the macros/matchit.vim plugin,
" The following lines, along with the matchit.vim plugin,
" make it easy to navigate the different sections of a spec file
" with the % key (thanks to Max Ischenko).

View File

@ -32,7 +32,7 @@ let &l:include .= '\|\\include{'
" TeX file has \include{fname} (LaTeX only), strip everything except "fname".
let &l:includeexpr = "substitute(v:fname, '^.\\{-}{\\|}.*', '', 'g')"
" The following lines enable the macros/matchit.vim plugin for
" The following lines enable the matchit.vim plugin for
" extended matching with the % key.
" ftplugin/plaintex.vim already defines b:match_skip and b:match_ignorecase
" and matches \(, \), \[, \], \{, and \} .

View File

@ -7923,7 +7923,7 @@ function vim.fn.setbufvar(buf, varname, val) end
--- To clear the overrides pass an empty {list}: >vim
--- call setcellwidths([])
---
--- <You can use the script $VIMRUNTIME/tools/emoji_list.lua to see
--- <You can use the script $VIMRUNTIME/scripts/emoji_list.lua to see
--- the effect for known emoji characters. Move the cursor
--- through the text to check if the cell widths of your terminal
--- match with what Vim knows about each emoji. If it doesn't

View File

@ -1,75 +0,0 @@
" System gvimrc file for Mac OS X
" Author: Benji Fisher <benji@member.AMS.org>
" Last Change: Thu Mar 09 09:00 AM 2006 EST
"
" Define Mac-standard keyboard shortcuts.
" We don't change 'cpoptions' here, because it would not be set properly when
" a .vimrc file is found later. Thus don't use line continuation and use
" <special> in mappings.
nnoremap <special> <D-n> :confirm enew<CR>
vmap <special> <D-n> <Esc><D-n>gv
imap <special> <D-n> <C-O><D-n>
cmap <special> <D-n> <C-C><D-n>
omap <special> <D-n> <Esc><D-n>
nnoremap <special> <D-o> :browse confirm e<CR>
vmap <special> <D-o> <Esc><D-o>gv
imap <special> <D-o> <C-O><D-o>
cmap <special> <D-o> <C-C><D-o>
omap <special> <D-o> <Esc><D-o>
nnoremap <silent> <special> <D-w> :if winheight(2) < 0 <Bar> confirm enew <Bar> else <Bar> confirm close <Bar> endif<CR>
vmap <special> <D-w> <Esc><D-w>gv
imap <special> <D-w> <C-O><D-w>
cmap <special> <D-w> <C-C><D-w>
omap <special> <D-w> <Esc><D-w>
nnoremap <silent> <special> <D-s> :if expand("%") == ""<Bar>browse confirm w<Bar> else<Bar>confirm w<Bar>endif<CR>
vmap <special> <D-s> <Esc><D-s>gv
imap <special> <D-s> <C-O><D-s>
cmap <special> <D-s> <C-C><D-s>
omap <special> <D-s> <Esc><D-s>
nnoremap <special> <D-S-s> :browse confirm saveas<CR>
vmap <special> <D-S-s> <Esc><D-s>gv
imap <special> <D-S-s> <C-O><D-s>
cmap <special> <D-S-s> <C-C><D-s>
omap <special> <D-S-s> <Esc><D-s>
" From the Edit menu of SimpleText:
nnoremap <special> <D-z> u
vmap <special> <D-z> <Esc><D-z>gv
imap <special> <D-z> <C-O><D-z>
cmap <special> <D-z> <C-C><D-z>
omap <special> <D-z> <Esc><D-z>
vnoremap <special> <D-x> "+x
vnoremap <special> <D-c> "+y
cnoremap <special> <D-c> <C-Y>
nnoremap <special> <D-v> "+gP
cnoremap <special> <D-v> <C-R>+
execute 'vnoremap <script> <special> <D-v>' paste#paste_cmd['v']
execute 'inoremap <script> <special> <D-v>' paste#paste_cmd['i']
nnoremap <silent> <special> <D-a> :if &slm != ""<Bar>exe ":norm gggH<C-O>G"<Bar> else<Bar>exe ":norm ggVG"<Bar>endif<CR>
vmap <special> <D-a> <Esc><D-a>
imap <special> <D-a> <Esc><D-a>
cmap <special> <D-a> <C-C><D-a>
omap <special> <D-a> <Esc><D-a>
nnoremap <special> <D-f> /
vmap <special> <D-f> <Esc><D-f>
imap <special> <D-f> <Esc><D-f>
cmap <special> <D-f> <C-C><D-f>
omap <special> <D-f> <Esc><D-f>
nnoremap <special> <D-g> n
vmap <special> <D-g> <Esc><D-g>
imap <special> <D-g> <C-O><D-g>
cmap <special> <D-g> <C-C><D-g>
omap <special> <D-g> <Esc><D-g>

View File

@ -1,119 +0,0 @@
" Vim Plugin: Edit the file with an existing Vim if possible
" Maintainer: The Vim Project <https://github.com/vim/vim>
" Last Change: 2023 Aug 13
" This is a plugin, drop it in your (Unix) ~/.vim/plugin or (Win32)
" $VIM/vimfiles/plugin directory. Or make a symbolic link, so that you
" automatically use the latest version.
" This plugin serves two purposes:
" 1. On startup, if we were invoked with one file name argument and the file
" is not modified then try to find another Vim instance that is editing
" this file. If there is one then bring it to the foreground and exit.
" 2. When a file is edited and a swap file exists for it, try finding that
" other Vim and bring it to the foreground. Requires Vim 7, because it
" uses the SwapExists autocommand event.
if v:version < 700
finish
endif
" Function that finds the Vim instance that is editing "filename" and brings
" it to the foreground.
func s:EditElsewhere(filename)
let fname_esc = substitute(a:filename, "'", "''", "g")
let servers = serverlist()
while servers != ''
" Get next server name in "servername"; remove it from "servers".
let i = match(servers, "\n")
if i == -1
let servername = servers
let servers = ''
else
let servername = strpart(servers, 0, i)
let servers = strpart(servers, i + 1)
endif
" Skip ourselves.
if servername ==? v:servername
continue
endif
" Check if this server is editing our file.
if remote_expr(servername, "bufloaded('" . fname_esc . "')")
" Yes, bring it to the foreground.
if has("win32")
call remote_foreground(servername)
endif
call remote_expr(servername, "foreground()")
if remote_expr(servername, "exists('*EditExisting')")
" Make sure the file is visible in a window (not hidden).
" If v:swapcommand exists and is set, send it to the server.
if exists("v:swapcommand")
let c = substitute(v:swapcommand, "'", "''", "g")
call remote_expr(servername, "EditExisting('" . fname_esc . "', '" . c . "')")
else
call remote_expr(servername, "EditExisting('" . fname_esc . "', '')")
endif
endif
if !(has('vim_starting') && has('gui_running') && has('gui_win32'))
" Tell the user what is happening. Not when the GUI is starting
" though, it would result in a message box.
echomsg "File is being edited by " . servername
sleep 2
endif
return 'q'
endif
endwhile
return ''
endfunc
" When the plugin is loaded and there is one file name argument: Find another
" Vim server that is editing this file right now.
if argc() == 1 && !&modified
if s:EditElsewhere(expand("%:p")) == 'q'
quit
endif
endif
" Setup for handling the situation that an existing swap file is found.
try
au! SwapExists * let v:swapchoice = s:EditElsewhere(expand("<afile>:p"))
catch
" Without SwapExists we don't do anything for ":edit" commands
endtry
" Function used on the server to make the file visible and possibly execute a
" command.
func! EditExisting(fname, command)
" Get the window number of the file in the current tab page.
let winnr = bufwinnr(a:fname)
if winnr <= 0
" Not found, look in other tab pages.
let bufnr = bufnr(a:fname)
for i in range(tabpagenr('$'))
if index(tabpagebuflist(i + 1), bufnr) >= 0
" Make this tab page the current one and find the window number.
exe 'tabnext ' . (i + 1)
let winnr = bufwinnr(a:fname)
break
endif
endfor
endif
if winnr > 0
exe winnr . "wincmd w"
elseif exists('*fnameescape')
exe "split " . fnameescape(a:fname)
else
exe "split " . escape(a:fname, " \t\n*?[{`$\\%#'\"|!<")
endif
if a:command != ''
exe "normal! " . a:command
endif
redraw
endfunc

View File

@ -1,3 +0,0 @@
" Load the justify package.
" For those users who were loading the justify plugin from here.
packadd justify

View File

@ -1,2 +0,0 @@
" This file is a compatibility stub for any plugins which source it.
" Nvim already loads the matchit plugin by default; see ':help pi_matchit.txt'.

View File

@ -1,3 +0,0 @@
" Load the shellmenu package.
" For those users who were loading the shellmenu plugin from here.
packadd shellmenu

View File

@ -1,3 +0,0 @@
" Load the swapmouse package.
" For those users who were loading the swapmous plugin from here.
packadd swapmouse

View File

@ -4,7 +4,7 @@ rem Read stdin if no arguments were given.
rem Written by Ken Takata.
if "%1"=="" (
nvim --cmd "let no_plugin_maps = 1" -c "runtime! macros/less.vim" -
nvim --cmd "let no_plugin_maps = 1" -c "runtime! scripts/less.vim" -
) else (
nvim --cmd "let no_plugin_maps = 1" -c "runtime! macros/less.vim" %*
nvim --cmd "let no_plugin_maps = 1" -c "runtime! scripts/less.vim" %*
)

View File

@ -8,9 +8,9 @@ if test -t 1; then
echo "Missing filename" 1>&2
exit
fi
nvim --cmd 'let no_plugin_maps = 1' -c 'runtime! macros/less.vim' -
nvim --cmd 'let no_plugin_maps = 1' -c 'runtime! scripts/less.vim' -
else
nvim --cmd 'let no_plugin_maps = 1' -c 'runtime! macros/less.vim' "$@"
nvim --cmd 'let no_plugin_maps = 1' -c 'runtime! scripts/less.vim' "$@"
fi
else
# Output is not a terminal, cat arguments or stdin

View File

@ -1,252 +0,0 @@
" This script tests a color scheme for some errors and lists potential errors.
" Load the scheme and source this script, like this:
" :edit colors/desert.vim | :so tools/check_colors.vim
let s:save_cpo= &cpo
set cpo&vim
func! Test_check_colors()
let l:savedview = winsaveview()
call cursor(1,1)
" err is
" {
" colors_name: "message",
" init: "message",
" background: "message",
" ....etc
" highlight: {
" 'Normal': "Missing ...",
" 'Conceal': "Missing ..."
" ....etc
" }
" }
let err = {}
" 1) Check g:colors_name is existing
if search('\<\%(g:\)\?colors_name\>', 'cnW') == 0
let err['colors_name'] = 'g:colors_name not set'
else
let err['colors_name'] = 'OK'
endif
" 2) Check for some well-defined highlighting groups
let hi_groups = [
\ 'ColorColumn',
\ 'Comment',
\ 'Conceal',
\ 'Constant',
\ 'Cursor',
\ 'CursorColumn',
\ 'CursorLine',
\ 'CursorLineNr',
\ 'DiffAdd',
\ 'DiffChange',
\ 'DiffDelete',
\ 'DiffText',
\ 'Directory',
\ 'EndOfBuffer',
\ 'Error',
\ 'ErrorMsg',
\ 'FoldColumn',
\ 'Folded',
\ 'Identifier',
\ 'Ignore',
\ 'IncSearch',
\ 'LineNr',
\ 'MatchParen',
\ 'ModeMsg',
\ 'MoreMsg',
\ 'NonText',
\ 'Normal',
\ 'Pmenu',
\ 'PmenuSbar',
\ 'PmenuSel',
\ 'PmenuThumb',
\ 'PreProc',
\ 'Question',
\ 'QuickFixLine',
\ 'Search',
\ 'SignColumn',
\ 'Special',
\ 'SpecialKey',
\ 'SpellBad',
\ 'SpellCap',
\ 'SpellLocal',
\ 'SpellRare',
\ 'Statement',
\ 'StatusLine',
\ 'StatusLineNC',
\ 'StatusLineTerm',
\ 'StatusLineTermNC',
\ 'TabLine',
\ 'TabLineFill',
\ 'TabLineSel',
\ 'Title',
\ 'Todo',
\ 'ToolbarButton',
\ 'ToolbarLine',
\ 'Type',
\ 'Underlined',
\ 'VertSplit',
\ 'Visual',
\ 'VisualNOS',
\ 'WarningMsg',
\ 'WildMenu',
\ ]
let groups = {}
for group in hi_groups
if search('\c@suppress\s\+\<' .. group .. '\>', 'cnW')
" skip check, if the script contains a line like
" @suppress Visual:
continue
endif
if search('hi\%[ghlight]!\= \+link \+' .. group, 'cnW') " Linked group
continue
endif
if !search('hi\%[ghlight] \+\<' .. group .. '\>', 'cnW')
let groups[group] = 'No highlight definition for ' .. group
continue
endif
if !search('hi\%[ghlight] \+\<' .. group .. '\>.*[bf]g=', 'cnW')
let groups[group] = 'Missing foreground or background color for ' .. group
continue
endif
if search('hi\%[ghlight] \+\<' .. group .. '\>.*guibg=', 'cnW') &&
\ !search('hi\%[ghlight] \+\<' .. group .. '\>.*ctermbg=', 'cnW')
\ && group != 'Cursor'
let groups[group] = 'Missing bg terminal color for ' .. group
continue
endif
if !search('hi\%[ghlight] \+\<' .. group .. '\>.*guifg=', 'cnW')
\ && group !~ '^Diff'
let groups[group] = 'Missing guifg definition for ' .. group
continue
endif
if !search('hi\%[ghlight] \+\<' .. group .. '\>.*ctermfg=', 'cnW')
\ && group !~ '^Diff'
\ && group != 'Cursor'
let groups[group] = 'Missing ctermfg definition for ' .. group
continue
endif
" do not check for background colors, they could be intentionally left out
call cursor(1,1)
endfor
let err['highlight'] = groups
" 3) Check, that it does not set background highlighting
" Doesn't ':hi Normal ctermfg=253 ctermfg=233' also set the background sometimes?
let bg_set = '\(set\?\|setl\(ocal\)\?\) .*\(background\|bg\)=\(dark\|light\)'
let bg_let = 'let \%([&]\%([lg]:\)\?\)\%(background\|bg\)\s*=\s*\([''"]\?\)\w\+\1'
let bg_pat = '\%(' .. bg_set .. '\|' .. bg_let .. '\)'
let line = search(bg_pat, 'cnW')
if search(bg_pat, 'cnW')
exe line
if search('hi \U\w\+\s\+\S', 'cbnW')
let err['background'] = 'Should not set background option after :hi statement'
endif
else
let err['background'] = 'OK'
endif
call cursor(1,1)
" 4) Check, that t_Co is checked
let pat = '[&]t_Co\s*[<>=]=\?\s*\d\+'
if !search(pat, 'ncW')
let err['t_Co'] = 'Does not check terminal for capable colors'
endif
" 5) Initializes correctly, e.g. should have a section like
" hi clear
" if exists("syntax_on")
" syntax reset
" endif
let pat = 'hi\%[ghlight]\s*clear\n\s*if\s*exists(\([''"]\)syntax_on\1)\n\s*syn\%[tax]\s*reset\n\s*endif'
if !search(pat, 'cnW')
let err['init'] = 'No initialization'
endif
" 6) Does not use :syn on
if search('syn\%[tax]\s\+on', 'cnW')
let err['background'] = 'Should not issue :syn on'
endif
" 7) Does not define filetype specific groups like vimCommand, htmlTag,
let hi_groups = filter(getcompletion('', 'filetype'), { _,v -> v !~# '\%[no]syn\%(color\|load\|tax\)' })
let ft_groups = []
" let group = '\%('.join(hi_groups, '\|').'\)' " More efficient than a for loop, but less informative
for group in hi_groups
let pat = '\Chi\%[ghlight]!\= *\%[link] \+\zs' .. group .. '\w\+\>\ze \+.' " Skips `hi clear`
if search(pat, 'cW')
call add(ft_groups, matchstr(getline('.'), pat))
endif
call cursor(1,1)
endfor
if !empty(ft_groups)
let err['filetype'] = get(err, 'filetype', 'Should not define: ') . join(uniq(sort(ft_groups)))
endif
" 8) Were debugPC and debugBreakpoint defined?
for group in ['debugPC', 'debugBreakpoint']
let pat = '\Chi\%[ghlight]!\= *\%[link] \+\zs' .. group .. '\>'
if search(pat, 'cnW')
let line = search(pat, 'cW')
let err['filetype'] = get(err, 'filetype', 'Should not define: ') . matchstr(getline('.'), pat). ' '
endif
call cursor(1,1)
endfor
" 9) Normal should be defined first, not use reverse, fg or bg
call cursor(1,1)
let pat = 'hi\%[ghlight] \+\%(link\|clear\)\@!\w\+\>'
call search(pat, 'cW') " Look for the first hi def, skipping `hi link` and `hi clear`
if getline('.') !~# '\m\<Normal\>'
let err['highlight']['Normal'] = 'Should be defined first'
elseif getline('.') =~# '\m\%(=\%(fg\|bg\)\)'
let err['highlight']['Normal'] = "Should not use 'fg' or 'bg'"
elseif getline('.') =~# '\m=\%(inv\|rev\)erse'
let err['highlight']['Normal'] = 'Should not use reverse mode'
endif
call winrestview(l:savedview)
let g:err = err
" print Result
call Result(err)
endfu
fu! Result(err)
let do_groups = 0
echohl Title|echomsg "---------------"|echohl Normal
for key in sort(keys(a:err))
if key ==# 'highlight'
let do_groups = !empty(a:err[key])
continue
else
if a:err[key] !~ 'OK'
echohl Title
endif
echomsg printf("%15s: %s", key, a:err[key])
echohl Normal
endif
endfor
echohl Title|echomsg "---------------"|echohl Normal
if do_groups
echohl Title | echomsg "Groups" | echohl Normal
for v1 in sort(keys(a:err['highlight']))
echomsg printf("%25s: %s", v1, a:err['highlight'][v1])
endfor
endif
endfu
try
call Test_check_colors()
catch
echohl ErrorMsg
echomsg v:exception
echohl NONE
finally
let &cpo = s:save_cpo
unlet s:save_cpo
endtry

View File

@ -9540,7 +9540,7 @@ M.funcs = {
To clear the overrides pass an empty {list}: >vim
call setcellwidths([])
<You can use the script $VIMRUNTIME/tools/emoji_list.lua to see
<You can use the script $VIMRUNTIME/scripts/emoji_list.lua to see
the effect for known emoji characters. Move the cursor
through the text to check if the cell widths of your terminal
match with what Vim knows about each emoji. If it doesn't