This commit is contained in:
2025-06-17 22:33:09 +08:00
parent 956b146cb2
commit 0bde25e91d
28 changed files with 858 additions and 40 deletions

19
lua/plug/ext_git.lua Normal file
View File

@ -0,0 +1,19 @@
return {
{
"lewis6991/gitsigns.nvim",
event = "VeryLazy",
opts = {
current_line_blame = true,
current_line_blame_opts = {
virt_text = true,
virt_text_pos = "right_align",
delay = 1000,
ignore_whitespace = false,
},
},
config = function(_, opts)
require("gitsigns").setup(opts)
end,
},
}

View File

@ -0,0 +1,78 @@
return {
{
"Wansmer/symbol-usage.nvim",
event = "BufReadPre",
config = function()
local function h(name)
return vim.api.nvim_get_hl(0, { name = name })
end
-- hl-groups can have any name
vim.api.nvim_set_hl(0, "SymbolUsageRounding", { fg = h("CursorLine").bg, italic = true })
vim.api.nvim_set_hl(
0,
"SymbolUsageContent",
{ bg = h("CursorLine").bg, fg = h("Comment").fg, italic = true }
)
vim.api.nvim_set_hl(0, "SymbolUsageRef", { fg = h("Function").fg, bg = h("CursorLine").bg, italic = true })
vim.api.nvim_set_hl(0, "SymbolUsageDef", { fg = h("Type").fg, bg = h("CursorLine").bg, italic = true })
vim.api.nvim_set_hl(0, "SymbolUsageImpl", { fg = h("@keyword").fg, bg = h("CursorLine").bg, italic = true })
local function text_format(symbol)
local res = {}
local round_start = { "", "SymbolUsageRounding" }
local round_end = { "", "SymbolUsageRounding" }
-- Indicator that shows if there are any other symbols in the same line
local stacked_functions_content = symbol.stacked_count > 0 and ("+%s"):format(symbol.stacked_count)
or ""
if symbol.references then
local usage = symbol.references <= 1 and "usage" or "usages"
local num = symbol.references == 0 and "no" or symbol.references
table.insert(res, round_start)
table.insert(res, { "󰌹 ", "SymbolUsageRef" })
table.insert(res, { ("%s %s"):format(num, usage), "SymbolUsageContent" })
table.insert(res, round_end)
end
if symbol.definition then
if #res > 0 then
table.insert(res, { " ", "NonText" })
end
table.insert(res, round_start)
table.insert(res, { "󰳽 ", "SymbolUsageDef" })
table.insert(res, { symbol.definition .. " defs", "SymbolUsageContent" })
table.insert(res, round_end)
end
if symbol.implementation then
if #res > 0 then
table.insert(res, { " ", "NonText" })
end
table.insert(res, round_start)
table.insert(res, { "󰡱 ", "SymbolUsageImpl" })
table.insert(res, { symbol.implementation .. " impls", "SymbolUsageContent" })
table.insert(res, round_end)
end
if stacked_functions_content ~= "" then
if #res > 0 then
table.insert(res, { " ", "NonText" })
end
table.insert(res, round_start)
table.insert(res, { "", "SymbolUsageImpl" })
table.insert(res, { stacked_functions_content, "SymbolUsageContent" })
table.insert(res, round_end)
end
return res
end
require("symbol-usage").setup({
text_format = text_format,
})
end,
},
}

View File

@ -0,0 +1,17 @@
return {
{
-- FIX: Tag Test
-- TODO: Tag test
-- HACK: Tag test
-- WARN: Tag test
-- PERF: Tag test
-- NOTE: Tag test
-- TEST: Tag test
"folke/todo-comments.nvim",
dependencies = { "nvim-lua/plenary.nvim" },
event = "VeryLazy",
config = function()
require("todo-comments").setup()
end,
},
}

View File

@ -0,0 +1,35 @@
return {
{
"akinsho/bufferline.nvim",
event = "VeryLazy",
version = "*",
dependencies = {
"nvim-tree/nvim-web-devicons",
},
opts = {
options = {
numbers = "buffer_id",
right_mouse_command = false,
-- underline
indicator = {
icon = '',
style = 'underline',
},
-- diagnostics
diagnostics = "nvim_lsp",
diagnostics_indicator = function(count, level)
local icons = require("nvim-web-devicons").get_icons()
local icon_error = icons.diagnostic_error.icon
local icon_warn = icons.diagnostic_warn.icon
local icon = level:match("error") and icon_error or icon_warn
return " " .. icon .. " " .. count
end,
separator_style = "slant",
always_show_bufferline = false,
},
},
config = function(_, opts)
require("bufferline").setup(opts)
end,
},
}

