starter/lua/config/keymaps.lua

49 lines
2.1 KiB
Lua
Raw Normal View History

2023-01-07 17:52:40 +08:00
-- Keymaps are automatically loaded on the VeryLazy event
-- Default keymaps that are always set: https://github.com/LazyVim/LazyVim/blob/main/lua/lazyvim/config/keymaps.lua
-- Add any additional keymaps here
local map = vim.keymap.set
2024-05-24 15:20:16 +08:00
-- Essential
2024-05-13 12:51:21 +08:00
map({ "n", "v" }, ";", ":", { desc = "Enter command mode", noremap = true, nowait = true })
2024-05-16 10:16:59 +08:00
-- Theme
map("n", "<leader>uh", "<CMD>HighlightColors Toggle<CR>", { desc = "Toggle highlighting color", nowait = true })
2024-05-13 11:23:16 +08:00
2024-05-24 15:20:16 +08:00
-- File management
map("n", "<leader>op", "<CMD>Oil<CR>", { desc = "Open parent directory" })
2024-05-27 22:44:08 +08:00
map("n", "<C-_>", "<CMD>ToggleTerm direction=float<CR>", { desc = "Open Floating terminal" })
2024-05-24 15:20:16 +08:00
-- Markdown
map("n", "<leader>ct", ":lua require('toggle-checkbox').toggle()<CR>", { desc = "Toggle Checkbox" })
2024-05-24 15:20:16 +08:00
map("n", "<leader>pb", function()
2024-05-25 23:27:46 +08:00
require("gitpad").toggle_gitpad_branch()
2024-05-24 15:20:16 +08:00
end, { desc = "Toogle Gitpad branch" })
2024-05-15 09:38:41 +08:00
map("n", "<leader>pd", function()
2024-05-25 23:27:46 +08:00
local date_filename = "daily-" .. os.date("%Y-%m-%d.md")
require("gitpad").toggle_gitpad({ filename = date_filename }) -- or require('gitpad').toggle_gitpad({ filename = date_filename, title = 'Daily notes' })
2024-05-15 09:38:41 +08:00
end, { desc = "Toogle Gitpad Daily notes" })
map("n", "<leader>pf", function()
2024-05-25 23:27:46 +08:00
local filename = vim.fn.expand("%:p") -- or just use vim.fn.bufname()
if filename == "" then
vim.notify("empty bufname")
return
end
filename = vim.fn.pathshorten(filename, 2) .. ".md"
require("gitpad").toggle_gitpad({ filename = filename }) -- or require('gitpad').toggle_gitpad({ filename = filename, title = 'Current file notes' })
2024-05-15 09:38:41 +08:00
end, { desc = "Toogle Gitpad per file notes" })
2024-05-24 15:20:16 +08:00
-- Git
map("n", "<leader>gb", "<CMD>GitBlameToggle<CR>", { desc = "Toggle Git Blame" })
2024-05-15 10:04:27 +08:00
2024-05-24 15:20:16 +08:00
-- Development
2024-05-16 11:09:13 +08:00
map({ "n", "i", "v" }, "<f12>", function()
2024-05-25 23:27:46 +08:00
vim.lsp.buf.definition()
2024-05-16 11:09:13 +08:00
end, { desc = "Go to definition" })
2024-05-21 23:45:22 +08:00
map({ "n", "i", "v" }, "<S-f12>", function()
2024-05-25 23:27:46 +08:00
vim.lsp.buf.declaration()
2024-05-16 11:09:13 +08:00
end, { desc = "Go to declaration" })
2024-05-20 18:00:57 +08:00
map("n", "<F6>", "<CMD>CompilerOpen<CR>", { desc = "Open compiler" })
map("n", "<S-F6>", "<CMD>CompilerRedo<CR>", { desc = "Compiler redo" })
map("n", "<S-F7>", "<CMD>CompilerToggleResults<CR>", { desc = "Compiler results" })