before upgrade
This commit is contained in:
+27
-20
@@ -2,6 +2,13 @@ vim.g.mapleader = " "
|
||||
|
||||
vim.cmd("command! W w")
|
||||
|
||||
vim.api.nvim_create_user_command("Mdtf", function(opts)
|
||||
vim.cmd(string.format("%d,%d!column -t -s '|' -o '|'", opts.line1, opts.line2))
|
||||
end, {
|
||||
range = true,
|
||||
})
|
||||
vim.keymap.set("v", "<leader>mt", ":!column -t -s '|' -o '|'<CR>", { desc = "Format markdown table" })
|
||||
|
||||
-- Macros
|
||||
|
||||
vim.keymap.set("t", "<Esc>", "<C-\\><C-n>")
|
||||
@@ -72,26 +79,26 @@ vim.keymap.set("n", "<space>l", ":.lua<CR>")
|
||||
vim.keymap.set("v", "<space>l", ":lua<CR>")
|
||||
|
||||
local function swap_words()
|
||||
local start = vim.fn.getpos("'<")[2]
|
||||
local finish = vim.fn.getpos("'>")[2]
|
||||
local start = vim.fn.getpos("'<")[2]
|
||||
local finish = vim.fn.getpos("'>")[2]
|
||||
|
||||
local w1 = vim.fn.input("Word 1: ")
|
||||
local w2 = vim.fn.input("Word 2: ")
|
||||
local w1 = vim.fn.input("Word 1: ")
|
||||
local w2 = vim.fn.input("Word 2: ")
|
||||
|
||||
if w1 == "" or w2 == "" then
|
||||
return
|
||||
end
|
||||
if w1 == "" or w2 == "" then
|
||||
return
|
||||
end
|
||||
|
||||
local lines = vim.api.nvim_buf_get_lines(0, start - 1, finish, false)
|
||||
local lines = vim.api.nvim_buf_get_lines(0, start - 1, finish, false)
|
||||
|
||||
for i, line in ipairs(lines) do
|
||||
line = line:gsub(vim.pesc(w1), "__TMP__")
|
||||
line = line:gsub(vim.pesc(w2), w1)
|
||||
line = line:gsub("__TMP__", w2)
|
||||
lines[i] = line
|
||||
end
|
||||
for i, line in ipairs(lines) do
|
||||
line = line:gsub(vim.pesc(w1), "__TMP__")
|
||||
line = line:gsub(vim.pesc(w2), w1)
|
||||
line = line:gsub("__TMP__", w2)
|
||||
lines[i] = line
|
||||
end
|
||||
|
||||
vim.api.nvim_buf_set_lines(0, start - 1, finish, false, lines)
|
||||
vim.api.nvim_buf_set_lines(0, start - 1, finish, false, lines)
|
||||
end
|
||||
|
||||
vim.keymap.set("v", "<leader>ws", swap_words, { desc = "Swap two words in selection" })
|
||||
@@ -99,11 +106,11 @@ vim.keymap.set("n", "<leader>ws", swap_words, { desc = "Swap two words in select
|
||||
|
||||
-- @source https://github.com/benlubas/.dotfiles/blob/main/nvim%2Fafter%2Fftplugin%2Fqf.lua
|
||||
local del_qf_item = function()
|
||||
local items = vim.fn.getqflist()
|
||||
local line = vim.fn.line('.')
|
||||
table.remove(items, line)
|
||||
vim.fn.setqflist(items, "r")
|
||||
vim.api.nvim_win_set_cursor(0, { line, 0 })
|
||||
local items = vim.fn.getqflist()
|
||||
local line = vim.fn.line('.')
|
||||
table.remove(items, line)
|
||||
vim.fn.setqflist(items, "r")
|
||||
vim.api.nvim_win_set_cursor(0, { line, 0 })
|
||||
end
|
||||
|
||||
-- this is super basic. I might improve it at some point, but it's good enough for how little I use
|
||||
|
||||
@@ -19,6 +19,7 @@ vim.opt.expandtab = true
|
||||
vim.opt.smartindent = true
|
||||
|
||||
vim.opt.wrap = true--false
|
||||
-- vim.opt.linebreak = true
|
||||
|
||||
vim.opt.swapfile = false
|
||||
vim.opt.backup = false
|
||||
|
||||
Reference in New Issue
Block a user