nvim: delete unused lua files

This commit is contained in:
js0ny 2025-11-17 15:31:52 +00:00
parent 8a266783a2
commit 51e6343b9e
18 changed files with 42 additions and 781 deletions

View file

@ -1,12 +0,0 @@
[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
[*.lua]
indent_type = "Spaces"
indent_width = 2
column_width = 120

View file

@ -1,36 +0,0 @@
local M = {}
-- Markdown
local function set_markdown_keymaps(bufnr)
local markdown_opt = { noremap = true, silent = true, buffer = bufnr }
for _, map in ipairs(M.markdown) do
local opts = vim.tbl_extend("force", markdown_opt, map.opts or {})
vim.keymap.set(map.mode, map.keys, map.cmd, opts)
end
end
M.markdown = {
{ mode = "v", keys = "`", cmd = "c`<Esc>pi`<Esc>", desc = "Wrap selection in ` for inline code" },
{ mode = "v", keys = "*", cmd = "c**<Esc>pi**<Esc>", desc = "Wrap selection in ** for bold" },
{ mode = "v", keys = "_", cmd = "c*<Esc>pi*<Esc>", desc = "Wrap selection in * for italic" },
}
vim.api.nvim_create_autocmd("FileType", {
pattern = "markdown",
callback = function()
set_markdown_keymaps(0)
vim.opt_local.shiftwidth = 2
vim.opt_local.tabstop = 2
end,
})
vim.api.nvim_create_autocmd("FileType", {
pattern = "nix",
callback = function()
vim.opt_local.shiftwidth = 2
vim.opt_local.tabstop = 2
end,
})
return M

View file

@ -1,194 +0,0 @@
local M = {}
local formatFx = function()
require("conform").format({ async = true })
end
local renameCurrentBuffer = function()
local old_name = vim.fn.expand("%:p")
local new_name = vim.fn.input("New name: ", vim.fn.expand("%:p:h") .. "/")
if new_name == "" then
print("No new name provided")
return
elseif new_name == old_name then
return
end
vim.cmd("write")
local success, err = os.rename(old_name, new_name)
if not success then
print("Error renaming file: " .. err)
return
end
vim.cmd("edit " .. new_name)
vim.cmd("bdelete " .. old_name)
end
-- 通用映射函数
local function apply_mappings(maps, prefix)
for _, map in ipairs(maps) do
local new_map = {
keys = prefix .. map.keys,
cmd = map.cmd,
opts = map.opts,
}
table.insert(M, new_map)
end
end
vim.api.nvim_create_user_command("Rename", renameCurrentBuffer, {})
local leader_mappings = {
general = {
{ keys = "<leader>", cmd = ":Telescope find_files<CR>", opts = { desc = "Find Files" } },
{ keys = "/", cmd = ":Telescope live_grep<CR>", opts = { desc = "Grep Files" } },
{ keys = "-", cmd = ":split<CR>", opts = { desc = "Split to down" } },
{ keys = "\\", cmd = ":vsplit<CR>", opts = { desc = "Split to right" } },
{ keys = "|", cmd = ":vsplit<CR>", opts = { desc = "Split to right" } },
{ keys = "h", cmd = "<C-w>h", opts = { desc = "Left Window" } },
{ keys = "n", cmd = "<C-w>j", opts = { desc = "Down Window" } },
{ keys = "e", cmd = "<C-w>k", opts = { desc = "Up Window" } },
{ keys = "i", cmd = "<C-w>l", opts = { desc = "Right Window" } },
{ keys = "F", cmd = ":NvimTreeFindFileToggle<CR>", opts = { desc = "Toggle File Explorer" } },
{ keys = "<Tab>", cmd = "<Cmd>b#<CR>", opts = { desc = "Switch to last buffer" } },
{ keys = "!", cmd = ":FloatermToggle<CR>", opts = { desc = "Toggle Terminal" } },
{ keys = '"', cmd = ":!wezterm-gui &<CR>", pots = { desc = "Open External Terminal(wezterm)" } },
{ keys = ";", cmd = ":Telescope<CR>", pots = { desc = "Show Telescope Commands" } },
},
b = { -- +buffer
{ keys = "0", cmd = "<Cmd>b#<CR>", opts = { desc = "Switch to last buffer" } },
{ keys = "1", cmd = ":BufferLineGotoBuffer 1<CR>", opts = { desc = "Switch to Buffer #1" } },
{ keys = "2", cmd = ":BufferLineGotoBuffer 2<CR>", opts = { desc = "Switch to Buffer #2" } },
{ keys = "3", cmd = ":BufferLineGotoBuffer 3<CR>", opts = { desc = "Switch to Buffer #3" } },
{ keys = "4", cmd = ":BufferLineGotoBuffer 4<CR>", opts = { desc = "Switch to Buffer #4" } },
{ keys = "5", cmd = ":BufferLineGotoBuffer 5<CR>", opts = { desc = "Switch to Buffer #5" } },
{ keys = "6", cmd = ":BufferLineGotoBuffer 6<CR>", opts = { desc = "Switch to Buffer #6" } },
{ keys = "7", cmd = ":BufferLineGotoBuffer 7<CR>", opts = { desc = "Switch to Buffer #7" } },
{ keys = "8", cmd = ":BufferLineGotoBuffer 8<CR>", opts = { desc = "Switch to Buffer #8" } },
{ keys = "9", cmd = ":BufferLineGotoBuffer 9<CR>", opts = { desc = "Switch to Buffer #9" } },
{ keys = "a", cmd = ":Alpha<CR>", opts = { desc = "Dashboard" } },
{ keys = "b", cmd = ":BufferLinePick<CR>", opts = { desc = "Quick Switch Buffers" } },
{ keys = "B", cmd = ":Telescope buffers<CR>", opts = { desc = "List Buffers" } },
{ keys = "d", cmd = ":bdelete<CR>", opts = { desc = "Delete Buffer" } },
{ keys = "D", cmd = ":BufferLineCloseOthers<CR>", opts = { desc = "Delete Other Buffers" } },
{ keys = "xx", cmd = ":BufferLineCloseOthers<CR>", opts = { desc = "Delete Other Buffers" } },
{ keys = "xh", cmd = ":BufferLineCloseLeft<CR>", opts = { desc = "Delete Buffers Left" } },
{ keys = "xi", cmd = ":BufferLineCloseRight<CR>", opts = { desc = "Delete Buffers Right" } },
{ keys = "X", cmd = ":BufferLineCloseOthers<CR>", opts = { desc = "Delete Other Buffers" } },
{ keys = "h", cmd = ":bprevious<CR>", opts = { desc = "Previous Buffer" } },
{ keys = "i", cmd = ":bnext<CR>", opts = { desc = "Next Buffer" } },
{ keys = "H", cmd = ":bfirst<CR>", opts = { desc = "First Buffer" } },
{ keys = "I", cmd = ":blast<CR>", opts = { desc = "Last Buffer" } },
{ keys = "0", cmd = ":bfirst<CR>", opts = { desc = "First Buffer" } },
{ keys = "^", cmd = ":bfirst<CR>", opts = { desc = "First Buffer" } },
{ keys = "$", cmd = ":blast<CR>", opts = { desc = "Last Buffer" } },
{ keys = "s", cmd = ":new<CR>", opts = { desc = "Scratch buffers" } },
{ keys = "t", cmd = ":BufferLineTogglePin<CR>", opts = { desc = "Pin Buffer" } },
{ keys = "y", cmd = ":%y+<CR>", opts = { desc = "Copy Buffer to Clipboard" } },
},
c = { -- +code/compile
{ keys = "r", cmd = ":RunCode<CR>", opts = { desc = "Run code" } },
{ keys = "R", cmd = vim.lsp.buf.rename, opts = { desc = "Rename symbol under cursor" } },
{ keys = "e", cmd = ":Telescope diagnostics<CR>", opts = { desc = "Navigate errors/warnings" } },
{ keys = "f", cmd = formatFx, opts = { desc = "Format buffer" } },
{ keys = "s", cmd = ":Telescope treesitter<CR>", opts = { desc = "Search symbols" } },
{ keys = "S", cmd = ":Telescope grep_string<CR>", opts = { desc = "Search current symbol" } },
},
f = { -- +file/find
{ keys = "f", cmd = ":Telescope fd<CR>", opts = { desc = "Find Files" } },
{ keys = "F", cmd = ":GrugFar<CR>", opts = { desc = "Search & Replace" } },
{ keys = "l", cmd = ":set filetype=", opts = { desc = "Set Filetype to ..." } },
{ keys = "n", cmd = ":new<CR>", opts = { desc = "New File" } },
{ keys = "s", cmd = ":write<CR>", opts = { desc = "Save File" } },
{ keys = "S", cmd = ":wall<CR>", opts = { desc = "Save All Files" } },
{ keys = "b", cmd = ":Telescope buffers<CR>", opts = { desc = "List Buffers" } },
{ keys = "D", cmd = "!trash-rm %<CR>", opts = { desc = "Delete current file" } },
{ keys = "t", cmd = ":NvimTreeFindFileToggle<CR>", opts = { desc = "Toggle File Tree" } },
{ keys = "T", cmd = ":FloatermNew<CR>", opts = { desc = "Spawn a float terminal" } },
{ keys = "h", cmd = ":Telescope oldfiles<CR>", opts = { desc = "Search history files" } },
{ keys = "c", cmd = ":Telescope find_files cwd=~/.config/nvim<CR>", opts = { desc = "Search Config" } },
{ keys = "o", cmd = ":!open %<CR>", opts = { desc = "Open file in default program" } },
{ keys = "R", cmd = renameCurrentBuffer, opts = { desc = "Rename current file" } },
{ keys = "x", cmd = ":Lazy<CR>", opts = { desc = "Open extension view" } },
{ keys = "yy", cmd = ":let @+ = expand('%:p')<CR>", opts = { desc = "Copy file path" } },
{ keys = "yY", cmd = ":let @+ = expand('%')<CR>", opts = { desc = "Copy relative file path" } },
{ keys = "yn", cmd = ":let @+ = expand('%:t')<CR>", opts = { desc = "Copy file name" } },
{ keys = "yN", cmd = ":let @+ = expand('%:t:r')<CR>", opts = { desc = "Copy file name without extension" } },
{ keys = "yd", cmd = ":let @+ = expand('%:p:h')<CR>", opts = { desc = "Copy directory path" } },
{
keys = "yl",
cmd = ":let @+ = expand('%:p') . ':' . line('.')<CR>",
opts = { desc = "Copy file path with line number" },
},
{
keys = "yL",
cmd = ":let @+ = expand('%') . ':' . line('.')<CR>",
opts = { desc = "Copy relative file path with line number" },
},
},
g = { -- +git/version control
{ keys = "g", cmd = ":LazyGit<CR>", opts = { desc = "Toggle LazyGit" } },
{ keys = "c", cmd = ":Telescope git_commits<CR>", opts = { desc = "Show commits" } },
{ keys = "b", cmd = ":Gitsigns blame<CR>", opts = { desc = "Blame file" } },
{ keys = "d", cmd = ":Gitsigns diffthis<CR>", opts = { desc = "Diff file" } },
{ keys = "B", cmd = ":Gitsigns toggle_current_line_blame<CR>", opts = { desc = "Toggle line blame" } },
{ keys = "s", cmd = ":Telescope git_status<CR>", opts = { desc = "Git Status" } },
{ keys = "t", cmd = ":Telescope git_branches<CR>", opts = { desc = "Git Branches" } },
},
j = { -- +lsp
{ keys = "r", cmd = vim.lsp.buf.references, opts = { desc = "Show current reference" } },
},
p = { -- +project
{ keys = "p", cmd = ":Telescope projects<CR>", opts = { desc = "List all Projects" } },
{ keys = "g", cmd = ":Telescope projects<CR>", opts = { desc = "List all Git Projects" } },
{ keys = "s", cmd = ":Telescope session-lens<CR>", opts = { desc = "List all sessions" } },
},
q = { -- +quit
{ keys = "q", cmd = ":q<CR>", opts = { desc = "Quit" } },
{ keys = "Q", cmd = ":qa!<CR>", opts = { desc = "Force Quit" } },
{ keys = "w", cmd = ":wq<CR>", opts = { desc = "Write and Quit" } },
{ keys = "W", cmd = ":wall<CR>:qa!<CR>", opts = { desc = "Write all and Force Quit" } },
},
t = { -- +toggle/test
{ keys = "f", cmd = ":NvimTreeToggle", opts = { desc = "Toggle File Explorer" } },
{ keys = "F", cmd = ":FormatToggle<CR>", opts = { desc = "Toggle autoformat-on-save" } },
{ keys = "t", cmd = ":FloatermToggle<CR>", opts = { desc = "toggle visibility of the float terminal" } },
},
u = { -- +ui
{ keys = "i", cmd = ":Telescope colorscheme<CR>", opts = { desc = "Change colorscheme" } },
{ keys = " ", cmd = ":set list!", opts = { desc = "Toggle show all symbols" } },
},
w = { -- +window
{ keys = "h", cmd = "<C-w>h", opts = { desc = "Left Window" } },
{ keys = "n", cmd = "<C-w>j", opts = { desc = "Down Window" } },
{ keys = "e", cmd = "<C-w>k", opts = { desc = "Up Window" } },
{ keys = "i", cmd = "<C-w>l", opts = { desc = "Right Window" } },
{ keys = "H", cmd = "<C-w>H", opts = { desc = "Move Window Left" } },
{ keys = "N", cmd = "<C-w>J", opts = { desc = "Move Window Down" } },
{ keys = "E", cmd = "<C-w>K", opts = { desc = "Move Window Up" } },
{ keys = "I", cmd = "<C-w>L", opts = { desc = "Move Window Right" } },
{ keys = "-", cmd = ":split<CR>", opts = { desc = "Split to down" } },
{ keys = "|", cmd = ":vsplit<CR>", opts = { desc = "Split to right" } },
{ keys = "/", cmd = ":vsplit<CR>", opts = { desc = "Split to right" } },
{ keys = "d", cmd = "<C-w>c", opts = { desc = "Close Window" } },
{ keys = "D", cmd = "<C-w>o", opts = { desc = "Close Other Windows" } },
{ keys = "r", cmd = "<C-w>r", opts = { desc = "Rotate Windows" } },
{ keys = "R", cmd = "<C-w>R", opts = { desc = "Reverse Rotate Windows" } },
{ keys = "t", cmd = "<C-w>T", opts = { desc = "Move Window to New Tab" } },
{ keys = "]", cmd = ":resize +5<CR>", opts = { desc = "Increase Window Size" } },
{ keys = "[", cmd = ":resize -5<CR>", opts = { desc = "Decrease Window Size" } },
{ keys = "M", cmd = ":resize<CR>:vertical resize<CR>", opts = { desc = "Maximize window size" } },
},
}
for key, maps in pairs(leader_mappings) do
if key == "general" then
apply_mappings(maps, "<leader>")
else
apply_mappings(maps, "<leader>" .. key)
end
end
return M

View file

@ -4,29 +4,6 @@ local formatFx = function()
require("conform").format({ async = true })
end
local renameCurrentBuffer = function()
local old_name = vim.fn.expand("%:p")
local new_name = vim.fn.input("New name: ", vim.fn.expand("%:p:h") .. "/")
if new_name == "" then
print("No new name provided")
return
elseif new_name == old_name then
return
end
vim.cmd("write")
local success, err = os.rename(old_name, new_name)
if not success then
print("Error renaming file: " .. err)
return
end
vim.cmd("edit " .. new_name)
vim.cmd("bdelete " .. old_name)
end
-- 通用映射函数
local function apply_mappings(maps, prefix)
for _, map in ipairs(maps) do
@ -38,8 +15,8 @@ local function apply_mappings(maps, prefix)
table.insert(M, new_map)
end
end
vim.api.nvim_create_user_command("Rename", renameCurrentBuffer, {})
-- stylua: ignore start
local leader_mappings = {
general = {
{ keys = "-", cmd = ":split<CR>", opts = { desc = "Split to down" } },
@ -92,7 +69,7 @@ local leader_mappings = {
{ keys = "D", cmd = "!trash-rm %<CR>", opts = { desc = "Delete current file" } },
-- { keys = "t", cmd = ":NvimTreeFindFileToggle<CR>", opts = { desc = "Toggle File Tree" } },
-- { keys = "o", cmd = ":!open %<CR>", opts = { desc = "Open file in default program" } },
{ keys = "R", cmd = renameCurrentBuffer, opts = { desc = "Rename current file" } },
{ keys = "R", cmd = "<cmd>Rename<CR>", opts = { desc = "Rename current file" } },
{ keys = "x", cmd = ":Lazy<CR>", opts = { desc = "Open extension view" } },
{ keys = "yy", cmd = ":let @+ = expand('%:p')<CR>", opts = { desc = "Copy file path" } },
{ keys = "yY", cmd = ":let @+ = expand('%')<CR>", opts = { desc = "Copy relative file path" } },
@ -152,6 +129,7 @@ local leader_mappings = {
{ keys = "M", cmd = ":resize<CR>:vertical resize<CR>", opts = { desc = "Maximize window size" } },
},
}
-- stylua: ignore end
for key, maps in pairs(leader_mappings) do
if key == "general" then

View file

@ -1,3 +1,4 @@
-- stylua: ignore start
local M = {
{ keys = "gd", cmd = vim.lsp.buf.definition, opts = { desc = "Goto Definition" } },
{ keys = "<C-CR>", cmd = vim.lsp.buf.definition, opts = { desc = "Goto Definition" } },
@ -10,17 +11,7 @@ local M = {
-- [c]hange [d]efinition
{ keys = "cd", cmd = vim.lsp.buf.rename, opts = { desc = "Rename symbol under cursor" } },
}
-- local function smart_split_definition()
-- local width = vim.api.nvim_win_get_width(0)
-- if width > 80 then -- Adjust 80 to your preference
-- vim.api.nvim_command("vsp")
-- else
-- vim.api.nvim_command("sp")
-- end
-- vim.lsp.buf.definition()
-- end
-- vim.keymap.set("n", "<C-w>d", smart_split_definition, { desc = "Go to Definition (Smart Split)" })
-- stylua: ignore end
local function smart_split(func)
local width = vim.api.nvim_win_get_width(0)

View file

@ -1,9 +1,4 @@
local keymaps_modifier = {
-- Use C-w to move between windows
-- { keys = "<C-w>h", cmd = "<C-w>h", opts = { desc = "left Window" } },
-- { keys = "<C-w>n", cmd = "<C-w>j", opts = { desc = "Down Window" } },
-- { keys = "<C-w>e", cmd = "<C-w>k", opts = { desc = "Up Window" } },
-- { keys = "<C-w>i", cmd = "<C-w>l", opts = { desc = "Right Window" } },
{ keys = "<A-x>", cmd = "<Cmd>FzfLua commands<CR>", opts = { desc = "Commands" } },
}

View file

@ -1,87 +0,0 @@
local M = {}
M.event = "BufEnter"
M.global = {
{ mode = "n", keys = "<leader>E", cmd = ":NvimTreeToggle<CR>" },
{ mode = "n", keys = "<A-0>", cmd = ":NvimTreeFindFileToggle<CR>" },
}
function M.plugin(api, opts)
-- mode is set to "n" by default, in `./lua/plugins/nvim-tree.lua`
return {
-- Toggle
{ keys = "<leader>e", cmd = ":NvimTreeToggle<CR>", opts = opts("Toggle") },
-- Arrow 箭头 hnei
{ keys = "h", cmd = api.node.navigate.parent_close, opts = opts("Close node") },
{ keys = "i", cmd = api.node.open.edit, opts = opts("Open") },
{ keys = "H", cmd = api.tree.toggle_hidden_filter, opts = opts("Toggle Dotfiles") },
{ keys = "N", cmd = api.node.navigate.sibling.next, opts = opts("Next Sibling") },
{ keys = "E", cmd = api.node.navigate.sibling.prev, opts = opts("Previous Sibling") },
{ keys = "I", cmd = api.tree.toggle_gitignore_filter, opts = opts("Toggle GitIgnored") },
-- CONTROL KEYS 控制键
{ keys = "<BS>", cmd = api.node.navigate.parent_close, opts = opts("Close node") },
{ keys = "<CR>", cmd = api.node.open.edit, opts = opts("Open") },
{ keys = "<Tab>", cmd = api.node.open.preview, opts = opts("Open Preview") },
-- Alpha 字母键
{ keys = "a", cmd = api.fs.create, opts = opts("Create") },
{ keys = "A", cmd = api.fs.create, opts = opts("Create") },
{ keys = "bd", cmd = api.marks.bulk.delete, opts = opts("Delete Bookmarked") },
{ keys = "bt", cmd = api.marks.bulk.trash, opts = opts("Trash Bookmarked") },
{ keys = "bmv", cmd = api.marks.bulk.move, opts = opts("Move Bookmarked") },
{ keys = "B", cmd = api.tree.toggle_no_buffer_filter, opts = opts("Toggle Filter: No Buffer") },
{ keys = "c", cmd = api.fs.copy.node, opts = opts("Copy") },
{ keys = "C", cmd = api.fs.copy.filename, opts = opts("Copy") },
{ keys = "d", cmd = api.fs.remove, opts = opts("Delete") },
{ keys = "D", cmd = api.fs.trash, opts = opts("Trash") },
{ keys = "]e", cmd = api.node.navigate.diagnostics.next, opts = opts("Next Diagnostic") },
{ keys = "[e", cmd = api.node.navigate.diagnostics.prev, opts = opts("Prev Diagnostic") },
{ keys = "F", cmd = api.live_filter.clear, opts = opts("Live Filter: Clear") },
{ keys = "f", cmd = api.live_filter.start, opts = opts("Live Filter: Start") },
{ keys = "[g", cmd = api.node.navigate.git.prev, opts = opts("Prev Git") },
{ keys = "]g", cmd = api.node.navigate.git.next, opts = opts("Next Git") },
{ keys = "L", cmd = api.node.open.toggle_group_empty, opts = opts("Toggle Group Empty") },
{ keys = "M", cmd = api.tree.toggle_no_bookmark_filter, opts = opts("Toggle Filter: No Bookmark") },
{ keys = "m", cmd = api.marks.toggle, opts = opts("Toggle Bookmark") },
{ keys = "o", cmd = api.node.open.edit, opts = opts("Open") },
{ keys = "O", cmd = api.node.open.no_window_picker, opts = opts("Open: No Window Picker") },
{ keys = "p", cmd = api.fs.paste, opts = opts("Paste") },
{ keys = "P", cmd = api.node.navigate.parent, opts = opts("Parent Directory") },
{ keys = "q", cmd = api.tree.close, opts = opts("Close") },
{ keys = "r", cmd = api.fs.rename, opts = opts("Rename") },
{ keys = "R", cmd = api.tree.reload, opts = opts("Refresh") },
{ keys = "s", cmd = api.node.run.system, opts = opts("Run System") },
{ keys = "S", cmd = api.tree.search_node, opts = opts("Search") },
{ keys = "u", cmd = api.fs.rename_full, opts = opts("Rename: Full Path") },
{ keys = "U", cmd = api.tree.toggle_custom_filter, opts = opts("Toggle Filter: Hidden") },
{ keys = "W", cmd = api.tree.collapse_all, opts = opts("Collapse") },
{ keys = "x", cmd = api.fs.cut, opts = opts("Cut") },
{ keys = "y", cmd = api.fs.copy.relative_path, opts = opts("Copy Relative Path") },
{ keys = "Y", cmd = api.fs.copy.absolute_path, opts = opts("Copy Absolute Path") },
-- From Directory Opus
{ keys = "#", cmd = "<Cmd>set relativenumber!<CR>", opts = opts("Toggle Relative Number") },
-- Numeric 数字键
{ keys = "!", cmd = api.node.run.cmd, opts = opts("Run Command") },
-- Non-Alphanumeric 非字母数字键
{ keys = "?", cmd = api.tree.toggle_help, opts = opts("Help") },
{ keys = ">", cmd = api.node.navigate.sibling.next, opts = opts("Next Sibling") },
{ keys = "<", cmd = api.node.navigate.sibling.prev, opts = opts("Previous Sibling") },
{ keys = ".", cmd = api.node.run.cmd, opts = opts("Run Command") },
{ keys = ";", cmd = api.node.run.cmd, opts = opts("Run Command") },
{ keys = "-", cmd = api.tree.change_root_to_parent, opts = opts("Up") },
-- MOD KEYS Ctrl+
{ keys = "<C-]>", cmd = api.tree.change_root_to_node, opts = opts("CD") },
{ keys = "<C-e>", cmd = api.node.open.replace_tree_buffer, opts = opts("Open: In Place") },
{ keys = "<C-k>", cmd = api.node.show_info_popup, opts = opts("Info") },
{ keys = "<C-r>", cmd = api.fs.rename_sub, opts = opts("Rename: Omit Filename") },
{ keys = "<C-t>", cmd = api.node.open.tab, opts = opts("Open: New Tab") },
{ keys = "<C-v>", cmd = api.node.open.vertical, opts = opts("Open: Vertical Split") },
{ keys = "<C-h>", cmd = api.node.open.horizontal, opts = opts("Open: Horizontal Split") },
{ keys = "<A-0>", cmd = ":b#<CR>", opts = opts("Focus to previous buffer") },
-- Mouse 鼠标键
{ keys = "<2-LeftMouse>", cmd = api.node.open.edit, opts = opts("Open") },
{ keys = "<2-RightMouse>", cmd = api.tree.change_root_to_node, opts = opts("CD") },
}
end
return M

View file

@ -34,3 +34,27 @@ vim.api.nvim_create_user_command("Reload", function()
end, {
desc = "Reload Neovim configuration",
})
local renameCurrentBuffer = function()
local old_name = vim.fn.expand("%:p")
local new_name = vim.fn.input("New name: ", vim.fn.expand("%:p:h") .. "/")
if new_name == "" then
print("No new name provided")
return
elseif new_name == old_name then
return
end
vim.cmd("write")
local success, err = os.rename(old_name, new_name)
if not success then
print("Error renaming file: " .. err)
return
end
vim.cmd("edit " .. new_name)
vim.cmd("bdelete " .. old_name)
end
vim.api.nvim_create_user_command("Rename", renameCurrentBuffer, {})

View file

@ -1,9 +0,0 @@
-- Note that this plugin is a fork for colemak
-- Use mouse to select multiple cursors
vim.g.VM_mouse_mappings = 1
-- Disable default mappings
vim.g.VM_maps = {
["Add Cursor Down"] = "<A-n>",
["Add Cursor Up"] = "<A-e>",
}

View file

@ -1,3 +1,4 @@
-- TODO:
-- Debugger setups
return {
{

View file

@ -3,7 +3,7 @@ return {
"folke/flash.nvim",
event = "BufEnter",
opts = {},
-- stylua: ignore
-- stylua: ignore start
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" },
@ -11,6 +11,7 @@ return {
{ "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" },
},
-- stylua: ignore end
},
{ import = "plugins.mod.img-clip" },
{ import = "plugins.mod.mc" }, -- Multiple-cursors

View file

@ -1,55 +0,0 @@
-- 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>"),
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

@ -1,58 +0,0 @@
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

@ -1,22 +0,0 @@
-- I forgot why I keep this plugin, I use snacks.nvim currently
return {}
-- 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

@ -1,111 +0,0 @@
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

@ -1,40 +0,0 @@
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

@ -1,53 +0,0 @@
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

@ -1,52 +0,0 @@
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 ..." },
},
}