updated configuration

This commit is contained in:
2026-01-12 23:12:11 -07:00
parent 6d79fde026
commit dc98d50a31
14 changed files with 1219 additions and 224 deletions

View File

@@ -1,8 +1,108 @@
-- Autocmds are automatically loaded on the VeryLazy event
-- Default autocmds that are always set: https://github.com/LazyVim/LazyVim/blob/main/lua/lazyvim/config/autocmds.lua
--
-- Add any additional autocmds here
-- with `vim.api.nvim_create_autocmd`
--
-- Or remove existing autocmds by their group name (which is prefixed with `lazyvim_` for the defaults)
-- e.g. vim.api.nvim_del_augroup_by_name("lazyvim_wrap_spell")
-- Autocommands
local augroup = vim.api.nvim_create_augroup
local autocmd = vim.api.nvim_create_autocmd
-- Highlight on yank
augroup("YankHighlight", { clear = true })
autocmd("TextYankPost", {
group = "YankHighlight",
callback = function()
vim.highlight.on_yank({ higroup = "IncSearch", timeout = 200 })
end,
})
-- Resize splits when window is resized
augroup("ResizeSplits", { clear = true })
autocmd("VimResized", {
group = "ResizeSplits",
callback = function()
vim.cmd("tabdo wincmd =")
end,
})
-- Go to last location when opening a buffer
augroup("LastLocation", { clear = true })
autocmd("BufReadPost", {
group = "LastLocation",
callback = function(event)
local exclude = { "gitcommit" }
local buf = event.buf
if vim.tbl_contains(exclude, vim.bo[buf].filetype) or vim.b[buf].lazyvim_last_loc then
return
end
vim.b[buf].lazyvim_last_loc = true
local mark = vim.api.nvim_buf_get_mark(buf, '"')
local lcount = vim.api.nvim_buf_line_count(buf)
if mark[1] > 0 and mark[1] <= lcount then
pcall(vim.api.nvim_win_set_cursor, 0, mark)
end
end,
})
-- Close certain filetypes with q
augroup("CloseWithQ", { clear = true })
autocmd("FileType", {
group = "CloseWithQ",
pattern = {
"help",
"lspinfo",
"man",
"notify",
"qf",
"spectre_panel",
"startuptime",
"checkhealth",
},
callback = function(event)
vim.bo[event.buf].buflisted = false
vim.keymap.set("n", "q", "<cmd>close<cr>", { buffer = event.buf, silent = true })
end,
})
-- Auto create parent directories when saving
augroup("AutoCreateDir", { clear = true })
autocmd("BufWritePre", {
group = "AutoCreateDir",
callback = function(event)
if event.match:match("^%w%w+://") then
return
end
local file = vim.uv.fs_realpath(event.match) or event.match
vim.fn.mkdir(vim.fn.fnamemodify(file, ":p:h"), "p")
end,
})
-- Set specific options for certain filetypes
augroup("FileTypeSettings", { clear = true })
-- Go files: use tabs
autocmd("FileType", {
group = "FileTypeSettings",
pattern = "go",
callback = function()
vim.opt_local.expandtab = false
vim.opt_local.tabstop = 4
vim.opt_local.shiftwidth = 4
end,
})
-- Makefile: use tabs
autocmd("FileType", {
group = "FileTypeSettings",
pattern = "make",
callback = function()
vim.opt_local.expandtab = false
vim.opt_local.tabstop = 4
vim.opt_local.shiftwidth = 4
end,
})
-- Markdown: enable wrap
autocmd("FileType", {
group = "FileTypeSettings",
pattern = "markdown",
callback = function()
vim.opt_local.wrap = true
vim.opt_local.spell = true
end,
})

View File

