From 7071a667a1617d5755fbec2d947fd21e166e81ba Mon Sep 17 00:00:00 2001 From: Yuan Chiu Date: Mon, 5 May 2025 22:40:38 +0800 Subject: [PATCH] =?UTF-8?q?nvim:=20align=20...=E7=9A=84=E5=B1=8D=E9=AB=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../exact_plugins/exact_editor/align.lua | 91 +++++++++++++++++++ 1 file changed, 91 insertions(+) create mode 100644 dot_config/nvim/exact_lua/exact_plugins/exact_editor/align.lua diff --git a/dot_config/nvim/exact_lua/exact_plugins/exact_editor/align.lua b/dot_config/nvim/exact_lua/exact_plugins/exact_editor/align.lua new file mode 100644 index 0000000..ebce2e7 --- /dev/null +++ b/dot_config/nvim/exact_lua/exact_plugins/exact_editor/align.lua @@ -0,0 +1,91 @@ +if true then return {} end -- 暫時停用(不會用🫠) +return { + { + 'Vonr/align.nvim', + branch = "v2", + lazy = true, + init = function() + -- Create your mappings here + local NS = { noremap = true, silent = true } + + -- Aligns to 1 character + vim.keymap.set( + 'x', + 'aa', + function() + require'align'.align_to_char({ + length = 1, + }) + end, + NS + ) + + -- Aligns to 2 characters with previews + vim.keymap.set( + 'x', + 'ad', + function() + require'align'.align_to_char({ + preview = true, + length = 2, + }) + end, + NS + ) + + -- Aligns to a string with previews + vim.keymap.set( + 'x', + 'aw', + function() + require'align'.align_to_string({ + preview = true, + regex = false, + }) + end, + NS + ) + + -- Aligns to a Vim regex with previews + vim.keymap.set( + 'x', + 'ar', + function() + require'align'.align_to_string({ + preview = true, + regex = true, + }) + end, + NS + ) + + -- Example gawip to align a paragraph to a string with previews + vim.keymap.set( + 'n', + 'gaw', + function() + local a = require'align' + a.operator( + a.align_to_string, + { + regex = false, + preview = true, + } + ) + end, + NS + ) + + -- Example gaaip to align a paragraph to 1 character + vim.keymap.set( + 'n', + 'gaa', + function() + local a = require'align' + a.operator(a.align_to_char) + end, + NS + ) + end + } +}