This commit is contained in:
2025-05-09 22:16:19 +08:00
commit b868f3fd04
23 changed files with 575 additions and 0 deletions

35
lua/config/autocmds.lua Normal file
View File

@@ -0,0 +1,35 @@
local function augroup(name)
return vim.api.nvim_create_augroup("lazyvim_" .. name, { clear = true })
end
vim.api.nvim_create_autocmd("FileType", {
group = augroup("wrap_spell"),
pattern = { "gitcommit", "markdown" },
callback = function()
vim.opt_local.wrap = true
-- vim.opt_local.spell = false -- 覆盖默认的 true
end,
})
vim.api.nvim_create_autocmd("FileType", {
group = augroup("associate_filetype"),
pattern = { "cpp","php","go","jsx","js","html","css","c", "rust", "python","lua" },
callback = function()
-- vim.opt.shiftwidth = 2
-- 防止使用 o 切换到下一行的时候自动加上注释符号(在上一行是注释的情况下)
vim.opt.formatoptions:remove({ "o" })
end,
})
vim.api.nvim_create_autocmd("FileType", {
group = augroup("associate_filetype"),
pattern = { "cpp","php","go","jsx","js","html","css","c", "rust", "python","lua" },
callback = function()
vim.opt.shiftwidth = 4
-- 防止使用 o 切换到下一行的时候自动加上注释符号(在上一行是注释的情况下)
vim.opt.formatoptions:remove({ "o" })
end,
})

14
lua/config/keymaps.lua Normal file
View File

@@ -0,0 +1,14 @@
-- Keymaps are automatically loaded on the VeryLazy event
-- Default keymaps that are always set: https://github.com/LazyVim/LazyVim/blob/main/lua/lazyvim/config/keymaps.lua
-- Add any additional keymaps here
local map = LazyVim.safe_keymap_set
map("n", ",c", "<cmd>HopChar2<cr>")
map("n", ",s", "<cmd>HopPattern<cr>")
map("n", ",l", "<cmd>HopLineStart<cr>")
map("n", ",w", "<cmd>HopWord<cr>")
map("i", "jj", "<esc>", { noremap = false,desc = "BACK NORMAL" })
map("i", "jk", "<esc>", { noremap = false,desc = "BACK NORMAL" })
map("i", "kk", "<esc>", { noremap = false,desc = "BACK NORMAL" })

55
lua/config/lazy.lua Normal file
View File

@@ -0,0 +1,55 @@
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not (vim.uv or vim.loop).fs_stat(lazypath) then
local lazyrepo = "https://github.com/folke/lazy.nvim.git"
local out = vim.fn.system({ "git", "clone", "--filter=blob:none", "--branch=stable", lazyrepo, lazypath })
if vim.v.shell_error ~= 0 then
vim.api.nvim_echo({
{ "Failed to clone lazy.nvim:\n", "ErrorMsg" },
{ out, "WarningMsg" },
{ "\nPress any key to exit..." },
}, true, {})
vim.fn.getchar()
os.exit(1)
end
end
vim.opt.rtp:prepend(lazypath)
require("lazy").setup({
spec = {
-- add LazyVim and import its plugins
{ "LazyVim/LazyVim", import = "lazyvim.plugins" },
-- { import = "lazyvim.plugins.extras.ui.alpha" },
-- { import = "lazyvim.plugins.extras.ai.codeium" },
-- import/override with your plugins
{ import = "plugins" },
},
defaults = {
-- By default, only LazyVim plugins will be lazy-loaded. Your custom plugins will load during startup.
-- If you know what you're doing, you can set this to `true` to have all your custom plugins lazy-loaded by default.
lazy = false,
-- It's recommended to leave version=false for now, since a lot the plugin that support versioning,
-- have outdated releases, which may break your Neovim install.
version = false, -- always use the latest git commit
-- version = "*", -- try installing the latest stable version for plugins that support semver
},
install = { colorscheme = { "tokyonight", "habamax" } },
checker = {
enabled = true, -- check for plugin updates periodically
notify = false, -- notify on update
}, -- automatically check for plugin updates
performance = {
rtp = {
-- disable some rtp plugins
disabled_plugins = {
"gzip",
-- "matchit",
-- "matchparen",
-- "netrwPlugin",
"tarPlugin",
"tohtml",
"tutor",
"zipPlugin",
},
},
},
})

9
lua/config/options.lua Normal file
View File

@@ -0,0 +1,9 @@
vim.g.autoformat = false
local opt = vim.opt
opt.spell = false
opt.wrap = true
opt.relativenumber = false
opt.mouse="a"

View File

@@ -0,0 +1,23 @@
return {
"akinsho/bufferline.nvim",
event = "VeryLazy",
opts = {
options = {
separator_style = { " ", " " },
},
highlights = {
buffer_selected = { italic = false, bold = false },
},
},
config = function(_, opts)
require("bufferline").setup(opts)
-- Fix bufferline when restoring a session
vim.api.nvim_create_autocmd("BufAdd", {
callback = function()
vim.schedule(function()
pcall(nvim_bufferline)
end)
end,
})
end,
}

