init commit

This commit is contained in:
Aditya Gupta
2026-06-19 16:51:18 +05:30
commit 16434d2dbc
14 changed files with 380 additions and 0 deletions

2
init.lua Normal file
View File

@@ -0,0 +1,2 @@
require("config.lazy")

20
lazy-lock.json Normal file
View File

@@ -0,0 +1,20 @@
{
"lazy.nvim": { "branch": "main", "commit": "306a05526ada86a7b30af95c5cc81ffba93fef97" },
"lualine.nvim": { "branch": "master", "commit": "221ce6b2d999187044529f49da6554a92f740a96" },
"mini.ai": { "branch": "main", "commit": "bfb26d9072670c3aaefab0f53024b2f3729c8083" },
"mini.bracketed": { "branch": "main", "commit": "e50e3abcf6a3a5d234f58e4a247dfb3035f30a65" },
"mini.comment": { "branch": "main", "commit": "a0c721115faff8d05505c0a12dab410084d9e536" },
"mini.cursorword": { "branch": "main", "commit": "dda0f57d55bb1fa19423b7201b2ba892c7d2bb3c" },
"mini.indentscope": { "branch": "main", "commit": "0308f949f31769e509696af5d5f91cebb2159c69" },
"mini.move": { "branch": "main", "commit": "4d214202d71e0a4066b6288176bbe88f268f9777" },
"mini.pairs": { "branch": "main", "commit": "d5a29b6254dad07757832db505ea5aeab9aad43a" },
"mini.surround": { "branch": "main", "commit": "88c52297ed3e69ecf9f8652837888ecc727a28ee" },
"mini.tabline": { "branch": "main", "commit": "caf23615b9b99bacc79ecd60f61c4e6a8ec18c84" },
"mini.trailspace": { "branch": "main", "commit": "f8083ca969e1b2098480c10f3c3c4d2ce3586680" },
"nvim-tree.lua": { "branch": "master", "commit": "85d1145ac71c1b8e1423862c78165a1f609faf60" },
"nvim-treesitter": { "branch": "main", "commit": "4916d6592ede8c07973490d9322f187e07dfefac" },
"nvim-web-devicons": { "branch": "master", "commit": "dfbfaa967a6f7ec50789bead7ef87e336c1fa63c" },
"plenary.nvim": { "branch": "master", "commit": "74b06c6c75e4eeb3108ec01852001636d85a932b" },
"telescope-fzf-native.nvim": { "branch": "main", "commit": "b25b749b9db64d375d782094e2b9dce53ad53a40" },
"telescope.nvim": { "branch": "master", "commit": "5255aa27c422de944791318024167ad5d40aad20" }
}

68
lua/config/autocmds.lua Normal file
View File

@@ -0,0 +1,68 @@
-- ================================================================================================
-- TITLE : auto-commands
-- ABOUT : automatically run code on defined events (e.g. save, yank)
-- ================================================================================================
-- local on_attach = require("utils.lsp").on_attach
-- Restore last cursor position when reopening a file
local last_cursor_group = vim.api.nvim_create_augroup("LastCursorGroup", {})
vim.api.nvim_create_autocmd("BufReadPost", {
group = last_cursor_group,
callback = function()
local mark = vim.api.nvim_buf_get_mark(0, '"')
local lcount = vim.api.nvim_buf_line_count(0)
if mark[1] > 0 and mark[1] <= lcount then
pcall(vim.api.nvim_win_set_cursor, 0, mark)
end
end,
})
-- Highlight the yanked text for 200ms
local highlight_yank_group = vim.api.nvim_create_augroup("HighlightYank", {})
vim.api.nvim_create_autocmd("TextYankPost", {
group = highlight_yank_group,
pattern = "*",
callback = function()
vim.hl.on_yank({
higroup = "IncSearch",
timeout = 200,
})
end,
})
--
-- -- format on save using efm langserver and configured formatters
-- local lsp_fmt_group = vim.api.nvim_create_augroup("FormatOnSaveGroup", {})
-- vim.api.nvim_create_autocmd("BufWritePre", {
-- group = lsp_fmt_group,
-- callback = function()
-- require("mini.trailspace").trim()
-- local efm = vim.lsp.get_clients({ name = "efm" })
-- if vim.tbl_isempty(efm) then
-- return
-- end
-- vim.lsp.buf.format({ name = "efm", async = true })
-- end,
-- })
--
-- -- on attach function shortcuts
-- local lsp_on_attach_group = vim.api.nvim_create_augroup("LspMappings", {})
-- vim.api.nvim_create_autocmd("LspAttach", {
-- group = lsp_on_attach_group,
-- callback = on_attach,
-- })
--
-- custom options for text/markdown files
local markdown_options = vim.api.nvim_create_augroup("MardownOptions", {})
vim.api.nvim_create_autocmd("FileType", {
group = markdown_options,
pattern = { "markdown", "text", "gitcommit" },
callback = function()
vim.opt_local.wrap = true
vim.opt_local.linebreak = true
vim.opt_local.relativenumber = false
vim.opt_local.number = false
vim.opt_local.cursorline = false
vim.opt_local.colorcolumn = ""
vim.opt_local.signcolumn = "no"
end,
})

