dotfiles/home/private_dot_config/lvim/lua/keybindings.lua

65 lines
2.3 KiB
Lua
Raw Normal View History

2021-12-08 09:38:24 -06:00
-- Map a key with optional options
2022-02-03 16:58:34 -06:00
local function map(mode, keys, action, options)
2021-12-08 09:38:24 -06:00
if options == nil then
2022-06-20 11:22:38 -05:00
options = { noremap = true }
2021-12-08 09:38:24 -06:00
end
2022-06-20 11:22:38 -05:00
vim.api.nvim_set_keymap(mode, keys, action, options)
2021-12-08 09:38:24 -06:00
end
2022-02-03 16:58:34 -06:00
vim.g.mapleader = " "
2022-06-20 11:22:38 -05:00
map('i', 'jk', '<Esc>', { noremap = true })
map('v', 'jk', '<Esc>', { noremap = true })
map('n', "H", "^", { noremap = true })
map('n', "L", "$", { noremap = true })
map('n', 'j', "v:count ? 'j' : 'gj'", { expr = true, noremap = true })
map('n', 'k', "v:count ? 'k' : 'gk'", { expr = true, noremap = true })
2022-07-21 17:41:26 -05:00
map('n', "<C-j>","}",{noremap = true})
map('n', "<C-k>","{",{noremap = true})
2022-06-04 11:50:57 -05:00
2022-02-03 16:58:34 -06:00
-- zettelkasten keybindings
-- Create a new note after asking for its title.
-- map("n", "<leader>zn", "<Cmd>ZkNew { title = vim.fn.input('Title: ') }<CR>")
-- -- Open notes.
-- map("n", "<leader>zo", "<Cmd>ZkNotes { sort = { 'modified' } }<CR>")
-- -- Open notes associated with the selected tags.
-- map("n", "<leader>zt", "<Cmd>ZkTags<CR>")
-- -- Search for the notes matching a given query.
-- map("n", "<leader>zf", "<Cmd>ZkNotes { sort = { 'modified' }, match = vim.fn.input('Search: ') }<CR>")
-- -- Search for the notes matching the current visual selection.
2022-06-20 11:22:38 -05:00
2022-02-03 16:58:34 -06:00
map("v", "<leader>zf", ":'<,'>ZkMatch<CR>")
2022-02-08 13:42:16 -06:00
local mappings = lvim.builtin.which_key.mappings
mappings["z"] = {
2022-06-20 11:22:38 -05:00
name = "zk",
n = { "<Cmd>ZkNew { title = vim.fn.input('Title: ') }<CR>", "New" },
o = { "<Cmd>ZkNotes { sort = { 'modified' } }<CR>", "Open" },
t = { "<Cmd>ZkTags<CR>", "Tags" },
f = { "<Cmd>ZkNotes { sort = { 'modified' }, match = vim.fn.input('Search: ') }<CR>", "Fuzzy Search" },
}
mappings["s"]["p"] = { "<cmd>Telescope projects<CR>", "Recent Projects" }
mappings["s"]["w"] = { "<cmd>Telescope live_grep<CR>", "Find Word" }
-- Change Telescope navigation to use j and k for navigation and n and p for history in both input and normal mode.
-- we use protected-mode (pcall) just in case the plugin wasn't loaded yet.
local _, actions = pcall(require, "telescope.actions")
lvim.builtin.telescope.defaults.mappings = {
-- for input mode
i = {
["<C-j>"] = actions.move_selection_next,
["<C-k>"] = actions.move_selection_previous,
["<C-n>"] = actions.cycle_history_next,
["<C-p>"] = actions.cycle_history_prev,
},
-- for normal mode
n = {
["<C-j>"] = actions.move_selection_next,
["<C-k>"] = actions.move_selection_previous,
},
2022-02-03 16:58:34 -06:00
}