---------------------- -- EXPERIMENTS: ---------------------- -- date vim.keymap.set({ 'i', 'v' }, ':w', ':w', { desc = "Write File, in insert modde", silent = false }) ---------------------- -- [[ Basic Keymaps ]] ---------------------- -- Keymaps for better default experience -- See `:help vim.keymap.set()` vim.keymap.set({ 'n', 'v' }, '', '', { silent = true }) vim.keymap.set({ 'n', 'v' }, 'q', '', { desc = "", silent = true }) -------------------------- -- EXPERIMENTAL -------------------------- local map = vim.keymap.set -- not working map( "n", "cd", "cd! %:h", { desc = "cd to current buffer path" } ) -- works map("n", "..", "cd! ..", { desc = "cd up a level" }) -------------------------- -------------------------- -- REF: https://nanotipsforvim.prose.sh/keeping-your-register-clean-from-dd -- By default, action dd stores in reg ?? -- If you then dd on blank line "" replaces content in reg ?? -- So, if dd action holds content: keep it (don't replace) -- if dd action holds BLANK LINE: sent to black hole _dd (discard it) vim.keymap.set("n", "dd", function() if vim.fn.getline(".") == "" then return '"_dd' end return "dd" end, { expr = true }) -- vim.keymap.set( {'n', ']nc', -- Remap for dealing with word wrap -- jr 2023-10-07 Not cause of sticky line --vim.keymap.set('n', 'k', "v:count == 0 ? 'gk' : 'k'", { expr = true, silent = true }) --vim.keymap.set('n', 'j', "v:count == 0 ? 'gj' : 'j'", { expr = true, silent = true }) vim.keymap.set('n', '', 'zz', { desc = 'Move Up, center' }) vim.keymap.set('n', '', 'zz', { desc = 'Move Down, center' }) -- vim.keymap.set('n', 'ck', ':e ~/.config/kickstart/init.lua', { desc = 'Config Kickstart' }) vim.keymap.set('n', 'bw', 'i**Ea**w', { desc = "[B]old [W]ord" }) -- insert # --------... vim.keymap.set("n", "ic", "yypVr-I# ", { desc = "[ic]insert comment line" }) --------------------- -- Diagnostic keymaps --------------------- vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, { desc = 'Go to previous diagnostic message' }) vim.keymap.set('n', ']d', vim.diagnostic.goto_next, { desc = 'Go to next diagnostic message' }) vim.keymap.set('n', 'e', vim.diagnostic.open_float, { desc = 'Open floating diagnostic message' }) vim.keymap.set('n', 'q', vim.diagnostic.setloclist, { desc = 'Open diagnostics list' }) ------------------------------------------------------ -- which-key ------------------------------------------------------ -- experiment; add my keymaps to which-key -- stolen: REF: https://github.com/hackorum/nfs/blob/master/lua/whichkey-config/init.lua ------------------------------------------------------ --{{{ local wk = require 'which-key' wk.setup { plugins = { marks = false, registers = true, spelling = { enabled = false, suggestions = 20 }, presets = { operators = false, motions = false, text_objects = false, windows = false, nav = false, -- z = false, g = false, }, }, show_help = true, -- (default) show a help message in the command line for using WhichKey key_labels = { -- override the label used to display some keys. It doesn't effect WK in any other way. -- For example: [""] = "SPACE", ["n"] = "notes", -- [""] = "RET", -- [""] = "TAB", }, } local mappings = { -- g is an experiment and duplicates done elsewhere g = { name = "temp file", -- checkhealth, gb, gc are conflicts f = { "Telescope find_files", "Find File" }, -- create a binding with label g = { "Telescope live_grep", "Full Text Search" }, -- gb taken by comments plugin bu = { "Telescope buffers", "Telescope [Bu]ffers" }, q = { "q", 'Quit - no warn' }, }, n = { name = "my notes", a = { "cd ~/code/docs/ALZ/", "cd [A]LZ [Notes]" }, m = { "e ~/code/docs/tech_notes/500_ML_Notes.qmd", "[M]L [Notes]" }, h = { "e ~/code/docs/health_notes/medical_notes.qmd", "[H]ealth [Notes]" }, o = { "cd ~/code/docs/misc_files/", "cd Misc Notes" }, t = { "e ~/code/docs/tech_notes/300_tech_notes.qmd", "[T]ech [Notes]" }, --vim.keymap.set('n', 'tn', ':e ~/code/docs/tech_notes/300_tech_notes.qmd', { desc = 'Tech Notes' }) --vim.keymap.set('n', 'mln', ':e ~/code/docs/tech_notes/500_ML_Notes.qmd', { desc = 'ML Notes' }) }, r = { name = "extra R cmds", sx = { "RStop", "interrupt R, RStop" }, x = { "RStop", "interrupt R, RStop" }, }, t = { name = "telescope", f = { "Telescope find_files", "Find File" }, -- create a binding with label -- tz is conflict -- z = { "Telescope find_files", "Find File", desc = "Search Home", pwd = '/home/jim' }, -- create a binding with label }, q = { ":q", "Quit - no warn" }, Q = { ":wq", "Save & Quit" }, w = { ":w", "Save" }, x = { ":bdelete", "Close" }, -- use :RKill to stop R, close terminal (not guaranteed) z1 = { 'p', 'other window' }, z2 = { 'pAjunk', 'other window junk' }, rk = { ':RKill', 'RKill , but not guaranteed to close terminal' }, -- use ck E = { ':e ~/.config/kickstart/init.lua', 'Edit KICKSTART config' }, ck = { ':e ~/.config/kickstart/init.lua', '[ck] Edit KICKSTART config' }, -- f = { ":Telescope find_files", "Telescope Find Files" }, -- r = { ":Telescope live_grep", "Telescope Live Grep" }, } local opts = { prefix = '' } wk.register(mappings, opts) -- }}}