2
lua/config/globals.lua Normal file
View File

@@ -0,0 +1,2 @@
vim.g.mapleader = " "
vim.g.maplocalleader = " "

25
lua/config/keymaps.lua Normal file
View File

@@ -0,0 +1,25 @@
vim.g.mapleader = " "
vim.g.maplocalleader = " "
vim.keymap.set("n", "<leader>bn", ":bnext<CR>", { desc = "Next buffer" })
vim.keymap.set("n", "<leader>bp", ":bprevious<CR>", { desc = "Previous buffer" })
vim.keymap.set("n", "<leader>sv", ":vsplit<CR>", { desc = "Split window vertically" })
vim.keymap.set("n", "<leader>sh", ":split<CR>", { desc = "Split window horizontally" })
vim.keymap.set("n", "<C-Up>", ":resize +2<CR>", { desc = "Increase window height" })
vim.keymap.set("n", "<C-Down>", ":resize -2<CR>", { desc = "Decrease window height" })
vim.keymap.set("n", "<C-Left>", ":vertical resize -2<CR>", { desc = "Decrease window width" })
vim.keymap.set("n", "<C-Right>", ":vertical resize +2<CR>", { desc = "Increase window width" })
vim.keymap.set("n", "<A-j>", ":m .+1<CR>==", { desc = "Move line down" })
vim.keymap.set("n", "<A-k>", ":m .-2<CR>==", { desc = "Move line up" })
vim.keymap.set("v", "<A-j>", ":m '>+1<CR>gv=gv", { desc = "Move selection down" })
vim.keymap.set("v", "<A-k>", ":m '<-2<CR>gv=gv", { desc = "Move selection up" })
vim.keymap.set("n", "<leader>e", "<Cmd>NvimTreeToggle<CR>", {desc = "Togle Nvim Tree"})
-- Telescope keymaps (loaded on demand)
vim.keymap.set('n', '<leader><leader>', function() require('telescope.builtin').find_files() end, { desc = 'Telescope find files' })
vim.keymap.set('n', '<leader>fg', function() require('telescope.builtin').live_grep() end, { desc = 'Telescope live grep' })
vim.keymap.set('n', '<leader>fb', function() require('telescope.builtin').buffers() end, { desc = 'Telescope buffers' })
vim.keymap.set('n', '<leader>fh', function() require('telescope.builtin').help_tags() end, { desc = 'Telescope help tags' })

42
lua/config/lazy.lua Normal file
View File

@@ -0,0 +1,42 @@
-- 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"
local out = vim.fn.system({ "git", "clone", "--filter=blob:none", "--branch=stable", lazyrepo, lazypath })
if vim.v.shell_error ~= 0 then
vim.api.nvim_echo({
{ "Failed to clone lazy.nvim:\n", "ErrorMsg" },
{ out, "WarningMsg" },
{ "\nPress any key to exit..." },
}, true, {})
vim.fn.getchar()
os.exit(1)
end
end
vim.opt.rtp:prepend(lazypath)
require("config.options")
require("config.keymaps")
require("config.globals")
require("config.autocmds")
-- Setup lazy.nvim
require("lazy").setup({
spec = {
-- import your plugins
{ import = "plugins" },
},
rtp = {
disabled_plugins = {
"netrw",
"netrwPlugin"
}
},
-- Configure any other settings here. See the documentation for more details.
-- colorscheme that will be used when installing plugins.
install = { colorscheme = { "melange" } },
-- automatically check for plugin updates
checker = { enabled = true },
})

95
lua/config/options.lua Normal file
View File

