configs/nvim/lua/config/keymaps.lua
Kacper Marzecki c1ca16583b init
link tmux

td-cli bindings & script

disable c-j c-k bindings - interference with fzf

zsh adjustmets + tmux-td finally not closing on ESC! :)

add diffview & custom Harpoon list (with line in file)
2025-03-18 19:22:27 +01:00

135 lines
6.7 KiB
Lua
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

-- Keymaps are automatically loaded on the VeryLazy event
-- Default keymaps that are always set: https://github.com/LazyVim/LazyVim/blob/main/lua/lazyvim/config/keymaps.lua
-- Add any additional keymaps here
--
--
-- KEYMAPS SPIDER
vim.keymap.set({ "n", "o", "x" }, "w", "<cmd>lua require('spider').motion('w')<CR>", { desc = "Spider-w" })
vim.keymap.set({ "n", "o", "x" }, "e", "<cmd>lua require('spider').motion('e')<CR>", { desc = "Spider-e" })
vim.keymap.set({ "n", "o", "x" }, "b", "<cmd>lua require('spider').motion('b')<CR>", { desc = "Spider-b" })
vim.keymap.set({ "n", "o", "x" }, "C-D", "<PageDown>", { desc = "page down" })
-- :SnipRun lua requiresniprun.run() <Plug>SnipRun
-- (normal node) lua requiresniprun.run(n) <Plug>SnipRunOperator
-- :<,>SnipRun (visual mode) lua requiresniprun.run(v) <Plug>SnipRun
-- :SnipInfo lua requiresniprun.info() <Plug>SnipInfo
-- :SnipReset lua requiresniprun.reset() <Plug>SnipReset
-- :SnipReplMemoryClean lua requiresniprun.clear_repl() <Plug>SnipReplMemoryClean
-- :SnipClose lua requiresniprun.display.close_all() <Plug>SnipClose
-- :SnipLive lua requiresniprun.live_mode.toggle() <Plug>SnipLive
-- vim.keymap.set({ "n", "x" }, "<leader>r", "<cmd>SnipRun<CR>", { desc = "SnipRun" })
-- vim.keymap.set({ "v" }, "<leader>r", "<cmd>'<,'>SnipRun<CR>", { desc = "SnipRun v" })
vim.api.nvim_set_keymap("v", "<leader>r", "<Plug>SnipRun", { silent = true })
vim.api.nvim_set_keymap("n", "<leader>r", "<Plug>SnipRun", { silent = true })
vim.api.nvim_set_keymap("n", "<leader>f", "<Plug>SnipRunOperator", { silent = true })
-- AI
-- vim.keymap.set({ "n", "o", "x" }, "<leader>ac", "<cmd>GpChatToggle split<CR>", { desc = "toggle GP chat" })
-- vim.keymap.set({ "n", "o", "x" }, "<leader>aa", "<cmd>GpAppend<CR>", { desc = "Add with Copilot" })
-- vim.keymap.set("n", "<leader>ap", ":GpPrepend<CR>", { noremap = true, silent = true, desc = "Prepend with copilot" })
-- vim.keymap.set({ "v" }, "<leader>ar", "<cmd>'<,'>GpRewrite<CR>", { desc = "replace with Copilot" })
local bm = require("bookmarks")
local map = vim.keymap.set
map("n", "<leader>mm", bm.bookmark_toggle, { desc = "Toggle bookmark" })
map("n", "<leader>mi", bm.bookmark_ann, { desc = "Edit annotation" })
map("n", "<leader>mc", bm.bookmark_clean, { desc = "Clean marks" })
map("n", "<leader>mn", bm.bookmark_next, { desc = "Next mark" })
map("n", "<leader>mp", bm.bookmark_prev, { desc = "Prev mark" })
map("n", "<leader>ml", "<cmd>Telescope bookmarks list<CR>", { desc = "List marks" })
map("n", "<leader>mx", bm.bookmark_clear_all, { desc = "Clear all bookmarks" })
map("n", "<leader>srf", function()
local file_path = vim.api.nvim_buf_get_name(0)
print(file_path)
require("grug-far").open({
transient = true,
prefills = {
paths = file_path,
},
})
end, { desc = "Search n replace in file" })
map("n", "<leader>ff", "<cmd>FzfLua<cr>", { desc = "FZF commands" })
-- map("n", "<leader>mm", bm.bookmark_toggle) -- add or remove bookmark at current line
-- map("n", "<leader>mi", bm.bookmark_ann) -- add or edit mark annotation at current line
-- map("n", "<leader>mc", bm.bookmark_clean) -- clean all marks in local buffer
-- map("n", "<leader>mn", bm.bookmark_next) -- jump to next mark in local buffer
-- map("n", "<leader>mp", bm.bookmark_prev) -- jump to previous mark in local buffer
-- map("n", "<leader>ml", "<cmd>Telescope bookmarks list<CR>") -- show marked file list in quickfix window
-- map("n", "<leader>mx", bm.bookmark_clear_all) -- removes all bookmarks
-- -- floating terminal
-- map("n", "<leader>fT", function() Snacks.terminal() end, { desc = "Terminal (cwd)" })
-- map("n", "<leader>ft", function() Snacks.terminal(nil, { cwd = LazyVim.root() }) end, { desc = "Terminal (Root Dir)" })
-- map("n", "<vh-/>", function() Snacks.terminal(nil, { cwd = LazyVim.root() }) end, { desc = "Terminal (Root Dir)" })
-- map("n", "<c-_>", function() Snacks.terminal(nil, { cwd = LazyVim.root() }) end, { desc = "which_key_ignore" })
--
-- -- Terminal Mappings
-- map("t", "<C-/>", "<cmd>close<cr>", { desc = "Hide Terminal" })
-- map("t", "<c-_>", "<cmd>close<cr>", { desc = "which_key_ignore" })
map("n", "<leader>qw", "<cmd>wq<cr>", { desc = "save & quit" })
-- local td_cli = require("toggleterm.terminal").Terminal:new({
-- cmd = "node /home/omnissiah/git/td/dist/cli.js",
-- direction = "float",
-- close_on_exit = false,
-- hidden = true,
-- on_open = function(term)
-- vim.api.nvim_buf_set_keymap(term.bufnr, "n", "q", "<cmd>close<CR>", { noremap = true, silent = true })
-- vim.api.nvim_buf_set_keymap(term.bufnr, "t", "<C-q>", "<C-\\><C-n>:close<CR>", { noremap = true, silent = true })
-- vim.api.nvim_buf_set_keymap(term.bufnr, "t", "<C-q>", "<cmd>close<CR>", { noremap = true, silent = true })
-- end,
-- })
-- vim.keymap.set("t", "\\", function()
-- td_cli:toggle()
-- end, { desc = "Toggle TD CLI floating terminal" })
vim.keymap.set("n", "\\", function()
vim.cmd("!tmux-td")
end, { desc = "Toggle TD CLI floating terminal and run tmux-td" })
-- vim.keymap.set("t", "<C-\\>", "<cmd>ToggleTerm<cr>", { noremap = true, silent = true })
--
--
local harpoon = require("harpoon")
vim.keymap.set("n", "<leader>H", function()
harpoon:list("file_with_line"):add()
end, { desc = "Harpoon add" })
vim.keymap.set("n", "<leader>h", function()
harpoon.ui:toggle_quick_menu(harpoon:list("file_with_line"))
end, { desc = "Harpoon list" })
-- DIFFVIEW
local function diffOpenWithInput()
local user_input = vim.fn.input("Revision to Open: ")
vim.cmd("DiffviewOpen " .. user_input)
end
local function diffOpenFileHistory()
local user_input = vim.fn.input("Files to Open: ")
vim.cmd("DiffviewFileHistory" .. user_input)
end
local function command(cmd)
return function()
vim.cmd(cmd)
end
end
-- Key maps
require("which-key").add({
-- { "<leader>g", group = "Git" },
{ "<leader>gvf", diffOpenFileHistory, desc = "Open DiffView on Files" },
{ "<leader>gt", command("DiffviewToggleFiles"), desc = "Open DiffView on Files" },
{ "<leader>gvo", diffOpenWithInput, desc = "Open DiffView" },
})
-- diffOpenFileHistory with . opens commit wise history of entire codebase.
-- diffOpenFileHistory with % opens commit wise history of current file.
-- diffOpenFileHistory with <any file path> opens commit wise history of that file.
-- diffOpenWithInput with HEAD opens diff of latest commit.
-- diffOpenWithInput with HEAD~3 opens diff of last 3 commits.
-- diffOpenWithInput with master..HEAD opens changes of your feature branch.
--
--
vim.api.nvim_set_keymap("c", "<C-j>", "<Down>", { noremap = true, silent = true })
vim.api.nvim_set_keymap("c", "<C-k>", "<Up>", { noremap = true, silent = true })
print("dupsko")
-- exec lua
map("v", "<leader>ce", "<cmd>'<,'>lua<cr>", { desc = "exec Lua" })