-- Map a key with optional options local function map(mode, keys, action, options) if options == nil then options = { noremap = true } end vim.api.nvim_set_keymap(mode, keys, action, options) end vim.g.mapleader = " " map('i', 'jk', '', { noremap = true }) map('v', 'jk', '', { 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 }) map('n', "","}",{noremap = true}) map('n', "","{",{noremap = true}) -- zettelkasten keybindings -- Create a new note after asking for its title. -- map("n", "zn", "ZkNew { title = vim.fn.input('Title: ') }") -- -- Open notes. -- map("n", "zo", "ZkNotes { sort = { 'modified' } }") -- -- Open notes associated with the selected tags. -- map("n", "zt", "ZkTags") -- -- Search for the notes matching a given query. -- map("n", "zf", "ZkNotes { sort = { 'modified' }, match = vim.fn.input('Search: ') }") -- -- Search for the notes matching the current visual selection. map("v", "zf", ":'<,'>ZkMatch") local mappings = lvim.builtin.which_key.mappings mappings["z"] = { name = "zk", n = { "ZkNew { title = vim.fn.input('Title: ') }", "New" }, o = { "ZkNotes { sort = { 'modified' } }", "Open" }, t = { "ZkTags", "Tags" }, f = { "ZkNotes { sort = { 'modified' }, match = vim.fn.input('Search: ') }", "Fuzzy Search" }, } mappings["s"]["p"] = { "Telescope projects", "Recent Projects" } mappings["s"]["w"] = { "Telescope live_grep", "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 = { [""] = actions.move_selection_next, [""] = actions.move_selection_previous, [""] = actions.cycle_history_next, [""] = actions.cycle_history_prev, }, -- for normal mode n = { [""] = actions.move_selection_next, [""] = actions.move_selection_previous, }, }