@@ -0,0 +1,95 @@
-- ================================================================================================
-- TITLE : NeoVim options
-- ABOUT : basic settings native to neovim
-- ================================================================================================
-- Basic Settings
vim.opt.number = true -- Line numbers
vim.opt.relativenumber = true -- Relative line numbers
vim.opt.cursorline = true -- Highlight current line
vim.opt.scrolloff = 10 -- Keep 10 lines above/below cursor
vim.opt.sidescrolloff = 8 -- Keep 8 columns left/right of cursor
vim.opt.wrap = false -- Don't wrap lines
vim.opt.cmdheight = 1 -- Command line height
vim.opt.spelllang = { "en", "de" } -- Set language for spellchecking
-- Tabbing / Indentation
vim.opt.tabstop = 2 -- Tab width
vim.opt.shiftwidth = 2 -- Indent width
vim.opt.softtabstop = 2 -- Soft tab stop
vim.opt.expandtab = true -- Use spaces instead of tabs
vim.opt.smartindent = true -- Smart auto-indenting
vim.opt.autoindent = true -- Copy indent from current line
vim.opt.grepprg = "rg --vimgrep" -- Use ripgrep if available
vim.opt.grepformat = "%f:%l:%c:%m" -- filename, line number, column, content
-- Search Settings
vim.opt.ignorecase = true -- Case-insensitive search
vim.opt.smartcase = true -- Case-sensitive if uppercase in search
vim.opt.hlsearch = false -- Don't highlight search results
vim.opt.incsearch = true -- Show matches as you type
-- Visual Settings
vim.opt.termguicolors = true -- Enable 24-bit colors
vim.opt.signcolumn = "yes" -- Always show sign column
vim.opt.colorcolumn = "100" -- Show column at 100 characters
vim.opt.showmatch = true -- Highlight matching brackets
vim.opt.matchtime = 2 -- How long to show matching bracket
vim.opt.completeopt = "menuone,noinsert,noselect" -- Completion options
vim.opt.showmode = false -- Don't show mode in command line
vim.opt.pumheight = 10 -- Popup menu height
vim.opt.pumblend = 10 -- Popup menu transparency
vim.opt.winblend = 0 -- Floating window transparency
vim.opt.conceallevel = 2 -- Obsidian requirement
vim.opt.concealcursor = "" -- Show markup even on cursor line
vim.opt.redrawtime = 10000 -- Timeout for syntax highlighting redraw
vim.opt.maxmempattern = 20000 -- Max memory for pattern matching
vim.opt.synmaxcol = 300 -- Syntax highlighting column limit
-- File Handling
vim.opt.backup = false -- Don't create backup files
vim.opt.writebackup = false -- Don't backup before overwriting
vim.opt.swapfile = false -- Don't create swap files
vim.opt.undofile = true -- Persistent undo
vim.opt.updatetime = 300 -- Time in ms to trigger CursorHold
vim.opt.timeoutlen = 500 -- Time in ms to wait for mapped sequence
vim.opt.ttimeoutlen = 0 -- No wait for key code sequences
vim.opt.autoread = true -- Auto-reload file if changed outside
vim.opt.autowrite = false -- Don't auto-save on some events
vim.opt.diffopt:append("vertical") -- Vertical diff splits
vim.opt.diffopt:append("algorithm:patience") -- Better diff algorithm
vim.opt.diffopt:append("linematch:60") -- Better diff highlighting (smart line matching)
-- Set undo directory and ensure it exists
local undodir = "~/.local/share/nvim/undodir" -- Undo directory path
vim.opt.undodir = vim.fn.expand(undodir) -- Expand to full path
local undodir_path = vim.fn.expand(undodir)
if vim.fn.isdirectory(undodir_path) == 0 then
vim.fn.mkdir(undodir_path, "p") -- Create if not exists
end
-- Behavior Settings
vim.opt.errorbells = false -- Disable error sounds
vim.opt.backspace = "indent,eol,start" -- Make backspace behave naturally
vim.opt.autochdir = false -- Don't change directory automatically
vim.opt.iskeyword:append("-") -- Treat dash as part of a word
vim.opt.path:append("**") -- Search into subfolders with `gf`
vim.opt.selection = "inclusive" -- Use inclusive selection
vim.opt.mouse = "a" -- Enable mouse support
vim.opt.clipboard:append("unnamedplus") -- Use system clipboard
vim.opt.modifiable = true -- Allow editing buffers
vim.opt.encoding = "UTF-8" -- Use UTF-8 encoding
vim.opt.wildmenu = true -- Enable command-line completion menu
vim.opt.wildmode = "longest:full,full" -- Completion mode for command-line
vim.opt.wildignorecase = true -- Case-insensitive tab completion in commands
-- Cursor Settings
-- Folding Settings
vim.opt.foldmethod = "expr" -- Use expression for folding
vim.opt.foldexpr = "v:lua.vim.treesitter.foldexpr()" -- Use treesitter for folding
vim.opt.foldlevel = 99 -- Keep all folds open by default
-- Split Behavior
vim.opt.splitbelow = true -- Horizontal splits open below
vim.opt.splitright = true -- Vertical splits open to the right

