update some plugins

main
maye 2025-05-20 20:50:40 +08:00
parent 1456a51539
commit 5ea9a3c10b
17 changed files with 374 additions and 99 deletions

6
.luarc.json Normal file
View File

@ -0,0 +1,6 @@
{
"diagnostics.globals": [
"vim",
"Snacks"
]
}

7
ftdetect/beancount.vim Normal file
View File

@ -0,0 +1,7 @@
function! s:setf(filetype) abort
if &filetype !=# a:filetypee
let &filetype = a:filetype
endif
endfunction
au BufNewFile,BufRead *.bean call s:setf("beancount")

View File

@ -6,11 +6,17 @@
"gitsigns.nvim": { "branch": "main", "commit": "ee0606259ee5d5dd40398be26755048e8965086e" },
"gruvbox.nvim": { "branch": "main", "commit": "00e38a379bab3389e187b3953566d67d494dfddd" },
"lazy.nvim": { "branch": "main", "commit": "6c3bda4aca61a13a9c63f1c1d1b16b9d3be90d7a" },
"lualine.nvim": { "branch": "master", "commit": "ecfcfee812ef4fee1e86ae8f315c4a045f7da719" },
"mason.nvim": { "branch": "main", "commit": "9eaedb864cdadc29c6eb7d761a6c0d8aee26c91b" },
"neo-tree.nvim": { "branch": "v3.x", "commit": "f481de16a0eb59c985abac8985e3f2e2f75b4875" },
"nui.nvim": { "branch": "main", "commit": "f535005e6ad1016383f24e39559833759453564e" },
"nvim-autopairs": { "branch": "master", "commit": "4d74e75913832866aa7de35e4202463ddf6efd1b" },
"nvim-colorizer.lua": { "branch": "master", "commit": "a065833f35a3a7cc3ef137ac88b5381da2ba302e" },
"nvim-lspconfig": { "branch": "master", "commit": "ac1dfbe3b60e5e23a2cff90e3bd6a3bc88031a57" },
"nvim-tree.lua": { "branch": "master", "commit": "be5b788f2dc1522c73fb7afad9092331c8aebe80" },
"nvim-treesitter": { "branch": "master", "commit": "066fd6505377e3fd4aa219e61ce94c2b8bdb0b79" },
"nvim-web-devicons": { "branch": "master", "commit": "1fb58cca9aebbc4fd32b086cb413548ce132c127" },
"plenary.nvim": { "branch": "master", "commit": "857c5ac632080dba10aae49dba902ce3abf91b35" },
"snacks.nvim": { "branch": "main", "commit": "bc0630e43be5699bb94dadc302c0d21615421d93" },
"tiny-code-action.nvim": { "branch": "main", "commit": "dc0bcd1420124dfd82e625f28caee5a825ffa317" },
"which-key.nvim": { "branch": "main", "commit": "370ec46f710e058c9c1646273e6b225acf47cbed" }
}

View File

@ -13,4 +13,5 @@ return {
})
vim.cmd.colorscheme("gruvbox")
end,
}
}

View File

@ -5,9 +5,7 @@ return {
keys = {
{
"<leader>ff",
function()
require("conform").format()
end,
function() require("conform").format() end,
mode = { "n", "v" },
desc = "Use Conform to format current buffer",
},
@ -26,7 +24,14 @@ return {
javascript = { "prettier", stop_after_first = true },
sh = { "shfmt" },
},
formatters = { injected = { options = { ignore_errors = true } } },
format_on_save = { timeout_ms = 500, lsp_format = "fallback" },
},
config = function(_, opts)
local conform = require("conform")
conform.setup(opts)
conform.formatters.stylua = {
prepend_args = { "--collapse-simple-statement", "Always" },
}
end,
}

View File

