mirror of
https://github.com/boxpositron/absolute-vim.git
synced 2026-02-28 11:40:36 +00:00
style(remap.lua): improve code readability by adding comments and whitespace
feat(remap.lua): add logic to only source specific file extensions to enhance security and prevent unintended sourcing of files
This commit is contained in:
@@ -79,14 +79,24 @@ vim.keymap.set("n", "<leader>f", vim.lsp.buf.format, opts)
|
||||
opts.desc = "Regex Replace"
|
||||
vim.keymap.set("n", "<leader>sr", [[:%s/\<<C-r><C-w>\>/<C-r><C-w>/gI<Left><Left><Left>]], opts)
|
||||
|
||||
|
||||
opts.desc = "Replace selected text"
|
||||
vim.keymap.set("v", "<leader>ss", [[:s/\<<C-r><C-w>\>/<C-r><C-w>/gI<Left><Left><Left>]], opts)
|
||||
|
||||
-- Source File Keymap
|
||||
opts.desc = "Source File"
|
||||
vim.keymap.set("n", "<leader><leader>", function()
|
||||
vim.cmd("so")
|
||||
-- Only source these file extensions
|
||||
local allowed_extensions = [[".vim", ".lua", ".vimrc", ".gvimrc", ".nvim", ".nvimrc", ".sh"]]
|
||||
|
||||
-- Get the file extension
|
||||
local file_extension = vim.fn.expand("%:e")
|
||||
|
||||
-- Check if the file extension is allowed
|
||||
if string.find(allowed_extensions, file_extension) then
|
||||
vim.cmd("so %")
|
||||
else
|
||||
print("Filetype not supported")
|
||||
end
|
||||
end, opts)
|
||||
|
||||
-- Manage VIM Maximizer
|
||||
|
||||
Reference in New Issue
Block a user