@@ -1,13 +1,70 @@
-- Keymaps are automatically loaded on the VeryLazy event
-- Default keymaps that are always set: https://github.com/LazyVim/LazyVim/blob/main/lua/lazyvim/config/keymaps.lua
-- Add any additional keymaps here
-- Custom keymaps
local map = vim.keymap.set
vim.keymap.set("n", "<leader>th", function()
vim.cmd("lcd %:p:h")
-- Terminal keymaps
-- <leader>th - Open terminal in horizontal split
map("n", "<leader>th", function()
vim.cmd("split | terminal")
end, { desc = "Terminal (horizontal)" })
vim.cmd("startinsert")
end, { desc = "Terminal (horizontal split)" })
vim.keymap.set("n", "<leader>tv", function()
vim.cmd("lcd %:p:h")
-- <leader>tv - Open terminal in vertical split
map("n", "<leader>tv", function()
vim.cmd("vsplit | terminal")
end, { desc = "Terminal (vertical)" })
vim.cmd("startinsert")
end, { desc = "Terminal (vertical split)" })
-- Terminal mode: Escape to normal mode
map("t", "<Esc><Esc>", "<C-\\><C-n>", { desc = "Exit terminal mode" })
-- Explorer keymaps (Snacks explorer)
-- Ctrl+Shift+e - Toggle explorer
map("n", "<C-S-e>", function() Snacks.explorer() end, { desc = "Toggle Explorer" })
map("i", "<C-S-e>", function() Snacks.explorer() end, { desc = "Toggle Explorer" })
-- Note: Ctrl+Shift+v and Ctrl+Shift+h for opening files in splits
-- are configured in the snacks picker config (lua/plugins/editor.lua)
-- as they need to work within the explorer buffer context
-- Additional useful keymaps
-- Better window navigation
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" })
-- Resize windows with arrows
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" })
-- Buffer navigation
map("n", "<S-h>", "<cmd>bprevious<cr>", { desc = "Prev buffer" })
map("n", "<S-l>", "<cmd>bnext<cr>", { desc = "Next buffer" })
-- Clear search highlight
map("n", "<Esc>", "<cmd>nohlsearch<cr>", { desc = "Clear search highlight" })
-- Save file
map({ "n", "i", "v", "s" }, "<C-s>", "<cmd>w<cr><esc>", { desc = "Save file" })
-- Better indenting in visual mode
map("v", "<", "<gv")
map("v", ">", ">gv")
-- Move lines up/down
map("n", "<A-j>", "<cmd>m .+1<cr>==", { desc = "Move line down" })
map("n", "<A-k>", "<cmd>m .-2<cr>==", { desc = "Move line up" })
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" })
-- Quick access to AI chat
map("n", "<leader>aa", "<cmd>AvanteAsk<cr>", { desc = "AI Ask" })
map("v", "<leader>aa", "<cmd>AvanteAsk<cr>", { desc = "AI Ask (selection)" })
map("n", "<leader>ac", "<cmd>AvanteChat<cr>", { desc = "AI Chat" })
map("n", "<leader>at", "<cmd>AvanteToggle<cr>", { desc = "AI Toggle" })
-- Database keymaps
map("n", "<leader>db", "<cmd>DBUIToggle<cr>", { desc = "Toggle DB UI" })
map("n", "<leader>da", "<cmd>DBUIAddConnection<cr>", { desc = "Add DB Connection" })

View File

