-- ====================== -- 1. Basic Configuration -- ====================== vim.g.mapleader = " " vim.g.maplocalleader = " " -- Editor Settings vim.opt.number = true vim.opt.relativenumber = true vim.opt.mouse = "a" vim.opt.showmode = false vim.opt.clipboard = "unnamedplus" vim.opt.breakindent = true vim.opt.undofile = true vim.opt.ignorecase = true vim.opt.smartcase = true vim.opt.signcolumn = "yes" vim.opt.updatetime = 250 vim.opt.timeoutlen = 300 vim.opt.splitright = true vim.opt.splitbelow = true vim.opt.list = true vim.opt.listchars = { tab = "» ", trail = "·", nbsp = "␣" } vim.opt.inccommand = "split" vim.opt.cursorline = true vim.opt.scrolloff = 10 vim.opt.hlsearch = true vim.opt.termguicolors = true vim.opt.expandtab = true vim.opt.tabstop = 2 vim.opt.shiftwidth = 2 vim.opt.smartindent = true vim.opt.wrap = false vim.opt.swapfile = false vim.opt.backup = false vim.opt.writebackup = false -- Smoother scrolling vim.opt.smoothscroll = true -- ====================== -- 2. Plugin Management -- ====================== 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) -- ====================== -- 3. Plugin Specifications (Updated) -- ====================== local plugins = { -- Theme (unchanged) { "drewtempelmeyer/palenight.vim", priority = 1000, config = function() vim.g.palenight_terminal_italics = 1 vim.cmd("colorscheme palenight") end, }, -- File Explorer { "nvim-neo-tree/neo-tree.nvim", branch = "v3.x", dependencies = { "nvim-lua/plenary.nvim", "nvim-tree/nvim-web-devicons", "MunifTanjim/nui.nvim" }, }, -- Fuzzy Finder { "nvim-telescope/telescope.nvim", dependencies = { "nvim-lua/plenary.nvim" } }, -- LSP Configuration { "neovim/nvim-lspconfig", dependencies = { "williamboman/mason.nvim", "williamboman/mason-lspconfig.nvim", "WhoIsSethDaniel/mason-tool-installer.nvim", { "j-hui/fidget.nvim", opts = {} }, { "folke/neodev.nvim", opts = {} }, }, }, -- Enhanced Autocompletion { "hrsh7th/nvim-cmp", event = "InsertEnter", dependencies = { "L3MON4D3/LuaSnip", "saadparwaiz1/cmp_luasnip", "hrsh7th/cmp-nvim-lsp", "hrsh7th/cmp-path", "hrsh7th/cmp-buffer", "rafamadriz/friendly-snippets", }, }, -- Auto Pairs { "windwp/nvim-autopairs", event = "InsertEnter", config = true, }, -- Git Integration { "lewis6991/gitsigns.nvim", opts = {} }, { "tpope/vim-fugitive" }, { "kdheepak/lazygit.nvim", dependencies = { "nvim-lua/plenary.nvim" } }, { "akinsho/git-conflict.nvim", version = "*" }, -- UI Enhancements { "nvim-lualine/lualine.nvim", dependencies = { "nvim-tree/nvim-web-devicons" }, opts = { options = { theme = "palenight", component_separators = { left = '', right = '' }, section_separators = { left = '', right = '' }, } }, }, -- Modern tab/bufferline with animations { "akinsho/bufferline.nvim", version = "*", dependencies = "nvim-tree/nvim-web-devicons", opts = { options = { mode = "tabs", diagnostics = "nvim_lsp", always_show_bufferline = true, show_close_icon = false, color_icons = true, offsets = { { filetype = "neo-tree", text = "File Explorer", highlight = "Directory", text_align = "left", }, }, hover = { enabled = true, delay = 200, reveal = { 'close' } }, } } }, -- Better split resizing with animations { "anuvyklack/windows.nvim", dependencies = { "anuvyklack/middleclass", "anuvyklack/animation.nvim" }, config = function() vim.o.winwidth = 10 vim.o.winminwidth = 10 vim.o.equalalways = false require('windows').setup({ autowidth = { enable = true, winwidth = 10, filetype = { help = 2, }, }, ignore = { buftype = { 'quickfix' }, filetype = { 'NvimTree', 'neo-tree', 'undotree', 'gundo' } }, animation = { enable = true, duration = 300, fps = 30, easing = 'in_out_sine' } }) end }, -- Better indent guides { "lukas-reineke/indent-blankline.nvim", main = "ibl", opts = { indent = { char = "│" }, scope = { enabled = true }, } }, -- Syntax & Editing { "nvim-treesitter/nvim-treesitter", build = ":TSUpdate" }, { "numToStr/Comment.nvim", opts = {} }, -- Productivity { "akinsho/toggleterm.nvim", version = "*", config = true }, { "folke/which-key.nvim", event = "VimEnter" }, { "stevearc/conform.nvim" }, { "mfussenegger/nvim-lint", event = { "BufReadPre", "BufNewFile" } }, -- Smooth scrolling { "karb94/neoscroll.nvim", config = true }, -- Better notifications { "rcarriga/nvim-notify", config = function() vim.notify = require("notify") end } } -- ====================== -- 4. Plugin Configuration -- ====================== require("lazy").setup(plugins, { ui = { icons = vim.g.have_nerd_font and {} or { cmd = "⌘", config = "🛠", event = "📅", ft = "📂", init = "⚙", keys = "🗝", plugin = "🔌", runtime = "💻", require = "🌙", source = "📄", start = "🚀", task = "📌", lazy = "💤 ", }, }, }) -- Neo-tree Configuration require("neo-tree").setup({ close_if_last_window = false, popup_border_style = "rounded", enable_git_status = true, enable_diagnostics = true, filesystem = { follow_current_file = { enabled = true }, hijack_netrw_behavior = "open_current", use_libuv_file_watcher = true, }, window = { position = "right", width = 30, mappings = { [""] = "none", ["o"] = "open", [""] = "open", ["t"] = "open_tabnew", ["v"] = "open_vsplit", ["s"] = "open_split", ["r"] = "rename", ["d"] = "delete", ["a"] = "add", ["A"] = "add_directory", ["R"] = "refresh", ["."] = "toggle_hidden", }, }, }) -- Telescope Configuration require("telescope").setup({ defaults = { mappings = { i = { [""] = "move_selection_next", [""] = "move_selection_previous", [""] = "move_selection_next", [""] = "move_selection_previous", [""] = "select_tab", [""] = "select_vertical", [""] = "select_horizontal", [""] = "clear_prompt", [""] = "close", }, }, layout_strategy = "flex", layout_config = { horizontal = { preview_width = 0.6, }, }, }, pickers = { find_files = { theme = "dropdown", }, live_grep = { theme = "dropdown", }, }, }) -- LSP Setup local capabilities = vim.lsp.protocol.make_client_capabilities() capabilities = require("cmp_nvim_lsp").default_capabilities(capabilities) capabilities.textDocument.completion.completionItem.snippetSupport = true require("mason").setup() require("mason-lspconfig").setup({ ensure_installed = { "lua_ls", "pyright", "ruff", "ts_ls", "html", "cssls", "tailwindcss", "bashls", "jsonls", "yamlls", "dockerls" }, }) local lspconfig = require("lspconfig") lspconfig.lua_ls.setup({ capabilities = capabilities, settings = { Lua = { completion = { callSnippet = "Replace" }, diagnostics = { globals = { "vim" } }, workspace = { checkThirdParty = false }, telemetry = { enable = false }, }, }, }) for _, server in ipairs({ "pyright", "ts_ls", "html", "cssls", "bashls", "jsonls" }) do lspconfig[server].setup({ capabilities = capabilities }) end -- Completion Setup local cmp = require("cmp") local luasnip = require("luasnip") require("luasnip.loaders.from_vscode").lazy_load() local has_words_before = function() unpack = unpack or table.unpack local line, col = unpack(vim.api.nvim_win_get_cursor(0)) return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil end cmp.setup({ snippet = { expand = function(args) luasnip.lsp_expand(args.body) end, }, mapping = cmp.mapping.preset.insert({ [""] = cmp.mapping(function(fallback) if cmp.visible() then cmp.select_next_item() elseif luasnip.expand_or_locally_jumpable() then luasnip.expand_or_jump() elseif has_words_before() then cmp.complete() else fallback() end end, { "i", "s" }), [""] = 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" }), [""] = cmp.mapping.confirm({ behavior = cmp.ConfirmBehavior.Replace, select = false, }), [""] = cmp.mapping.complete(), }), sources = cmp.config.sources({ { name = "nvim_lsp" }, { name = "luasnip" }, { name = "path" }, { name = "buffer" }, }), }) -- ====================== -- 5. Key Mappings (Enhanced) -- ====================== -- 🚀 General Keybinds vim.keymap.set("n", "e", vim.diagnostic.open_float) vim.keymap.set("n", "[d", vim.diagnostic.goto_prev) vim.keymap.set("n", "]d", vim.diagnostic.goto_next) vim.keymap.set("n", "n", ":Neotree toggle") vim.keymap.set("n", "ff", ":Telescope find_files") vim.keymap.set("n", "fg", ":Telescope live_grep") vim.keymap.set("n", "gs", ":Git") vim.keymap.set("n", "gg", ":LazyGit") -- 📝 Editing vim.keymap.set("n", "gd", vim.lsp.buf.definition) vim.keymap.set("n", "gr", vim.lsp.buf.references) vim.keymap.set("n", "K", vim.lsp.buf.hover) vim.keymap.set("n", "rn", vim.lsp.buf.rename) -- 💻 LSP vim.keymap.set("n", "d", vim.diagnostic.setloclist) vim.keymap.set("n", "ca", vim.lsp.buf.code_action) vim.keymap.set("n", "f", function() vim.lsp.buf.format({ async = true }) end) vim.keymap.set("n", "wa", vim.lsp.buf.add_workspace_folder) vim.keymap.set("n", "wr", vim.lsp.buf.remove_workspace_folder) vim.keymap.set("n", "wl", function() print(vim.inspect(vim.lsp.buf.list_workspace_folders())) end) -- 💾 Buffer/Tab Management vim.keymap.set("n", "bd", ":bdelete") vim.keymap.set("n", "bn", ":BufferLineCycleNext") vim.keymap.set("n", "bp", ":BufferLineCyclePrev") vim.keymap.set("n", "bl", ":Telescope buffers") vim.keymap.set("n", "1", ":BufferLineGoToBuffer 1") vim.keymap.set("n", "2", ":BufferLineGoToBuffer 2") vim.keymap.set("n", "3", ":BufferLineGoToBuffer 3") vim.keymap.set("n", "4", ":BufferLineGoToBuffer 4") vim.keymap.set("n", "5", ":BufferLineGoToBuffer 5") -- 🖥️ Window Management vim.keymap.set("n", "", "h") vim.keymap.set("n", "", "j") vim.keymap.set("n", "", "k") vim.keymap.set("n", "", "l") -- Split resizing with Ctrl+Arrow keys vim.keymap.set("n", "", ":resize +2") vim.keymap.set("n", "", ":resize -2") vim.keymap.set("n", "", ":vertical resize -2") vim.keymap.set("n", "", ":vertical resize +2") -- Maximize current split vim.keymap.set("n", "wm", ":WindowsMaximize") -- 🐱 Git vim.keymap.set("n", "gc", ":Git commit") vim.keymap.set("n", "gp", ":Git push") vim.keymap.set("n", "gl", ":Telescope git_commits") vim.keymap.set("n", "gd", ":Gdiff") vim.keymap.set("n", "gb", ":Git blame") -- 🔄 Terminal vim.keymap.set("t", "", "") vim.keymap.set("t", "", "") vim.keymap.set("n", "tt", ":ToggleTerm") vim.keymap.set("n", "tf", ":ToggleTerm direction=float") -- ====================== -- 6. Autocommands -- ====================== vim.api.nvim_create_autocmd("TextYankPost", { pattern = "*", callback = function() vim.highlight.on_yank() end, }) vim.api.nvim_create_autocmd("BufWritePre", { pattern = "*", callback = function() require("conform").format({ async = false, lsp_fallback = true }) end, }) -- Enable treesitter require("nvim-treesitter.configs").setup({ ensure_installed = { "lua", "python", "javascript", "typescript", "html", "css", "bash", "json", "yaml" }, highlight = { enable = true }, indent = { enable = true }, incremental_selection = { enable = true, keymaps = { init_selection = "gnn", node_incremental = "grn", scope_incremental = "grc", node_decremental = "grm", }, }, }) -- Enable smooth scrolling require('neoscroll').setup({ mappings = { '', '', '', '' }, hide_cursor = true, stop_eof = true, respect_scrolloff = false, cursor_scrolls_alone = true, }) -- Enable better window management require('windows').setup()