breaking: Remove setup script and use chezmoi

This commit is contained in:
js0ny 2025-09-27 02:25:06 +01:00
parent 02bbb24cac
commit 0051a163c3
190 changed files with 118 additions and 3456 deletions

View file

@ -0,0 +1,56 @@
-- alpha-nvim.lua
return {
{
"goolord/alpha-nvim",
dependencies = {},
keys = {
{ "<leader>ba", "<cmd>Alpha<CR>", desc = "Toggle Alpha Dashboard" },
},
cmd = {
"Alpha",
},
config = function()
local alpha = require("alpha")
local dashboard = require("alpha.themes.dashboard")
dashboard.section.header.val = {
" ",
"================= =============== =============== ======== ========",
"\\\\ . . . . . . .\\\\ //. . . . . . .\\\\ //. . . . . . .\\\\ \\\\. . .\\\\// . . //",
"||. . ._____. . .|| ||. . ._____. . .|| ||. . ._____. . .|| || . . .\\/ . . .||",
"|| . .|| ||. . || || . .|| ||. . || || . .|| ||. . || ||. . . . . . . ||",
"||. . || || . .|| ||. . || || . .|| ||. . || || . .|| || . | . . . . .||",
"|| . .|| ||. _-|| ||-_ .|| ||. . || || . .|| ||. _-|| ||-_.|\\ . . . . ||",
"||. . || ||-' || || `-|| || . .|| ||. . || ||-' || || `|\\_ . .|. .||",
"|| . _|| || || || || ||_ . || || . _|| || || || |\\ `-_/| . ||",
"||_-' || .|/ || || \\|. || `-_|| ||_-' || .|/ || || | \\ / |-_.||",
"|| ||_-' || || `-_|| || || ||_-' || || | \\ / | `||",
"|| `' || || `' || || `' || || | \\ / | ||",
"|| .===' `===. .==='.`===. .===' /==. | \\/ | ||",
"|| .==' \\_|-_ `===. .===' _|_ `===. .===' _-|/ `== \\/ | ||",
"|| .==' _-' `-_ `=' _-' `-_ `=' _-' `-_ /| \\/ | ||",
"|| .==' _-' `-__\\._-' `-_./__-' `' |. /| | ||",
"||.==' _-' `' | /==.||",
"==' _-' j s 0 n y N E O V I M \\/ `==",
"\\ _-' `-_ /",
" `'' ``' ",
}
dashboard.section.buttons.val.leader = "SPC"
dashboard.section.buttons.val = {
-- leader = "SPC",
dashboard.button("p", "󰈞 查找项目", "<cmd>Telescope projects<CR>"),
dashboard.button("h", " 历史文件", "<cmd>Telescope oldfiles<CR>"),
dashboard.button("l", " 加载会话", "<cmd>SessionSearch<CR>"),
-- FIXME: This does not work on Windows - Make it more portable
dashboard.button("c", " 转到设置", "<cmd>Telescope find_files cwd=~/.config/nvim<CR>"),
dashboard.button("SPC q", "󱊷 退出", "<cmd>qa<CR>"),
}
dashboard.section.footer.val = "今日 " .. os.date("%Y-%m-%d %A") .. " "
dashboard.config.opts.noautocmd = true
-- vim.cmd[[autocmd User AlphaReady echo 'Alpha ready!']]
alpha.setup(dashboard.config)
end,
},
}

View file

@ -0,0 +1,21 @@
return {
"windwp/nvim-autopairs",
event = "InsertEnter",
config = function()
local npairs = require("nvim-autopairs")
local Rule = require("nvim-autopairs.rule")
npairs.setup()
npairs.add_rule(Rule("$", "$", "markdown"))
npairs.add_rule(Rule("\\(", "\\)", "tex"))
npairs.add_rule(Rule("\\[", "\\]", "tex"))
npairs.add_rules({
Rule("%(", "%)", "cmd"):with_pair(function(opts)
if vim.fn.getcmdtype() == ":" then
return true
end
end),
})
end,
}

View file

@ -0,0 +1,35 @@
return {
"yetone/avante.nvim",
event = "BufRead",
-- lazy = false,
version = false, -- Set this to "*" to always pull the latest release version, or set it to false to update to the latest code changes.
opts = {
-- add any opts here
-- for example
provider = "openai",
openai = {
endpoint = "https://aihubmix.com/v1",
model = "claude-3-7-sonnet-20250219", -- your desired model (or use gpt-4o, etc.)
timeout = 30000, -- timeout in milliseconds
temperature = 0, -- adjust if needed
max_tokens = 4096,
-- reasoning_effort = "high" -- only supported for "o" models
},
},
-- if you want to build from source then do `make BUILD_FROM_SOURCE=true`
build = "make",
-- build = "powershell -ExecutionPolicy Bypass -File Build.ps1 -BuildFromSource false" -- for windows
dependencies = {
"nvim-treesitter/nvim-treesitter",
"stevearc/dressing.nvim",
"nvim-lua/plenary.nvim",
"MunifTanjim/nui.nvim",
--- The below dependencies are optional,
-- "nvim-telescope/telescope.nvim", -- for file_selector provider telescope
"ibhagwan/fzf-lua",
"hrsh7th/nvim-cmp", -- autocompletion for avante commands and mentions
"nvim-tree/nvim-web-devicons", -- or echasnovski/mini.icons
"zbirenbaum/copilot.lua", -- for providers='copilot'
"HakonHarnes/img-clip.nvim",
},
}

