Initial Commit - Add nvim config
Signed-off-by: Daniel Henry <iamdanhenry@gmail.com>
This commit is contained in:
58
.config/nvim/lua/core/keybindings.lua
Normal file
58
.config/nvim/lua/core/keybindings.lua
Normal file
@@ -0,0 +1,58 @@
|
||||
-- Global/editor keymaps live here.
|
||||
-- Tip: keep them conservative so they don't surprise language buffers.
|
||||
|
||||
-- Global/editor keymaps only (language-specific go in e.g. c/keybindings.lua)
|
||||
local map = vim.keymap.set
|
||||
|
||||
-- Save / quit (kept from earlier)
|
||||
-- map("n", "<leader>w", "<cmd>write<CR>", { desc = "Write file" })
|
||||
map("n", "<leader>q", "<cmd>quit<CR>", { desc = "Quit window" })
|
||||
|
||||
-- File explorer (loads Neo-tree on demand)
|
||||
map("n", "<leader>ee", "<cmd>Neotree toggle<CR>", { desc = "Explorer: toggle" })
|
||||
map("n", "<leader>er", "<cmd>Neotree reveal<CR>", { desc = "Explorer: reveal current file" })
|
||||
map("n", "<leader>ef", "<cmd>Neotree focus<CR>", { desc = "Explorer: focus" })
|
||||
|
||||
-- === Splits ===
|
||||
-- Horizontal split (under your left hand)
|
||||
map("n", "<leader>-", "<cmd>split<CR>", { desc = "Split: horizontal" })
|
||||
-- Vertical split (pipe looks like a vertical divider)
|
||||
map("n", "<leader>|", "<cmd>vsplit<CR>", { desc = "Split: vertical" })
|
||||
|
||||
-- === Window navigation (hjkl with Ctrl) ===
|
||||
-- These mirror Vim's native <C-w> h/j/k/l but are faster to type
|
||||
map("n", "<C-h>", "<C-w>h", { desc = "Window left" })
|
||||
map("n", "<C-j>", "<C-w>j", { desc = "Window down" })
|
||||
map("n", "<C-k>", "<C-w>k", { desc = "Window up" })
|
||||
map("n", "<C-l>", "<C-w>l", { desc = "Window right" })
|
||||
|
||||
-- which-key groups (v3 list-style spec)
|
||||
local ok, wk = pcall(require, "which-key") -- this will load the plugin if needed
|
||||
if ok then
|
||||
wk.add({
|
||||
{ "<leader>e", group = "Explorer" },
|
||||
{ "<leader>f", group = "Find" },
|
||||
{ "<leader>g", group = "Git" },
|
||||
{ "<leader>w", group = "Write/Windows" }, -- optional grouping for your own keys
|
||||
})
|
||||
end
|
||||
|
||||
-- Find group (which-key already labels <leader>f as "Find")
|
||||
map("n", "<leader>ff", "<cmd>Telescope find_files<CR>", { desc = "Find files" })
|
||||
map("n", "<leader>fg", "<cmd>Telescope live_grep<CR>", { desc = "Grep project" })
|
||||
map("n", "<leader>fb", "<cmd>Telescope buffers<CR>", { desc = "Switch buffer" })
|
||||
map("n", "<leader>fh", "<cmd>Telescope help_tags<CR>", { desc = "Help tags" })
|
||||
map("n", "<leader>fr", "<cmd>Telescope oldfiles<CR>", { desc = "Recent files" })
|
||||
map("n", "<leader>fs", "<cmd>Telescope grep_string<CR>", { desc = "Grep word under cursor" })
|
||||
local tb = require("telescope.builtin")
|
||||
map("n", "<leader>fs", tb.lsp_workspace_symbols, { desc = "Find: workspace symbols (LSP fuzzy)" })
|
||||
map("n", "<leader>fd", tb.lsp_document_symbols, { desc = "Find: document symbols (LSP fuzzy)" })
|
||||
|
||||
-- Open a small hover with all diagnostics at the cursor
|
||||
map("n", "<leader>xx", "<cmd>Trouble diagnostics toggle<CR>", { desc="Diagnostics: Trouble list" })
|
||||
|
||||
-- Toggle right-side virtual text on/off (sometimes nice to declutter)
|
||||
map("n", "<leader>xt", function()
|
||||
local cfg = vim.diagnostic.config()
|
||||
vim.diagnostic.config({ virtual_text = not cfg.virtual_text })
|
||||
end, { desc = "Diagnostics: toggle virtual text" })
|
||||
Reference in New Issue
Block a user