commit 34280b6c33e7eb0ed846686323bb583b08fa6606 Author: zeekling Date: Sat Jun 8 12:17:10 2024 +0800 初始化neovim 配置 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..76aade5 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +./lazy-lock.json diff --git a/init.lua b/init.lua new file mode 100644 index 0000000..7e01e25 --- /dev/null +++ b/init.lua @@ -0,0 +1,8 @@ +vim.g.mapleader = " " + +local vim = vim + +vim.colorscheme = "oceanic-next" + +require("lazynvim-init") +require("keybindings") diff --git a/lua/keybindings.lua b/lua/keybindings.lua new file mode 100644 index 0000000..5c35bb4 --- /dev/null +++ b/lua/keybindings.lua @@ -0,0 +1,13 @@ +vim.g.mapleader = " " + +vim.keymap.set("n", "mk", "MarkdownPreview", { silent = true }) +vim.keymap.set("n", "ds", "NvimTreeToggle", { silent = true }) +vim.keymap.set("n", "dc", "NvimTreeClose", { silent = true }) + + +vim.keymap.set("n", "bp", "BufferLineCyclePrev", { silent = true }) +vim.keymap.set("n", "bn", "BufferLineCycleNext", { silent = true }) +vim.keymap.set("n", "bd", "bd", { silent = true }) + + + diff --git a/lua/lazynvim-init.lua b/lua/lazynvim-init.lua new file mode 100644 index 0000000..17e7c1e --- /dev/null +++ b/lua/lazynvim-init.lua @@ -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 设置为运行时路径 +-- rtp(runtime path) +-- nvim进行路径搜索的时候,除已有的路径,还会从prepend的路径中查找 +-- 否则,下面 require("lazy") 是找不到的 +vim.opt.rtp:prepend(lazypath) + +-- 3. 加载lazy.nvim模块 +require("lazy").setup("plugins") diff --git a/lua/plugins/auto-complete.lua b/lua/plugins/auto-complete.lua new file mode 100644 index 0000000..34d1686 --- /dev/null +++ b/lua/plugins/auto-complete.lua @@ -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({ + [''] = cmp.mapping.scroll_docs(-4), + [''] = cmp.mapping.scroll_docs(4), + [''] = cmp.mapping.complete(), + [''] = cmp.mapping.abort(), + [''] = cmp.mapping.confirm({ select = true }), + }), + sources = cmp.config.sources({ + { name = 'nvim_lsp' }, + { name = 'luasnip' }, + }, { + { name = 'buffer' }, + { name = "path" }, + }), + }) + end, + }, +} + diff --git a/lua/plugins/help.lua b/lua/plugins/help.lua new file mode 100644 index 0000000..a56e03d --- /dev/null +++ b/lua/plugins/help.lua @@ -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, + }, +} diff --git a/lua/plugins/lsp_signature.lua b/lua/plugins/lsp_signature.lua new file mode 100644 index 0000000..3b6c66e --- /dev/null +++ b/lua/plugins/lsp_signature.lua @@ -0,0 +1,8 @@ +return { + { + "ray-x/lsp_signature.nvim", + event = "BufRead", + config = function() require"lsp_signature".on_attach() end, +}, + +} diff --git a/lua/plugins/markdown.lua b/lua/plugins/markdown.lua new file mode 100644 index 0000000..953cd35 --- /dev/null +++ b/lua/plugins/markdown.lua @@ -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; +} + diff --git a/lua/plugins/plugin-base.lua b/lua/plugins/plugin-base.lua new file mode 100644 index 0000000..9a11486 --- /dev/null +++ b/lua/plugins/plugin-base.lua @@ -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'}} + } +} diff --git a/lua/plugins/plugin-git.lua b/lua/plugins/plugin-git.lua new file mode 100644 index 0000000..43e2865 --- /dev/null +++ b/lua/plugins/plugin-git.lua @@ -0,0 +1,20 @@ +return { +{ + "tpope/vim-fugitive", + cmd = { + "G", + "Git", + "Gdiffsplit", + "Gread", + "Gwrite", + "Ggrep", + "GMove", + "GDelete", + "GBrowse", + "GRemove", + "GRename", + "Glgrep", + "Gedit" + } + } +} diff --git a/lua/plugins/plugin-nvim-tree.lua b/lua/plugins/plugin-nvim-tree.lua new file mode 100644 index 0000000..69bfeef --- /dev/null +++ b/lua/plugins/plugin-nvim-tree.lua @@ -0,0 +1,10 @@ +return { + { + "nvim-tree/nvim-tree.lua", + version = "*", + dependencies = {"nvim-tree/nvim-web-devicons"}, + config = function() + require("nvim-tree").setup {} + end + } +} diff --git a/lua/plugins/symbols-outline.lua b/lua/plugins/symbols-outline.lua new file mode 100644 index 0000000..2037cce --- /dev/null +++ b/lua/plugins/symbols-outline.lua @@ -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 = { "", "q" }, + goto_location = "", + focus_location = "o", + hover_symbol = "", + 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, +}, + +}