View File

@ -0,0 +1,40 @@
return {
{
"folke/tokyonight.nvim",
config = function(_, opts)
vim.cmd.colorscheme("tokyonight-night")
end,
},
{
"loctvl842/monokai-pro.nvim",
event = "VeryLazy",
enabled = false,
opts = {
transparent_background = false,
terminal_colors = true,
devicons = true,
filter = "machine",
background_clear = {
"float_win",
"telescope",
"renamer",
"notify",
"neo-tree",
},
plugins = {
bufferline = {
underline_selected = true,
underline_visible = true,
},
indent_blankline = {
context_highlight = "pro", -- default | pro
context_start_underline = false,
},
},
},
config = function(_, opts)
require("monokai-pro").setup(opts)
vim.cmd.colorscheme("monokai-pro")
end,
},
}

30
lua/plug/gui_filetree.lua Normal file
View File

@ -0,0 +1,30 @@
return {
{
"nvim-neo-tree/neo-tree.nvim",
branch = "v3.x",
cmd = "Neotree",
dependencies = {
"nvim-lua/plenary.nvim",
"nvim-tree/nvim-web-devicons",
"MunifTanjim/nui.nvim",
},
opts = {
filesystem = {
follow_current_file = { enabled = true },
},
},
config = function(_, opts)
local icons = require("nvim-web-devicons").get_icons()
vim.fn.sign_define("DiagnosticSignError",
{ text = icons.diagnostic_error.icon, texthl = "DiagnosticSignError"})
vim.fn.sign_define("DiagnosticSignWarn",
{ text = icons.diagnostic_warn.icon, texthl = "DiagnosticSignWarn"})
vim.fn.sign_define("DiagnosticSignInfo",
{ text = icons.diagnostic_info.icon, texthl = "DiagnosticSignInfo"})
vim.fn.sign_define("DiagnosticSignHint",
{ text = icons.diagnostic_hint.icon, texthl = "DiagnosticSignHint"})
require("neo-tree").setup(opts)
end,
},
}

View File

@ -0,0 +1,45 @@
return {
{
"lukas-reineke/indent-blankline.nvim",
event = "VeryLazy",
opts = {
indent = {
char = "",
tab_char = "",
},
},
main = "ibl",
config = function(_, opts)
require("ibl").setup(opts)
end,
},
{
"echasnovski/mini.indentscope",
version = false,
event = "VeryLazy",
opts = {
symbol = "",
options = { try_as_border = true },
},
init = function()
vim.api.nvim_create_autocmd("FileType", {
pattern = {
"help",
"alpha",
"dashboard",
"neo-tree",
"Trouble",
"trouble",
"lazy",
"mason",
"notify",
"toggleterm",
"lazyterm",
},
callback = function()
vim.b.miniindentscope_disable = true
end,
})
end,
},
}

View File

@ -0,0 +1,20 @@
return {
{
"nvim-lualine/lualine.nvim",
event = "VeryLazy",
dependencies = {
"nvim-tree/nvim-web-devicons",
},
opts = {
options = {
globalstatus = true,
theme = "molokai",
-- section_separators = { left = "", right = "" },
-- component_separators = { left = "", right = "" },
},
},
config = function(_, opts)
require("lualine").setup(opts)
end,
},
}

View File

@ -0,0 +1,25 @@
return {
{
"folke/which-key.nvim",
event = "VeryLazy",
init = function()
vim.o.timeout = true
vim.o.timeoutlen = 300
end,
config = function()
local wk = require("which-key")
wk.add({
{ "<leader>f", group = "File" },
{ "<leader>fo", ":Neotree position=float<cr>", desc = "open" },
{ "<leader>fx", ":q<cr>", desc = "exit" },
{ "<leader>v", group = "View" },
{ "<leader>vf", ":Neotree position=left toggle<cr>", desc = "explorer" },
{ "<leader>vo", ":AerialToggle<cr>", desc = "outline" },
{ "<leader>b", group = "Buffer" },
{ "<leader>bn", ":bn<cr>", desc = "next" },
{ "<leader>bp", ":bp<cr>", desc = "prev" },
{ "<leader>bd", ":bd<cr>", desc = "delete" },
})
end,
},
}

36
lua/plug/libraries.lua Normal file
View File

