Merge pull request #19 from saccarosium/main

remotes/origin/HEAD
pseudometa 2023-06-25 01:29:33 +02:00 committed by GitHub
commit bae71cc310
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 11 deletions

10
.editorconfig Normal file
View File

@ -0,0 +1,10 @@
root = true
[*]
indent_style = tab
indent_size = 3
trim_trailing_whitespace = true
insert_final_newline = true
[*.md]
trim_trailing_whitespace = false

View File

@ -6,13 +6,13 @@ local fn = vim.fn
local cmd = vim.cmd local cmd = vim.cmd
local function bwipeout(bufnr) local function bwipeout(bufnr)
local bufnr_int = bufnr and vim.fn.bufnr(bufnr) or vim.fn.bufnr('%') local bufnr_int = bufnr and vim.fn.bufnr(bufnr) or vim.fn.bufnr('%')
if pcall(require, 'bufdelete') then if pcall(require, 'bufdelete') then
require'bufdelete'.bufwipeout(bufnr_int) require 'bufdelete'.bufwipeout(bufnr_int)
else else
vim.cmd.bwipeout(bufnr_int) vim.cmd.bwipeout(bufnr_int)
end end
end end
local function leaveVisualMode() local function leaveVisualMode()
@ -68,15 +68,15 @@ local function fileOp(op)
if not newName then return end -- input has been cancelled if not newName then return end -- input has been cancelled
local invalidName = newName:find("^%s+$") local invalidName = newName:find("^%s+$")
or newName:find("[\\:]") or newName:find("[\\:]")
or newName:find("/$") or newName:find("/$")
or (newName:find("^/") and not op == "move-rename") or (newName:find("^/") and not op == "move-rename")
local sameName = newName == oldName local sameName = newName == oldName
local emptyInput = newName == "" local emptyInput = newName == ""
if invalidName or sameName or (emptyInput and op ~= "new") then if invalidName or sameName or (emptyInput and op ~= "new") then
if op == "newFromSel" then if op == "newFromSel" then
cmd.undo() -- undo deletion cmd.undo() -- undo deletion
fn.setreg("z", prevReg) -- restore register content fn.setreg("z", prevReg) -- restore register content
end end
if invalidName or emptyInput then if invalidName or emptyInput then
@ -124,7 +124,7 @@ local function fileOp(op)
elseif op == "new" or op == "newFromSel" then elseif op == "new" or op == "newFromSel" then
cmd.edit(newFilePath) cmd.edit(newFilePath)
if op == "newFromSel" then if op == "newFromSel" then
cmd("put z") -- cmd.put("z") does not work here :/ cmd("put z") -- cmd.put("z") does not work here :/
fn.setreg("z", prevReg) -- restore register content fn.setreg("z", prevReg) -- restore register content
end end
cmd.write(newFilePath) cmd.write(newFilePath)