feat: add script for neovim
This commit is contained in:
parent
67266797d9
commit
afda305c27
22
vim.lua
Normal file
22
vim.lua
Normal file
|
@ -0,0 +1,22 @@
|
|||
-- A script for vim to map the word under the cursor with portingtools by pressing m, and all
|
||||
-- mapped expressions in the file with M
|
||||
local function map(name)
|
||||
return vim.fn.systemlist("portingtools map", name)[1]
|
||||
end
|
||||
|
||||
vim.keymap.set("n", "m", function()
|
||||
local word = vim.fn.expand "<cword>"
|
||||
local mapped = map(word)
|
||||
local replaced = vim.fn.getline("."):gsub(word, mapped);
|
||||
vim.fn.setline(".", replaced)
|
||||
end)
|
||||
|
||||
vim.keymap.set("n", "M", function()
|
||||
local nlines = 99
|
||||
for i = 1, nlines do
|
||||
print(i .. "/" .. nlines)
|
||||
local line = vim.fn.getline(i)
|
||||
local mapped = line:gsub("field_%d+_[%a_]+", map):gsub("func_%d+_[%a_]+", map);
|
||||
vim.fn.setline(i, mapped)
|
||||
end
|
||||
end)
|
Loading…
Reference in a new issue