@ -0,0 +1,36 @@
return {
-- Provides Nerd Font icons (glyphs) for use by neovim plugins
{
"nvim-tree/nvim-web-devicons",
config = function()
require("nvim-web-devicons").set_icon({
diagnostic_error = {
icon = "",
color = "#e8274b",
name = "DiagnosticError"
},
diagnostic_warn = {
icon = "",
color = "#cbcb41",
name = "DiagnosticWarn"
},
diagnostic_info = {
icon = "",
color = "#00c58e",
name = "DiagnosticInfo"
},
diagnostic_hint = {
icon = "󰌵",
name = "DiagnosticHint"
},
})
end,
},
-- plenary: full; complete; entire; absolute; unqualified.
-- All the lua functions I don't want to write twice.
{ "nvim-lua/plenary.nvim" },
-- UI Component Library for Neovim.
{ "MunifTanjim/nui.nvim" },
-- Promise & Async in Lua
{ "kevinhwang91/promise-async" },
}

View File

@ -0,0 +1,93 @@
return {
{
"hrsh7th/nvim-cmp",
event = "VeryLazy",
dependencies = {
-- sources
{ "hrsh7th/cmp-nvim-lsp" },
{ "hrsh7th/cmp-nvim-lua" },
{ "hrsh7th/cmp-buffer" },
{ "hrsh7th/cmp-path" },
{ "hrsh7th/cmp-nvim-lsp-document-symbol" },
-- snippets
{ "L3MON4D3/LuaSnip" },
{ "saadparwaiz1/cmp_luasnip" },
{ "rafamadriz/friendly-snippets" },
-- lsp diagnostics
{ "hrsh7th/cmp-nvim-lsp-signature-help" },
{ "onsails/lspkind.nvim" },
},
config = function()
local cmp = require("cmp")
local lspkind = require("lspkind")
local luasnip = require("luasnip")
cmp.setup({
snippet = {
expand = function(args)
require("luasnip").lsp_expand(args.body) -- Luasnip expand
end,
},
window = {
completion = { border = "rounded" },
documentation = { border = "rounded" },
},
mapping = {
["<CR>"] = cmp.mapping(function(fallback)
if cmp.visible() then
if luasnip.expandable() then
luasnip.expand()
else
cmp.confirm({ select = true })
end
else
fallback()
end
end),
["<Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_next_item()
elseif luasnip.locally_jumpable(1) then
luasnip.jump(1)
else
fallback()
end
end, { "i", "s" }),
["S-<Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_prev_item()
elseif luasnip.locally_jumpable(-1) then
luasnip.jump(-1)
else
fallback()
end
end, { "i", "s" }),
},
sources = cmp.config.sources({
{ name = "nvim_lsp" },
{ name = "nvim_lsp_signature_help" },
{ name = "nvim_lsp_document_symbol" },
{ name = "nvim_lua" },
{ name = "luasnip" },
}, {
{ name = "buffer" },
{ name = "path" },
}),
formatting = {
format = lspkind.cmp_format({
mode = "symbol_text",
maxwidth = function() return math.floor(0.5 * vim.o.columns) end,
ellipsis_char = "...",
show_labelDetails = true,
before = function(_, vim_item)
return vim_item
end,
}),
},
})
-- Add snippets from Friendly Snippets
require("luasnip/loaders/from_vscode").lazy_load()
end,
},
}

View File

