regexp match "no jump on load" filetypes

Tue, 14 Mar 2023 01:11:40 -0500

author
Meredith Howard <mhoward@roomag.org>
date
Tue, 14 Mar 2023 01:11:40 -0500
changeset 1086
82f517e1ae76
parent 1085
c2d11f022cf0
child 1087
bfcf9813c223

regexp match "no jump on load" filetypes

.config/nvim/lua/config/autocmds.lua file | annotate | diff | comparison | revisions
--- a/.config/nvim/lua/config/autocmds.lua
+++ b/.config/nvim/lua/config/autocmds.lua
@@ -34,10 +34,12 @@ autocmd(g, "BufWritePre", "*", {
 -- >> auto session ?
 
 -- >> jump to last position on open
+local nojump = vim.regex([[mail\|commit\|rebase]])
+assert(nojump, "Couldn't compile nojump regexp?")
+
 autocmd(g, "BufReadPost", "*", function()
-  local ft = vim.bo.filetype
-  if ft == "mail" or string.match(ft, "^git") or string.match(ft, "^hg") then
-    return ""
+  if nojump:match_str(vim.bo.filetype or "") then
+    return
   end
 
   local lastpos = fn.line([['"]])

mercurial