Files
Neovim/lua/keyboard.lua
T
faumaray 95dc3b686a initial
Signed-off-by: faumaray <faumaray@gmail.com>
2026-04-17 00:23:01 +03:00

63 lines
2.3 KiB
Lua

-- This file is intentionally left empty
-- Put your keybindings with wk package here
local wk = require('which-key')
local function mdesc(opt, description)
return vim.tbl_extend("force", opt, { desc = description })
end
local map = function(mode, lhs, rhs, opts, desc)
opts = opts and opts or {}
opts = mdesc(opts, desc)
vim.keymap.set(mode, lhs, rhs, opts)
end
local builtin = require('telescope.builtin')
vim.keymap.set('n', '<leader>ff', builtin.find_files, { desc = 'Telescope find files' })
vim.keymap.set('n', '<leader>fg', builtin.live_grep, { desc = 'Telescope live grep' })
vim.keymap.set('n', '<leader>fb', builtin.buffers, { desc = 'Telescope buffers' })
vim.keymap.set('n', '<leader>fh', builtin.help_tags, { desc = 'Telescope help tags' })
map({ "t", "i" }, "<C-h>", [[<C-\><C-N><C-w>h]])
map({ "t", "i" }, "<C-j>", [[<C-\><C-N><C-w>j]])
map({ "t", "i" }, "<C-k>", [[<C-\><C-N><C-w>k]])
map({ "t", "i" }, "<C-l>", [[<C-\><C-N><C-w>l]])
-- Move to window using the <ctrl> hjkl keys
map("n", "<C-h>", "<C-w>h", { desc = "Go to left window" })
map("n", "<C-j>", "<C-w>j", { desc = "Go to lower window" })
map("n", "<C-k>", "<C-w>k", { desc = "Go to upper window" })
map("n", "<C-l>", "<C-w>l", { desc = "Go to right window" })
map("n", "<C-Up>", "<cmd>resize +2<cr>", { desc = "Increase window height" })
map("n", "<C-Down>", "<cmd>resize -2<cr>", { desc = "Decrease window height" })
map(
"n",
"<C-Left>",
"<cmd>vertical resize -2<cr>",
{ desc = "Decrease window width" }
)
map(
"n",
"<C-Right>",
"<cmd>vertical resize +2<cr>",
{ desc = "Increase window width" }
)
map("n", "<leader>sh", "<C-W>s", { desc = "Split window below" })
map("n", "<leader>sv", "<C-W>v", { desc = "Split window right" })
map({ "i", "v", "n", "s" }, "<C-s>", function()
vim.cmd([[w]])
end, { desc = "Save file" })
map({ "i", "v", "n", "s" }, "<leader>ww", function()
vim.cmd([[w]])
end, { desc = "Save file" })
map("n", "j", "v:count == 0 ? 'gj' : 'j'", { expr = true, silent = true })
map("n", "k", "v:count == 0 ? 'gk' : 'k'", { expr = true, silent = true })
-- === Terminal === "
-- Mapping to open terminal emulator in nvim
-- open terminal on alt+t
map({ "n", "t" }, "<M-t>", function()
vim.cmd.split({ "term://" .. vim.env.SHELL })
vim.cmd.resize({ 15 })
end)
-- mapping to close terminal emulator
map("t", "<M-t>", [[<C-\><C-n>:bd!<CR>]])