@ -7,10 +7,8 @@ return {
local fzf_lua = require("fzf-lua")
vim.keymap.set("n", "<C-p>", fzf_lua.files, {})
vim.keymap.set("n", "<C-d>", function()
fzf_lua.diagnostics_workspace({ multiline = false })
end, {})
vim.keymap.set("n","<leader>fg",fzf_lua.live_grep,{})
vim.keymap.set("n", "<C-d>", function() fzf_lua.diagnostics_workspace({ multiline = false }) end, {})
vim.keymap.set("n", "<leader>fg", fzf_lua.live_grep, {})
vim.keymap.set("n", "<leader>rg", fzf_lua.registers, {})
vim.keymap.set("n", "<leader>gs", fzf_lua.git_status, {})

View File

@ -1,10 +1,9 @@
return {
"lewis6991/gitsigns.nvim",
key = {},
opts = {
current_line_blame = true,
current_line_blame_opts = {delay = 100},
on_attach = function(bufnr)
end
},
"lewis6991/gitsigns.nvim",
key = {},
opts = {
current_line_blame = true,
current_line_blame_opts = { delay = 100 },
on_attach = function(bufnr) end,
},
}

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

@ -0,0 +1,141 @@
return {
"nvim-lualine/lualine.nvim",
event = "VeryLazy",
init = function()
vim.g.lualine_laststatus = vim.o.laststatus
if vim.fn.argc(-1) > 0 then
vim.o.statusline = " "
else
vim.o.laststatus = 0
end
end,
opts = function()
local lualine = require("lualine")
local conditions = {
buffer_not_empty = function() return vim.fn.empty(vim.fn.expand("%:t")) ~= 1 end,
hide_in_width = function() return vim.fn.winwidth(0) > 80 end,
check_git_workspace = function()
local filepath = vim.fn.expand("%:p:h")
local gitdir = vim.fn.finddir(".git", filepath .. ";")
return gitdir and #gitdir > 0 and #gitdir < #filepath
end,
}
-- Config
local config = {
options = {
component_separators = "",
section_separators = "",
theme = "auto",
},
sections = {
-- these are to remove the defaults
lualine_a = {},
lualine_b = {},
lualine_y = {},
lualine_z = {},
-- These will be filled later
lualine_c = {},
lualine_x = {},
},
inactive_sections = {
-- these are to remove the defaults
lualine_a = {},
lualine_b = {},
lualine_y = {},
lualine_z = {},
lualine_c = {},
lualine_x = {},
},
}
-- Inserts a component in lualine_c at left section
local function ins_left(component) table.insert(config.sections.lualine_c, component) end
-- Inserts a component in lualine_x ot right section
local function ins_right(component) table.insert(config.sections.lualine_x, component) end
ins_left({
-- mode component
function() return "" end,
})
ins_left({
"filename",
cond = conditions.buffer_not_empty,
})
ins_left({
"branch",
icon = "",
})
ins_left({
"diff",
-- Is it me or the symbol for modified us really weird
symbols = {
added = "",
modified = "",
removed = "",
},
cond = conditions.hide_in_width,
})
-- Insert mid section. You can make any number of sections in neovim :)
-- for lualine it"s any number greater then 2
ins_left({
function() return "%=" end,
})
ins_right({
-- Lsp server name .
function()
local msg = "null"
local clients = vim.lsp.get_clients()
if next(clients) == nil then return msg end
local client_names = {}
for _, client in ipairs(clients) do
table.insert(client_names, client.name)
end
return table.concat(client_names, ",")
end,
icon = " LSP:",
})
ins_right({
"diagnostics",
sources = { "nvim_diagnostic" },
symbols = {
error = "",
warn = "",
info = "",
hints = "󰛩 ",
},
always_visible = true,
})
ins_right({
"o:encoding", -- option component same as &encoding in viml
fmt = string.upper,
cond = conditions.hide_in_width,
})
ins_right({
"fileformat",
fmt = string.upper,
icons_enabled = true,
})
ins_right({
"location",
})
ins_right({
"progress",
})
-- Now don"t forget to initialize lualine
lualine.setup(config)
end,
}

View File

@ -1,3 +1,4 @@
return {
"mason-org/mason.nvim",
"mason-org/mason.nvim",
opts = {},
}

64
lua/plugins/neo-tree.lua Normal file
View File

