initial dotfiles
This commit is contained in:
commit
a11473e308
20 changed files with 2831 additions and 0 deletions
16
nvim/init.lua
Normal file
16
nvim/init.lua
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
-- Bootstrap lazy.nvim (auto-installs on first launch)
|
||||
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
|
||||
if not vim.loop.fs_stat(lazypath) then
|
||||
vim.fn.system({
|
||||
"git", "clone", "--filter=blob:none",
|
||||
"https://github.com/folke/lazy.nvim.git",
|
||||
"--branch=stable", lazypath,
|
||||
})
|
||||
end
|
||||
vim.opt.rtp:prepend(lazypath)
|
||||
|
||||
require("options")
|
||||
require("keymaps")
|
||||
require("lazy").setup("plugins", {
|
||||
change_detection = { notify = false },
|
||||
})
|
||||
33
nvim/lua/keymaps.lua
Normal file
33
nvim/lua/keymaps.lua
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
local map = vim.keymap.set
|
||||
|
||||
-- Space as leader key (must be set before lazy loads plugins)
|
||||
vim.g.mapleader = " "
|
||||
vim.g.maplocalleader = " "
|
||||
|
||||
-- ── File ────────────────────────────────────────────────────────────────────
|
||||
map("n", "<leader>w", "<cmd>w<cr>", { desc = "Save file" })
|
||||
map("n", "<leader>q", "<cmd>q<cr>", { desc = "Quit" })
|
||||
map("n", "<leader>Q", "<cmd>qa<cr>", { desc = "Quit all" })
|
||||
|
||||
-- ── Buffers ─────────────────────────────────────────────────────────────────
|
||||
map("n", "<S-l>", "<cmd>bnext<cr>", { desc = "Next buffer" })
|
||||
map("n", "<S-h>", "<cmd>bprev<cr>", { desc = "Prev buffer" })
|
||||
map("n", "<leader>x", "<cmd>bd<cr>", { desc = "Close buffer" })
|
||||
|
||||
-- ── Window navigation (Ctrl + hjkl) ─────────────────────────────────────────
|
||||
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" })
|
||||
|
||||
-- ── Editing quality of life ──────────────────────────────────────────────────
|
||||
map("i", "jk", "<Esc>", { desc = "Exit insert mode" }) -- quick escape
|
||||
map("n", "<Esc>", "<cmd>nohl<cr>", { desc = "Clear search highlight" })
|
||||
|
||||
-- Keep indent when tabbing in visual mode
|
||||
map("v", "<", "<gv")
|
||||
map("v", ">", ">gv")
|
||||
|
||||
-- Move selected lines up/down
|
||||
map("v", "<A-j>", ":m '>+1<cr>gv=gv", { desc = "Move selection down" })
|
||||
map("v", "<A-k>", ":m '<-2<cr>gv=gv", { desc = "Move selection up" })
|
||||
41
nvim/lua/options.lua
Normal file
41
nvim/lua/options.lua
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
local opt = vim.opt
|
||||
|
||||
-- Line numbers
|
||||
opt.number = true
|
||||
opt.relativenumber = true
|
||||
opt.cursorline = true
|
||||
opt.signcolumn = "yes" -- always show (prevents layout shifting with LSP)
|
||||
|
||||
-- Indentation (spaces, 2-wide by default; LSP/treesitter adjusts per language)
|
||||
opt.tabstop = 2
|
||||
opt.shiftwidth = 2
|
||||
opt.expandtab = true
|
||||
opt.smartindent = true
|
||||
|
||||
-- Search
|
||||
opt.ignorecase = true
|
||||
opt.smartcase = true -- case-sensitive when query has uppercase
|
||||
opt.hlsearch = true
|
||||
|
||||
-- System clipboard — y/p work with Ctrl+C/Ctrl+V from other apps
|
||||
opt.clipboard = "unnamedplus"
|
||||
|
||||
-- Splits open in natural directions
|
||||
opt.splitbelow = true
|
||||
opt.splitright = true
|
||||
|
||||
-- Appearance
|
||||
opt.termguicolors = true
|
||||
opt.wrap = false
|
||||
opt.scrolloff = 8 -- keep 8 lines visible above/below cursor
|
||||
|
||||
-- Files & undo
|
||||
opt.swapfile = false
|
||||
opt.undofile = true -- persistent undo across sessions
|
||||
|
||||
-- Performance
|
||||
opt.updatetime = 250 -- faster CursorHold (used by LSP hover)
|
||||
opt.timeoutlen = 300 -- faster which-key popup
|
||||
|
||||
-- Mouse support
|
||||
opt.mouse = "a"
|
||||
11
nvim/lua/plugins/colorscheme.lua
Normal file
11
nvim/lua/plugins/colorscheme.lua
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
return {
|
||||
{
|
||||
"catppuccin/nvim",
|
||||
name = "catppuccin",
|
||||
priority = 1000, -- load before everything else
|
||||
config = function()
|
||||
require("catppuccin").setup({ flavour = "mocha" })
|
||||
vim.cmd.colorscheme("catppuccin")
|
||||
end,
|
||||
},
|
||||
}
|
||||
40
nvim/lua/plugins/editor.lua
Normal file
40
nvim/lua/plugins/editor.lua
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
-- Editor quality-of-life: auto-pairs, key hints, git signs
|
||||
return {
|
||||
|
||||
-- Auto-close brackets, quotes, etc.
|
||||
{
|
||||
"windwp/nvim-autopairs",
|
||||
event = "InsertEnter",
|
||||
config = true,
|
||||
},
|
||||
|
||||
-- Press <leader> and wait to see all available keybindings
|
||||
{
|
||||
"folke/which-key.nvim",
|
||||
event = "VeryLazy",
|
||||
config = function()
|
||||
require("which-key").setup({})
|
||||
end,
|
||||
},
|
||||
|
||||
-- Git change indicators in the gutter + hunk actions
|
||||
-- <leader>gp → preview hunk diff
|
||||
-- <leader>gb → blame current line
|
||||
{
|
||||
"lewis6991/gitsigns.nvim",
|
||||
config = function()
|
||||
require("gitsigns").setup({
|
||||
signs = {
|
||||
add = { text = "▎" },
|
||||
change = { text = "▎" },
|
||||
delete = { text = "" },
|
||||
topdelete = { text = "" },
|
||||
changedelete = { text = "▎" },
|
||||
},
|
||||
})
|
||||
local map = vim.keymap.set
|
||||
map("n", "<leader>gp", "<cmd>Gitsigns preview_hunk<cr>", { desc = "Preview hunk" })
|
||||
map("n", "<leader>gb", "<cmd>Gitsigns blame_line<cr>", { desc = "Git blame line" })
|
||||
end,
|
||||
},
|
||||
}
|
||||
28
nvim/lua/plugins/explorer.lua
Normal file
28
nvim/lua/plugins/explorer.lua
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
-- File tree (Neo-tree)
|
||||
-- <leader>e → toggle
|
||||
-- <leader>o → focus/reveal current file
|
||||
return {
|
||||
{
|
||||
"nvim-neo-tree/neo-tree.nvim",
|
||||
branch = "v3.x",
|
||||
dependencies = {
|
||||
"nvim-lua/plenary.nvim",
|
||||
"nvim-tree/nvim-web-devicons",
|
||||
"MunifTanjim/nui.nvim",
|
||||
},
|
||||
config = function()
|
||||
require("neo-tree").setup({
|
||||
window = { width = 30 },
|
||||
filesystem = {
|
||||
filtered_items = {
|
||||
hide_dotfiles = false, -- show dotfiles (useful for configs)
|
||||
hide_gitignored = true,
|
||||
},
|
||||
follow_current_file = { enabled = true }, -- auto-reveal open file
|
||||
},
|
||||
})
|
||||
vim.keymap.set("n", "<leader>e", "<cmd>Neotree toggle<cr>", { desc = "Toggle file tree" })
|
||||
vim.keymap.set("n", "<leader>o", "<cmd>Neotree reveal<cr>", { desc = "Reveal file in tree" })
|
||||
end,
|
||||
},
|
||||
}
|
||||
123
nvim/lua/plugins/lsp.lua
Normal file
123
nvim/lua/plugins/lsp.lua
Normal file
|
|
@ -0,0 +1,123 @@
|
|||
-- LSP stack:
|
||||
-- mason → installs language servers automatically
|
||||
-- lspconfig → configures them
|
||||
-- nvim-cmp → completion popup
|
||||
-- LuaSnip → snippet engine (required by cmp)
|
||||
--
|
||||
-- LSP keymaps (active when a file has an attached language server):
|
||||
-- K → hover documentation
|
||||
-- gd → go to definition
|
||||
-- gr → list references
|
||||
-- <leader>rn → rename symbol
|
||||
-- <leader>ca → code actions (quick fixes, imports, etc.)
|
||||
-- <leader>d → show line diagnostics
|
||||
-- [d / ]d → jump to prev/next diagnostic
|
||||
return {
|
||||
|
||||
-- ── Mason: auto-installs language servers ──────────────────────────────────
|
||||
{
|
||||
"williamboman/mason.nvim",
|
||||
config = function()
|
||||
require("mason").setup()
|
||||
end,
|
||||
},
|
||||
{
|
||||
"williamboman/mason-lspconfig.nvim",
|
||||
dependencies = { "williamboman/mason.nvim" },
|
||||
config = function()
|
||||
require("mason-lspconfig").setup({
|
||||
ensure_installed = {
|
||||
"bashls", -- Bash
|
||||
"pyright", -- Python
|
||||
"omnisharp", -- C#
|
||||
},
|
||||
automatic_installation = true,
|
||||
})
|
||||
end,
|
||||
},
|
||||
|
||||
-- ── Completion ─────────────────────────────────────────────────────────────
|
||||
{
|
||||
"hrsh7th/nvim-cmp",
|
||||
dependencies = {
|
||||
"hrsh7th/cmp-nvim-lsp", -- LSP completions
|
||||
"hrsh7th/cmp-buffer", -- words from current buffer
|
||||
"hrsh7th/cmp-path", -- file paths
|
||||
"L3MON4D3/LuaSnip", -- snippet engine
|
||||
"saadparwaiz1/cmp_luasnip",
|
||||
},
|
||||
config = function()
|
||||
local cmp = require("cmp")
|
||||
local luasnip = require("luasnip")
|
||||
|
||||
cmp.setup({
|
||||
snippet = {
|
||||
expand = function(args) luasnip.lsp_expand(args.body) end,
|
||||
},
|
||||
mapping = cmp.mapping.preset.insert({
|
||||
["<C-Space>"] = cmp.mapping.complete(),
|
||||
["<CR>"] = cmp.mapping.confirm({ select = true }),
|
||||
["<Tab>"] = cmp.mapping(function(fallback)
|
||||
if cmp.visible() then
|
||||
cmp.select_next_item()
|
||||
elseif luasnip.expand_or_jumpable() then
|
||||
luasnip.expand_or_jump()
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end, { "i", "s" }),
|
||||
["<S-Tab>"] = cmp.mapping(function(fallback)
|
||||
if cmp.visible() then
|
||||
cmp.select_prev_item()
|
||||
elseif luasnip.jumpable(-1) then
|
||||
luasnip.jump(-1)
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end, { "i", "s" }),
|
||||
}),
|
||||
sources = cmp.config.sources({
|
||||
{ name = "nvim_lsp" },
|
||||
{ name = "luasnip" },
|
||||
}, {
|
||||
{ name = "buffer" },
|
||||
{ name = "path" },
|
||||
}),
|
||||
})
|
||||
end,
|
||||
},
|
||||
|
||||
-- ── LSP config ─────────────────────────────────────────────────────────────
|
||||
{
|
||||
"neovim/nvim-lspconfig",
|
||||
dependencies = {
|
||||
"williamboman/mason-lspconfig.nvim",
|
||||
"hrsh7th/cmp-nvim-lsp",
|
||||
},
|
||||
config = function()
|
||||
local lspconfig = require("lspconfig")
|
||||
local capabilities = require("cmp_nvim_lsp").default_capabilities()
|
||||
|
||||
-- Keymaps applied whenever an LSP attaches to a buffer
|
||||
vim.api.nvim_create_autocmd("LspAttach", {
|
||||
callback = function(ev)
|
||||
local map = vim.keymap.set
|
||||
local opts = function(desc) return { buffer = ev.buf, desc = desc } end
|
||||
|
||||
map("n", "K", vim.lsp.buf.hover, opts("Hover docs"))
|
||||
map("n", "gd", vim.lsp.buf.definition, opts("Go to definition"))
|
||||
map("n", "gr", vim.lsp.buf.references, opts("References"))
|
||||
map("n", "<leader>rn", vim.lsp.buf.rename, opts("Rename symbol"))
|
||||
map("n", "<leader>ca", vim.lsp.buf.code_action, opts("Code action"))
|
||||
map("n", "<leader>d", vim.diagnostic.open_float, opts("Line diagnostics"))
|
||||
map("n", "[d", vim.diagnostic.goto_prev, opts("Prev diagnostic"))
|
||||
map("n", "]d", vim.diagnostic.goto_next, opts("Next diagnostic"))
|
||||
end,
|
||||
})
|
||||
|
||||
lspconfig.bashls.setup({ capabilities = capabilities })
|
||||
lspconfig.pyright.setup({ capabilities = capabilities })
|
||||
lspconfig.omnisharp.setup({ capabilities = capabilities })
|
||||
end,
|
||||
},
|
||||
}
|
||||
35
nvim/lua/plugins/telescope.lua
Normal file
35
nvim/lua/plugins/telescope.lua
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
-- Fuzzy finder — search files, text, buffers, recent files
|
||||
-- <leader>ff → find files
|
||||
-- <leader>fg → search text in project (live grep)
|
||||
-- <leader>fb → open buffers
|
||||
-- <leader>fr → recently opened files
|
||||
-- <leader>fh → help tags
|
||||
return {
|
||||
{
|
||||
"nvim-telescope/telescope.nvim",
|
||||
tag = "0.1.x",
|
||||
dependencies = {
|
||||
"nvim-lua/plenary.nvim",
|
||||
-- Optional: native FZF sorter for faster matching
|
||||
{ "nvim-telescope/telescope-fzf-native.nvim", build = "make" },
|
||||
},
|
||||
config = function()
|
||||
local telescope = require("telescope")
|
||||
local builtin = require("telescope.builtin")
|
||||
|
||||
telescope.setup({
|
||||
defaults = {
|
||||
path_display = { "smart" },
|
||||
},
|
||||
})
|
||||
pcall(telescope.load_extension, "fzf") -- load fzf if compiled ok
|
||||
|
||||
local map = vim.keymap.set
|
||||
map("n", "<leader>ff", builtin.find_files, { desc = "Find files" })
|
||||
map("n", "<leader>fg", builtin.live_grep, { desc = "Search in project" })
|
||||
map("n", "<leader>fb", builtin.buffers, { desc = "Open buffers" })
|
||||
map("n", "<leader>fr", builtin.oldfiles, { desc = "Recent files" })
|
||||
map("n", "<leader>fh", builtin.help_tags, { desc = "Help tags" })
|
||||
end,
|
||||
},
|
||||
}
|
||||
20
nvim/lua/plugins/treesitter.lua
Normal file
20
nvim/lua/plugins/treesitter.lua
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
-- Treesitter: better syntax highlighting and code understanding
|
||||
return {
|
||||
{
|
||||
"nvim-treesitter/nvim-treesitter",
|
||||
build = ":TSUpdate",
|
||||
config = function()
|
||||
require("nvim-treesitter.configs").setup({
|
||||
ensure_installed = {
|
||||
"lua", "vim", "vimdoc",
|
||||
"python", "bash",
|
||||
"c_sharp",
|
||||
"json", "yaml", "toml", "markdown",
|
||||
},
|
||||
auto_install = true,
|
||||
highlight = { enable = true },
|
||||
indent = { enable = true },
|
||||
})
|
||||
end,
|
||||
},
|
||||
}
|
||||
31
nvim/lua/plugins/ui.lua
Normal file
31
nvim/lua/plugins/ui.lua
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
-- Status line, buffer tabs, indent guides
|
||||
return {
|
||||
{
|
||||
"nvim-lualine/lualine.nvim",
|
||||
dependencies = { "nvim-tree/nvim-web-devicons" },
|
||||
config = function()
|
||||
require("lualine").setup({ options = { theme = "catppuccin" } })
|
||||
end,
|
||||
},
|
||||
|
||||
{
|
||||
"akinsho/bufferline.nvim",
|
||||
version = "*",
|
||||
dependencies = { "nvim-tree/nvim-web-devicons" },
|
||||
config = function()
|
||||
require("bufferline").setup({
|
||||
options = {
|
||||
diagnostics = "nvim_lsp", -- show LSP error counts on tabs
|
||||
},
|
||||
})
|
||||
end,
|
||||
},
|
||||
|
||||
{
|
||||
"lukas-reineke/indent-blankline.nvim",
|
||||
main = "ibl",
|
||||
config = function()
|
||||
require("ibl").setup()
|
||||
end,
|
||||
},
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue