Regenerate nvim config
This commit is contained in:
54
config/neovim/store/lazy-plugins/yanky.nvim/spec/init.lua
Normal file
54
config/neovim/store/lazy-plugins/yanky.nvim/spec/init.lua
Normal file
@ -0,0 +1,54 @@
|
||||
local M = {}
|
||||
|
||||
function M.root(root)
|
||||
local f = debug.getinfo(1, "S").source:sub(2)
|
||||
return vim.fn.fnamemodify(f, ":p:h:h") .. "/" .. (root or "")
|
||||
end
|
||||
|
||||
---@param plugin string
|
||||
function M.load(plugin)
|
||||
local name = plugin:match(".*/(.*)")
|
||||
local package_root = M.root(".spec/site/pack/deps/start/")
|
||||
if not vim.loop.fs_stat(package_root .. name) then
|
||||
print("Installing " .. plugin)
|
||||
vim.fn.mkdir(package_root, "p")
|
||||
vim.fn.system({
|
||||
"git",
|
||||
"clone",
|
||||
"--depth=1",
|
||||
"https://github.com/" .. plugin .. ".git",
|
||||
package_root .. "/" .. name,
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
function M.setup()
|
||||
vim.cmd([[set runtimepath=$VIMRUNTIME]])
|
||||
vim.opt.runtimepath:append(M.root())
|
||||
vim.opt.packpath = { M.root(".spec/site") }
|
||||
|
||||
M.load("nvim-lua/plenary.nvim")
|
||||
|
||||
vim.api.nvim_set_option("clipboard", "")
|
||||
|
||||
require("yanky").setup({ ring = { storage = "memory" } })
|
||||
require("yanky").register_plugs()
|
||||
|
||||
vim.keymap.set("n", "p", "<Plug>(YankyPutAfter)", {})
|
||||
vim.keymap.set("n", "P", "<Plug>(YankyPutBefore)", {})
|
||||
vim.keymap.set("x", "p", "<Plug>(YankyPutAfter)", {})
|
||||
vim.keymap.set("x", "P", "<Plug>(YankyPutBefore)", {})
|
||||
|
||||
vim.keymap.set("n", "gp", "<Plug>(YankyGPutAfter)", {})
|
||||
vim.keymap.set("n", "gP", "<Plug>(YankyGPutBefore)", {})
|
||||
vim.keymap.set("x", "gp", "<Plug>(YankyGPutAfter)", {})
|
||||
vim.keymap.set("x", "gP", "<Plug>(YankyGPutBefore)", {})
|
||||
|
||||
vim.keymap.set("n", ",p", "<Plug>(YankyCycleForward)", {})
|
||||
vim.keymap.set("n", ",P", "<Plug>(YankyCycleBackward)", {})
|
||||
|
||||
vim.keymap.set("n", "y", "<Plug>(YankyYank)", {})
|
||||
vim.keymap.set("x", "y", "<Plug>(YankyYank)", {})
|
||||
end
|
||||
|
||||
M.setup()
|
||||
@ -0,0 +1,77 @@
|
||||
local yanky = require("yanky")
|
||||
|
||||
local function get_buf_lines()
|
||||
local result = vim.api.nvim_buf_get_lines(0, 0, vim.api.nvim_buf_line_count(0), false)
|
||||
return result
|
||||
end
|
||||
|
||||
local function execute_keys(feedkeys)
|
||||
local keys = vim.api.nvim_replace_termcodes(feedkeys, true, false, true)
|
||||
vim.api.nvim_feedkeys(keys, "x!", false)
|
||||
end
|
||||
|
||||
local function setup()
|
||||
yanky.setup({ ring = { storage = "memory" } })
|
||||
|
||||
local buf = vim.api.nvim_create_buf(false, true)
|
||||
vim.api.nvim_command("buffer " .. buf)
|
||||
|
||||
vim.api.nvim_buf_set_lines(0, 0, -1, true, {
|
||||
"void test() {",
|
||||
" int a = 1;",
|
||||
" int b = 2;",
|
||||
" for (int i = 0; i < 10; ++i) {",
|
||||
" cout << a;",
|
||||
" cout << b;",
|
||||
" }",
|
||||
"}",
|
||||
})
|
||||
|
||||
vim.cmd("set ft=c")
|
||||
end
|
||||
|
||||
describe("Special Put", function()
|
||||
before_each(setup)
|
||||
|
||||
it("should PutAfterFilter", function()
|
||||
vim.cmd("5")
|
||||
execute_keys("2yy")
|
||||
vim.cmd("3")
|
||||
vim.cmd('execute "normal \\<Plug>(YankyPutAfterFilter)"')
|
||||
assert.are.same({
|
||||
"void test() {",
|
||||
" int a = 1;",
|
||||
" int b = 2;",
|
||||
" cout << a;",
|
||||
" cout << b;",
|
||||
" for (int i = 0; i < 10; ++i) {",
|
||||
" cout << a;",
|
||||
" cout << b;",
|
||||
" }",
|
||||
"}",
|
||||
}, get_buf_lines())
|
||||
|
||||
assert.are.same({ 4, 4 }, vim.api.nvim_win_get_cursor(0))
|
||||
end)
|
||||
|
||||
it("should GPutBeforeFilter", function()
|
||||
vim.cmd("5")
|
||||
execute_keys("2yy")
|
||||
vim.cmd("4")
|
||||
vim.cmd('execute "normal \\<Plug>(YankyGPutBeforeFilter)"')
|
||||
assert.are.same({
|
||||
"void test() {",
|
||||
" int a = 1;",
|
||||
" int b = 2;",
|
||||
" cout << a;",
|
||||
" cout << b;",
|
||||
" for (int i = 0; i < 10; ++i) {",
|
||||
" cout << a;",
|
||||
" cout << b;",
|
||||
" }",
|
||||
"}",
|
||||
}, get_buf_lines())
|
||||
|
||||
assert.are.same({ 6, 0 }, vim.api.nvim_win_get_cursor(0))
|
||||
end)
|
||||
end)
|
||||
@ -0,0 +1,29 @@
|
||||
local yanky = require("yanky")
|
||||
-- local system_clipboard = require("yanky.system_clipboard")
|
||||
-- local utils = require("yanky.utils")
|
||||
|
||||
describe("Sync clipbard", function()
|
||||
before_each(function()
|
||||
yanky.setup({
|
||||
ring = {
|
||||
storage = "memory",
|
||||
},
|
||||
system_clipboard = {
|
||||
sync_with_ring = true,
|
||||
},
|
||||
})
|
||||
end)
|
||||
|
||||
it("should add system clipboard to history on focus", function()
|
||||
-- vim.fn.setreg("*", "default_value", "V")
|
||||
-- system_clipboard.on_focus_lost()
|
||||
--
|
||||
-- vim.fn.setreg("*", "new_value", "v")
|
||||
-- system_clipboard.on_focus_gained()
|
||||
--
|
||||
-- assert.are.same({
|
||||
-- regcontents = "new_value",
|
||||
-- regtype = "v",
|
||||
-- }, yanky.history.first())
|
||||
end)
|
||||
end)
|
||||
@ -0,0 +1,116 @@
|
||||
local yanky = require("yanky")
|
||||
|
||||
local function execute_keys(feedkeys)
|
||||
local keys = vim.api.nvim_replace_termcodes(feedkeys, true, false, true)
|
||||
vim.api.nvim_feedkeys(keys, "x!", false)
|
||||
end
|
||||
|
||||
local function get_buf_lines()
|
||||
local result = vim.api.nvim_buf_get_lines(0, 0, vim.api.nvim_buf_line_count(0), false)
|
||||
return result
|
||||
end
|
||||
|
||||
local function setup()
|
||||
yanky.setup({ ring = { storage = "memory" } })
|
||||
|
||||
local buf = vim.api.nvim_create_buf(false, true)
|
||||
vim.api.nvim_command("buffer " .. buf)
|
||||
|
||||
vim.api.nvim_buf_set_lines(0, 0, -1, true, { "Lorem", "ipsum", "dolor", "sit", "amet" })
|
||||
execute_keys("i<BS><C-G>u<esc>") -- Breaks undo sequence, don't know why I should do that
|
||||
end
|
||||
|
||||
describe("Cycle", function()
|
||||
before_each(setup)
|
||||
|
||||
it("should work in charwise mode", function()
|
||||
execute_keys("yw")
|
||||
execute_keys("j")
|
||||
execute_keys("yw")
|
||||
execute_keys("ll")
|
||||
|
||||
execute_keys("p")
|
||||
assert.are.same({ "Lorem", "ipsipsumum", "dolor", "sit", "amet" }, get_buf_lines())
|
||||
|
||||
execute_keys(",p")
|
||||
assert.are.same({ "Lorem", "ipsLoremum", "dolor", "sit", "amet" }, get_buf_lines())
|
||||
|
||||
execute_keys(",P")
|
||||
assert.are.same({ "Lorem", "ipsipsumum", "dolor", "sit", "amet" }, get_buf_lines())
|
||||
|
||||
execute_keys(",P")
|
||||
assert.are.same({ "Lorem", "ipsipsumum", "dolor", "sit", "amet" }, get_buf_lines())
|
||||
end)
|
||||
|
||||
it("should work in linewise mode", function()
|
||||
execute_keys("yy")
|
||||
execute_keys("j")
|
||||
execute_keys("yw")
|
||||
execute_keys("j")
|
||||
execute_keys("yy")
|
||||
|
||||
execute_keys("p")
|
||||
assert.are.same({ "Lorem", "ipsum", "dolor", "dolor", "sit", "amet" }, get_buf_lines())
|
||||
|
||||
execute_keys(",p")
|
||||
assert.are.same({ "Lorem", "ipsum", "dipsumolor", "sit", "amet" }, get_buf_lines())
|
||||
|
||||
execute_keys(",p")
|
||||
assert.are.same({ "Lorem", "ipsum", "dolor", "Lorem", "sit", "amet" }, get_buf_lines())
|
||||
end)
|
||||
|
||||
it("should work in visual mode", function()
|
||||
execute_keys("yy")
|
||||
execute_keys("j")
|
||||
execute_keys("yw")
|
||||
execute_keys("j")
|
||||
execute_keys("yy")
|
||||
|
||||
execute_keys("v3l")
|
||||
|
||||
execute_keys("p")
|
||||
assert.are.same({ "Lorem", "ipsum", "", "dolor", "r", "sit", "amet" }, get_buf_lines())
|
||||
|
||||
-- Should not do that but cant manage to make it works now
|
||||
execute_keys(",p")
|
||||
assert.are.same({ "Lorem", "ipsum", "", "dolor", "r", "sit", "amet" }, get_buf_lines())
|
||||
|
||||
execute_keys(",p")
|
||||
assert.are.same({ "Lorem", "ipsum", "ipsumr", "sit", "amet" }, get_buf_lines())
|
||||
|
||||
execute_keys(",p")
|
||||
assert.are.same({ "Lorem", "ipsum", "", "Lorem", "r", "sit", "amet" }, get_buf_lines())
|
||||
|
||||
execute_keys(",P")
|
||||
assert.are.same({ "Lorem", "ipsum", "ipsumr", "sit", "amet" }, get_buf_lines())
|
||||
|
||||
execute_keys(",P")
|
||||
assert.are.same({ "Lorem", "ipsum", "", "dolor", "r", "sit", "amet" }, get_buf_lines())
|
||||
|
||||
execute_keys(",P")
|
||||
assert.are.same({ "Lorem", "ipsum", "dolor", "sit", "amet" }, get_buf_lines())
|
||||
|
||||
execute_keys(",P")
|
||||
assert.are.same({ "Lorem", "ipsum", "dolor", "sit", "amet" }, get_buf_lines())
|
||||
end)
|
||||
|
||||
it("should work in visual-block mode", function()
|
||||
execute_keys("yy")
|
||||
execute_keys("j")
|
||||
execute_keys("yw")
|
||||
execute_keys("j")
|
||||
execute_keys("yy")
|
||||
|
||||
execute_keys("gg<c-v>jl")
|
||||
|
||||
execute_keys("p")
|
||||
assert.are.same({ "rem", "sum", "dolor", "dolor", "sit", "amet" }, get_buf_lines())
|
||||
|
||||
-- Should not do that but cant manage to make it works now
|
||||
execute_keys(",p")
|
||||
assert.are.same({ "rem", "sum", "dolor", "dolor", "sit", "amet" }, get_buf_lines())
|
||||
|
||||
execute_keys(",p")
|
||||
assert.are.same({ "ipsumrem", "ipsumsum", "dolor", "sit", "amet" }, get_buf_lines())
|
||||
end)
|
||||
end)
|
||||
155
config/neovim/store/lazy-plugins/yanky.nvim/spec/yanky_spec.lua
Normal file
155
config/neovim/store/lazy-plugins/yanky.nvim/spec/yanky_spec.lua
Normal file
@ -0,0 +1,155 @@
|
||||
local yanky = require("yanky")
|
||||
|
||||
local function get_buf_lines()
|
||||
local result = vim.api.nvim_buf_get_lines(0, 0, vim.api.nvim_buf_line_count(0), false)
|
||||
return result
|
||||
end
|
||||
|
||||
local function execute_keys(feedkeys)
|
||||
local keys = vim.api.nvim_replace_termcodes(feedkeys, true, false, true)
|
||||
vim.api.nvim_feedkeys(keys, "x!", false)
|
||||
end
|
||||
|
||||
local function setup()
|
||||
yanky.setup({ ring = { storage = "memory" } })
|
||||
|
||||
local buf = vim.api.nvim_create_buf(false, true)
|
||||
vim.api.nvim_command("buffer " .. buf)
|
||||
|
||||
vim.api.nvim_buf_set_lines(0, 0, -1, true, { "Lorem", "ipsum", "dolor", "sit", "amet" })
|
||||
end
|
||||
|
||||
describe("Put in charwise mode", function()
|
||||
before_each(setup)
|
||||
|
||||
it("should paste after word in charwise mode", function()
|
||||
execute_keys("yw")
|
||||
execute_keys("jll")
|
||||
execute_keys("p")
|
||||
|
||||
assert.are.same({ "Lorem", "ipsLoremum", "dolor", "sit", "amet" }, get_buf_lines())
|
||||
end)
|
||||
|
||||
it("should paste before word in charwise mode", function()
|
||||
execute_keys("lyw")
|
||||
execute_keys("jjll")
|
||||
execute_keys("P")
|
||||
|
||||
assert.are.same({ "Lorem", "ipsum", "doloremor", "sit", "amet" }, get_buf_lines())
|
||||
end)
|
||||
|
||||
it("should be repeatable in charwise mode", function()
|
||||
execute_keys("yw")
|
||||
execute_keys("jll")
|
||||
execute_keys("3p")
|
||||
|
||||
assert.are.same({ "Lorem", "ipsLoremLoremLoremum", "dolor", "sit", "amet" }, get_buf_lines())
|
||||
end)
|
||||
|
||||
it("should use specified register in charwise mode", function()
|
||||
vim.fn.setreg("a", "REGISTRED", "c")
|
||||
execute_keys("jll")
|
||||
execute_keys('"ap')
|
||||
|
||||
assert.are.same({ "Lorem", "ipsREGISTREDum", "dolor", "sit", "amet" }, get_buf_lines())
|
||||
end)
|
||||
end)
|
||||
|
||||
describe("Put in linewise mode", function()
|
||||
before_each(setup)
|
||||
|
||||
it("should paste after in linewise mode", function()
|
||||
execute_keys("yy")
|
||||
execute_keys("jll")
|
||||
execute_keys("p")
|
||||
|
||||
assert.are.same({ "Lorem", "ipsum", "Lorem", "dolor", "sit", "amet" }, get_buf_lines())
|
||||
end)
|
||||
|
||||
it("should paste before in linewise mode", function()
|
||||
execute_keys("yy")
|
||||
execute_keys("jll")
|
||||
execute_keys("P")
|
||||
|
||||
assert.are.same({ "Lorem", "Lorem", "ipsum", "dolor", "sit", "amet" }, get_buf_lines())
|
||||
end)
|
||||
|
||||
it("should be repeatable in linewise mode", function()
|
||||
execute_keys("2yy")
|
||||
execute_keys("jll")
|
||||
execute_keys("3p")
|
||||
|
||||
assert.are.same(
|
||||
{ "Lorem", "ipsum", "Lorem", "ipsum", "Lorem", "ipsum", "Lorem", "ipsum", "dolor", "sit", "amet" },
|
||||
get_buf_lines()
|
||||
)
|
||||
end)
|
||||
|
||||
it("should use specified register in linewise mode", function()
|
||||
vim.fn.setreg("b", "REGISTRED", "l")
|
||||
execute_keys("jll")
|
||||
execute_keys('"bp')
|
||||
|
||||
assert.are.same({ "Lorem", "ipsum", "REGISTRED", "dolor", "sit", "amet" }, get_buf_lines())
|
||||
end)
|
||||
end)
|
||||
|
||||
describe("Put in blocwise mode", function()
|
||||
before_each(setup)
|
||||
|
||||
it("should paste after", function()
|
||||
execute_keys("<c-v>jjlly")
|
||||
execute_keys("gg^")
|
||||
execute_keys("jll")
|
||||
execute_keys("p")
|
||||
|
||||
assert.are.same({ "Lorem", "ipsLorum", "dolipsor", "sitdol", "amet" }, get_buf_lines())
|
||||
end)
|
||||
|
||||
it("should paste before", function()
|
||||
execute_keys("<c-v>jjlly")
|
||||
execute_keys("gg^")
|
||||
execute_keys("jll")
|
||||
execute_keys("P")
|
||||
|
||||
assert.are.same({ "Lorem", "ipLorsum", "doipslor", "sidolt", "amet" }, get_buf_lines())
|
||||
end)
|
||||
|
||||
it("should be repeatable", function()
|
||||
execute_keys("<c-v>jjlly")
|
||||
execute_keys("gg^")
|
||||
execute_keys("jll")
|
||||
execute_keys("3p")
|
||||
|
||||
assert.are.same({ "Lorem", "ipsLorLorLorum", "dolipsipsipsor", "sitdoldoldol", "amet" }, get_buf_lines())
|
||||
end)
|
||||
end)
|
||||
|
||||
describe("Put in visual mode", function()
|
||||
before_each(setup)
|
||||
|
||||
it("should paste after", function()
|
||||
execute_keys("y3l")
|
||||
execute_keys("jvll")
|
||||
execute_keys("p")
|
||||
|
||||
assert.are.same({ "Lorem", "Lorum", "dolor", "sit", "amet" }, get_buf_lines())
|
||||
end)
|
||||
|
||||
it("should paste in linewise visual selection", function()
|
||||
execute_keys("y3l")
|
||||
execute_keys("jV")
|
||||
execute_keys("p")
|
||||
|
||||
assert.are.same({ "Lorem", "Lor", "dolor", "sit", "amet" }, get_buf_lines())
|
||||
end)
|
||||
|
||||
it("should be repeatable", function()
|
||||
execute_keys("y3l")
|
||||
execute_keys("j")
|
||||
execute_keys("vll")
|
||||
execute_keys("3p")
|
||||
|
||||
assert.are.same({ "Lorem", "LorLorLorum", "dolor", "sit", "amet" }, get_buf_lines())
|
||||
end)
|
||||
end)
|
||||
Reference in New Issue
Block a user