You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
66 lines
1.9 KiB
66 lines
1.9 KiB
local function map(mode, lhs, rhs, opts)
|
|
local options = { noremap = true }
|
|
if opts then
|
|
options = vim.tbl_extend("force", options, opts)
|
|
end
|
|
vim.api.nvim_set_keymap(mode, lhs, rhs, options)
|
|
end
|
|
|
|
vim.g.mapleader = " "
|
|
|
|
map("n", "j", "gj")
|
|
map("n", "k", "gk")
|
|
|
|
map("n", "<C-h>", "<C-w>h")
|
|
map("n", "<C-j>", "<C-w>j")
|
|
map("n", "<C-k>", "<C-w>k")
|
|
map("n", "<C-l>", "<C-w>l")
|
|
|
|
map("i", "<A-a>", "ā")
|
|
map("i", "<A-e>", "ē")
|
|
map("i", "<A-i>", "ī")
|
|
map("i", "<A-o>", "ō")
|
|
map("i", "<A-u>", "ū")
|
|
|
|
map("n", "<F12>", ":w|:!texbld run compile<CR>")
|
|
map("n", "<F5>", ":w|:!./test.sh<CR>")
|
|
|
|
-- hacks
|
|
vim.keymap.set("v", "J", ":m '>+1<CR>gv=gv")
|
|
vim.keymap.set("v", "K", ":m '<-2<CR>gv=gv")
|
|
|
|
vim.keymap.set("n", "J", "mzJ`z")
|
|
vim.keymap.set("n", "<C-d>", "<C-d>zz")
|
|
vim.keymap.set("n", "<C-u>", "<C-u>zz")
|
|
vim.keymap.set("n", "n", "nzzzv")
|
|
vim.keymap.set("n", "N", "Nzzzv")
|
|
|
|
vim.keymap.set("x", "<leader>p", [["_dP]])
|
|
vim.keymap.set({ "n", "v" }, "<leader>y", [["+y]])
|
|
vim.keymap.set("n", "<leader>Y", [["+Y]])
|
|
vim.keymap.set("n", "<leader>x", "<cmd>!chmod +x %<CR>", { silent = true })
|
|
vim.keymap.set("n", "<leader>X", "<cmd>!chmod -x %<CR>", { silent = true })
|
|
|
|
|
|
-- execute file
|
|
vim.keymap.set("n", "<leader>,", "<cmd>e ~/.config/nvim<CR>");
|
|
vim.keymap.set("n", "<leader>r", "<cmd>so ~/.config/nvim/init.lua<CR>")
|
|
vim.keymap.set("n", "<leader>e", "<cmd>!%:p<CR>", { silent = true })
|
|
|
|
vim.keymap.set("n", "<leader>vz", "<cmd>e ~/.zshrc<CR>");
|
|
|
|
vim.keymap.set("n", "<leader>fmt", function()
|
|
vim.lsp.buf.formatting_sync()
|
|
end)
|
|
|
|
if os.getenv("TMUX") ~= nil then
|
|
vim.keymap.set("n", "<C-f>", [[<cmd>silent !tmux neww "zsh -c '. ~/.zshenv; tmuxs'"<CR>]])
|
|
vim.keymap.set("n", "<C-y>", [[<cmd>silent !tmux neww ncmpcpp<CR>]])
|
|
else
|
|
local function unavailable()
|
|
print("Not in a tmux session")
|
|
end
|
|
|
|
vim.keymap.set("n", "<C-f>", unavailable)
|
|
vim.keymap.set("n", "<C-y>", unavailable)
|
|
end
|