View file

@ -0,0 +1,79 @@
return {
"saghen/blink.cmp",
-- optional: provides snippets for the snippet source
-- dependencies = { "L3MON4D3/LuaSnip", version = "v2.*" },
-- use a release tag to download pre-built binaries
version = "*",
event = "InsertEnter",
---@module 'blink.cmp'
---@type blink.cmp.Config
opts = {
enabled = function()
if vim.fn.getcmdtype() ~= "" then
return true
end
return not vim.tbl_contains({ "TelescopePrompt", "dap-repl", "snacks_picker_list" }, vim.bo.filetype)
end,
keymap = {
preset = "default",
["<Tab>"] = {
function(cmp)
if cmp.snippet_active() then
return cmp.accept()
else
return cmp.select_and_accept()
end
end,
"snippet_forward",
"fallback",
},
["<C-f>"] = { "select_and_accept" },
["<C-b>"] = { "hide", "fallback" },
["<CR>"] = { "accept", "fallback" },
},
completion = {
menu = { border = "single" },
documentation = { window = { border = "single" } },
},
signature = { window = { border = "single" } },
appearance = {
-- 'mono' (default) for 'Nerd Font Mono' or 'normal' for 'Nerd Font'
-- Adjusts spacing to ensure icons are aligned
nerd_font_variant = "normal",
},
snippets = {
preset = "luasnip",
},
sources = {
default = { "lazydev", "lsp", "path", "snippets", "buffer" },
per_filetype = {
org = { "orgmode" },
},
providers = {
lazydev = {
name = "LazyDev",
module = "lazydev.integrations.blink",
score_offset = 100,
},
orgmode = {
name = "Orgmode",
module = "orgmode.org.autocompletion.blink",
fallbacks = { "buffer" },
},
},
},
-- (Default) Rust fuzzy matcher for typo resistance and significantly better performance
-- You may use a lua implementation instead by using `implementation = "lua"` or fallback to the lua implementation,
-- when the Rust fuzzy matcher is not available, by using `implementation = "prefer_rust"`
--
-- See the fuzzy documentation for more information
fuzzy = { implementation = "prefer_rust_with_warning" },
},
opts_extend = { "sources.default" },
}

View file

@ -0,0 +1,55 @@
local function get_highlight()
if vim.g.colors_name == "catppuccin" then
return require("catppuccin.groups.integrations.bufferline").get()
elseif vim.g.colors_name == "rose-pine" then
return require("rose-pine.plugins.bufferline")
end
end
return {
"akinsho/bufferline.nvim",
dependencies = "nvim-tree/nvim-web-devicons", -- 图标支持
after = "catppuccin",
event = "VeryLazy",
keys = {
{ "<leader>b1", "<cmd>BufferLineGotoBuffer 1<CR>", desc = "Switch to Buffer #1" },
{ "<leader>b2", "<cmd>BufferLineGotoBuffer 2<CR>", desc = "Switch to Buffer #2" },
{ "<leader>b3", "<cmd>BufferLineGotoBuffer 3<CR>", desc = "Switch to Buffer #3" },
{ "<leader>b4", "<cmd>BufferLineGotoBuffer 4<CR>", desc = "Switch to Buffer #4" },
{ "<leader>b5", "<cmd>BufferLineGotoBuffer 5<CR>", desc = "Switch to Buffer #5" },
{ "<leader>b6", "<cmd>BufferLineGotoBuffer 6<CR>", desc = "Switch to Buffer #6" },
{ "<leader>b7", "<cmd>BufferLineGotoBuffer 7<CR>", desc = "Switch to Buffer #7" },
{ "<leader>b8", "<cmd>BufferLineGotoBuffer 8<CR>", desc = "Switch to Buffer #8" },
{ "<leader>b9", "<cmd>BufferLineGotoBuffer 9<CR>", desc = "Switch to Buffer #9" },
{ "<leader>bb", "<cmd>BufferLinePick<CR>", desc = "Quick Switch Buffers" },
{ "<leader>bD", "<cmd>BufferLineCloseOthers<CR>", desc = "Delete Other Buffers" },
{ "<leader>bxx", "<cmd>BufferLineCloseOthers<CR>", desc = "Delete Other Buffers" },
{ "<leader>bxh", "<cmd>BufferLineCloseLeft<CR>", desc = "Delete Buffers Left" },
{ "<leader>bxi", "<cmd>BufferLineCloseRight<CR>", desc = "Delete Buffers Right" },
{ "<leader>bX", "<cmd>BufferLineCloseOthers<CR>", desc = "Delete Other Buffers" },
{ "<leader>bt", "<cmd>BufferLineTogglePin<CR>", desc = "Pin Buffer" },
},
opts = {
options = {
indicator = {
icon = "", -- this should be omitted if indicator style is not 'icon'
style = "icon",
},
diagnostics = "nvim_lsp",
diagnostics_indicator = function(count, level, diagnostics_dict, context)
local icon = level:match("error") and "" or ""
return " " .. icon .. count
end,
show_buffer_icons = true,
numbers = "ordinal", -- 显示 buffer 序号
close_command = "bdelete! %d", -- 关闭 buffer 的命令
right_mouse_command = "bdelete! %d", -- 右键关闭
offsets = {
{ filetype = "NvimTree", text = "资源管理器", text_align = "center" },
},
separator_style = "thin",
},
highlights = get_highlight(),
},
}

