From 80e0df74c913bfb4c1c577f68760210ee422ce60 Mon Sep 17 00:00:00 2001 From: Sheldon Lee Date: Mon, 23 Dec 2024 12:07:22 +0800 Subject: [PATCH] Update config + add user command to align markdown tables --- init.lua | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/init.lua b/init.lua index 371510b..b993b34 100644 --- a/init.lua +++ b/init.lua @@ -91,7 +91,7 @@ vim.g.mapleader = ' ' vim.g.maplocalleader = ' ' -- Set to true if you have a Nerd Font installed and selected in the terminal -vim.g.have_nerd_font = false +vim.g.have_nerd_font = true -- [[ Setting options ]] -- See `:help vim.opt` @@ -155,9 +155,10 @@ vim.opt.inccommand = 'split' vim.opt.cursorline = true -- Minimal number of screen lines to keep above and below the cursor. -vim.opt.scrolloff = 10 +vim.opt.scrolloff = 5 vim.opt.linebreak = true +vim.opt.fixeol = false -- [[ Basic Keymaps ]] -- See `:help vim.keymap.set()` @@ -199,6 +200,16 @@ vim.keymap.set('n', 'pv', vim.cmd.Ex, { desc = 'File explorer' }) vim.keymap.set('n', '', vim.cmd.cnext, { desc = 'Quick fix list next' }) vim.keymap.set('n', '', vim.cmd.cprev, { desc = 'Quick fix list previous' }) +-- [[ User Commands ]] + +-- Align markdown table +vim.api.nvim_create_user_command('MDTableAlign', function(args) + print(args.line1 .. '-' .. args.line2 .. ' pizzas') + local command = string.format("%d,%d! tr -s \" \" | column -t -s '|' -o '|'", args.line1, args.line2) + vim.cmd('silent ' .. command) + --vim.cmd("! tr -s \" \" | column -t -s '|' -o '|'") +end, { range = true, bang = false }) + -- [[ Basic Autocommands ]] -- See `:help lua-guide-autocommands`