This repository has been archived on 2023-03-02. You can view files and clone it, but cannot push or open issues or pull requests.
dotfiles/.config/nvim/lua/maps.lua

98 lines
2.4 KiB
Lua

-- Author : swytch
-- Created : Friday Mar 12, 2021 20:17:19 CET
-- License : GPLv3
-- Description : neovim mappings file
vim.keymap.set({ "n", "v" }, "<space>",
"<Nop>",
{
silent = true,
desc = "leader key"
})
vim.g.mapleader = " "
-- dealing with word wrap
vim.keymap.set("n", "k",
"v:count == 0 ? 'gk' : 'k'",
{
expr = true,
silent = true,
desc = "Smart up motion"
})
vim.keymap.set("n", "j",
"v:count == 0 ? 'gj' : 'j'",
{
expr = true,
silent = true,
desc = "Smart down motion"
})
-- yank and pasting
vim.keymap.set({ "n", "x" }, "<leader>y",
"\"+y",
{ desc = "Yank to clipboard"}
)
vim.keymap.set("n", "<leader>p",
"\"+P",
{ desc = "Paste from clipboard" }
)
vim.keymap.set("x", "<leader>p",
"\"_dP",
{ desc = "Send selection to void register and paste from clipboard" }
)
-- deletion
vim.keymap.set({ "n", "x" }, "<leader>d",
"\"_d",
{ desc = "Send selection to void register" }
)
-- comfort zone
vim.keymap.set("n", "<leader><enter>",
"<cmd>w! | !compiler %<CR>",
{ desc = "Compile current file using ~/.local/bin/compiler" }
)
-- packer
vim.keymap.set("n", "<leader>u",
function() require("packer").sync() end,
{ desc = "Sync packer config and update plugins" }
)
-- telescope
vim.keymap.set("n", "<leader>tf",
function() require("telescope.builtin").find_files() end,
{ desc = "Fuzzy find files" }
)
vim.keymap.set("n", "<leader>tb",
function() require("telescope").extensions.file_browser.file_browser() end,
{ desc = "Open file browser" }
)
vim.keymap.set("n", "<leader>t/",
function() require("telescope.builtin").buffers() end,
{ desc = "Grep through buffers" }
)
vim.keymap.set("n", "<leader>tg",
function() require("telescope.builtin").grep_string() end,
{ desc = "Grep current word" }
)
vim.keymap.set("n", "<leader>th",
function() require("telescope.builtin").help_tags() end,
{ desc = "Search through help" }
)
vim.keymap.set("n", "<leader>tl",
function() require("telescope.builtin").live_grep() end,
{ desc = "Grep interactively" }
)
-- colorscheme
vim.keymap.set("n", "<leader>s",
function() require("astronomy").toggle_variant() end,
{ desc = "Switch between dark and light colorscheme" }
)
-- snippets
vim.keymap.set({ "i", "s" }, "<C-E>", "<Plug>luasnip-next-choice",
{ desc = "Cycle through luasnip choices" }
)