@@ -1,3 +1,4 @@
-- Bootstrap lazy.nvim
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not (vim.uv or vim.loop).fs_stat(lazypath) then
local lazyrepo = "https://github.com/folke/lazy.nvim.git"
@@ -14,45 +15,46 @@ if not (vim.uv or vim.loop).fs_stat(lazypath) then
end
vim.opt.rtp:prepend(lazypath)
-- Set leader keys before loading plugins
vim.g.mapleader = " "
vim.g.maplocalleader = "\\"
-- Setup lazy.nvim with LazyVim
require("lazy").setup({
spec = {
-- add LazyVim and import its plugins
{ "LazyVim/LazyVim", import = "lazyvim.plugins" },
-- Language support (these enable LSP, formatting, linting & DAP)
-- Import LazyVim and its plugins
{
"LazyVim/LazyVim",
import = "lazyvim.plugins",
opts = {
colorscheme = "tokyonight",
},
},
-- Import LazyVim extras for languages
{ import = "lazyvim.plugins.extras.lang.go" },
{ import = "lazyvim.plugins.extras.lang.python" },
{ import = "lazyvim.plugins.extras.lang.json" },
{ import = "lazyvim.plugins.extras.lang.yaml" },
{ import = "lazyvim.plugins.extras.lang.markdown" },
{ import = "lazyvim.plugins.extras.lang.typescript" },
{ import = "lazyvim.plugins.extras.lang.tailwind" },
{ import = "lazyvim.plugins.extras.lang.json" },
-- DAP (Debug Adapter Protocol)
-- DAP for debugging
{ import = "lazyvim.plugins.extras.dap.core" },
-- import/override with your plugins
-- Import custom plugins
{ import = "plugins" },
},
defaults = {
-- By default, only LazyVim plugins will be lazy-loaded. Your custom plugins will load during startup.
-- If you know what you're doing, you can set this to `true` to have all your custom plugins lazy-loaded by default.
lazy = false,
-- It's recommended to leave version=false for now, since a lot the plugin that support versioning,
-- have outdated releases, which may break your Neovim install.
version = false, -- always use the latest git commit
-- version = "*", -- try installing the latest stable version for plugins that support semver
version = false,
},
install = { colorscheme = { "tokyonight", "habamax" } },
checker = {
enabled = true, -- check for plugin updates periodically
notify = false, -- notify on update
}, -- automatically check for plugin updates
enabled = true,
notify = false,
},
performance = {
rtp = {
-- disable some rtp plugins
disabled_plugins = {
"gzip",
-- "matchit",
-- "matchparen",
-- "netrwPlugin",
"tarPlugin",
"tohtml",
"tutor",
@@ -61,3 +63,8 @@ require("lazy").setup({
},
},
})
-- Load custom config
require("config.options")
require("config.keymaps")
require("config.autocmds")

View File

@@ -1,3 +1,47 @@
-- Options are automatically loaded before lazy.nvim startup
-- Default options that are always set: https://github.com/LazyVim/LazyVim/blob/main/lua/lazyvim/config/options.lua
-- Add any additional options here
local opt = vim.opt
-- General
opt.clipboard = "unnamedplus" -- Sync with system clipboard
opt.confirm = true -- Confirm before closing unsaved buffer
opt.cursorline = true -- Highlight current line
opt.mouse = "a" -- Enable mouse
opt.number = true -- Show line numbers
opt.relativenumber = true -- Relative line numbers
opt.signcolumn = "yes" -- Always show sign column
opt.termguicolors = true -- True color support
opt.wrap = false -- Disable line wrap
-- Indentation
opt.expandtab = true -- Use spaces instead of tabs
opt.shiftwidth = 2 -- Size of indent
opt.tabstop = 2 -- Number of spaces tabs count for
opt.smartindent = true -- Smart indentation
-- Search
opt.ignorecase = true -- Ignore case
opt.smartcase = true -- Don't ignore case with capitals
opt.hlsearch = true -- Highlight search results
opt.incsearch = true -- Show search results as you type
-- Split behavior
opt.splitbelow = true -- Put new windows below current
opt.splitright = true -- Put new windows right of current
-- Undo
opt.undofile = true -- Persistent undo
opt.undolevels = 10000 -- Maximum undo levels
-- Performance
opt.updatetime = 200 -- Faster completion
opt.timeoutlen = 300 -- Faster key sequence completion
-- Completion
opt.completeopt = "menu,menuone,noselect"
-- Folding (using treesitter)
opt.foldmethod = "expr"
opt.foldexpr = "nvim_treesitter#foldexpr()"
opt.foldlevel = 99 -- Start with all folds open