初始化neovim 配置

This commit is contained in:
LingZhaoHui 2024-06-08 12:17:10 +08:00
commit 34280b6c33
Signed by: zeekling
GPG Key ID: D96E4E75267CA2CC
12 changed files with 379 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
./lazy-lock.json

8
init.lua Normal file
View File

@ -0,0 +1,8 @@
vim.g.mapleader = " "
local vim = vim
vim.colorscheme = "oceanic-next"
require("lazynvim-init")
require("keybindings")

13
lua/keybindings.lua Normal file
View File

@ -0,0 +1,13 @@
vim.g.mapleader = " "
vim.keymap.set("n", "<leader>mk", "<cmd>MarkdownPreview<cr>", { silent = true })
vim.keymap.set("n", "<leader>ds", "<cmd>NvimTreeToggle<cr>", { silent = true })
vim.keymap.set("n", "<leader>dc", "<cmd>NvimTreeClose<cr>", { silent = true })
vim.keymap.set("n", "<leader>bp", "<cmd>BufferLineCyclePrev<cr>", { silent = true })
vim.keymap.set("n", "<leader>bn", "<cmd>BufferLineCycleNext<cr>", { silent = true })
vim.keymap.set("n", "<leader>bd", "<cmd>bd<cr>", { silent = true })

20
lua/lazynvim-init.lua Normal file
View File

@ -0,0 +1,20 @@
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
vim.fn.system({
"git",
"clone",
"--filter=blob:none",
"git@github.com:folke/lazy.nvim.git",
"--branch=stable", -- latest stable release
lazypath,
})
end
--
-- 2. 将 lazypath 设置为运行时路径
-- rtpruntime path
-- nvim进行路径搜索的时候除已有的路径还会从prepend的路径中查找
-- 否则,下面 require("lazy") 是找不到的
vim.opt.rtp:prepend(lazypath)
-- 3. 加载lazy.nvim模块
require("lazy").setup("plugins")

View File

@ -0,0 +1,39 @@
return {
{
"hrsh7th/nvim-cmp",
dependencies = {
"hrsh7th/cmp-buffer",
"hrsh7th/cmp-path",
"hrsh7th/cmp-nvim-lsp",
"L3MON4D3/LuaSnip",
"saadparwaiz1/cmp_luasnip",
},
config = function()
local cmp = require("cmp")
cmp.setup({
snippet = {
expand = function(args)
require("luasnip").lsp_expand(args.body)
end,
},
mapping = cmp.mapping.preset.insert({
['<C-b>'] = cmp.mapping.scroll_docs(-4),
['<C-f>'] = cmp.mapping.scroll_docs(4),
['<C-Space>'] = cmp.mapping.complete(),
['<C-e>'] = cmp.mapping.abort(),
['<CR>'] = cmp.mapping.confirm({ select = true }),
}),
sources = cmp.config.sources({
{ name = 'nvim_lsp' },
{ name = 'luasnip' },
}, {
{ name = 'buffer' },
{ name = "path" },
}),
})
end,
},
}

13
lua/plugins/help.lua Normal file
View File

@ -0,0 +1,13 @@
return {
{
"folke/which-key.nvim",
config = function()
vim.o.timeout = true
vim.o.timeoutlen = 300
local wk = require("which-key")
-- 快捷键在这里定义
wk.setup()
end,
},
}

View File

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

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

@ -0,0 +1,10 @@
return {
"iamcco/markdown-preview.nvim",
cmd = { "MarkdownPreviewToggle", "MarkdownPreview", "MarkdownPreviewStop" },
ft = { "markdown" },
build = function()
vim.fn["mkdp#util#install"]()
end,
lazy = true;
}

165
lua/plugins/plugin-base.lua Normal file
View File