21
lua/plugins/lualine.lua Normal file
View File

@@ -0,0 +1,21 @@
-- ================================================================================================
-- TITLE : lualine.nvim
-- LINKS :
-- > github : https://github.com/nvim-lualine/lualine.nvim
-- ABOUT : A blazing fast and easy to configure Neovim statusline written in Lua.
-- ================================================================================================
return {
"nvim-lualine/lualine.nvim",
config = function()
require("lualine").setup({
options = {
-- theme = "melange",
icons_enabled = true,
section_separators = { left = "", right = "" },
component_separators = "|",
},
})
end,
dependencies = { "nvim-tree/nvim-web-devicons" },
}

13
lua/plugins/mini-nvim.lua Normal file
View File

@@ -0,0 +1,13 @@
return {
{"nvim-mini/mini.ai", version = "*", opts = {}},
{"nvim-mini/mini.comment", version = "*", opts = {}},
{"nvim-mini/mini.move", version = "*", opts = {}},
{"nvim-mini/mini.cursorword", version = "*", opts= {}},
{ 'nvim-mini/mini.bracketed', version = '*' },
{ 'nvim-mini/mini.surround', version = '*' },
{ 'nvim-mini/mini.pairs', version = '*' },
{ 'nvim-mini/mini.indentscope', version = '*' },
{ 'nvim-mini/mini.trailspace', version = '*' },
{ 'nvim-mini/mini.tabline', version = '*' },
}

19
lua/plugins/nvim-tree.lua Normal file
View File

@@ -0,0 +1,19 @@
return {
"nvim-tree/nvim-tree.lua",
version = "*",
lazy = false,
dependencies = {
"nvim-tree/nvim-web-devicons",
},
config = function()
-- vim.cmd([[hi NvimTreeNormal guibg=NONE ctermbd=NONE]])
require("nvim-tree").setup {
filters= {
dotfiles = false,
},
view = {
adaptive_size = true,
}
}
end,
}

View File

@@ -0,0 +1 @@
return { 'nvim-telescope/telescope-fzf-native.nvim', build = 'cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release && cmake --build build --config Release --target install' }

View File

@@ -0,0 +1,8 @@
return {
'nvim-telescope/telescope.nvim', version = '*',
dependencies = {
'nvim-lua/plenary.nvim',
-- optional but recommended
{ 'nvim-telescope/telescope-fzf-native.nvim', build = 'make' },
}
}

View File

@@ -0,0 +1,61 @@
return {
"nvim-treesitter/nvim-treesitter",
branch = "main",
build = ":TSUpdate",
event = { "BufReadPost", "BufNewFile" },
lazy = false,
config = function()
local treesitter = require("nvim-treesitter")
treesitter.setup({})
local ensure_installed = {
"lua",
"python",
"bash",
"typescript",
"javascript",
"html",
"css",
"json",
"yaml",
"go",
"markdown",
"dockerfile",
"markdown_inline",
"c",
"cpp",
"vue",
"rust",
"java",
"regex",
"svelte",
"tsx",
"xml",
"astro"
}
local config = require("nvim-treesitter.config")
local already_installed = config.get_installed()
local parsers_to_install = {}
for _, parser in ipairs(ensure_installed) do
if not vim.tbl_contains(already_installed, parser) then
table.insert(parsers_to_install, parser)
end
end
if #parsers_to_install > 0 then
treesitter.install(parsers_to_install)
end
local group = vim.api.nvim_create_augroup("TreeSitterConfig", { clear = true })
vim.api.nvim_create_autocmd("FileType", {
group = group,
callback = function(args)
if vim.list_contains(treesitter.get_installed(), vim.treesitter.language.get_lang(args.match)) then
vim.treesitter.start(args.buf)
end
end,
})
end,
}

View File

@@ -0,0 +1,3 @@
return {"nvim-tree/nvim-web-devicons", opts={}}