@ -0,0 +1,64 @@
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>n",
function() require("neo-tree.command").execute({ toggle = true, dir = vim.uv.cwd() }) end,
desc = "Explorer NeoTree",
},
{
"<leader>ge",
function() require("nvim-tree.command").exceute({ source = "git_status", toggle = true }) end,
desc = "Git Explorer",
},
},
init = function()
vim.api.nvim_create_autocmd("BufEnter", {
group = vim.api.nvim_create_augroup("Neotree_start_directory", { clear = true }),
desc = "Start Neo-Tree with directory",
once = true,
callback = function()
if package.loaded["neo-tree"] then
return
else
local stats = vim.uv.fs_stat(vim.fn.argv(0))
if stats and stats.type == "directory" then require("neo-tree") end
end
end,
})
end,
---@module "neo-tree"
---@type neotree.Config?
opts = {
sources = { "filesystem", "buffers", "git_status" },
open_files_do_not_replace_types = { "terminal", "Trouble", "trouble", "qf", "Outline" },
filesystem = {
bind_to_cwd = false,
follow_current_file = { enabled = true },
use_libuv_file_watcher = true,
},
window = {
mappings = {
["l"] = "open",
["h"] = "close_node",
["<space>"] = "none",
["Y"] = {
function(state)
local node = state.tree:get_node()
local path = node:get_id()
vim.fn.setreg("+", path, "c")
end,
desc = "Copy Path to Clipboard",
},
},
},
},
config = function(_, opts) require("neo-tree").setup(opts) end,
}

View File

@ -0,0 +1,7 @@
return {
"norcalli/nvim-colorizer.lua",
config = function(_)
require("colorizer").setup()
vim.defer_fn(function() require("colorizer").attach_to_buffer(0) end, 0)
end,
}

View File

@ -1,36 +0,0 @@
return {
"nvim-tree/nvim-tree.lua",
version = "*",
lazy = false,
dependencies = { "nvim-tree/nvim-web-devicons" },
keys = {
{
"<leader>n",
":NvimTreeToggle<CR>",
mode = { "n" },
desc = "Use Conform to format current buffer",
},
},
config = function()
vim.g.loaded_netrw = 1
vim.g.loaded_netrwPlugin = 1
vim.opt.termguicolors = true
require("nvim-tree").setup({
diagnostics = {
enable = true,
show_on_dirs = true,
},
filters = {
git_ignored = false,
},
renderer = {
indent_markers = { enable = true },
},
view = {
number = true,
relativenumber = true,
},
})
end,
}

58
lua/plugins/snacks.lua Normal file
View File

@ -0,0 +1,58 @@
return {
"folke/snacks.nvim",
priority = 1000,
lazy = false,
---@type snacks.Config
opts = {
-- your configuration comes here
-- or leave it empty to use the default settings
-- refer to the configuration section below
bigfile = { enabled = true },
dashboard = { enabled = true },
explorer = { enabled = true },
indent = { enabled = true },
input = { enabled = true },
picker = { enabled = true },
notifier = { enabled = true },
quickfile = { enabled = true },
scope = { enabled = true },
scroll = { enabled = true },
statuscolumn = { enabled = true },
words = { enabled = true },
},
keys = {
{ "<leader><space>", function() Snacks.picker.smart() end, desc = "Smart Find Files" },
{ "<leader>fg", function() Snacks.picker.git_files() end, desc = "Find Git Files" },
{ "<leader>fp", function() Snacks.picker.projects() end, desc = "Projects" },
-- git
{ "<leader>gb", function() Snacks.picker.git_branches() end, desc = "Git Branches" },
{ "<leader>gl", function() Snacks.picker.git_log() end, desc = "Git Log" },
{ "<leader>gL", function() Snacks.picker.git_log_line() end, desc = "Git Log Line" },
{ "<leader>gs", function() Snacks.picker.git_status() end, desc = "Git Status" },
{ "<leader>gS", function() Snacks.picker.git_stash() end, desc = "Git Stash" },
{ "<leader>gd", function() Snacks.picker.git_diff() end, desc = "Git Diff (Hunks)" },
{ "<leader>gf", function() Snacks.picker.git_log_file() end, desc = "Git Log File" },
-- Grep
{ "<leader>sb", function() Snacks.picker.lines() end, desc = "Buffer Lines" },
{ "<leader>sB", function() Snacks.picker.grep_buffers() end, desc = "Grep Open Buffers" },
{ "<leader>sg", function() Snacks.picker.grep() end, desc = "Grep" },
{
"<leader>sw",
function() Snacks.picker.grep_word() end,
desc = "Visual selection or word",
mode = { "n", "x" },
},
-- LSP
{ "gd", function() Snacks.picker.lsp_definitions() end, desc = "Goto Definition" },
{ "gD", function() Snacks.picker.lsp_declarations() end, desc = "Goto Declaration" },
{ "gr", function() Snacks.picker.lsp_references() end, nowait = true, desc = "References" },
{ "gI", function() Snacks.picker.lsp_implementations() end, desc = "Goto Implementation" },
{ "gy", function() Snacks.picker.lsp_type_definitions() end, desc = "Goto T[y]pe Definition" },
{ "<leader>ss", function() Snacks.picker.lsp_symbols() end, desc = "LSP Symbols" },
{ "<leader>sS", function() Snacks.picker.lsp_workspace_symbols() end, desc = "LSP Workspace Symbols" },
-- Other
{ "]]", function() Snacks.words.jump(vim.v.count1) end, desc = "Next Reference", mode = { "n", "t" } },
{ "[[", function() Snacks.words.jump(-vim.v.count1) end, desc = "Prev Reference", mode = { "n", "t" } },
{ "<c-/>", function() Snacks.terminal() end, desc = "Toggle Terminal" },
},
}

