103 lines
3.2 KiB
Lua
103 lines
3.2 KiB
Lua
local map = require("helpers.keys").map
|
|
|
|
|
|
|
|
-- Quick access to some common actions
|
|
map("n", "<leader>fw", "<cmd>w<cr>", "Write")
|
|
map("n", "<leader>fa", "<cmd>wa<cr>", "Write all")
|
|
map("n", "<leader>qq", "<cmd>q<cr>", "Quit")
|
|
map("n", "<leader>qa", "<cmd>qa!<cr>", "Quit all")
|
|
map("n", "<leader>dw", "<cmd>close<cr>", "Window")
|
|
map("n", ";", "A;<Esc>", "places \";\" at end of line")
|
|
|
|
-- Diagnostic keymaps
|
|
map('n', 'gx', vim.diagnostic.open_float, "Show diagnostics under cursor")
|
|
|
|
-- Easier access to beginning and end of lines
|
|
map("n", "<M-h>", "^", "Go to beginning of line")
|
|
map("n", "<M-l>", "$", "Go to end of line")
|
|
|
|
-- Better window navigation
|
|
map("n", "<C-h>", "<C-w><C-h>", "Navigate windows to the left")
|
|
map("n", "<C-j>", "<C-w><C-j>", "Navigate windows down")
|
|
map("n", "<C-k>", "<C-w><C-k>", "Navigate windows up")
|
|
map("n", "<C-l>", "<C-w><C-l>", "Navigate windows to the right")
|
|
|
|
-- Move with shift-arrows
|
|
map("n", "<S-Left>", "<C-w><S-h>", "Move window to the left")
|
|
map("n", "<S-Down>", "<C-w><S-j>", "Move window down")
|
|
map("n", "<S-Up>", "<C-w><S-k>", "Move window up")
|
|
map("n", "<S-Right>", "<C-w><S-l>", "Move window to the right")
|
|
|
|
-- Resize with arrows
|
|
map("n", "<C-Up>", ":resize +2<CR>")
|
|
map("n", "<C-Down>", ":resize -2<CR>")
|
|
map("n", "<C-Left>", ":vertical resize +2<CR>")
|
|
map("n", "<C-Right>", ":vertical resize -2<CR>")
|
|
|
|
-- Deleting buffers
|
|
local buffers = require("helpers.buffers")
|
|
map("n", "<leader>db", buffers.delete_this, "Current buffer")
|
|
map("n", "<leader>do", buffers.delete_others, "Other buffers")
|
|
map("n", "<leader>da", buffers.delete_all, "All buffers")
|
|
|
|
-- Navigate buffers
|
|
map("n", "<S-l>", ":bnext<CR>")
|
|
map("n", "<S-h>", ":bprevious<CR>")
|
|
|
|
-- Stay in indent mode
|
|
map("v", "<", "<gv")
|
|
map("v", ">", ">gv")
|
|
|
|
-- Switch between light and dark modes
|
|
map("n", "<leader>ut", function()
|
|
if vim.o.background == "dark" then
|
|
vim.o.background = "light"
|
|
else
|
|
vim.o.background = "dark"
|
|
end
|
|
end, "Toggle between light and dark themes")
|
|
|
|
-- Clear after search
|
|
map("n", "<leader>ur", "<cmd>nohl<cr>", "Clear highlights")
|
|
|
|
-- Open config
|
|
map("n", "<leader>Nc", "<cmd>tabnew ~/.config/nvim/init.lua<cr>", "Open Config")
|
|
|
|
-- Open Weather
|
|
map("n", "<leader>w", "<cmd>lua require'wttr'.get_forecast()<cr>", "Open Weather")
|
|
|
|
-- Open Common Files
|
|
map("n", "<leader>fm", "<cmd>tabnew ~/vex/roberts<cr>", "Open Roberts")
|
|
map("n", "<leader>fp", "<cmd>tabnew ~/vex/patch<cr>", "Open Patch")
|
|
|
|
-- New Tab Terminal (for more perminent use)
|
|
map("n", "<leader>ft", "<cmd>tabf term://fish<cr>i", "Open New Terminal")
|
|
map("t", "<Esc><leader>", "<C-\\><C-n>", "Return to normal mode")
|
|
|
|
|
|
-- Lazygit config
|
|
local Terminal = require('toggleterm.terminal').Terminal
|
|
local lazygit = Terminal:new({cmd = "lazygit", hidden = true, direction='tab'})
|
|
|
|
function _lazygit_toggle()
|
|
lazygit:toggle()
|
|
end
|
|
map("n", "<leader>gg", "<cmd>lua _lazygit_toggle()<cr>", "open lazygit")
|
|
|
|
-- Bacon config
|
|
local bacon = Terminal:new({cmd = "bacon --job clippy", hidden = true, direction='tab'})
|
|
|
|
function _bacon_toggle()
|
|
bacon:toggle()
|
|
end
|
|
map("n", "<leader>h", "<cmd>lua _bacon_toggle()<cr>", "open bacon")
|
|
|
|
-- Wiki-tui config
|
|
local wiki = Terminal:new({cmd = "wiki-tui", hidden = true, direction='tab'})
|
|
|
|
function _wiki_toggle()
|
|
wiki:toggle()
|
|
end
|
|
map("n", "<leader>sl", "<cmd>lua _wiki_toggle()<cr>", "open wiki-tui")
|