Build/editor stuff and fix mod compilation
This commit is contained in:
33
lua/snippets.lua
Normal file
33
lua/snippets.lua
Normal file
@@ -0,0 +1,33 @@
|
||||
-- Header guard snippet
|
||||
vim.keymap.set('n', ',hg', function()
|
||||
local function uuid()
|
||||
local template = 'xxxxxxxx_xxxx_4xxx_yxxx_xxxxxxxxxxxx'
|
||||
return string.gsub(template, '[xy]', function(c)
|
||||
local v = (c == 'x') and math.random(0, 0xf) or math.random(8, 0xb)
|
||||
return string.format('%X', v)
|
||||
end)
|
||||
end
|
||||
local v = '_' .. uuid()
|
||||
vim.api.nvim_put({ '#ifndef ' .. v,
|
||||
"#define " .. v,
|
||||
"",
|
||||
"namespace ng {",
|
||||
"",
|
||||
"}",
|
||||
"",
|
||||
'#endif // ' .. v,
|
||||
}, 'c', false, true)
|
||||
vim.cmd("normal! 3k")
|
||||
end, { desc = 'Inser header boiler plate' })
|
||||
|
||||
vim.keymap.set('n', ',xx', function()
|
||||
local cmd = vim.api.nvim_replace_termcodes(":s/x/y/g<Left><Left>", true, true, true)
|
||||
vim.api.nvim_feedkeys(cmd, "n", false)
|
||||
end)
|
||||
vim.keymap.set('n', ',xty', function()
|
||||
vim.api.nvim_feedkeys("yyp", "n", false)
|
||||
local cmd = vim.api.nvim_replace_termcodes(":s/x/y/g<CR>", true, true, true)
|
||||
vim.api.nvim_feedkeys(cmd, "n", false)
|
||||
end)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user