@ -0,0 +1,80 @@
return {
{
"mason-org/mason.nvim",
opts = {
ui = {
icons = {
package_installed = "",
package_pending = "",
package_uninstalled = "",
},
},
},
config = function(_, opts)
require("mason").setup(opts)
end,
},
{
"mason-org/mason-lspconfig.nvim",
event = "VeryLazy",
dependencies = {
{ "mason-org/mason.nvim" },
{ "neovim/nvim-lspconfig" },
{ "folke/neodev.nvim" },
},
config = function()
-- setup lsps
vim.lsp.config('lua_ls', {
settings = {
Lua = {
hint = { enable = true },
runtime = { version = "LuaJIT" },
diagnostics = { globals = { "vim", "require" } },
workspace = {
checkThirdParty = true,
library = {
[vim.fn.expand("$VIMRUNTIME/lua")] = true,
[vim.fn.expand("$VIMRUNTIME/lua/vim/lsp")] = true,
},
},
},
},
})
require("mason-lspconfig").setup {
ensure_installed = { "lua_ls", "vimls", "bashls" },
automatic_enable = { 'lua_ls', 'vimls', 'bashls' }
}
require("neodev").setup()
-- setup keymaps
vim.api.nvim_create_autocmd("LspAttach", {
callback = function(_)
-- local fn_format = function()
-- vim.lsp.buf.format({ async = true })
-- end
-- hover
vim.keymap.set("n", "K", vim.lsp.buf.hover, { desc = "hover (K)" })
-- vim.keymap.set("n", "<leader>lah", vim.lsp.buf.hover, { desc = "hover (K)" })
-- format
-- vim.keymap.set({ "n", "v" }, "<leader>laf", fn_format, { desc = "formatting" })
-- rename
-- vim.keymap.set({ "n", "v" }, "<leader>lar", vim.lsp.buf.rename, { desc = "rename" })
-- code_action
-- vim.keymap.set({ "n", "v" }, "<leader>laa", vim.lsp.buf.code_action, { desc = "code_action" })
-- definition
-- vim.keymap.set("n", "<leader>lgd", vim.lsp.buf.definition, { desc = "definition" })
-- declaration
-- vim.keymap.set("n", "<leader>lgD", vim.lsp.buf.declaration, { desc = "declaration" })
-- implementation
-- vim.keymap.set("n", "<leader>lgi", vim.lsp.buf.implementation, { desc = "implementation" })
-- references
-- vim.keymap.set("n", "<leader>lgr", vim.lsp.buf.references, { desc = "references" })
-- type_definition
-- vim.keymap.set("n", "<leader>lgt", vim.lsp.buf.type_definition, { desc = "type_definition" })
end,
})
end,
},
}

View File

@ -0,0 +1,9 @@
return {
{
"ray-x/lsp_signature.nvim",
event = "LspAttach",
config = function()
require("lsp_signature").setup({})
end,
},
}

57
lua/plug/ts_folding.lua Normal file
View File

@ -0,0 +1,57 @@
return {
{
"kevinhwang91/nvim-ufo",
event = "VeryLazy",
dependencies = {
"kevinhwang91/promise-async",
"nvim-treesitter/nvim-treesitter",
},
config = function()
vim.o.foldenable = true
vim.o.foldcolumn = "1"
vim.o.foldlevel = 99
vim.o.foldlevelstart = 99
-- vim.keymap.set("n", "zR", require("ufo").openAllFolds)
-- vim.keymap.set("n", "zM", require("ufo").closeAllFolds)
local handler = function(virtText, lnum, endLnum, width, truncate)
local newVirtText = {}
local suffix = (" 󰁂 %d "):format(endLnum - lnum)
local sufWidth = vim.fn.strdisplaywidth(suffix)
local targetWidth = width - sufWidth
local curWidth = 0
for _, chunk in ipairs(virtText) do
local chunkText = chunk[1]
local chunkWidth = vim.fn.strdisplaywidth(chunkText)
if targetWidth > curWidth + chunkWidth then
table.insert(newVirtText, chunk)
else
chunkText = truncate(chunkText, targetWidth - curWidth)
local hlGroup = chunk[2]
table.insert(newVirtText, { chunkText, hlGroup })
chunkWidth = vim.fn.strdisplaywidth(chunkText)
-- str width returned from truncate() may less than 2nd argument, need padding
if curWidth + chunkWidth < targetWidth then
suffix = suffix .. (" "):rep(targetWidth - curWidth - chunkWidth)
end
break
end
curWidth = curWidth + chunkWidth
end
table.insert(newVirtText, { suffix, "MoreMsg" })
return newVirtText
end
-- Option 3: treesitter as a main provider instead
-- (Note: the `nvim-treesitter` plugin is *not* needed.)
require("ufo").setup({
provider_selector = function(bufnr, filetype, buftype)
return { "treesitter", "indent" }
end,
fold_virt_text_handler = handler,
})
end,
},
}

13
lua/plug/ts_outline.lua Normal file
View File

@ -0,0 +1,13 @@
return {
{
"stevearc/aerial.nvim",
cmd = "AerialToggle",
dependencies = {
"nvim-treesitter/nvim-treesitter",
"nvim-tree/nvim-web-devicons",
},
config = function()
require("aerial").setup()
end,
},
}

View File

@ -0,0 +1,19 @@
return {
{
"nvim-treesitter/nvim-treesitter",
build = ":TSUpdate",
event = { "BufReadPost", "BufNewFile" },
opts = {
ensure_installed = { "c", "lua", "vim", "vimdoc", "javascript", "html" },
sync_install = false,
highlight = {
enable = true,
additional_vim_regex_highlighting = false,
},
indent = { enable = true },
},
config = function(_, opts)
require("nvim-treesitter.configs").setup(opts)
end,
},
}