]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
runtime(fish): Add matchit support to filetype plugin
authorPhạm Bình An <phambinhanctb2004@gmail.com>
Fri, 20 Mar 2026 21:29:57 +0000 (21:29 +0000)
committerChristian Brabandt <cb@256bit.org>
Fri, 20 Mar 2026 21:29:57 +0000 (21:29 +0000)
closes: #19701

Co-authored-by: Doug Kearns <dougkearns@gmail.com>
Signed-off-by: Phạm Bình An <phambinhanctb2004@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
runtime/ftplugin/fish.vim

index 55d7ea8dd957393095682d47b53c78d06eff74e7..685ff4d1705b1b1e708a0b3426f5e276b2c6dd73 100644 (file)
@@ -5,10 +5,15 @@
 " Last Change:  February 1, 2023
 "               2023 Aug 28 by Vim Project (undo_ftplugin)
 "               2024 May 23 by Riley Bruins <ribru17@gmail.com> ('commentstring')
+"               2026 Mar 16 by Phạm Bình An (add matchit support)
 
 if exists("b:did_ftplugin")
     finish
 endif
+
+let s:saved_cpo = &cpo
+set cpo-=C
+
 let b:did_ftplugin = 1
 
 setlocal iskeyword=@,48-57,_,192-255,-,.
@@ -17,3 +22,20 @@ setlocal commentstring=#\ %s
 setlocal formatoptions+=crjq
 
 let b:undo_ftplugin = "setl cms< com< fo< isk<"
+
+" Define patterns for the matchit plugin
+if exists("loaded_matchit") && !exists("b:match_words")
+  let b:match_words =
+      \ '\<\%(else\s\+\)\@<!if\>\|\<\%(switch\|begin\|function\|while\|for\)\>:' ..
+      \ '\<else\%(\s\+if\)\?\>\|\<case\>:' ..
+      \ '\<end\>'
+
+  let b:match_ignorecase = 0
+  let b:match_skip = "S:keyword"
+
+  let b:undo_ftplugin ..= " | unlet! b:match_words b:match_ignorecase b:match_skip"
+endif
+
+" Restore 'cpo' to its original value
+let &cpo = s:saved_cpo
+unlet s:saved_cpo