aboutsummaryrefslogtreecommitdiffstats
path: root/plugin/20-keymaps.lua
blob: f0905ed87a7f84729ef0cdeb7af15525dc88e8b8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
--[[ 20-keymaps.lua — the leader key and the miscellaneous keymaps that belong to no feature.

Sets the leader key, so the low numeric prefix loads this file before the `50-*` features define
their `<Leader>` maps; feature-specific keymaps live in their feature's plugin file.
See <nvim-help://key-notation> and <nvim-help://%3CCmd%3E>;
`:map \ ` lists (most) user keymaps (those starting with the `<Leader>` key).

Keymaps:
  `<M-z>`        toggle fold (recursively) under cursor
  `<Leader>lh`   toggle inlay hints (LSP)
  `<Leader>mm`   show all messages
  `<Leader>mc`   clear all messages
  `<Leader>y+`   copy file path to clipboard
  `<Leader>w`    toggle text wrap
]]

----------------------------------------------------------------------------------------------------
-- Local functions ---------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------

local function toggle_wrap()
	vim.o.wrap = not vim.o.wrap
end

----------------------------------------------------------------------------------------------------
-- Keymaps -----------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------

vim.g.mapleader = " " -- Set before any `vim.keymap.set()` call that maps `<Leader>`

-- stylua: ignore start
-- Miscellaneous
vim.keymap.set("n", "<M-z>", "zA", { desc = "Toggle fold (recursively) under cursor" })
vim.keymap.set("n", "<Leader>lh", vim.cmd.LspHintToggle, { desc = "Toggle inlay hints (LSP)" })
vim.keymap.set("n", "<Leader>mm", "<Cmd>messages<CR>", { desc = "Show all messages" })
vim.keymap.set("n", "<Leader>mc", "<Cmd>messages clear<CR>", { desc = "Clear all messages" })
-- Files
vim.keymap.set("n", "<Leader>y+", "<Cmd>let @+ = expand('%:p')<CR>", { desc = "Copy file path to clipboard" })
-- Buffers
vim.keymap.set("n", "<Leader>w", toggle_wrap, { desc = "Toggle text wrap" })