View file

@ -0,0 +1,38 @@
return {
"stevearc/conform.nvim",
event = { "BufWritePre" },
cmd = { "ConformInfo" },
-- This will provide type hinting with LuaLS
---@module "conform"
---@type conform.setupOpts
opts = {
-- Define your formatters
formatters_by_ft = {
lua = { "stylua" },
python = { "isort", "black" },
javascript = { "prettierd", "prettier", stop_after_first = true },
},
-- Set default options
default_format_opts = {
lsp_format = "fallback",
},
-- Set up format-on-save
format_on_save = function(bufnr)
-- Disable with a global or buffer-local variable
if vim.g.disable_autoformat or vim.b[bufnr].disable_autoformat then
return
end
return { timeout_ms = 500, lsp_format = "fallback" }
end,
-- Customize formatters
formatters = {
shfmt = {
prepend_args = { "-i", "2" },
},
},
},
init = function()
-- If you want the formatexpr, here is the place to set it
vim.o.formatexpr = "v:lua.require'conform'.formatexpr()"
end,
}

View file

@ -0,0 +1,23 @@
return {
"zbirenbaum/copilot.lua",
cmd = "Copilot",
build = ":Copilot auth",
event = "BufReadPost",
opts = {
suggestion = {
enabled = not vim.g.ai_cmp,
auto_trigger = true,
hide_during_completion = vim.g.ai_cmp,
keymap = {
accept = "<M-f>",
next = "<M-]>",
prev = "<M-[>",
},
},
panel = { enabled = false },
filetypes = {
markdown = true,
help = true,
},
},
}

View file

@ -0,0 +1,30 @@
return {
"ibhagwan/fzf-lua",
-- optional for icon support
dependencies = { "nvim-tree/nvim-web-devicons" },
cmd = "FzfLua",
keys = {
{ "<leader><leader>", "<cmd>FzfLua files<CR>", desc = "Find Files" },
{ "<leader>fc", "<cmd>FzfLua files cwd=~/.config/nvim<CR>", desc = "Edit configs" },
{ "<leader>/", "<cmd>FzfLua live_grep<CR>", desc = "Grep Files" },
{ "<leader>;", "<cmd>FzfLua<CR>", desc = "Show Telescope Commands" },
{ "<leader>ui", "<cmd>FzfLua colorschemes<CR>", desc = "Change colorscheme" },
-- find_files { "<leader>pp", "<cmd>FzfLua projects<CR>", desc = "Listfind_files all Projects" },
{ "<leader>pd", "<cmd>FzfLua zoxide<CR>", desc = "List recent directories" },
-- { "<leader>pg", "<cmd>FzfLua projects<CR>", desc = "List all Git Projects" },
{ "<leader>ps", "<cmd>FzfLua session-lens<CR>", desc = "List all sessions" },
{ "<leader>gs", "<cmd>FzfLua git_status<CR>", desc = "Git Status" },
{ "<leader>gt", "<cmd>FzfLua git_branches<CR>", desc = "Git Branches" },
{ "<leader>gc", "<cmd>FzfLua git_commits<CR>", desc = "Show commits" },
{ "<leader>fb", "<cmd>FzfLua buffers<CR>", desc = "List Buffers" },
{ "<leader>ff", "<cmd>FzfLua fd<CR>", desc = "Find Files" },
{ "<leader>fh", "<cmd>FzfLua oldfiles<CR>", desc = "Recent Files" },
{ "<leader>ce", "<cmd>FzfLua diagnostics<CR>", desc = "Navigate errors/warnings" },
{ "<leader>cs", "<cmd>FzfLua treesitter<CR>", desc = "Search symbols" },
{ "<leader>cS", "<cmd>FzfLua grep_string<CR>", desc = "Search current symbol" },
{ "<leader>bB", "<cmd>FzfLua buffers<CR>", desc = "List Buffers" },
{ "<leader>fl", "<cmd>FzfLua filetypes<CR>", desc = "Set Filetype/Lang to ..." },
{ "<leader>R", "<cmd>FzfLua resume<CR>", desc = "Resume FzfLua" },
},
opts = {},
}

View file

@ -0,0 +1,58 @@
return {
"lewis6991/hover.nvim",
opts = {
init = function()
-- Require providers
require("hover.providers.lsp")
-- require('hover.providers.gh')
-- require('hover.providers.gh_user')
-- require('hover.providers.jira')
-- require('hover.providers.dap')
-- require('hover.providers.fold_preview')
require("hover.providers.diagnostic")
-- require('hover.providers.man')
-- require('hover.providers.dictionary')
end,
preview_opts = {
border = "single",
},
-- Whether the contents of a currently open hover window should be moved
-- to a :h preview-window when pressing the hover keymap.
preview_window = false,
title = true,
mouse_providers = {
"LSP",
},
mouse_delay = 1000,
},
keys = {
{
"gE",
function()
require("hover").hover_select()
end,
desc = "hover.nvim (select)",
},
{
"<C-p>",
function()
require("hover").hover_switch("previous")
end,
desc = "hover.nvim (previous source)",
},
{
"<C-n>",
function()
require("hover").hover_switch("next")
end,
desc = "hover.nvim (next source)",
},
{
"<MouseMove>",
function()
require("hover").hover_mouse()
end,
desc = "hover.nvim (mouse)",
},
},
}

