From 57407e8ef891129ce63a9c5f6f23ad64d3a88bf4 Mon Sep 17 00:00:00 2001 From: Harivansh Rathi Date: Wed, 22 Oct 2025 22:19:33 -0400 Subject: [PATCH] nvim config --- .gitignore | 2 + .neoconf.json | 20 +++ .stylua.toml | 7 + init.lua | 65 ++++++++++ lazy-lock.json | 32 +++++ lua/plugins/arrow.lua | 8 ++ lua/plugins/autopairs.lua | 7 + lua/plugins/blink.lua | 130 +++++++++++++++++++ lua/plugins/colorscheme.lua | 68 ++++++++++ lua/plugins/comment.lua | 14 ++ lua/plugins/flash.lua | 18 +++ lua/plugins/git.lua | 72 +++++++++++ lua/plugins/gitsigns.lua | 15 +++ lua/plugins/lsp.lua | 57 ++++++++ lua/plugins/lualine.lua | 20 +++ lua/plugins/neo-tree.lua | 29 +++++ lua/plugins/telescope.lua | 24 ++++ lua/plugins/treesitter.lua | 17 +++ lua/plugins/which-key.lua | 18 +++ nvim_cheatsheet.md | 139 ++++++++++++++++++++ ~/.config/nvim/check_issues.lua | 222 ++++++++++++++++++++++++++++++++ 21 files changed, 984 insertions(+) create mode 100644 .gitignore create mode 100644 .neoconf.json create mode 100644 .stylua.toml create mode 100644 init.lua create mode 100644 lazy-lock.json create mode 100644 lua/plugins/arrow.lua create mode 100644 lua/plugins/autopairs.lua create mode 100644 lua/plugins/blink.lua create mode 100644 lua/plugins/colorscheme.lua create mode 100644 lua/plugins/comment.lua create mode 100644 lua/plugins/flash.lua create mode 100644 lua/plugins/git.lua create mode 100644 lua/plugins/gitsigns.lua create mode 100644 lua/plugins/lsp.lua create mode 100644 lua/plugins/lualine.lua create mode 100644 lua/plugins/neo-tree.lua create mode 100644 lua/plugins/telescope.lua create mode 100644 lua/plugins/treesitter.lua create mode 100644 lua/plugins/which-key.lua create mode 100644 nvim_cheatsheet.md create mode 100644 ~/.config/nvim/check_issues.lua diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..dfeb471 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +/undodir +.DS_Store diff --git a/.neoconf.json b/.neoconf.json new file mode 100644 index 0000000..2d7a81f --- /dev/null +++ b/.neoconf.json @@ -0,0 +1,20 @@ +{ + "neodev": { + "library": { + "enabled": true, + "plugins": true + } + }, + "neoconf": { + "plugins": { + "lua_ls": { + "enabled": true + } + } + }, + "lspconfig": { + "lua_ls": { + "Lua.format.enable": false + } + } +} diff --git a/.stylua.toml b/.stylua.toml new file mode 100644 index 0000000..bfcffff --- /dev/null +++ b/.stylua.toml @@ -0,0 +1,7 @@ +column_width = 120 +line_endings = "Unix" +indent_type = "Spaces" +indent_width = 2 +quote_style = "AutoPreferDouble" +call_parentheses = "None" +collapse_simple_statement = "Always" diff --git a/init.lua b/init.lua new file mode 100644 index 0000000..5ac7290 --- /dev/null +++ b/init.lua @@ -0,0 +1,65 @@ +-- Bootstrap lazy.nvim +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) + +-- Basic settings +vim.g.mapleader = " " +vim.g.maplocalleader = "," + +-- Essential vim options +vim.opt.number = true +vim.opt.relativenumber = true +vim.opt.tabstop = 2 +vim.opt.shiftwidth = 2 +vim.opt.expandtab = true +vim.opt.smartindent = true +vim.opt.wrap = true +vim.opt.swapfile = false +vim.opt.backup = false +vim.opt.undodir = os.getenv("HOME") .. "/.config/nvim/undodir" +vim.opt.undofile = true +vim.opt.hlsearch = false +vim.opt.incsearch = true +vim.opt.termguicolors = true +vim.opt.scrolloff = 8 +vim.opt.signcolumn = "yes" +vim.opt.updatetime = 50 +vim.opt.colorcolumn = "" +vim.opt.mouse = "a" +vim.opt.ignorecase = true +vim.opt.smartcase = true +vim.opt.splitbelow = true +vim.opt.splitright = true +vim.opt.cursorline = true +vim.opt.clipboard = "unnamedplus" + +-- Keymaps +vim.keymap.set("n", "q", ":q", { desc = "Quit" }) + +-- Load plugins +require("lazy").setup("plugins", { + defaults = { lazy = true }, + performance = { + rtp = { + disabled_plugins = { + "gzip", + "matchit", + "matchparen", + "netrwPlugin", + "tarPlugin", + "tohtml", + "zipPlugin", + }, + }, + }, +}) \ No newline at end of file diff --git a/lazy-lock.json b/lazy-lock.json new file mode 100644 index 0000000..5c93310 --- /dev/null +++ b/lazy-lock.json @@ -0,0 +1,32 @@ +{ + "Comment.nvim": { "branch": "master", "commit": "e30b7f2008e52442154b66f7c519bfd2f1e32acb" }, + "arrow.nvim": { "branch": "master", "commit": "6e0f726f55f99332dd726a53effd6813786b6d49" }, + "blink-cmp-copilot": { "branch": "main", "commit": "439cff78780c033aa23cf061d7315314b347e3c1" }, + "blink-ripgrep.nvim": { "branch": "main", "commit": "f8d4dc5d826ddfa7539472f3fbbe72646788534f" }, + "blink.cmp": { "branch": "main", "commit": "485c03400608cb6534bbf84da8c1c471fc4808c0" }, + "colorful-menu.nvim": { "branch": "master", "commit": "bc3e82609f2fcf7dad7ca87c20e65e51d5d9d87c" }, + "copilot.lua": { "branch": "master", "commit": "81d289a8ce5d4ee1dea9b1c8ee4ac376b2e27a5f" }, + "diffview.nvim": { "branch": "main", "commit": "4516612fe98ff56ae0415a259ff6361a89419b0a" }, + "flash.nvim": { "branch": "main", "commit": "3c942666f115e2811e959eabbdd361a025db8b63" }, + "friendly-snippets": { "branch": "main", "commit": "572f5660cf05f8cd8834e096d7b4c921ba18e175" }, + "gitsigns.nvim": { "branch": "main", "commit": "6e3c66548035e50db7bd8e360a29aec6620c3641" }, + "lazy.nvim": { "branch": "main", "commit": "6c3bda4aca61a13a9c63f1c1d1b16b9d3be90d7a" }, + "lazygit.nvim": { "branch": "main", "commit": "2305deed25bc61b866d5d39189e9105a45cf1cfb" }, + "lualine.nvim": { "branch": "master", "commit": "b8c23159c0161f4b89196f74ee3a6d02cdc3a955" }, + "mason-lspconfig.nvim": { "branch": "main", "commit": "5e085efe67fccb13372d54331d849219662a7e93" }, + "mason.nvim": { "branch": "main", "commit": "7dc4facca9702f95353d5a1f87daf23d78e31c2a" }, + "neo-tree.nvim": { "branch": "v3.x", "commit": "f1deac7ecec88c28a250d890ba7bb35843e69cbd" }, + "neogit": { "branch": "master", "commit": "6617978288d58eb121754b5dd890e893d9a7e8d6" }, + "nui.nvim": { "branch": "main", "commit": "de740991c12411b663994b2860f1a4fd0937c130" }, + "nvim-autopairs": { "branch": "master", "commit": "23320e75953ac82e559c610bec5a90d9c6dfa743" }, + "nvim-lspconfig": { "branch": "master", "commit": "c8b90ae5cbe21d547b342b05c9266dcb8ca0de8f" }, + "nvim-treesitter": { "branch": "master", "commit": "42fc28ba918343ebfd5565147a42a26580579482" }, + "nvim-web-devicons": { "branch": "master", "commit": "6e51ca170563330e063720449c21f43e27ca0bc1" }, + "plenary.nvim": { "branch": "master", "commit": "b9fd5226c2f76c951fc8ed5923d85e4de065e509" }, + "solarized.nvim": { "branch": "main", "commit": "c0dfe1cbfabd93b546baf5f1408f5df7e02e2050" }, + "telescope.nvim": { "branch": "master", "commit": "d90956833d7c27e73c621a61f20b29fdb7122709" }, + "tokyonight": { "branch": "main", "commit": "057ef5d260c1931f1dffd0f052c685dcd14100a3" }, + "vesper": { "branch": "main", "commit": "1717b1ad657c94bec3fc2bdebb0c55452d9fe46d" }, + "vim-fugitive": { "branch": "master", "commit": "61b51c09b7c9ce04e821f6cf76ea4f6f903e3cf4" }, + "which-key.nvim": { "branch": "main", "commit": "370ec46f710e058c9c1646273e6b225acf47cbed" } +} diff --git a/lua/plugins/arrow.lua b/lua/plugins/arrow.lua new file mode 100644 index 0000000..b17a973 --- /dev/null +++ b/lua/plugins/arrow.lua @@ -0,0 +1,8 @@ +return { + "otavioschwanck/arrow.nvim", + event = 'VeryLazy', + opts = { + show_icons = true, + leader_key = '-' + } +} \ No newline at end of file diff --git a/lua/plugins/autopairs.lua b/lua/plugins/autopairs.lua new file mode 100644 index 0000000..9d8c80c --- /dev/null +++ b/lua/plugins/autopairs.lua @@ -0,0 +1,7 @@ +return { + "windwp/nvim-autopairs", + event = "InsertEnter", + config = function() + require("nvim-autopairs").setup({}) + end, +} \ No newline at end of file diff --git a/lua/plugins/blink.lua b/lua/plugins/blink.lua new file mode 100644 index 0000000..6782f12 --- /dev/null +++ b/lua/plugins/blink.lua @@ -0,0 +1,130 @@ +return { + "saghen/blink.cmp", + lazy = false, + dependencies = { + "rafamadriz/friendly-snippets", + "zbirenbaum/copilot.lua", + "giuxtaposition/blink-cmp-copilot", + "mikavilpas/blink-ripgrep.nvim", + "xzbdmw/colorful-menu.nvim", + }, + + version = "v0.*", + opts = function() + local has_colorful, colorful = pcall(require, "colorful-menu") + + return { + keymap = { + preset = "super-tab", + [''] = { function(cmp) cmp.accept({ index = 1 }) end }, + [''] = { function(cmp) cmp.accept({ index = 2 }) end }, + [''] = { function(cmp) cmp.accept({ index = 3 }) end }, + [''] = { function(cmp) cmp.accept({ index = 4 }) end }, + [''] = { function(cmp) cmp.accept({ index = 5 }) end }, + [''] = { function(cmp) cmp.accept({ index = 6 }) end }, + [''] = { function(cmp) cmp.accept({ index = 7 }) end }, + [''] = { function(cmp) cmp.accept({ index = 8 }) end }, + [''] = { function(cmp) cmp.accept({ index = 9 }) end }, + [''] = { function(cmp) cmp.accept({ index = 10 }) end }, + }, + appearance = { + use_nvim_cmp_as_default = true, + nerd_font_variant = "mono", + kind_icons = { + Copilot = "", + Text = '󰉿', + Method = '󰊕', + Function = '󰊕', + Constructor = '󰒓', + + Field = '󰜢', + Variable = '󰆦', + Property = '󰖷', + + Class = '󱡠', + Interface = '󱡠', + Struct = '󱡠', + Module = '󰅩', + + Unit = '󰪚', + Value = '󰦨', + Enum = '󰦨', + EnumMember = '󰦨', + + Keyword = '󰻾', + Constant = '󰏿', + + Snippet = '󱄽', + Color = '󰏘', + File = '󰈔', + Reference = '󰬲', + Folder = '󰉋', + Event = '󱐋', + Operator = '󰪚', + TypeParameter = '󰬛', + }, + }, + completion = { + menu = { + border = "single", + draw = has_colorful and { + columns = { { "kind_icon" }, { "label", gap = 1 } }, + components = { + label = { + text = colorful.blink_components_text, + highlight = colorful.blink_components_highlight, + }, + }, + } or { + columns = { { "kind_icon" }, { "label", gap = 1 } }, + } + }, + documentation = { + window = { + border = "single", + } + } + }, + signature = { window = { border = 'single' } }, + cmdline = { enabled = true }, + sources = { + default = { "snippets", "lsp", "path", "buffer", "copilot", "ripgrep" }, + providers = { + copilot = { + name = "copilot", + module = "blink-cmp-copilot", + score_offset = 100, + async = true, + transform_items = function(_, items) + local CompletionItemKind = require("blink.cmp.types").CompletionItemKind + local kind_idx = #CompletionItemKind + 1 + CompletionItemKind[kind_idx] = "Copilot" + for _, item in ipairs(items) do + item.kind = kind_idx + end + return items + end, + }, + ripgrep = { + module = "blink-ripgrep", + name = "Ripgrep", + opts = { + prefix_min_len = 3, + backend = { + context_size = 5, + ripgrep = { + max_filesize = "1M", + additional_rg_options = {}, + }, + }, + }, + }, + }, + }, + } + end, + opts_extend = { + "sources.default", + "sources.providers", + }, +} \ No newline at end of file diff --git a/lua/plugins/colorscheme.lua b/lua/plugins/colorscheme.lua new file mode 100644 index 0000000..d793386 --- /dev/null +++ b/lua/plugins/colorscheme.lua @@ -0,0 +1,68 @@ +return { + { + "datsfilipe/vesper.nvim", + name = "vesper", + priority = 1000, + lazy = false, + }, + { + 'maxmx03/solarized.nvim', + lazy = false, + priority = 1000, + ---@type solarized.config + opts = {}, + }, + { + "folke/tokyonight.nvim", + name = "tokyonight", + priority = 1000, + lazy = false, + config = function() + -- Auto-detect light/dark mode + local function set_theme() + -- Check if running in VSCode + if vim.env.VSCODE or vim.env.TERM_PROGRAM == "vscode" then + vim.o.termguicolors = true + vim.o.background = "light" + require('solarized').setup({}) + vim.cmd.colorscheme("solarized") + return + end + + -- Check COLORFGBG for other terminals + if os.getenv("COLORFGBG") then + local colors = vim.split(os.getenv("COLORFGBG"), ";") + if colors[2] and tonumber(colors[2]) > 7 then + vim.o.termguicolors = true + vim.o.background = "light" + require('solarized').setup({}) + vim.cmd.colorscheme("solarized") + return + end + end + + -- Default to dark + vim.o.background = "dark" + require("vesper").setup({ transparent = true }) + vim.cmd.colorscheme("vesper") + end + + -- Set theme on startup + set_theme() + + -- Add command to manually toggle + vim.api.nvim_create_user_command("ToggleTheme", function() + if vim.g.colors_name == "vesper" then + vim.o.termguicolors = true + vim.o.background = "light" + require('solarized').setup({}) + vim.cmd.colorscheme("solarized") + else + vim.o.background = "dark" + require("vesper").setup({ transparent = true }) + vim.cmd.colorscheme("vesper") + end + end, {}) + end, + }, +} \ No newline at end of file diff --git a/lua/plugins/comment.lua b/lua/plugins/comment.lua new file mode 100644 index 0000000..7b88c01 --- /dev/null +++ b/lua/plugins/comment.lua @@ -0,0 +1,14 @@ +return { + "numToStr/Comment.nvim", + keys = { + { "gcc", mode = "n", desc = "Comment toggle current line" }, + { "gc", mode = { "n", "o" }, desc = "Comment toggle linewise" }, + { "gc", mode = "x", desc = "Comment toggle linewise (visual)" }, + { "gbc", mode = "n", desc = "Comment toggle current block" }, + { "gb", mode = { "n", "o" }, desc = "Comment toggle blockwise" }, + { "gb", mode = "x", desc = "Comment toggle blockwise (visual)" }, + }, + config = function() + require("Comment").setup() + end, +} \ No newline at end of file diff --git a/lua/plugins/flash.lua b/lua/plugins/flash.lua new file mode 100644 index 0000000..d578874 --- /dev/null +++ b/lua/plugins/flash.lua @@ -0,0 +1,18 @@ +return { + "folke/flash.nvim", + event = "VeryLazy", + opts = { + modes = { + search = { + enabled = true, + } + } + }, + keys = { + { "s", mode = { "n", "x", "o" }, function() require("flash").jump() end, desc = "Flash" }, + { "S", mode = { "n", "x", "o" }, function() require("flash").treesitter() end, desc = "Flash Treesitter" }, + { "r", mode = "o", function() require("flash").remote() end, desc = "Remote Flash" }, + { "R", mode = { "o", "x" }, function() require("flash").treesitter_search() end, desc = "Treesitter Search" }, + { "", mode = { "c" }, function() require("flash").toggle() end, desc = "Toggle Flash Search" }, + }, +} \ No newline at end of file diff --git a/lua/plugins/git.lua b/lua/plugins/git.lua new file mode 100644 index 0000000..0eed773 --- /dev/null +++ b/lua/plugins/git.lua @@ -0,0 +1,72 @@ +return { + -- Neogit: Modern Git interface with tree view + { + "NeogitOrg/neogit", + dependencies = { + "nvim-lua/plenary.nvim", -- required + "sindrets/diffview.nvim", -- optional - Diff integration + "nvim-telescope/telescope.nvim", -- optional + }, + config = function() + require('neogit').setup({ + -- Neo-tree style integration + kind = "split", + commit_editor = { + kind = "split", + }, + popup = { + kind = "split", + }, + -- Signs for different git states + signs = { + -- { CLOSED, OPENED } + hunk = { "", "" }, + item = { "", "" }, + section = { "", "" }, + }, + -- Integrations + integrations = { + telescope = true, + diffview = true, + }, + }) + end, + keys = { + { "gg", "Neogit", desc = "Open Neogit" }, + { "gc", "Neogit commit", desc = "Git Commit" }, + { "gp", "Neogit push", desc = "Git Push" }, + { "gl", "Neogit pull", desc = "Git Pull" }, + }, + }, + + -- Diffview: Enhanced diff viewing + { + "sindrets/diffview.nvim", + cmd = { "DiffviewOpen", "DiffviewClose", "DiffviewToggleFiles", "DiffviewFocusFiles" }, + config = function() + require("diffview").setup({ + diff_binaries = false, -- Show diffs for binaries + enhanced_diff_hl = false, -- See ':h diffview-config-enhanced_diff_hl' + git_cmd = { "git" }, -- The git executable followed by default args. + use_icons = true, -- Requires nvim-web-devicons + show_help_hints = true, -- Show hints for how to open the help panel + watch_index = true, -- Update views and index on git index changes. + }) + end, + keys = { + { "gdo", "DiffviewOpen", desc = "Open Diffview" }, + { "gdc", "DiffviewClose", desc = "Close Diffview" }, + { "gdh", "DiffviewFileHistory", desc = "File History" }, + }, + }, + + -- Fugitive: Additional Git commands + { + 'tpope/vim-fugitive', + cmd = { 'Git', 'Gblame', 'Gdiff', 'Gread', 'Gwrite', 'Ggrep' }, + keys = { + { 'gb', 'Git blame', desc = 'Git Blame' }, + { 'gd', 'Gdiff', desc = 'Git Diff (Fugitive)' }, + } + }, +} diff --git a/lua/plugins/gitsigns.lua b/lua/plugins/gitsigns.lua new file mode 100644 index 0000000..b217958 --- /dev/null +++ b/lua/plugins/gitsigns.lua @@ -0,0 +1,15 @@ +return { + "lewis6991/gitsigns.nvim", + event = { "BufReadPre", "BufNewFile" }, + config = function() + require("gitsigns").setup({ + signs = { + add = { text = "│" }, + change = { text = "│" }, + delete = { text = "_" }, + topdelete = { text = "‾" }, + changedelete = { text = "~" }, + }, + }) + end, +} \ No newline at end of file diff --git a/lua/plugins/lsp.lua b/lua/plugins/lsp.lua new file mode 100644 index 0000000..492787e --- /dev/null +++ b/lua/plugins/lsp.lua @@ -0,0 +1,57 @@ +return { + { + "neovim/nvim-lspconfig", + dependencies = { + "williamboman/mason.nvim", + "williamboman/mason-lspconfig.nvim", + }, + config = function() + require("mason").setup() + require("mason-lspconfig").setup({ + ensure_installed = { "lua_ls", "pyright", "tsserver" }, + automatic_installation = true, + }) + + local lspconfig = require("lspconfig") + local capabilities = vim.lsp.protocol.make_client_capabilities() + + -- Basic LSP keymaps + vim.api.nvim_create_autocmd("LspAttach", { + group = vim.api.nvim_create_augroup("UserLspConfig", {}), + callback = function(ev) + local opts = { buffer = ev.buf } + vim.keymap.set("n", "gD", vim.lsp.buf.declaration, opts) + vim.keymap.set("n", "gd", vim.lsp.buf.definition, opts) + vim.keymap.set("n", "K", vim.lsp.buf.hover, opts) + vim.keymap.set("n", "gi", vim.lsp.buf.implementation, opts) + vim.keymap.set("n", "rn", vim.lsp.buf.rename, opts) + vim.keymap.set({ "n", "v" }, "ca", vim.lsp.buf.code_action, opts) + vim.keymap.set("n", "gr", vim.lsp.buf.references, opts) + vim.keymap.set("n", "f", function() + vim.lsp.buf.format({ async = true }) + end, opts) + end, + }) + + -- Setup language servers + lspconfig.lua_ls.setup({ + capabilities = capabilities, + settings = { + Lua = { + diagnostics = { + globals = { "vim" }, + }, + }, + }, + }) + + lspconfig.pyright.setup({ + capabilities = capabilities, + }) + + lspconfig.tsserver.setup({ + capabilities = capabilities, + }) + end, + }, +} \ No newline at end of file diff --git a/lua/plugins/lualine.lua b/lua/plugins/lualine.lua new file mode 100644 index 0000000..2b8f66e --- /dev/null +++ b/lua/plugins/lualine.lua @@ -0,0 +1,20 @@ +return { + 'nvim-lualine/lualine.nvim', + event = 'VeryLazy', + dependencies = { 'nvim-tree/nvim-web-devicons' }, + opts = { + options = { + theme = 'auto', + component_separators = { left = '', right = '' }, + section_separators = { left = '', right = '' }, + }, + sections = { + lualine_a = {'mode'}, + lualine_b = {'branch', 'diff', 'diagnostics'}, + lualine_c = {'filename'}, + lualine_x = {'encoding', 'fileformat', 'filetype'}, + lualine_y = {'progress'}, + lualine_z = {'location'} + }, + } +} \ No newline at end of file diff --git a/lua/plugins/neo-tree.lua b/lua/plugins/neo-tree.lua new file mode 100644 index 0000000..bcc0b7e --- /dev/null +++ b/lua/plugins/neo-tree.lua @@ -0,0 +1,29 @@ +return { + "nvim-neo-tree/neo-tree.nvim", + branch = "v3.x", + dependencies = { + "nvim-lua/plenary.nvim", + "nvim-tree/nvim-web-devicons", + "MunifTanjim/nui.nvim", + }, + cmd = "Neotree", + keys = { + { "e", "Neotree toggle", desc = "Toggle file explorer" }, + }, + config = function() + require("neo-tree").setup({ + close_if_last_window = true, + window = { + width = 30, + }, + filesystem = { + filtered_items = { + visible = true, -- Show filtered items (hidden files) + hide_dotfiles = false, -- Show dotfiles + hide_gitignored = false, -- Show git ignored files + hide_hidden = false, -- Show hidden files on Windows + }, + }, + }) + end, +} \ No newline at end of file diff --git a/lua/plugins/telescope.lua b/lua/plugins/telescope.lua new file mode 100644 index 0000000..dedc95d --- /dev/null +++ b/lua/plugins/telescope.lua @@ -0,0 +1,24 @@ +return { + "nvim-telescope/telescope.nvim", + tag = "0.1.5", + dependencies = { "nvim-lua/plenary.nvim" }, + cmd = "Telescope", + keys = { + { "ff", "Telescope find_files", desc = "Find files" }, + { "fg", "Telescope live_grep", desc = "Live grep" }, + { "fb", "Telescope buffers", desc = "Buffers" }, + { "fh", "Telescope help_tags", desc = "Help tags" }, + }, + config = function() + require("telescope").setup({ + defaults = { + mappings = { + i = { + [""] = "move_selection_next", + [""] = "move_selection_previous", + }, + }, + }, + }) + end, +} \ No newline at end of file diff --git a/lua/plugins/treesitter.lua b/lua/plugins/treesitter.lua new file mode 100644 index 0000000..c68d0cf --- /dev/null +++ b/lua/plugins/treesitter.lua @@ -0,0 +1,17 @@ +return { + "nvim-treesitter/nvim-treesitter", + build = ":TSUpdate", + event = { "BufReadPost", "BufNewFile" }, + config = function() + require("nvim-treesitter.configs").setup({ + ensure_installed = { "lua", "vim", "vimdoc", "query", "javascript", "typescript", "python", "html", "css", "json", "yaml", "markdown" }, + auto_install = true, + highlight = { + enable = true, + }, + indent = { + enable = true, + }, + }) + end, +} \ No newline at end of file diff --git a/lua/plugins/which-key.lua b/lua/plugins/which-key.lua new file mode 100644 index 0000000..9c490b3 --- /dev/null +++ b/lua/plugins/which-key.lua @@ -0,0 +1,18 @@ +return { + "folke/which-key.nvim", + event = 'VeryLazy', + opts = { + win = { + border = { "┏", "━", "┓", "┃", "┛","━", "┗", "┃" }, + }, + }, + keys = { + { + "?", + function() + require("which-key").show({ global = false }) + end, + desc = "Buffer Local Keymaps (which-key)", + }, + }, +} \ No newline at end of file diff --git a/nvim_cheatsheet.md b/nvim_cheatsheet.md new file mode 100644 index 0000000..6c450a4 --- /dev/null +++ b/nvim_cheatsheet.md @@ -0,0 +1,139 @@ +# Neovim Configuration Cheat Sheet + +## Leader Keys +- **Leader**: `Space` +- **Local Leader**: `,` + +## Basic Vim Shortcuts + +### Navigation +- `h j k l` - Move left, down, up, right +- `w` - Move forward by word +- `b` - Move backward by word +- `0` - Move to beginning of line +- `$` - Move to end of line +- `gg` - Go to top of file +- `G` - Go to bottom of file +- `Ctrl+u` - Scroll up half page +- `Ctrl+d` - Scroll down half page +- `Ctrl+o` - Jump back to previous location +- `Ctrl+i` - Jump forward to next location + +### Editing +- `i` - Insert mode before cursor +- `a` - Insert mode after cursor +- `o` - Insert new line below and enter insert mode +- `O` - Insert new line above and enter insert mode +- `dd` - Delete current line +- `yy` - Yank (copy) current line +- `p` - Paste after cursor +- `P` - Paste before cursor +- `u` - Undo +- `Ctrl+r` - Redo +- `x` - Delete character under cursor +- `r` - Replace character under cursor + +### Visual Mode +- `v` - Visual mode (character selection) +- `V` - Visual line mode +- `Ctrl+v` - Visual block mode +- `y` - Yank selection +- `d` - Delete selection + +### Search & Replace +- `/` - Search forward +- `?` - Search backward +- `n` - Next search result +- `N` - Previous search result +- `:%s/old/new/g` - Replace all occurrences + +## Plugin Shortcuts + +### Telescope (File Navigation) +- `ff` - Find files +- `fg` - Live grep (search in files) +- `fb` - Browse buffers +- `fh` - Help tags + +### Neo-tree (File Explorer) +- `e` - Toggle file explorer + +### Comment.nvim (Code Commenting) +- `gcc` - Toggle comment on current line +- `gc` - Toggle comment (linewise) +- `gbc` - Toggle block comment on current line +- `gb` - Toggle block comment + +### LSP (Language Server Protocol) +- `gD` - Go to declaration +- `gd` - Go to definition +- `K` - Show hover information +- `gi` - Go to implementation +- `rn` - Rename symbol +- `ca` - Code actions +- `gr` - Find references +- `f` - Format code + +### Window Management +- `Ctrl+w h` - Move to left window +- `Ctrl+w j` - Move to bottom window +- `Ctrl+w k` - Move to top window +- `Ctrl+w l` - Move to right window +- `Ctrl+w v` - Split window vertically +- `Ctrl+w s` - Split window horizontally +- `Ctrl+w q` - Close current window + +### Buffer Management +- `:bnext` or `:bn` - Next buffer +- `:bprev` or `:bp` - Previous buffer +- `:bd` - Delete/close buffer +- `:ls` - List all buffers + +## Features Enabled + +### Auto-completion & Pairs +- Automatic bracket, quote, and parentheses pairing +- Smart indentation + +### Git Integration (Gitsigns) +- Git change indicators in the gutter +- Visual indicators for added (`│`), changed (`│`), deleted (`_`) lines + +### Syntax Highlighting (Treesitter) +- Enhanced syntax highlighting for: + - Lua, Vim, JavaScript, TypeScript + - Python, HTML, CSS, JSON, YAML, Markdown + +### Language Servers (LSP) +- **Lua**: lua_ls +- **Python**: pyright +- **JavaScript/TypeScript**: tsserver +- Automatic installation via Mason + +### Theme +- **Vesper** colorscheme with true color support + +## Configuration Details + +### Editor Settings +- Line numbers with relative numbering +- 2-space indentation +- No swap files, persistent undo +- Case-insensitive search (smart case) +- Clipboard integration with system +- 80-character color column +- Mouse support enabled +- Auto-split below and right + +### Performance Optimizations +- Lazy loading for most plugins +- Disabled unused vim plugins (gzip, netrw, etc.) +- Fast updatetime (50ms) + +## Quick Tips +- Use `ff` to quickly find files +- Use `fg` to search within files +- Press `K` on any function/variable for documentation +- Use `e` to toggle the file tree +- Comment code quickly with `gcc` +- Format code with `f` \ No newline at end of file diff --git a/~/.config/nvim/check_issues.lua b/~/.config/nvim/check_issues.lua new file mode 100644 index 0000000..80875ac --- /dev/null +++ b/~/.config/nvim/check_issues.lua @@ -0,0 +1,222 @@ +-- AstroNvim diagnostics script +-- This script helps identify common issues with AstroNvim configuration + +local REPORT_FILE = "/tmp/astronvim_diagnostics.json" + +-- Common error patterns to suppress in notifications +local ERROR_PATTERNS = { + "not a real value for ensure_installed", + "position_params", + "offset_encoding", + "failed to get treesitter parser", + "treesitter query error" +} + +-- Original notify function for capturing notifications +local orig_notify = vim.notify +local all_notifications = {} + +-- Function to check if message contains an error pattern +local function matches_error_pattern(msg) + if type(msg) ~= "string" then return false end + + for _, pattern in ipairs(ERROR_PATTERNS) do + if msg:match(pattern) then + return true + end + end + return false +end + +-- Intercept notifications +vim.notify = function(msg, level, opts) + -- Record the notification + table.insert(all_notifications, { + msg = msg, + level = level, + opts = opts, + is_error = (level == vim.log.levels.ERROR or matches_error_pattern(msg)) + }) + + -- Suppress known errors + if matches_error_pattern(msg) then + return + end + + return orig_notify(msg, level, opts) +end + +-- Run diagnostics +local function run_diagnostics() + local report = { + nvim_version = vim.version(), + astronvim_version = require("version").version or "unknown", + timestamp = os.time(), + notifications = all_notifications, + errors = {}, + warnings = {}, + loaded_plugins = {}, + checks = {} + } + + -- Check if critical plugins are loaded + local critical_plugins = { + "nvim-treesitter", + "mason", + "mason-lspconfig", + "lazy", + "astrocore" + } + + for _, plugin in ipairs(critical_plugins) do + local is_loaded = package.loaded[plugin] ~= nil + report.loaded_plugins[plugin] = is_loaded + + if not is_loaded then + table.insert(report.warnings, { + type = "plugin_not_loaded", + plugin = plugin + }) + end + end + + -- Check Treesitter + report.checks.treesitter = {} + if package.loaded["nvim-treesitter"] then + local ok, ts_info = pcall(function() + local data = {} + + -- Check configs + data.has_configs = package.loaded["nvim-treesitter.configs"] ~= nil + + -- Check parsers + if package.loaded["nvim-treesitter.parsers"] then + local parsers = require("nvim-treesitter.parsers") + data.available_parsers = parsers.available_parsers() + + -- Check core parsers + local core_parsers = {"c", "lua", "vim", "vimdoc", "query"} + data.core_parsers_status = {} + + for _, parser in ipairs(core_parsers) do + data.core_parsers_status[parser] = parsers.has_parser(parser) + if not parsers.has_parser(parser) then + table.insert(report.errors, { + type = "missing_core_parser", + parser = parser + }) + end + end + end + + return data + end) + + if ok then + report.checks.treesitter = ts_info + else + report.checks.treesitter.error = tostring(ts_info) + table.insert(report.errors, { + type = "treesitter_check_failed", + error = tostring(ts_info) + }) + end + end + + -- Check Mason + report.checks.mason = {} + if package.loaded["mason"] then + local ok, mason_info = pcall(function() + local data = {} + + -- Check registry + data.has_registry = package.loaded["mason-registry"] ~= nil + + -- Check installed packages + if package.loaded["mason-registry"] then + local registry = require("mason-registry") + data.installed_packages = {} + + for _, pkg in ipairs(registry.get_installed_packages()) do + table.insert(data.installed_packages, pkg.name) + end + end + + return data + end) + + if ok then + report.checks.mason = mason_info + else + report.checks.mason.error = tostring(mason_info) + table.insert(report.errors, { + type = "mason_check_failed", + error = tostring(mason_info) + }) + end + end + + -- Extract error notifications + for _, notif in ipairs(all_notifications) do + if notif.is_error then + table.insert(report.errors, { + type = "error_notification", + msg = notif.msg, + level = notif.level + }) + end + end + + -- Save report + local file = io.open(REPORT_FILE, "w") + if file then + file:write(vim.json.encode(report)) + file:close() + print("Diagnostic report written to " .. REPORT_FILE) + else + print("Failed to write diagnostic report to " .. REPORT_FILE) + end + + -- Print summary + print("\n=== AstroNvim Diagnostic Summary ===") + print("NeoVim version: " .. vim.version().major .. "." .. vim.version().minor .. "." .. vim.version().patch) + + if #report.errors > 0 then + print("\nErrors (" .. #report.errors .. "):") + for i, err in ipairs(report.errors) do + print(" " .. i .. ". " .. err.type .. ": " .. (err.msg or err.error or "")) + end + else + print("\nNo errors detected!") + end + + if #report.warnings > 0 then + print("\nWarnings (" .. #report.warnings .. "):") + for i, warn in ipairs(report.warnings) do + print(" " .. i .. ". " .. warn.type .. ": " .. (warn.plugin or "")) + end + else + print("\nNo warnings detected!") + end + + print("\nSteps to fix common issues:") + print("1. Run ':Lazy sync' to update and synchronize plugins") + print("2. Run ':MasonUpdate' to update Mason packages") + print("3. Run ':TSUpdate' to update all Treesitter parsers") + print("\nFor more details, check " .. REPORT_FILE) + + return report +end + +-- Run diagnostics after a short delay to allow plugins to load +vim.defer_fn(function() + run_diagnostics() + + -- Exit if in headless mode + if vim.g.headless then + vim.cmd("quit") + end +end, 1000) + +-- Return a message for interactive use +return "Running AstroNvim diagnostics... Results will appear shortly."