[General] Fixes
This commit is contained in:
@@ -1,19 +1,17 @@
|
||||
return {
|
||||
-- git buffer integration
|
||||
"lewis6991/gitsigns.nvim",
|
||||
event = "BufRead",
|
||||
config = function()
|
||||
require("gitsigns").setup({
|
||||
count_chars = { "¹", "²", "³", "⁴", "⁵", "⁶", "⁷", "⁸", "⁹", ["+"] = "⁺" },
|
||||
signs = {
|
||||
add = { show_count = true },
|
||||
change = { show_count = true },
|
||||
delete = { show_count = true },
|
||||
topdelete = { show_count = true },
|
||||
changedelete = { show_count = true },
|
||||
untracked = { show_count = true },
|
||||
},
|
||||
numhl = true,
|
||||
})
|
||||
end,
|
||||
-- git buffer integration
|
||||
"lewis6991/gitsigns.nvim",
|
||||
event = "BufRead",
|
||||
opts = {
|
||||
count_chars = { "¹", "²", "³", "⁴", "⁵", "⁶", "⁷", "⁸", "⁹", ["+"] = "⁺" },
|
||||
signs = {
|
||||
add = { show_count = true },
|
||||
change = { show_count = true },
|
||||
delete = { show_count = true },
|
||||
topdelete = { show_count = true },
|
||||
changedelete = { show_count = true },
|
||||
untracked = { show_count = true },
|
||||
},
|
||||
numhl = true,
|
||||
},
|
||||
}
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
return {
|
||||
-- open file at previous position
|
||||
"ethanholz/nvim-lastplace",
|
||||
event = { "BufReadPre", "BufNewFile" },
|
||||
config = function()
|
||||
require("nvim-lastplace").setup({})
|
||||
end,
|
||||
-- open file at previous position
|
||||
"ethanholz/nvim-lastplace",
|
||||
event = { "BufReadPre", "BufNewFile" },
|
||||
opts = {},
|
||||
}
|
||||
|
||||
@@ -1,18 +1,19 @@
|
||||
local utils = require("utils")
|
||||
return {
|
||||
opts = {},
|
||||
"fedepujol/move.nvim",
|
||||
keys = {
|
||||
{ "<A-S-k>", ":MoveLine(-1)<CR>", desc = "Move line up" },
|
||||
{ "<A-S-j>", ":MoveLine(1)<CR>", desc = "Move line down" },
|
||||
{ "<leader>mk", ":MoveLine(-1)<CR>", desc = "Move line up" },
|
||||
{ "<leader>mj", ":MoveLine(1)<CR>", desc = "Move line down" },
|
||||
opts = {},
|
||||
"fedepujol/move.nvim",
|
||||
keys = {
|
||||
{ "<A-S-k>", utils.run_vim_cmd("MoveLine(-1)"), desc = "Move line up" },
|
||||
{ "<A-S-j>", utils.run_vim_cmd("MoveLine(1)"), desc = "Move line down" },
|
||||
{ "<leader>mk", utils.run_vim_cmd("MoveLine(-1)"), desc = "Move line up" },
|
||||
{ "<leader>mj", utils.run_vim_cmd("MoveLine(1)"), desc = "Move line down" },
|
||||
|
||||
-- Move blocks in visual mode
|
||||
{ "<A-k>", ":MoveBlock(-1)<CR>", desc = "Move line up" },
|
||||
{ "<A-j>", ":MoveBlock(1)<CR>", desc = "Move line down" },
|
||||
-- Move blocks in visual mode
|
||||
{ "<A-k>", utils.run_vim_cmd("MoveBlock(-1)"), desc = "Move line up" },
|
||||
{ "<A-j>", utils.run_vim_cmd("MoveBlock(1)"), desc = "Move line down" },
|
||||
|
||||
-- Move lines in insert mode
|
||||
{ "<A-k>", "<C-o>:MoveLine(-1)<CR>", desc = "Move line up" },
|
||||
{ "<A-j>", "<C-o>:MoveLine(1)<CR>", desc = "Move line down" },
|
||||
},
|
||||
-- Move lines in insert mode
|
||||
{ "<A-k>", utils.run_vim_cmd("MoveLine(-1)"), desc = "Move line up" },
|
||||
{ "<A-j>", utils.run_vim_cmd("MoveLine(1)"), desc = "Move line down" },
|
||||
},
|
||||
}
|
||||
|
||||
@@ -1,16 +1,17 @@
|
||||
local utils = require("utils")
|
||||
return {
|
||||
"smoka7/multicursors.nvim",
|
||||
dependencies = {
|
||||
"nvimtools/hydra.nvim",
|
||||
},
|
||||
opts = {},
|
||||
cmd = { "MCstart", "MCvisual", "MCclear", "MCpattern", "MCvisualPattern", "MCunderCursor" },
|
||||
keys = {
|
||||
{
|
||||
mode = { "v", "n" },
|
||||
"<leader><leader>c",
|
||||
"<cmd>MCstart<cr>",
|
||||
desc = "Create a selection for selected text or word under the cursor",
|
||||
},
|
||||
},
|
||||
"smoka7/multicursors.nvim",
|
||||
dependencies = {
|
||||
"nvimtools/hydra.nvim",
|
||||
},
|
||||
opts = {},
|
||||
cmd = { "MCstart", "MCvisual", "MCclear", "MCpattern", "MCvisualPattern", "MCunderCursor" },
|
||||
keys = {
|
||||
{
|
||||
mode = { "v", "n" },
|
||||
"<leader><leader>c",
|
||||
utils.run_vim_cmd("MCstart(-1)"),
|
||||
desc = "Create a selection for selected text or word under the cursor",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
@@ -2,7 +2,5 @@ return {
|
||||
"kylechui/nvim-surround",
|
||||
version = "*",
|
||||
event = "InsertEnter",
|
||||
config = function()
|
||||
require("nvim-surround").setup()
|
||||
end,
|
||||
opts = {}
|
||||
}
|
||||
|
||||
@@ -3,56 +3,62 @@
|
||||
local M = {}
|
||||
|
||||
M.opts = function(desc)
|
||||
if desc then
|
||||
return { noremap = true, silent = true, desc = desc }
|
||||
else
|
||||
return { noremap = true, silent = true }
|
||||
end
|
||||
if desc then
|
||||
return { noremap = true, silent = true, desc = desc }
|
||||
else
|
||||
return { noremap = true, silent = true }
|
||||
end
|
||||
end
|
||||
|
||||
M.run_vim_cmd = function(cmd)
|
||||
return function()
|
||||
vim.cmd(cmd)
|
||||
end
|
||||
end
|
||||
|
||||
M.sudo_exec = function(cmd, print_output)
|
||||
vim.fn.inputsave()
|
||||
local password = vim.fn.inputsecret("Password: ")
|
||||
vim.fn.inputrestore()
|
||||
if not password or #password == 0 then
|
||||
print("Invalid password, sudo aborted")
|
||||
return false
|
||||
end
|
||||
local out = vim.fn.system(string.format("sudo -p '' -S %s", cmd), password)
|
||||
if vim.v.shell_error ~= 0 then
|
||||
print("\r\n")
|
||||
print(out)
|
||||
return false
|
||||
end
|
||||
if print_output then
|
||||
print("\r\n", out)
|
||||
end
|
||||
return true
|
||||
vim.fn.inputsave()
|
||||
local password = vim.fn.inputsecret("Password: ")
|
||||
vim.fn.inputrestore()
|
||||
if not password or #password == 0 then
|
||||
print("Invalid password, sudo aborted")
|
||||
return false
|
||||
end
|
||||
local out = vim.fn.system(string.format("sudo -p '' -S %s", cmd), password)
|
||||
if vim.v.shell_error ~= 0 then
|
||||
print("\r\n")
|
||||
print(out)
|
||||
return false
|
||||
end
|
||||
if print_output then
|
||||
print("\r\n", out)
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
M.sudo_write = function(tmpfile, filepath)
|
||||
if not tmpfile then
|
||||
tmpfile = vim.fn.tempname()
|
||||
end
|
||||
if not filepath then
|
||||
filepath = vim.fn.expand("%")
|
||||
end
|
||||
if not filepath or #filepath == 0 then
|
||||
print("E32: No file name")
|
||||
return
|
||||
end
|
||||
-- `bs=1048576` is equivalent to `bs=1M` for GNU dd or `bs=1m` for BSD dd
|
||||
-- Both `bs=1M` and `bs=1m` are non-POSIX
|
||||
local cmd = string.format("dd if=%s of=%s bs=1048576", vim.fn.shellescape(tmpfile), vim.fn.shellescape(filepath))
|
||||
-- no need to check error as this fails the entire function
|
||||
vim.api.nvim_exec(string.format("write! %s", tmpfile), true)
|
||||
if M.sudo_exec(cmd) then
|
||||
-- refreshes the buffer and prints the "written" message
|
||||
vim.cmd.checktime()
|
||||
-- exit command mode
|
||||
vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes("<Esc>", true, false, true), "n", true)
|
||||
end
|
||||
vim.fn.delete(tmpfile)
|
||||
if not tmpfile then
|
||||
tmpfile = vim.fn.tempname()
|
||||
end
|
||||
if not filepath then
|
||||
filepath = vim.fn.expand("%")
|
||||
end
|
||||
if not filepath or #filepath == 0 then
|
||||
print("E32: No file name")
|
||||
return
|
||||
end
|
||||
-- `bs=1048576` is equivalent to `bs=1M` for GNU dd or `bs=1m` for BSD dd
|
||||
-- Both `bs=1M` and `bs=1m` are non-POSIX
|
||||
local cmd = string.format("dd if=%s of=%s bs=1048576", vim.fn.shellescape(tmpfile), vim.fn.shellescape(filepath))
|
||||
-- no need to check error as this fails the entire function
|
||||
vim.api.nvim_exec(string.format("write! %s", tmpfile), true)
|
||||
if M.sudo_exec(cmd) then
|
||||
-- refreshes the buffer and prints the "written" message
|
||||
vim.cmd.checktime()
|
||||
-- exit command mode
|
||||
vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes("<Esc>", true, false, true), "n", true)
|
||||
end
|
||||
vim.fn.delete(tmpfile)
|
||||
end
|
||||
|
||||
return M
|
||||
|
||||
Reference in New Issue
Block a user