View file

@ -0,0 +1,18 @@
-- 2025-03-03
-- If current session is not spawn by neovide, do not load image.nvim
-- neovide did not support image viewer yet
-- https://github.com/neovide/neovide/issues/2088
-- Disable on: Neovide, alacritty and windows
if vim.g.neovide then
return {}
elseif vim.env.TERM_PROGRAM == "alacritty" then
return {}
elseif vim.loop.os_uname().sysname:lower() == "windows_nt" then
return {}
else
return {
"3rd/image.nvim",
opts = {},
event = "BufReadPre",
}
end

View file

@ -0,0 +1,30 @@
return {
{
-- support for image pasting
"HakonHarnes/img-clip.nvim",
event = "VeryLazy",
ft = { "avante", "markdown", "typst", "org", "tex" },
cmd = "PasteImage",
keys = {
{
"<localleader>p",
function()
require("img-clip").paste_image()
end,
desc = "Paste Image",
}
},
opts = {
-- recommended settings
default = {
embed_image_as_base64 = false,
prompt_for_file_name = false,
drag_and_drop = {
insert_mode = true,
},
-- required for Windows users
use_absolute_path = true,
},
}
}
}

View file

@ -0,0 +1,141 @@
local M = {}
local colors = require("config.colors")
local icons = require("config.icons")
local function diff_source()
local gitsigns = vim.b.gitsigns_status_dict
if gitsigns then
return {
added = gitsigns.added,
modified = gitsigns.changed,
removed = gitsigns.removed,
}
end
end
M.mode = {
function()
return ""
end,
-- color = mode_color_bg,
}
M.git = {
"branch",
icon = icons.git.Branch,
color = { fg = colors.scheme.violet, gui = "bold" },
}
M.diagnostics = {
"diagnostics",
sources = { "nvim_diagnostic" },
symbols = {
error = icons.diagnostics.Error .. " ",
warn = icons.diagnostics.Warning .. " ",
info = icons.diagnostics.Information .. " ",
hint = icons.diagnostics.Hint .. " ",
},
}
M.lsp = {
-- Lsp server name .
function()
local msg = "LSP Inactive"
local buf_ft = vim.api.nvim_get_option_value("filetype", { buf = 0 })
local clients = vim.lsp.get_clients()
if next(clients) == nil then
return msg
end
for _, client in ipairs(clients) do
local filetypes = client.config.filetypes
if filetypes and vim.fn.index(filetypes, buf_ft) ~= -1 then
return client.name
end
end
return msg
end,
icon = icons.lsp,
color = { fg = colors.scheme.yellow, gui = "italic" },
}
M.filetype = {
function()
return vim.bo.filetype
end,
color = { fg = colors.scheme.blue, gui = "bold" },
}
M.eol = {
function()
return vim.bo.eol == true and icons.eol or ""
end,
color = { fg = colors.scheme.red },
}
M.command = {
"command",
color = { fg = colors.scheme.green, gui = "bold" },
}
M.encoding = {
"o:encoding",
color = { fg = colors.scheme.green, gui = "bold" },
}
M.indent = {
function()
local shiftwidth = vim.api.nvim_get_option_value("shiftwidth", { buf = 0 })
return icons.indent .. " " .. shiftwidth
end,
padding = 1,
}
M.diff = {
"diff",
source = diff_source,
-- symbols = { added = " ", modified = "󰝤 ", removed = " " },
symbols = {
added = icons.git.Add .. " ",
modified = icons.git.Change .. " ",
removed = icons.git.Delete .. " ",
},
padding = { left = 2, right = 1 },
diff_color = {
added = { fg = colors.scheme.green },
modified = { fg = colors.scheme.yellow },
removed = { fg = colors.scheme.red },
},
cond = nil,
}
M.progress = {
"progress",
}
-- TODO: Implement orgmode
M.orgmode = {
function()
return _G.orgmode.statusline()
end,
}
-- 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,
-- }
-- local mode_color = colors.mode
--
-- local mode_color_bg = function()
-- return { fg = colors.mantle, bg = mode_color[vim.fn.mode()] }
-- end
return M

View file