3
lua/plugins/diffview.lua Normal file
View File

@@ -0,0 +1,3 @@
return {
"sindrets/diffview.nvim",
}

5
lua/plugins/disable.lua Normal file
View File

@@ -0,0 +1,5 @@
return {
{ "folke/flash.nvim", enabled = false },
{ "echasnovski/mini.pairs", enabled = false },
{ "folke/noice.nvim", enabled = false },
}

8
lua/plugins/hop.lua Normal file
View File

@@ -0,0 +1,8 @@
return {
"smoka7/hop.nvim",
version = "*",
vscode = true,
opts = {
keys = "etovxqpdygfblzhckisuran",
},
}

View File

@@ -0,0 +1,4 @@
return {
{ "mason-org/mason.nvim", version = "^1.0.0" },
{ "mason-org/mason-lspconfig.nvim", version = "^1.0.0" },
}

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

@@ -0,0 +1,36 @@
return {
"nvim-neo-tree/neo-tree.nvim",
cmd = "Neotree",
keys = {
{
"<leader>fe",
function()
require("neo-tree.command").execute({ toggle = true, reveal = true, dir = LazyVim.root() })
end,
desc = "Explorer NeoTree (Root Dir)",
},
{
"<leader>fE",
function()
require("neo-tree.command").execute({ toggle = true, reveal = true, dir = vim.uv.cwd() })
end,
desc = "Explorer NeoTree (cwd)",
},
{ "<leader>e", "<leader>fe", desc = "Explorer NeoTree (Root Dir)", remap = true },
{ "<leader>E", "<leader>fE", desc = "Explorer NeoTree (cwd)", remap = true },
{
"<leader>ge",
function()
require("neo-tree.command").execute({ source = "git_status", toggle = true })
end,
desc = "Git Explorer",
},
{
"<leader>be",
function()
require("neo-tree.command").execute({ source = "buffers", toggle = true })
end,
desc = "Buffer Explorer",
},
},
}

View File

@@ -0,0 +1,5 @@
return {
"windwp/nvim-autopairs",
event = "InsertEnter",
opts = {}, -- this is equalent to setup({}) function
}

39
lua/plugins/nvim-cmp.lua Normal file
View File

@@ -0,0 +1,39 @@
return {
"hrsh7th/nvim-cmp",
---@param opts cmp.ConfigSchema
opts = function(_, opts)
local has_words_before = function()
unpack = unpack or table.unpack
local line, col = unpack(vim.api.nvim_win_get_cursor(0))
return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil
end
local cmp = require("cmp")
opts.mapping = vim.tbl_extend("force", opts.mapping, {
["<Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then
-- You could replace select_next_item() with confirm({ select = true }) to get VS Code autocompletion behavior
cmp.select_next_item()
elseif vim.snippet.active({ direction = 1 }) then
vim.schedule(function()
vim.snippet.jump(1)
end)
elseif has_words_before() then
cmp.complete()
else
fallback()
end
end, { "i", "s" }),
["<S-Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_prev_item()
elseif vim.snippet.active({ direction = -1 }) then
vim.schedule(function()
vim.snippet.jump(-1)
end)
else
fallback()
end
end, { "i", "s" }),
})
end,
}

View File

@@ -0,0 +1,16 @@
-- surr*ound_words ysiw) (surround_words)
-- *make strings ys$" "make strings"
-- [delete ar*ound me!] ds] delete around me!
-- remove <b>HTML t*ags</b> dst remove HTML tags
-- 'change quot*es' cs'" "change quotes"
-- <b>or tag* types</b> csth1<CR> <h1>or tag types</h1>
-- delete(functi*on calls) dsf function calls
return {
"kylechui/nvim-surround",
version = "*", -- Use for stability; omit to use `main` branch for the latest features
event = "VeryLazy",
config = function()
require("nvim-surround").setup({
})
end,
}

25
lua/plugins/outline.lua Normal file
View File

@@ -0,0 +1,25 @@
return {
"hedyhli/outline.nvim",
keys = { { "<leader>cs", "<cmd>Outline<cr>", desc = "Toggle Outline" } },
cmd = "Outline",
opts = function()
local defaults = require("outline.config").defaults
local opts = {
symbols = {
icons = {},
filter = vim.deepcopy(LazyVim.config.kind_filter),
},
keymaps = {
up_and_jump = "<up>",
down_and_jump = "<down>",
},
}
for kind, symbol in pairs(defaults.symbols.icons) do
opts.symbols.icons[kind] = {
icon = LazyVim.config.icons.kinds[kind] or symbol.icon,
hl = symbol.hl,
}
end
return opts
end,
}

10
lua/plugins/theme.lua Normal file
View File

@@ -0,0 +1,10 @@
return {
{ "catppuccin/nvim", name = "catppuccin", priority = 1000, opts = { transparent_background = true } },
{ "projekt0n/github-nvim-theme", name = "github-theme", opts = {} },
{
"LazyVim/LazyVim",
opts = {
colorscheme = "catppuccin",
},
},
}