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