@ -0,0 +1,63 @@
local lualine = require("lualine")
-- Color table for highlights
-- local colors = require("config.colors")
local components = require("plugins.mod.lualine.components")
--[[
VSCode Style:
Remote | Git Branch | Diagnostics | Command | | MID | | Line:Column | Indent | Encoding | EOL | File Type LSP | Notifications
--]]
-- Config
local config = {
options = {
disabled_filetypes = {
statusline = { "NvimTree", "alpha", "grug-far", "snacks_dashboard" },
},
-- Disable sections and component separators
component_separators = { left = "", right = "" },
section_separators = { left = "", right = "" },
-- theme = "catppuccin",
theme = vim.g.colors_name,
-- IDE-like Global Status
globalstaus = true,
},
sections = {
-- these are to remove the defaults
lualine_a = {
components.mode,
},
lualine_b = {
components.diff,
},
lualine_c = {
components.diagnostics,
},
lualine_x = {
components.orgmode,
components.indent,
components.encoding,
components.eol,
},
lualine_y = {
components.filetype,
components.lsp,
},
lualine_z = {
components.progress,
},
},
inactive_sections = {
-- these are to remove the defaults
lualine_a = {},
lualine_b = {},
lualine_y = {},
lualine_z = {},
lualine_c = {},
lualine_x = {},
},
}
lualine.setup(config)

View file

@ -0,0 +1,47 @@
return {
"brenton-leighton/multiple-cursors.nvim",
version = "*", -- Use the latest tagged version
-- opts = , -- This causes the plugin setup function to be called
keys = {
{ "<A-n>", "<Cmd>MultipleCursorsAddDown<CR>", mode = { "n", "x" }, desc = "Add cursor and move down" },
{ "<A-e>", "<Cmd>MultipleCursorsAddUp<CR>", mode = { "n", "x" }, desc = "Add cursor and move up" },
{ "<C-Up>", "<Cmd>MultipleCursorsAddUp<CR>", mode = { "n", "i", "x" }, desc = "Add cursor and move up" },
{ "<C-Down>", "<Cmd>MultipleCursorsAddDown<CR>", mode = { "n", "i", "x" }, desc = "Add cursor and move down" },
{ "<A-LeftMouse>", "<Cmd>MultipleCursorsMouseAddDelete<CR>", mode = { "n", "i" }, desc = "Add or remove cursor" },
},
config = function()
local normal_mode_motion = require("multiple-cursors.normal_mode.motion")
local normal_mode_edit = require("multiple-cursors.normal_mode.edit")
local visual_mode_edit = require("multiple-cursors.visual_mode.edit")
local normal_mode_mode_change = require("multiple-cursors.normal_mode.mode_change")
local visual_mode_modify_area = require("multiple-cursors.visual_mode.modify_area")
require("multiple-cursors").setup({
pre_hook = function()
require("nvim-autopairs").disable()
end,
post_hook = function()
require("nvim-autopairs").enable()
end,
custom_key_maps = {
{ { "n", "x" }, { "e", "<Up>" }, normal_mode_motion.k, "nowrap" },
{ { "n", "x" }, { "n", "<Down>" }, normal_mode_motion.j, "nowrap" },
{ { "n", "x" }, { "i", "<Right>", "<Space>" }, normal_mode_motion.l, "nowrap" },
{ { "n", "x" }, "j", normal_mode_motion.e, "nowrap" },
{ { "n", "x" }, "J", normal_mode_motion.E, "nowrap" },
{ { "n", "x" }, "gj", normal_mode_motion.ge, "nowrap" },
{ { "n", "x" }, "gJ", normal_mode_motion.gE, "nowrap" },
{ "n", "E", normal_mode_edit.J, "nowrap" },
{ "n", "gE", normal_mode_edit.gJ, "nowrap" },
{ "n", { "l", "<Insert>" }, normal_mode_mode_change.i, "nowrap" },
{ "n", "L", normal_mode_mode_change.I, "nowrap" },
{ "x", "l", visual_mode_modify_area.i, "nowrap" },
{ "x", "E", visual_mode_edit.J, "nowrap" },
{ "x", "gE", visual_mode_edit.gJ, "nowrap" },
},
})
end,
}

View file

