From 384a9c451a4603932a9cab8bf0e488af38a8a850 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Sun, 28 Jun 2026 02:44:13 -0400 Subject: [PATCH 1/3] build(vim-patch): detect N/A C files based on diff vim_na_cfuncs.txt lists Vim C functions that are N/A to Nvim. Listed in 'src/proto/*.proto' files. Based on ':h vim-diff'. - features (ie. balloon, tabpanel) - Ex-commands - eval functions (ie. f_err_teapot()) On top of the existing algorithm, scan diff hunks on C files to filter out N/A C functions. If the remaining hunk contains applicable changes, then the patch is applicable. If the patch does not modify C files, then it is likely applicable. --- scripts/vim-patch.sh | 37 +++++++++++++++++++++++++------------ scripts/vim_na_cfuncs.txt | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 64 insertions(+), 12 deletions(-) create mode 100644 scripts/vim_na_cfuncs.txt diff --git a/scripts/vim-patch.sh b/scripts/vim-patch.sh index c6c35f3dba..26c02eb95c 100755 --- a/scripts/vim-patch.sh +++ b/scripts/vim-patch.sh @@ -901,21 +901,34 @@ is_na_patch() { local patch=$1 local NA_REGEXP="$NVIM_SOURCE_DIR/scripts/vim_na_regexp.txt" local NA_FILELIST="$NVIM_SOURCE_DIR/scripts/vim_na_files.txt" + local NA_CFUNC_LIST="$NVIM_SOURCE_DIR/scripts/vim_na_cfuncs.txt" - local FILES_REMAINING + local FILES_REMAINING C_FILES FILES_REMAINING="$(diff <(git -C "${VIM_SOURCE_DIR}" diff-tree --no-commit-id --name-only -r "$patch" | grep -v -f "$NA_REGEXP") "$NA_FILELIST" | - grep '^<')" || true + grep '^<' | sed 's/^< //')" || true test -z "$FILES_REMAINING" && return 0 - if test "$FILES_REMAINING" == "$(printf "< src/version.c\n")"; then - local VERSION_LNUM - VERSION_LNUM=$(git -C "${VIM_SOURCE_DIR}" diff-tree --no-commit-id --numstat -r "$patch" -- src/version.c | grep -c '^2\s\+0') - test "$VERSION_LNUM" -ne 1 && return 1 - local VERSION_VNUM - VERSION_VNUM="$(git -C "${VIM_SOURCE_DIR}" diff-tree --no-commit-id -U1 -r "$patch" -- src/version.c | - grep -Pzc '[ +]\/\*\*\/\n\+\s+[0-9]+,\n[ +]\/\*\*\/\n')" || true - test "$VERSION_VNUM" -eq 1 && return 0 - fi - return 1 + + C_FILES=$(echo "$FILES_REMAINING" | grep '.*\.c$') + test "$FILES_REMAINING" != "$C_FILES" && return 1 + + local VERSION_LNUM VERSION_VNUM + for file in $C_FILES; do + if test "$file" == "src/version.c"; then + VERSION_LNUM=$(git -C "${VIM_SOURCE_DIR}" diff-tree --no-commit-id --numstat -r "$patch" -- src/version.c | grep -c '^2\s\+0') + test "$VERSION_LNUM" -ne 1 && return 1 + VERSION_VNUM="$(git -C "${VIM_SOURCE_DIR}" diff-tree --no-commit-id -U1 -r "$patch" -- src/version.c | + grep -Pzc '[ +]\/\*\*\/\n\+\s+[0-9]+,\n[ +]\/\*\*\/\n')" || true + test "$VERSION_VNUM" -ne 1 && return 1 + else + HUNKS=$(git -C "${VIM_SOURCE_DIR}" diff-tree --no-commit-id -U0 -r "$patch" -- "$file" | grep -P '^@@ .* @@') + if test -n "$HUNKS"; then + HUNK_NUM_FINAL=$(echo "$HUNKS" | sed 's/^@@ .* @@ \?//' | grep -cv -f "$NA_CFUNC_LIST") + test "$HUNK_NUM_FINAL" -ne 0 && return 1 + fi + fi + done + + return 0 } list_na_patches() { diff --git a/scripts/vim_na_cfuncs.txt b/scripts/vim_na_cfuncs.txt new file mode 100644 index 0000000000..431da7bd68 --- /dev/null +++ b/scripts/vim_na_cfuncs.txt @@ -0,0 +1,39 @@ +^check_restricted( +^did_set_cscopequickfix( +^did_set_showtabpanel( +^do_fixdel( +^ex_behave( +^ex_open( +^ex_scriptversion( +^ex_shell( +^ex_smile( +^ex_tearoff( +^f_err_teapot( +^f_listener_add( +^f_redraw_listener_add( +^f_test_alloc_fail( +^f_test_autochdir( +^f_test_feedinput( +^f_test_garbagecollect_soon( +^f_test_getvalue( +^f_test_ignore_error( +^f_test_null_channel( +^f_test_null_job( +^f_test_option_not_set( +^f_test_override( +^f_test_scrollbar( +^f_test_setmouse( +^f_test_settime( +^f_test_srand_seed( +^f_test_void( +_balloon[a-zA-Z0-9_]\+( +_tabpanelopt( +bevalterm[a-zA-Z0-9_]\+( +clip_xterm_[a-zA-Z0-9_]\+( +crypt( +crypt[a-zA-Z0-9_]\+( +gui_mch_[a-zA-Z0-9_]\+( +mch_kitty_probe( +mzscheme_call_vim( +text_prop[a-zA-Z0-9_]\+( +x11_[a-zA-Z0-9_]\+( From e618d279b8eb3c1b476f642e49ce45eadf10b478 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Sun, 5 Jul 2026 20:47:47 -0400 Subject: [PATCH 2/3] build(vim-patch): version.c "included_patches[]" is N/A Nvim relies on commit history for automated updates to ported Vim patches across Vim releases via "included_patchsets[]". Each Vim commit is suppose to manually adjust "included_patches[]" but it is prone to human error such that vim-patch.sh found the following N/A commits: ``` 495282b6e Correct list of patch numbers 85d9b03f8 Correct list of patches. ``` Prior to this commit, vim-patch doesn't find the following N/A commit: ``` 9.0.2172: Vim9: compiling :defer may fail ``` https://github.com/neovim/neovim/pull/40519#issuecomment-4850337525 --- scripts/vim-patch.sh | 19 +++++-------------- .../{vim_na_cfuncs.txt => vim_na_hunks_c.txt} | 1 + 2 files changed, 6 insertions(+), 14 deletions(-) rename scripts/{vim_na_cfuncs.txt => vim_na_hunks_c.txt} (95%) diff --git a/scripts/vim-patch.sh b/scripts/vim-patch.sh index 26c02eb95c..e9c619eaa4 100755 --- a/scripts/vim-patch.sh +++ b/scripts/vim-patch.sh @@ -901,7 +901,7 @@ is_na_patch() { local patch=$1 local NA_REGEXP="$NVIM_SOURCE_DIR/scripts/vim_na_regexp.txt" local NA_FILELIST="$NVIM_SOURCE_DIR/scripts/vim_na_files.txt" - local NA_CFUNC_LIST="$NVIM_SOURCE_DIR/scripts/vim_na_cfuncs.txt" + local NA_HUNKS_C="$NVIM_SOURCE_DIR/scripts/vim_na_hunks_c.txt" local FILES_REMAINING C_FILES FILES_REMAINING="$(diff <(git -C "${VIM_SOURCE_DIR}" diff-tree --no-commit-id --name-only -r "$patch" | grep -v -f "$NA_REGEXP") "$NA_FILELIST" | @@ -911,20 +911,11 @@ is_na_patch() { C_FILES=$(echo "$FILES_REMAINING" | grep '.*\.c$') test "$FILES_REMAINING" != "$C_FILES" && return 1 - local VERSION_LNUM VERSION_VNUM for file in $C_FILES; do - if test "$file" == "src/version.c"; then - VERSION_LNUM=$(git -C "${VIM_SOURCE_DIR}" diff-tree --no-commit-id --numstat -r "$patch" -- src/version.c | grep -c '^2\s\+0') - test "$VERSION_LNUM" -ne 1 && return 1 - VERSION_VNUM="$(git -C "${VIM_SOURCE_DIR}" diff-tree --no-commit-id -U1 -r "$patch" -- src/version.c | - grep -Pzc '[ +]\/\*\*\/\n\+\s+[0-9]+,\n[ +]\/\*\*\/\n')" || true - test "$VERSION_VNUM" -ne 1 && return 1 - else - HUNKS=$(git -C "${VIM_SOURCE_DIR}" diff-tree --no-commit-id -U0 -r "$patch" -- "$file" | grep -P '^@@ .* @@') - if test -n "$HUNKS"; then - HUNK_NUM_FINAL=$(echo "$HUNKS" | sed 's/^@@ .* @@ \?//' | grep -cv -f "$NA_CFUNC_LIST") - test "$HUNK_NUM_FINAL" -ne 0 && return 1 - fi + HUNKS=$(git -C "${VIM_SOURCE_DIR}" diff-tree --no-commit-id -U0 -r "$patch" -- "$file" | grep -P '^@@ .* @@') + if test -n "$HUNKS"; then + HUNK_NUM_FINAL=$(echo "$HUNKS" | sed 's/^@@ .* @@ \?//' | grep -cv -f "$NA_HUNKS_C") + test "$HUNK_NUM_FINAL" -ne 0 && return 1 fi done diff --git a/scripts/vim_na_cfuncs.txt b/scripts/vim_na_hunks_c.txt similarity index 95% rename from scripts/vim_na_cfuncs.txt rename to scripts/vim_na_hunks_c.txt index 431da7bd68..785c388bcb 100644 --- a/scripts/vim_na_cfuncs.txt +++ b/scripts/vim_na_hunks_c.txt @@ -26,6 +26,7 @@ ^f_test_settime( ^f_test_srand_seed( ^f_test_void( +^static int included_patches\[\] = _balloon[a-zA-Z0-9_]\+( _tabpanelopt( bevalterm[a-zA-Z0-9_]\+( From 4713f0e9eb4e4927d3ae9fcdc7d365f2a9d727e3 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Mon, 6 Jul 2026 00:27:31 -0400 Subject: [PATCH 3/3] build(vim-patch): N/A option callbacks ':h vim-diff' lists N/A options. Vim triggers callbacks when updating some of these options (ie. compatible). These callbacks are N/A. --- scripts/vim_na_hunks_c.txt | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/scripts/vim_na_hunks_c.txt b/scripts/vim_na_hunks_c.txt index 785c388bcb..4b216359db 100644 --- a/scripts/vim_na_hunks_c.txt +++ b/scripts/vim_na_hunks_c.txt @@ -1,6 +1,20 @@ +^change_compatible( ^check_restricted( +^compatible_set(void) +^did_set_compatible( ^did_set_cscopequickfix( +^did_set_imactivatekey( +^did_set_imdisable( +^did_set_imstyle( +^did_set_insertmode( +^did_set_keyprotocol( +^did_set_maxcombine( +^did_set_pastetoggle( +^did_set_printencoding( ^did_set_showtabpanel( +^did_set_swapsync( +^did_set_toolbar[a-zA-Z0-9_]\+( +^did_set_ttymouse( ^do_fixdel( ^ex_behave( ^ex_open(