@ -0,0 +1,165 @@
return {
{
"nathom/filetype.nvim",
lazy = true,
event = "User FileOpened",
config = function()
require("filetype").setup({
overrides = {
extensions = {
h = "cpp",
},
}
})
end
},
{
"HiPhish/nvim-ts-rainbow2",
-- Bracket pair rainbow colorize
lazy = true,
event = { "User FileOpened" },
},
{
"romgrk/nvim-treesitter-context",
lazy = true,
event = { "User FileOpened" },
config = function()
require("treesitter-context").setup({
enable = true,
throttle = true,
max_lines = 0,
patterns = {
default = {
"class",
"function",
"method",
},
},
})
end,
},
{
"windwp/nvim-spectre",
lazy = true,
cmd = { "Spectre" },
config = function()
require("spectre").setup()
end,
},
{
"andymass/vim-matchup",
-- Highlight, jump between pairs like if..else
lazy = true,
event = { "User FileOpened" },
config = function()
vim.g.matchup_matchparen_offscreen = { method = "popup" }
lvim.builtin.treesitter.matchup.enable = true
end,
},
{
"rcarriga/nvim-notify",
lazy = true,
event = "VeryLazy",
config = function()
local notify = require("notify")
notify.setup({
-- "fade", "slide", "fade_in_slide_out", "static"
stages = "static",
on_open = nil,
on_close = nil,
timeout = 3000,
fps = 1,
render = "default",
background_colour = "Normal",
max_width = math.floor(vim.api.nvim_win_get_width(0) / 2),
max_height = math.floor(vim.api.nvim_win_get_height(0) / 4),
-- minimum_width = 50,
-- ERROR > WARN > INFO > DEBUG > TRACE
level = "TRACE",
})
vim.notify = notify
end,
},
{
"folke/noice.nvim",
enabled = ENABLE_NOICE,
lazy = true,
event = { "BufRead", "BufNewFile" },
dependencies = { "rcarriga/nvim-notify", "MunifTanjim/nui.nvim" },
config = function()
require("noice").setup({
lsp = {
progress = {
enabled = false,
},
},
presets = {
bottom_search = false,
command_palette = true,
long_message_to_split = true,
inc_rename = false,
lsp_doc_border = true,
},
messages = {
enabled = true,
view = "notify",
view_error = "notify",
view_warn = "notify",
view_history = "messages",
view_search = "virtualtext",
},
health = {
checker = false,
},
})
end,
},
{ "lukas-reineke/cmp-under-comparator", lazy = true },
{
"ray-x/cmp-treesitter",
lazy = true,
},
{
"mhartington/oceanic-next",
},
{
'nvim-lualine/lualine.nvim',
config = function()
require('lualine').setup()
end
},
{
"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", -- Optional image support in preview window: See `# Preview Mode` for more information
}
},
{
"tiagovla/scope.nvim",
lazy = false
},
{
"akinsho/bufferline.nvim",
tag = "v3.*",
config = function()
vim.g.termguicolors = true
require("bufferline").setup()
end,
},
{
'nvimdev/dashboard-nvim',
event = 'VimEnter',
config = function()
require('dashboard').setup {
-- config
}
end,
dependencies = { {'nvim-tree/nvim-web-devicons'}}
}
}

View File

@ -0,0 +1,20 @@
return {
{
"tpope/vim-fugitive",
cmd = {
"G",
"Git",
"Gdiffsplit",
"Gread",
"Gwrite",
"Ggrep",
"GMove",
"GDelete",
"GBrowse",
"GRemove",
"GRename",
"Glgrep",
"Gedit"
}
}
}

View File

@ -0,0 +1,10 @@
return {
{
"nvim-tree/nvim-tree.lua",
version = "*",
dependencies = {"nvim-tree/nvim-web-devicons"},
config = function()
require("nvim-tree").setup {}
end
}
}

View File

@ -0,0 +1,72 @@
return {
{
"simrat39/symbols-outline.nvim",
config = function()
require("symbols-outline").setup({
highlight_hovered_item = true,
show_guides = true,
auto_preview = false,
position = 'right',
relative_width = true,
width = 25,
auto_close = false,
show_numbers = false,
show_relative_numbers = false,
show_symbol_details = true,
preview_bg_highlight = 'Pmenu',
autofold_depth = nil,
auto_unfold_hover = true,
fold_markers = { '', '' },
wrap = false,
keymaps = {
-- These keymaps can be a string or a table for multiple keys
close = { "<Esc>", "q" },
goto_location = "<Cr>",
focus_location = "o",
hover_symbol = "<C-space>",
toggle_preview = "K",
rename_symbol = "r",
code_actions = "a",
fold = "h",
unfold = "l",
fold_all = "W",
unfold_all = "E",
fold_reset = "R",
},
lsp_blacklist = {},
symbol_blacklist = {},
symbols = {
File = { icon = "", hl = "@text.uri" },
Module = { icon = "", hl = "@namespace" },
Namespace = { icon = "", hl = "@namespace" },
Package = { icon = "", hl = "@namespace" },
Class = { icon = "𝓒", hl = "@type" },
Method = { icon = "ƒ", hl = "@method" },
Property = { icon = "", hl = "@method" },
Field = { icon = "", hl = "@field" },
Constructor = { icon = "", hl = "@constructor" },
Enum = { icon = "", hl = "@type" },
Interface = { icon = "", hl = "@type" },
Function = { icon = "", hl = "@function" },
Variable = { icon = "", hl = "@constant" },
Constant = { icon = "", hl = "@constant" },
String = { icon = "𝓐", hl = "@string" },
Number = { icon = "#", hl = "@number" },
Boolean = { icon = "", hl = "@boolean" },
Array = { icon = "", hl = "@constant" },
Object = { icon = "⦿", hl = "@type" },
Key = { icon = "🔐", hl = "@type" },
Null = { icon = "NULL", hl = "@type" },
EnumMember = { icon = "", hl = "@field" },
Struct = { icon = "𝓢", hl = "@type" },
Event = { icon = "🗲", hl = "@type" },
Operator = { icon = "+", hl = "@operator" },
TypeParameter = { icon = "𝙏", hl = "@parameter" },
Component = { icon = "", hl = "@function" },
Fragment = { icon = "", hl = "@constant" },
},
})
end,
},
}