-- Set up all my favorite keybindings and list them in my cheatsheet. -- This module assumes a lot of pre configured state, i.e. already installed and enabled plugins. -- The benefit of assembling all keybinds here is, that they are easy to find. -- But unfortunataly, by collecting them here, they are placed "far" from their logical place, i.e. the plugins configuration. return function(cheatsheet) -- Delegator over nvim_set_keymap, that sets some default options local map = function(mode, left_hand_side, right_hand_side, options) local default_options = { noremap = true, unique = true } if options then default_options = vim.tbl_extend('force', default_options, options) end vim.api.nvim_set_keymap( mode, left_hand_side, right_hand_side, default_options ) end -- Let the key be vim.g.mapleader = ' ' map('n', '', [[:lua require('glow').glow('')]]) cheatsheet 'LEADER + F12 => Render Markdown Preview' map('n', '', [[:tabnew ~/.config/nvim/init.lua]]) cheatsheet 'LEADER + F9 => Open nvim configuration in a new tab!' -- Change behaviour of :terminal to be less like a vim buffer and more what I am used to map('t', '', '') map('t', '', '') -- Clear highlighted search results whenever ESC is hit map('n', '', ':nohlsearch', { unique = false, silent = true }) map('n', 'b', [[:Telescope buffers]]) cheatsheet 'LEADER + b => Select a buffer' map('n', 'f', [[:Telescope file_browser]]) cheatsheet 'LEADER + f => Select a file' map('n', 'e', [[:NvimTreeToggle]]) cheatsheet 'LEADER + e => Toggle file explorer' --Open up a URL under the cursor local opener_program = '' if vim.fn.has("mac") == 1 then opener_program = 'open' elseif vim.fn.has("unix") == 1 then opener_program = 'xdg-open' elseif vim.fn.has('win32') == 1 then opener_program = 'explorer' else -- What should we do on unknown platforms? We guess... opener_program = 'firefox' end map('n', 'gx', [[lua require'spawn'(']] .. opener_program .. [[',{ vim.fn.expand('') } )]]) cheatsheet'gx => Open URL under cursor' end