]> git.madduck.net Git - etc/lazyvim.git/commitdiff

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

Mail area detection and &fo handling
authormartin f. krafft <madduck@madduck.net>
Wed, 30 Apr 2025 13:32:03 +0000 (15:32 +0200)
committermartin f. krafft <madduck@madduck.net>
Wed, 6 Aug 2025 09:57:17 +0000 (11:57 +0200)
.config/lazyvim/after/ftplugin/mail.lua
.config/lazyvim/lazy-lock.json

index f0b87eb51afe46dd466f9e39158f95599611ee67..b3d4005a731debe4d57fc1d4cad2000054a8f180 100644 (file)
@@ -16,9 +16,6 @@ vim.opt_local.formatexpr = ""
 vim.opt_local.formatoptions:remove("o")
 vim.opt_local.formatoptions:remove("r")
 vim.opt_local.formatoptions:remove("l")
-vim.opt_local.formatoptions:append("a")
-vim.opt_local.formatoptions:append("w")
-vim.opt_local.formatoptions:append("n")
 
 vim.keymap.set("n", "<leader>m", "", { buffer = true, desc = "mail functions" })
 vim.keymap.set("n", "<leader>ms", "", { buffer = true, desc = "subject manipulation" })
@@ -88,3 +85,37 @@ vim.api.nvim_create_autocmd({ "BufWrite" }, {
 })
 
 vim.cmd.runtime("greeting_abbrevs.vim")
+
+local function mail_area_detect()
+  local ts = vim.treesitter
+  if not ts then
+    return
+  end
+  local node = vim.treesitter.get_node()
+  if not node then
+    return
+  end
+  if node:type():find("^body") ~= nil then
+    vim.opt_local.formatoptions:append("a")
+    vim.opt_local.formatoptions:append("w")
+    vim.opt_local.formatoptions:append("n")
+    vim.opt_local.formatoptions:append("t")
+    vim.opt_local.formatoptions:append("c")
+    vim.w.in_body = true
+  else
+    vim.opt_local.formatoptions:remove("a")
+    vim.opt_local.formatoptions:remove("w")
+    vim.opt_local.formatoptions:remove("n")
+    vim.opt_local.formatoptions:remove("t")
+    vim.opt_local.formatoptions:remove("c")
+    vim.w.in_body = false
+  end
+end
+
+local cmdgroup = vim.api.nvim_create_augroup("mailarea", { clear = true })
+vim.api.nvim_create_autocmd({ "CursorMoved", "CursorMovedI" }, {
+  buffer = 0,
+  group = cmdgroup,
+  callback = mail_area_detect,
+})
+mail_area_detect()
index 8c7e86990bc01730de42f049a4bb7785e5b90326..1118c6b8147c6f929594038d9cd5156be370f461 100644 (file)
@@ -4,12 +4,12 @@
   "blink.compat": { "branch": "main", "commit": "2ed6d9a28b07fa6f3bface818470605f8896408c" },
   "bufferline.nvim": { "branch": "main", "commit": "655133c3b4c3e5e05ec549b9f8cc2894ac6f51b3" },
   "catppuccin": { "branch": "main", "commit": "5b5e3aef9ad7af84f463d17b5479f06b87d5c429" },
-  "cmp-lbdb": { "branch": "master", "commit": "a24ef0b13bf02274eead60efb99d058d27a711a5" },
+  "cmp-lbdb": { "branch": "master", "commit": "c6f0c43d53e7b0417a7aadf1792605203df8e7ca" },
   "conform.nvim": { "branch": "master", "commit": "372fc521f8421b7830ea6db4d6ea3bae1c77548c" },
   "flash.nvim": { "branch": "main", "commit": "3c942666f115e2811e959eabbdd361a025db8b63" },
-  "friendly-snippets": { "branch": "main", "commit": "fc8f183479a472df60aa86f00e295462f2308178" },
-  "gitsigns.nvim": { "branch": "main", "commit": "140ac646db125904e456e42ab8b538d28f9607d7" },
-  "grug-far.nvim": { "branch": "main", "commit": "631331f9c6611b1a47e887f50b92b7cf450f51e7" },
+  "friendly-snippets": { "branch": "main", "commit": "572f5660cf05f8cd8834e096d7b4c921ba18e175" },
+  "gitsigns.nvim": { "branch": "main", "commit": "fd50977fce4d5240b910d2b816e71fb726cbbaf7" },
+  "grug-far.nvim": { "branch": "main", "commit": "6ff8a205a29db3a9b08e5debe09452b4d6fd6591" },
   "lazy.nvim": { "branch": "main", "commit": "6c3bda4aca61a13a9c63f1c1d1b16b9d3be90d7a" },
   "lazydev.nvim": { "branch": "main", "commit": "2367a6c0a01eb9edb0464731cc0fb61ed9ab9d2c" },
   "lualine.nvim": { "branch": "master", "commit": "15884cee63a8c205334ab13ab1c891cd4d27101a" },
   "noice.nvim": { "branch": "main", "commit": "0427460c2d7f673ad60eb02b35f5e9926cf67c59" },
   "nui.nvim": { "branch": "main", "commit": "8d5b0b568517935d3c84f257f272ef004d9f5a59" },
   "nvim-lint": { "branch": "master", "commit": "9dfb77ef6c5092a19502883c02dc5a02ec648729" },
-  "nvim-lspconfig": { "branch": "master", "commit": "8b0f47d851ee5343d38fe194a06ad16b9b9bd086" },
+  "nvim-lspconfig": { "branch": "master", "commit": "94d0fec9135719e046903bbbbf8f39e3d3436d4e" },
   "nvim-nio": { "branch": "master", "commit": "21f5324bfac14e22ba26553caf69ec76ae8a7662" },
-  "nvim-treesitter": { "branch": "master", "commit": "684eeac91ed8e297685a97ef70031d19ac1de25a" },
-  "nvim-treesitter-textobjects": { "branch": "master", "commit": "205e3369bc83d8cb83f7409c36120e24611f8c5c" },
+  "nvim-treesitter": { "branch": "master", "commit": "94ea4f436d2b59c80f02e293466c374584f03b8c" },
+  "nvim-treesitter-textobjects": { "branch": "master", "commit": "ed373482db797bbf71bdff37a15c7555a84dce47" },
   "nvim-ts-autotag": { "branch": "main", "commit": "a1d526af391f6aebb25a8795cbc05351ed3620b5" },
   "persistence.nvim": { "branch": "main", "commit": "166a79a55bfa7a4db3e26fc031b4d92af71d0b51" },
   "plenary.nvim": { "branch": "master", "commit": "857c5ac632080dba10aae49dba902ce3abf91b35" },
-  "render-markdown.nvim": { "branch": "main", "commit": "6910fe12a9634be5ce4e19aff4d3b45abf3f0dd3" },
+  "render-markdown.nvim": { "branch": "main", "commit": "bd5657594bf1a96b04f900c87e8d74226a54d832" },
   "snacks.nvim": { "branch": "main", "commit": "bc0630e43be5699bb94dadc302c0d21615421d93" },
   "todo-comments.nvim": { "branch": "main", "commit": "304a8d204ee787d2544d8bc23cd38d2f929e7cc5" },
   "tokyonight.nvim": { "branch": "main", "commit": "057ef5d260c1931f1dffd0f052c685dcd14100a3" },