@ -0,0 +1,89 @@
return {
"nvim-neo-tree/neo-tree.nvim",
branch = "v3.x",
dependencies = {
"nvim-lua/plenary.nvim",
"nvim-tree/nvim-web-devicons", -- not strictly required, but recommended
"MunifTanjim/nui.nvim",
-- {"3rd/image.nvim", opts = {}}, -- Optional image support in preview window: See `# Preview Mode` for more information
},
lazy = false, -- neo-tree will lazily load itself
---@module "neo-tree"
---@type neotree.Config?
opts = {
window = {
mappings = {
["<space>"] = "noop",
["e"] = "noop",
["<2-LeftMouse>"] = "open",
["<cr>"] = "open",
["i"] = "open",
["<esc>"] = "cancel", -- close preview or floating neo-tree window
["P"] = { "toggle_preview", config = { use_float = true, use_image_nvim = true } },
-- Read `# Preview Mode` for more information
-- ["i"] = "focus_preview",
["S"] = "open_split",
["s"] = "open_vsplit",
-- ["S"] = "split_with_window_picker",
-- ["s"] = "vsplit_with_window_picker",
["t"] = "open_tabnew",
-- ["<cr>"] = "open_drop",
-- ["t"] = "open_tab_drop",
["w"] = "open_with_window_picker",
--["P"] = "toggle_preview", -- enter preview mode, which shows the current node without focusing
["C"] = "close_node",
-- ['C'] = 'close_all_subnodes',
["z"] = "close_all_nodes",
--["Z"] = "expand_all_nodes",
["a"] = {
"add",
-- this command supports BASH style brace expansion ("x{a,b,c}" -> xa,xb,xc). see `:h neo-tree-file-actions` for details
-- some commands may take optional config options, see `:h neo-tree-mappings` for details
config = {
show_path = "none", -- "none", "relative", "absolute"
},
},
["A"] = "add_directory", -- also accepts the optional config.show_path option like "add". this also supports BASH style brace expansion.
["d"] = "delete",
["r"] = "rename",
["b"] = "rename_basename",
["y"] = "copy_to_clipboard",
["x"] = "cut_to_clipboard",
["p"] = "paste_from_clipboard",
["c"] = "copy", -- takes text input for destination, also accepts the optional config.show_path option like "add":
-- ["c"] = {
-- "copy",
-- config = {
-- show_path = "none" -- "none", "relative", "absolute"
-- }
--}
["m"] = "move", -- takes text input for destination, also accepts the optional config.show_path option like "add".
["q"] = "close_window",
["R"] = "refresh",
["?"] = "show_help",
["<"] = "prev_source",
[">"] = "next_source",
["l"] = "show_file_details",
-- ["i"] = {
-- "show_file_details",
-- -- format strings of the timestamps shown for date created and last modified (see `:h os.date()`)
-- -- both options accept a string or a function that takes in the date in seconds and returns a string to display
-- -- config = {
-- -- created_format = "%Y-%m-%d %I:%M %p",
-- -- modified_format = "relative", -- equivalent to the line below
-- -- modified_format = function(seconds) return require('neo-tree.utils').relative_date(seconds) end
-- -- }
-- },
}
}
-- fill any relevant options here
},
keys = {
{
"<leader>ft",
"<cmd>Neotree toggle<CR>",
desc = "Toggle File Explorer",
}
}
}

View file