View File

@ -0,0 +1,20 @@
return {
"rachartier/tiny-code-action.nvim",
dependencies = {
{ "nvim-lua/plenary.nvim" },
},
keys = {
{
"<leader>ca",
function() require("tiny-code-action").code_action() end,
{ "n" },
},
},
event = "LspAttach",
opts = {
backend = "vim",
picker = {
"snacks",
},
},
}

View File

@ -1,33 +1,31 @@
return {
"nvim-treesitter/nvim-treesitter",
build = function()
require("nvim-treesitter.install").update({ with_sync = true })()
build = function() require("nvim-treesitter.install").update({ with_sync = true })() end,
config = function()
local configs = require("nvim-treesitter.configs")
configs.setup({
ensure_installed = {
"html",
"json",
"cmake",
"make",
"python",
"go",
"rust",
"yaml",
"bash",
},
highlight = {
enable = true,
disable = function(lang, buf)
local ok, stats = pcall(vim.uv.fs_stat, vim.api.nvim_buf_get_name(buf))
if ok and stats and stats.size > require("commons").constants.big_file_size_limit then
return true
end
end,
},
incremental_selection = { enable = true },
indent = { enable = true },
})
end,
config = function()
local configs = require("nvim-treesitter.configs")
configs.setup({
ensure_installed = {
'html',
'json',
'cmake',
'make',
'python',
'go',
'rust',
'yaml',
'bash'
},
highlight = {
enable = true,
disable = function(lang,buf)
local ok,stats = pcall(vim.uv.fs_stat, vim.api.nvim_buf_get_name(buf))
if ok and stats and stats.size > require("commons").constants.big_file_size_limit then
return true
end
end,
},
incremental_selection = {enable = true},
indent = {enable = true},
})
end
}

View File

@ -1,17 +1,17 @@
return {
"folke/which-key.nvim",
event = "VeryLazy",
opts = {
spec = {
{"<BS>", desc = "Decrement Selection", mode = "x"},
{"<c-space>", desc = "Increment Selection", mode = {"x", "n"}}
}
},
keys = {
{
"<leader>?",
function() require("which-key").show({global = false}) end,
desc = "Buffer Local Keymaps (which-key)"
}
}
"folke/which-key.nvim",
event = "VeryLazy",
opts = {
spec = {
{ "<BS>", desc = "Decrement Selection", mode = "x" },
{ "<c-space>", desc = "Increment Selection", mode = { "x", "n" } },
},
},
keys = {
{
"<leader>?",
function() require("which-key").show({ global = false }) end,
desc = "Buffer Local Keymaps (which-key)",
},
},
}