mirror of
https://github.com/harivansh-afk/nvim.git
synced 2026-04-15 03:00:47 +00:00
nvim config
This commit is contained in:
commit
57407e8ef8
21 changed files with 984 additions and 0 deletions
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
/undodir
|
||||
.DS_Store
|
||||
20
.neoconf.json
Normal file
20
.neoconf.json
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
{
|
||||
"neodev": {
|
||||
"library": {
|
||||
"enabled": true,
|
||||
"plugins": true
|
||||
}
|
||||
},
|
||||
"neoconf": {
|
||||
"plugins": {
|
||||
"lua_ls": {
|
||||
"enabled": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"lspconfig": {
|
||||
"lua_ls": {
|
||||
"Lua.format.enable": false
|
||||
}
|
||||
}
|
||||
}
|
||||
7
.stylua.toml
Normal file
7
.stylua.toml
Normal file
|
|
@ -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"
|
||||
65
init.lua
Normal file
65
init.lua
Normal file
|
|
@ -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", "<leader>q", ":q<CR>", { desc = "Quit" })
|
||||
|
||||
-- Load plugins
|
||||
require("lazy").setup("plugins", {
|
||||
defaults = { lazy = true },
|
||||
performance = {
|
||||
rtp = {
|
||||
disabled_plugins = {
|
||||
"gzip",
|
||||
"matchit",
|
||||
"matchparen",
|
||||
"netrwPlugin",
|
||||
"tarPlugin",
|
||||
"tohtml",
|
||||
"zipPlugin",
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
32
lazy-lock.json
Normal file
32
lazy-lock.json
Normal file
|
|
@ -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" }
|
||||
}
|
||||
8
lua/plugins/arrow.lua
Normal file
8
lua/plugins/arrow.lua
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
return {
|
||||
"otavioschwanck/arrow.nvim",
|
||||
event = 'VeryLazy',
|
||||
opts = {
|
||||
show_icons = true,
|
||||
leader_key = '-'
|
||||
}
|
||||
}
|
||||
7
lua/plugins/autopairs.lua
Normal file
7
lua/plugins/autopairs.lua
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
return {
|
||||
"windwp/nvim-autopairs",
|
||||
event = "InsertEnter",
|
||||
config = function()
|
||||
require("nvim-autopairs").setup({})
|
||||
end,
|
||||
}
|
||||
130
lua/plugins/blink.lua
Normal file
130
lua/plugins/blink.lua
Normal file
|
|
@ -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",
|
||||
['<A-1>'] = { function(cmp) cmp.accept({ index = 1 }) end },
|
||||
['<A-2>'] = { function(cmp) cmp.accept({ index = 2 }) end },
|
||||
['<A-3>'] = { function(cmp) cmp.accept({ index = 3 }) end },
|
||||
['<A-4>'] = { function(cmp) cmp.accept({ index = 4 }) end },
|
||||
['<A-5>'] = { function(cmp) cmp.accept({ index = 5 }) end },
|
||||
['<A-6>'] = { function(cmp) cmp.accept({ index = 6 }) end },
|
||||
['<A-7>'] = { function(cmp) cmp.accept({ index = 7 }) end },
|
||||
['<A-8>'] = { function(cmp) cmp.accept({ index = 8 }) end },
|
||||
['<A-9>'] = { function(cmp) cmp.accept({ index = 9 }) end },
|
||||
['<A-0>'] = { 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",
|
||||
},
|
||||
}
|
||||
68
lua/plugins/colorscheme.lua
Normal file
68
lua/plugins/colorscheme.lua
Normal file
|
|
@ -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,
|
||||
},
|
||||
}
|
||||
14
lua/plugins/comment.lua
Normal file
14
lua/plugins/comment.lua
Normal file
|
|
@ -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,
|
||||
}
|
||||
18
lua/plugins/flash.lua
Normal file
18
lua/plugins/flash.lua
Normal file
|
|
@ -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" },
|
||||
{ "<c-s>", mode = { "c" }, function() require("flash").toggle() end, desc = "Toggle Flash Search" },
|
||||
},
|
||||
}
|
||||
72
lua/plugins/git.lua
Normal file
72
lua/plugins/git.lua
Normal file
|
|
@ -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 = {
|
||||
{ "<leader>gg", "<cmd>Neogit<cr>", desc = "Open Neogit" },
|
||||
{ "<leader>gc", "<cmd>Neogit commit<cr>", desc = "Git Commit" },
|
||||
{ "<leader>gp", "<cmd>Neogit push<cr>", desc = "Git Push" },
|
||||
{ "<leader>gl", "<cmd>Neogit pull<cr>", 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 = {
|
||||
{ "<leader>gdo", "<cmd>DiffviewOpen<cr>", desc = "Open Diffview" },
|
||||
{ "<leader>gdc", "<cmd>DiffviewClose<cr>", desc = "Close Diffview" },
|
||||
{ "<leader>gdh", "<cmd>DiffviewFileHistory<cr>", desc = "File History" },
|
||||
},
|
||||
},
|
||||
|
||||
-- Fugitive: Additional Git commands
|
||||
{
|
||||
'tpope/vim-fugitive',
|
||||
cmd = { 'Git', 'Gblame', 'Gdiff', 'Gread', 'Gwrite', 'Ggrep' },
|
||||
keys = {
|
||||
{ '<leader>gb', '<cmd>Git blame<cr>', desc = 'Git Blame' },
|
||||
{ '<leader>gd', '<cmd>Gdiff<cr>', desc = 'Git Diff (Fugitive)' },
|
||||
}
|
||||
},
|
||||
}
|
||||
15
lua/plugins/gitsigns.lua
Normal file
15
lua/plugins/gitsigns.lua
Normal file
|
|
@ -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,
|
||||
}
|
||||
57
lua/plugins/lsp.lua
Normal file
57
lua/plugins/lsp.lua
Normal file
|
|
@ -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", "<leader>rn", vim.lsp.buf.rename, opts)
|
||||
vim.keymap.set({ "n", "v" }, "<leader>ca", vim.lsp.buf.code_action, opts)
|
||||
vim.keymap.set("n", "gr", vim.lsp.buf.references, opts)
|
||||
vim.keymap.set("n", "<leader>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,
|
||||
},
|
||||
}
|
||||
20
lua/plugins/lualine.lua
Normal file
20
lua/plugins/lualine.lua
Normal file
|
|
@ -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'}
|
||||
},
|
||||
}
|
||||
}
|
||||
29
lua/plugins/neo-tree.lua
Normal file
29
lua/plugins/neo-tree.lua
Normal file
|
|
@ -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 = {
|
||||
{ "<leader>e", "<cmd>Neotree toggle<cr>", 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,
|
||||
}
|
||||
24
lua/plugins/telescope.lua
Normal file
24
lua/plugins/telescope.lua
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
return {
|
||||
"nvim-telescope/telescope.nvim",
|
||||
tag = "0.1.5",
|
||||
dependencies = { "nvim-lua/plenary.nvim" },
|
||||
cmd = "Telescope",
|
||||
keys = {
|
||||
{ "<leader>ff", "<cmd>Telescope find_files<cr>", desc = "Find files" },
|
||||
{ "<leader>fg", "<cmd>Telescope live_grep<cr>", desc = "Live grep" },
|
||||
{ "<leader>fb", "<cmd>Telescope buffers<cr>", desc = "Buffers" },
|
||||
{ "<leader>fh", "<cmd>Telescope help_tags<cr>", desc = "Help tags" },
|
||||
},
|
||||
config = function()
|
||||
require("telescope").setup({
|
||||
defaults = {
|
||||
mappings = {
|
||||
i = {
|
||||
["<C-j>"] = "move_selection_next",
|
||||
["<C-k>"] = "move_selection_previous",
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
end,
|
||||
}
|
||||
17
lua/plugins/treesitter.lua
Normal file
17
lua/plugins/treesitter.lua
Normal file
|
|
@ -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,
|
||||
}
|
||||
18
lua/plugins/which-key.lua
Normal file
18
lua/plugins/which-key.lua
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
return {
|
||||
"folke/which-key.nvim",
|
||||
event = 'VeryLazy',
|
||||
opts = {
|
||||
win = {
|
||||
border = { "┏", "━", "┓", "┃", "┛","━", "┗", "┃" },
|
||||
},
|
||||
},
|
||||
keys = {
|
||||
{
|
||||
"<leader>?",
|
||||
function()
|
||||
require("which-key").show({ global = false })
|
||||
end,
|
||||
desc = "Buffer Local Keymaps (which-key)",
|
||||
},
|
||||
},
|
||||
}
|
||||
139
nvim_cheatsheet.md
Normal file
139
nvim_cheatsheet.md
Normal file
|
|
@ -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)
|
||||
- `<leader>ff` - Find files
|
||||
- `<leader>fg` - Live grep (search in files)
|
||||
- `<leader>fb` - Browse buffers
|
||||
- `<leader>fh` - Help tags
|
||||
|
||||
### Neo-tree (File Explorer)
|
||||
- `<leader>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
|
||||
- `<leader>rn` - Rename symbol
|
||||
- `<leader>ca` - Code actions
|
||||
- `gr` - Find references
|
||||
- `<leader>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 `<leader>ff` to quickly find files
|
||||
- Use `<leader>fg` to search within files
|
||||
- Press `K` on any function/variable for documentation
|
||||
- Use `<leader>e` to toggle the file tree
|
||||
- Comment code quickly with `gcc`
|
||||
- Format code with `<leader>f`
|
||||
222
~/.config/nvim/check_issues.lua
Normal file
222
~/.config/nvim/check_issues.lua
Normal file
|
|
@ -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."
|
||||
Loading…
Add table
Add a link
Reference in a new issue