@ -0,0 +1,111 @@
return {
"hrsh7th/nvim-cmp",
-- lazy = false,
event = "InsertEnter",
dependencies = {
"hrsh7th/cmp-nvim-lsp",
"hrsh7th/cmp-buffer",
"hrsh7th/cmp-path",
"hrsh7th/cmp-cmdline",
"L3MON4D3/LuaSnip",
"saadparwaiz1/cmp_luasnip",
},
config = function()
local cmp = require("cmp")
local capabilities = require("cmp_nvim_lsp").default_capabilities()
local servers_module = require("config.servers")
local luasnip = require("luasnip")
local servers = servers_module.servers
local servers_config = servers_module.server_config
-- 默认 LSP 配置
local default_server_config = {
capabilities = capabilities,
}
-- local raw_keymaps = require("keymaps.cmp_map")(cmp.mapping) -- require("keymaps").cmp_nvim_keymaps(cmp.mapping)
-- local mapped = set_keymaps(raw_keymaps)
local kind_icons = require("config.icons").lsp_kind
-- 配置 nvim-cmp
cmp.setup({
formatting = {
format = function(entry, vim_item)
vim_item.kind = string.format("%s %s", kind_icons[vim_item.kind] or "", vim_item.kind)
return vim_item
end,
},
snippet = {
expand = function(args)
require("luasnip").lsp_expand(args.body)
end,
},
mapping = {
-- cmp.mapping.preset.insert(mapped),
["<C-n>"] = cmp.mapping.select_next_item(),
["<C-p>"] = cmp.mapping.select_prev_item(),
["<C-f>"] = cmp.mapping.confirm({ select = true }),
["<C-b>"] = cmp.mapping.abort(),
["<C-Space>"] = cmp.mapping.complete(),
["<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.confirm({ select = true })
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" }),
}, -- cmp.mapping.preset.insert(mapped),
sources = cmp.config.sources({
{ name = "copilot", priority = 10 },
{ name = "nvim_lsp" },
{ name = "luasnip" },
{ name = "lazydev", group_index = 0 },
}, {
{ name = "buffer" },
{ name = "path" },
}),
})
cmp.setup.cmdline({ "/", "?" }, {
mapping = cmp.mapping.preset.cmdline(),
sources = {
{ name = "buffer" },
},
})
cmp.setup.cmdline(":", {
mapping = cmp.mapping.preset.cmdline(),
sources = cmp.config.sources({
{ name = "path" },
}, {
{ name = "cmdline" },
}),
matching = { disallow_symbol_nonprefix_matching = false },
})
end,
}

View file

@ -0,0 +1,40 @@
return {
"neovim/nvim-lspconfig",
dependencies = { "saghen/blink.cmp" },
event = {
"BufReadPost",
"BufWritePost",
"BufNewFile",
},
-- example using `opts` for defining servers
opts = {
servers = {
lua_ls = {},
bashls = {},
clangd = {},
eslint = {}, -- JavaScript
gopls = {}, -- Go
jsonls = {}, -- JSON
markdown_oxide = {}, -- Markdown
omnisharp = {}, -- C# & F#
powershell_es = {}, -- PowerShell
pyright = {}, -- Python
taplo = {}, -- TOML
rust_analyzer = {}, -- Rust
ts_ls = {}, -- TypeScript
vimls = {}, -- vimscript
yamlls = {}, -- YAML
beancount = {}, -- Beancount
},
},
config = function(_, opts)
local lspconfig = require("lspconfig")
for server, config in pairs(opts.servers) do
-- passing config.capabilities to blink.cmp merges with the capabilities in your
-- `opts[server].capabilities, if you've defined it
config.capabilities = require("blink.cmp").get_lsp_capabilities(config.capabilities)
lspconfig[server].setup(config)
end
end,

View file

@ -0,0 +1,53 @@
local function my_on_attach(bufnr)
-- local keymaps = require("config.keymaps")
local api = require("nvim-tree.api")
local default_mode = { "n" }
local keymaps = require("keymaps")
local function opts(desc)
return { desc = "nvim-tree: " .. desc, buffer = bufnr, noremap = true, silent = true, nowait = true }
end
local function set_keymaps(maps)
for _, map in ipairs(maps) do
local mode = map.mode or default_mode
vim.keymap.set(mode, map.keys, map.cmd, map.opts)
end
end
local raw_keymaps = require("keymaps.nvim-tree").plugin(api, opts)
set_keymaps(raw_keymaps)
end
return {
"nvim-tree/nvim-tree.lua",
version = "*",
lazy = false,
keys = {
{ "<leader>ft", "<cmd>NvimTreeToggle<CR>", desc = "Toggle File Explorer" },
},
dependencies = {
"nvim-tree/nvim-web-devicons",
},
opts = {
on_attach = my_on_attach,
sync_root_with_cwd = true,
respect_buf_cwd = true,
disable_netrw = true,
renderer = {
icons = {
glyphs = {
git = { -- https://github.com/nvim-neo-tree/neo-tree.nvim/blob/main/doc/neo-tree.txt#L1077C1-L1077C29
unmerged = "",
renamed = "",
deleted = "",
untracked = "",
ignored = "",
unstaged = "󰄱",
staged = "",
},
},
},
},
},
}

View file

@ -0,0 +1,96 @@
-- Welcome to nvim's systemd :D
return {
"folke/snacks.nvim",
priority = 1000,
lazy = false,
---@type snacks.Config
opts = {
bigfile = { enabled = true },
dashboard = {
enabled = true,
preset = {
keys = {
-- { key = "p", icon = "󰈞 ", desc = "查找项目", action = "<cmd>Telescope projects<CR>" },
{ key = "h", icon = "", desc = "历史文件", action = "<cmd>FzfLua oldfiles<CR>" },
{ key = "l", icon = "", desc = "加载会话", action = "<cmd>SessionSearch<CR>" },
{
key = "c",
icon = "",
desc = "转到设置",
action = "<cmd>FzfLua files cwd=~/.config/nvim<CR>",
},
{ key = "q", icon = "󱊷 ", desc = "退出", action = "<cmd>qa<CR>" },
},
header = [[
================= =============== =============== ======== ========
\\ . . . . . . .\\ //. . . . . . .\\ //. . . . . . .\\ \\. . .\\// . . //
||. . ._____. . .|| ||. . ._____. . .|| ||. . ._____. . .|| || . . .\/ . . .||
|| . .|| ||. . || || . .|| ||. . || || . .|| ||. . || ||. . . . . . . ||
||. . || || . .|| ||. . || || . .|| ||. . || || . .|| || . | . . . . .||
|| . .|| ||. _-|| ||-_ .|| ||. . || || . .|| ||. _-|| ||-_.|\ . . . . ||
||. . || ||-' || || `-|| || . .|| ||. . || ||-' || || `|\_ . .|. .||
|| . _|| || || || || ||_ . || || . _|| || || || |\ `-_/| . ||
||_-' || .|/ || || \|. || `-_|| ||_-' || .|/ || || | \ / |-_.||
|| ||_-' || || `-_|| || || ||_-' || || | \ / | `||
|| `' || || `' || || `' || || | \ / | ||
|| .===' `===. .==='.`===. .===' /==. | \/ | ||
|| .==' \_|-_ `===. .===' _|_ `===. .===' _-|/ `== \/ | ||
|| .==' _-' `-_ `=' _-' `-_ `=' _-' `-_ /| \/ | ||
|| .==' _-' '-__\._-' '-_./__-' `' |. /| | ||
||.==' _-' `' | /==.||
==' _-' N E O V I M \/ `==
\ _-' `-_ /
`'' ``'
]],
--[[header = [[
--]]
},
sections = {
{ section = "header" },
{ icon = "", title = "Keymaps", section = "keys", indent = 2, padding = 1 },
{ icon = "", title = "Recent Files", section = "recent_files", indent = 2, padding = 1 },
{ icon = "", title = "Projects", section = "projects", indent = 2, padding = 1 },
{ section = "startup" },
},
},
-- explorer = {
-- },
indent = { enabled = true },
-- input = { enabled = true },
notifier = { enabled = true },
-- quickfile = { enabled = true },
scope = { enabled = true },
-- scroll = { enabled = true },
statuscolumn = { enabled = true },
-- words = { enabled = true },
image = {
enabled = true,
img_dirs = { "_Global/Assets" }
},
},
keys = {
-- {
-- "<leader>ft",
-- function()
-- require("snacks").explorer()
-- end,
-- desc = "Toggle File Explorer",
-- },
},
}

View file

@ -0,0 +1,52 @@
return {
"nvim-telescope/telescope.nvim",
cmd = "Telescope",
opts = {
defaults = {
prompt_prefix = require("config.icons").telescope,
selection_caret = " ",
entry_prefix = " ",
layout_config = { -- https://github.com/NvChad/NvChad/blob/v2.5/lua/nvchad/configs/telescope.lua
horizontal = {
prompt_position = "top",
preview_width = 0.55,
},
width = 0.87,
height = 0.80,
},
mappings = {
n = {
["n"] = "move_selection_next",
["e"] = "move_selection_previous",
["w"] = "preview_scrolling_up",
["r"] = "preview_scrolling_down",
["a"] = "preview_scrolling_left",
["s"] = "preview_scrolling_right",
["q"] = require("telescope.actions").close,
},
},
},
},
dependencies = { "nvim-lua/plenary.nvim" },
keys = {
{ "<leader><leader>", "<cmd>Telescope find_files<CR>", desc = "Find Files" },
{ "<leader>fc", "<cmd>Telescope find_files cwd=~/.config/nvim<CR>", desc = "Edit configs" },
{ "<leader>/", "<cmd>Telescope live_grep<CR>", desc = "Grep Files" },
{ "<leader>;", "<cmd>Telescope<CR>", desc = "Show Telescope Commands" },
{ "<leader>ui", "<cmd>FzfLua colorscheme<CR>", desc = "Change colorscheme" },
{ "<leader>pp", "<cmd>Telescope projects<CR>", desc = "List all Projects" },
{ "<leader>pg", "<cmd>Telescope projects<CR>", desc = "List all Git Projects" },
{ "<leader>ps", "<cmd>Telescope session-lens<CR>", desc = "List all sessions" },
{ "<leader>gs", "<cmd>Telescope git_status<CR>", desc = "Git Status" },
{ "<leader>gt", "<cmd>Telescope git_branches<CR>", desc = "Git Branches" },
{ "<leader>gc", "<cmd>Telescope git_commits<CR>", desc = "Show commits" },
{ "<leader>fb", "<cmd>Telescope buffers<CR>", desc = "List Buffers" },
{ "<leader>ff", "<cmd>Telescope fd<CR>", desc = "Find Files" },
{ "<leader>fh", "<cmd>Telescope oldfiles<CR>", desc = "Recent Files" },
{ "<leader>ce", "<cmd>Telescope diagnostics<CR>", desc = "Navigate errors/warnings" },
{ "<leader>cs", "<cmd>Telescope treesitter<CR>", desc = "Search symbols" },
{ "<leader>cS", "<cmd>Telescope grep_string<CR>", desc = "Search current symbol" },
{ "<leader>bB", "<cmd>Telescope buffers<CR>", desc = "List Buffers" },
{ "<leader>fl", "<cmd>Telescope filetypes", desc = "Set Filetype/Lang to ..." },
},
}

View file

@ -0,0 +1,26 @@
local function get_highlight()
if vim.g.colors_name == "catppuccin" then
-- NOTE: This won't work since no integration is available
return require("catppuccin.groups.integrations.bufferline").get()
-- return require("rose-pine.plugins.toggleterm")
elseif vim.g.colors_name == "rose-pine" then
return require("rose-pine.plugins.toggleterm")
end
end
return {
"akinsho/toggleterm.nvim",
keys = {
{ "<leader>!", "<cmd>ToggleTerm direction=float<CR>", desc = "Toggle Terminal" },
{ "<leader>tf", "<cmd>ToggleTerm direction=float<CR>", desc = "Toggle Terminal" },
{ "<leader>tt", "<cmd>ToggleTerm<CR>", desc = "Spawn a float terminal" },
},
event = "ColorScheme",
opts = {
highlights = get_highlight(),
},
cmd = {
"ToggleTerm",
"LazyGit",
},
}

View file

@ -0,0 +1,37 @@
return {
"folke/trouble.nvim",
opts = {}, -- for default options, refer to the configuration section for custom setup.
cmd = "Trouble",
keys = {
{
"<leader>eE",
"<cmd>Trouble diagnostics toggle<cr>",
desc = "Diagnostics (Trouble)",
},
{
"<leader>ee",
"<cmd>Trouble diagnostics toggle filter.buf=0<cr>",
desc = "Buffer Diagnostics (Trouble)",
},
{
"<leader>es",
"<cmd>Trouble symbols toggle focus=false<cr>",
desc = "Symbols (Trouble)",
},
{
"<leader>el",
"<cmd>Trouble lsp toggle focus=false win.position=right<cr>",
desc = "LSP Definitions / references / ... (Trouble)",
},
{
"<leader>eL",
"<cmd>Trouble loclist toggle<cr>",
desc = "Location List (Trouble)",
},
{
"<leader>ef",
"<cmd>Trouble qflist toggle<cr>",
desc = "Quickfix List (Trouble)",
},
},
}

View file

@ -0,0 +1,16 @@
return {
"folke/which-key.nvim",
event = "VeryLazy",
opts = {
preset = "modern",
},
keys = {
{
"<leader>?",
function()
require("which-key").show({ global = false })
end,
desc = "Buffer Local Keymaps (which-key)",
},
},
}