44 lines
1.1 KiB
Lua
44 lines
1.1 KiB
Lua
-- Keymap function
|
|
function Keymap(mode, key, binding, opts)
|
|
local options = { noremap = true, silent = true }
|
|
if opts then
|
|
options = vim.tbl_extend("force", options, opts)
|
|
end
|
|
vim.keymap.set(mode, key, binding, options)
|
|
end
|
|
|
|
Keymap("n", "q:", ":") -- remove nonsense command
|
|
Keymap("n", "<leader>bd", function() -- delete buffer
|
|
vim.cmd("bd")
|
|
vim.cmd("echo 'Buffer deleted'")
|
|
end)
|
|
|
|
for _, bind in ipairs({ "i", "a", "A" }) do
|
|
-- Pass { expr = true } as the fourth argument
|
|
Keymap("n", bind, function()
|
|
if vim.fn.getline("."):match("^%s*$") then
|
|
return [["_cc]]
|
|
else
|
|
return bind
|
|
end
|
|
end, { expr = true })
|
|
end
|
|
|
|
Keymap("i", "<C-BS>", "<C-W>") -- C-Backscpace for whole words
|
|
|
|
Keymap("n", "<leader>d", "<cmd>lua vim.diagnostic.open_float()<CR>") -- Diagnostics for Linter
|
|
|
|
-- Flash keymaps
|
|
Keymap("n", "ss", function()
|
|
require("flash").jump()
|
|
end)
|
|
Keymap("n", "S", function()
|
|
require("flash").treesitter()
|
|
end)
|
|
Keymap("n", "<leader>r", function()
|
|
require("flash").remote()
|
|
end)
|
|
Keymap("n", "<leader>R", function()
|
|
require("flash").treesitter_search()
|
|
end)
|