diff runtime/ftplugin/vhdl.vim @ 33051:02939ae3aaca

runtime: Set b:undo_ftplugin where missing (#12943) Commit: https://github.com/vim/vim/commit/f937ab32a1ac3a560f217ca4ce8305ab2d5b0b74 Author: dkearns <dougkearns@gmail.com> Date: Tue Aug 29 05:32:27 2023 +1000 runtime: Set b:undo_ftplugin where missing (https://github.com/vim/vim/issues/12943) Signed-off-by: Christian Brabandt <cb@256bit.org>
author Christian Brabandt <cb@256bit.org>
date Mon, 28 Aug 2023 21:45:06 +0200
parents 8b8ef1fed009
children 8ae680be2a51
line wrap: on
line diff
--- a/runtime/ftplugin/vhdl.vim
+++ b/runtime/ftplugin/vhdl.vim
@@ -3,6 +3,7 @@
 " Maintainer:  R.Shankar <shankar.pec?gmail.com>
 " Modified By: Gerald Lai <laigera+vim?gmail.com>
 " Last Change: 2011 Dec 11
+"              2023 Aug 28 by Vim Project (undo_ftplugin, commentstring)
 
 " Only do this when not done yet for this buffer
 if exists("b:did_ftplugin")
@@ -22,13 +23,20 @@ set cpo&vim
 " Set 'comments' to format dashed lists in comments.
 "setlocal comments=sO:*\ -,mO:*\ \ ,exO:*/,s1:/*,mb:*,ex:*/,://
 
+setlocal commentstring=--\ %s
+
 " Format comments to be up to 78 characters long
 "setlocal tw=75
 
+" let b:undo_ftplugin = "setl cms< com< fo< tw<"
+
+let b:undo_ftplugin = "setl cms< "
+
 " Win32 can filter files in the browse dialog
 "if has("gui_win32") && !exists("b:browsefilter")
 "  let b:browsefilter = "Verilog Source Files (*.v)\t*.v\n" .
 "   \ "All Files (*.*)\t*.*\n"
+"  let b:undo_ftplugin .= " | unlet! b:browsefilter"
 "endif
 
 " Let the matchit plugin know what items can be matched.
@@ -52,37 +60,49 @@ if ! exists("b:match_words")  &&  exists
     \ s:notend.'\<package\>:\<end\s\+package\>,'.
     \ s:notend.'\<procedure\>:\<end\s\+procedure\>,'.
     \ s:notend.'\<configuration\>:\<end\s\+configuration\>'
+  let b:undo_ftplugin .= " | unlet! b:match_ignorecase b:match_words"
 endif
 
-" count repeat
-function! <SID>CountWrapper(cmd)
-  let i = v:count1
-  if a:cmd[0] == ":"
-    while i > 0
-      execute a:cmd
-      let i = i - 1
-    endwhile
-  else
-    execute "normal! gv\<Esc>"
-    execute "normal ".i.a:cmd
-    let curcol = col(".")
-    let curline = line(".")
-    normal! gv
-    call cursor(curline, curcol)
-  endif
-endfunction
+if !exists("no_plugin_maps") && !exists("no_vhdl_maps")
+  " count repeat
+  function! <SID>CountWrapper(cmd)
+    let i = v:count1
+    if a:cmd[0] == ":"
+      while i > 0
+	execute a:cmd
+	let i = i - 1
+      endwhile
+    else
+      execute "normal! gv\<Esc>"
+      execute "normal ".i.a:cmd
+      let curcol = col(".")
+      let curline = line(".")
+      normal! gv
+      call cursor(curline, curcol)
+    endif
+  endfunction
 
-" explore motion
-" keywords: "architecture", "block", "configuration", "component", "entity", "function", "package", "procedure", "process", "record", "units"
-let b:vhdl_explore = '\%(architecture\|block\|configuration\|component\|entity\|function\|package\|procedure\|process\|record\|units\)'
-noremap  <buffer><silent>[[ :<C-u>cal <SID>CountWrapper(':cal search("\\%(--.*\\)\\@<!\\%(\\<end\\s\\+\\)\\@<!\\<".b:vhdl_explore."\\>\\c\\<Bar>\\%^","bW")')<CR>
-noremap  <buffer><silent>]] :<C-u>cal <SID>CountWrapper(':cal search("\\%(--.*\\)\\@<!\\%(\\<end\\s\\+\\)\\@<!\\<".b:vhdl_explore."\\>\\c\\<Bar>\\%$","W")')<CR>
-noremap  <buffer><silent>[] :<C-u>cal <SID>CountWrapper(':cal search("\\%(--.*\\)\\@<!\\<end\\s\\+".b:vhdl_explore."\\>\\c\\<Bar>\\%^","bW")')<CR>
-noremap  <buffer><silent>][ :<C-u>cal <SID>CountWrapper(':cal search("\\%(--.*\\)\\@<!\\<end\\s\\+".b:vhdl_explore."\\>\\c\\<Bar>\\%$","W")')<CR>
-vnoremap <buffer><silent>[[ :<C-u>cal <SID>CountWrapper('[[')<CR>
-vnoremap <buffer><silent>]] :<C-u>cal <SID>CountWrapper(']]')<CR>
-vnoremap <buffer><silent>[] :<C-u>cal <SID>CountWrapper('[]')<CR>
-vnoremap <buffer><silent>][ :<C-u>cal <SID>CountWrapper('][')<CR>
+  " explore motion
+  " keywords: "architecture", "block", "configuration", "component", "entity", "function", "package", "procedure", "process", "record", "units"
+  let b:vhdl_explore = '\%(architecture\|block\|configuration\|component\|entity\|function\|package\|procedure\|process\|record\|units\)'
+  noremap  <buffer><silent>[[ :<C-u>cal <SID>CountWrapper(':cal search("\\%(--.*\\)\\@<!\\%(\\<end\\s\\+\\)\\@<!\\<".b:vhdl_explore."\\>\\c\\<Bar>\\%^","bW")')<CR>
+  noremap  <buffer><silent>]] :<C-u>cal <SID>CountWrapper(':cal search("\\%(--.*\\)\\@<!\\%(\\<end\\s\\+\\)\\@<!\\<".b:vhdl_explore."\\>\\c\\<Bar>\\%$","W")')<CR>
+  noremap  <buffer><silent>[] :<C-u>cal <SID>CountWrapper(':cal search("\\%(--.*\\)\\@<!\\<end\\s\\+".b:vhdl_explore."\\>\\c\\<Bar>\\%^","bW")')<CR>
+  noremap  <buffer><silent>][ :<C-u>cal <SID>CountWrapper(':cal search("\\%(--.*\\)\\@<!\\<end\\s\\+".b:vhdl_explore."\\>\\c\\<Bar>\\%$","W")')<CR>
+  vnoremap <buffer><silent>[[ :<C-u>cal <SID>CountWrapper('[[')<CR>
+  vnoremap <buffer><silent>]] :<C-u>cal <SID>CountWrapper(']]')<CR>
+  vnoremap <buffer><silent>[] :<C-u>cal <SID>CountWrapper('[]')<CR>
+  vnoremap <buffer><silent>][ :<C-u>cal <SID>CountWrapper('][')<CR>
+  let b:undo_ftplugin .=
+	\ " | silent! execute 'nunmap <buffer> [['" .
+	\ " | silent! execute 'nunmap <buffer> ]]'" .
+	\ " | silent! execute 'nunmap <buffer> []'" .
+	\ " | silent! execute 'nunmap <buffer> ]['" .
+	\ " | silent! execute 'vunmap <buffer> [['" .
+	\ " | silent! execute 'vunmap <buffer> ]]'" .
+	\ " | silent! execute 'vunmap <buffer> []'" .
+	\ " | silent! execute 'vunmap <buffer> ]['"
+endif
 
 let &cpo = s:cpo_save
 unlet s:cpo_save