✨ feat(qalc): add special keymappings for qalc windows
This commit is contained in:
+38
-1
@@ -74,7 +74,44 @@ autocmd({ "BufEnter" }, {
|
|||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
-- Set up autocommands and highlight settings
|
-- ━━━━━━━━━━━━━━━━━━━━━━━ Set up Qalc keymappings ━━━━━━━━━━━━━━━━━━━━━━━
|
||||||
|
-- Create a group for filetype-specific mappings
|
||||||
|
vim.api.nvim_create_augroup("QalcFileTypeMappings", { clear = true })
|
||||||
|
|
||||||
|
-- Create an autocommand for the qalc filetype
|
||||||
|
vim.api.nvim_create_autocmd("FileType", {
|
||||||
|
pattern = "qalc",
|
||||||
|
group = "QalcFileTypeMappings",
|
||||||
|
callback = function()
|
||||||
|
-- Set the key mapping: 'y' to run the :QalcYank command in normal mode
|
||||||
|
vim.keymap.set( -- Yank Result
|
||||||
|
"n",
|
||||||
|
"y",
|
||||||
|
":QalcYank +<CR>",
|
||||||
|
{ noremap = true, silent = true }
|
||||||
|
)
|
||||||
|
-- Set the key mapping: 'q' to run the :QalcClose command in normal mode
|
||||||
|
vim.keymap.set( -- Close Qalc
|
||||||
|
"n",
|
||||||
|
"q",
|
||||||
|
":QalcClose<CR>",
|
||||||
|
{ noremap = true, silent = true }
|
||||||
|
)
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
||||||
|
-- Define a custom command to close the Qalc buffer
|
||||||
|
vim.api.nvim_create_user_command("QalcClose", function()
|
||||||
|
local buf_name = vim.api.nvim_buf_get_name(0)
|
||||||
|
if buf_name ~= "" then
|
||||||
|
vim.cmd("bd!")
|
||||||
|
else
|
||||||
|
-- If the buffer has no name, just remove it without invoking :bd!
|
||||||
|
vim.api.nvim_buf_delete(0, { force = true })
|
||||||
|
end
|
||||||
|
end, { bang = true })
|
||||||
|
|
||||||
|
-- ━━━━━━━━━━━━━━━━━━━━━━━━━━ Set up highlights ━━━━━━━━━━━━━━━━━━━━━━━━━━
|
||||||
local load_highlight = require("utils.highlight")
|
local load_highlight = require("utils.highlight")
|
||||||
load_highlight.setup_autocommands()
|
load_highlight.setup_autocommands()
|
||||||
load_highlight.setup_dashboard_highlight()
|
load_highlight.setup_dashboard_highlight()
|
||||||
|
|||||||
Reference in New Issue
Block a user