Update config + add user command to align markdown tables

This commit is contained in:
Sheldon Lee 2024-12-23 12:07:22 +08:00
parent f02d74c282
commit 80e0df74c9

View File

@ -91,7 +91,7 @@ vim.g.mapleader = ' '
vim.g.maplocalleader = ' ' vim.g.maplocalleader = ' '
-- Set to true if you have a Nerd Font installed and selected in the terminal -- 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 ]] -- [[ Setting options ]]
-- See `:help vim.opt` -- See `:help vim.opt`
@ -155,9 +155,10 @@ vim.opt.inccommand = 'split'
vim.opt.cursorline = true vim.opt.cursorline = true
-- Minimal number of screen lines to keep above and below the cursor. -- 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.linebreak = true
vim.opt.fixeol = false
-- [[ Basic Keymaps ]] -- [[ Basic Keymaps ]]
-- See `:help vim.keymap.set()` -- See `:help vim.keymap.set()`
@ -199,6 +200,16 @@ vim.keymap.set('n', '<leader>pv', vim.cmd.Ex, { desc = 'File explorer' })
vim.keymap.set('n', '<C-j>', vim.cmd.cnext, { desc = 'Quick fix list next' }) vim.keymap.set('n', '<C-j>', vim.cmd.cnext, { desc = 'Quick fix list next' })
vim.keymap.set('n', '<C-k>', vim.cmd.cprev, { desc = 'Quick fix list previous' }) vim.keymap.set('n', '<C-k>', 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 ]] -- [[ Basic Autocommands ]]
-- See `:help lua-guide-autocommands` -- See `:help lua-guide-autocommands`