├── .gitignore ├── .luarc.json ├── LICENSE ├── ReadMe.md ├── \ ├── c.json ├── ftplugin ├── c.lua ├── cpp.lua ├── lua.lua └── python.lua ├── init.lua └── lua ├── autocmd.lua ├── basic.lua ├── dap ├── cpp.lua └── python.lua ├── keybindings.lua ├── lsp ├── cpp.lua ├── lua.lua └── python.lua ├── plugin-config ├── auto_session.lua ├── buffer.lua ├── cmp.lua ├── dap-config.lua ├── dap-ui.lua ├── dashboard.lua ├── gitsigns.lua ├── lspsaga.lua ├── lualine.lua ├── mason.lua ├── nvimgdb.lua ├── nvimtree.lua ├── symbols_outline.lua ├── telescope.lua ├── toggleterm.lua ├── tokyonight.lua ├── treesitter.lua ├── vscode.lua └── whichkey.lua └── plugins.lua /.gitignore: -------------------------------------------------------------------------------- 1 | plugin/packer_compiled.lua 2 | -------------------------------------------------------------------------------- /.luarc.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://raw.githubusercontent.com/sumneko/vscode-lua/master/setting/schema.json", 3 | "Lua.workspace.checkThirdParty": false 4 | } -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 aMonst 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /ReadMe.md: -------------------------------------------------------------------------------- 1 | # Neovim 配置介绍 2 | ========================== 3 | 4 | 本仓库主要作为 `neovim` 配置系列教程的演示仓库。当然,在它最后完成之后各位小伙伴也可以直接使用。 5 | 6 | 对应教程所在地址 7 | - [知乎](https://www.zhihu.com/column/c_1527964562929893376) 8 | - [csdn](https://blog.csdn.net/lanuage/category_11901740.html) 9 | - [博客园](https://www.cnblogs.com/lanuage/) 10 | - [简书](https://www.jianshu.com/nb/52884163) 11 | 12 | 以下几个是系统自动同步的博客园博客,顺序或者排版可能有误 13 | - [51cto博客](https://blog.51cto.com/u_11090813) 14 | - [腾讯云社区](https://cloud.tencent.com/developer/user/2939609) 15 | 16 | ## 书写计划 17 | - [x]: 基础配置 18 | - [x]: 快捷键 19 | - [x]: 插件管理 20 | - [x]: 主题配置 21 | - [x]: tab 配置 22 | - [x]: 目录树 23 | - [x]: 状态栏 24 | - [x]: 启动界面配置 25 | - [x]: witchkey 26 | - [ ]: 缩率图 27 | - [ ]: 终端配置 28 | - [ ]: 拼写检查 29 | - [ ]: 模糊查询 30 | - [ ]: workspace / session 管理 31 | - [ ]: 文件管理 32 | - [ ]: gtd orgmode markdown 33 | - [ ]: 快速移动 34 | - [ ]: 编程语言支持(lsp) 35 | - [ ]: 语法检查 36 | - [ ]: 快速跳转 37 | - [ ]: 自动缩进 38 | - [ ]: 编译与调试 39 | - [ ]: 代码片段 40 | - [ ]: git 集成 41 | 42 | 计划可能会改变,我会随着心情或者小伙伴的反馈来调整计划 43 | -------------------------------------------------------------------------------- /\: -------------------------------------------------------------------------------- 1 | -- 插件管理文件 2 | return require('packer').startup(function(use) 3 | -- Packer can manage itself 4 | use 'wbthomason/packer.nvim' 5 | -- 主题配置 6 | use 'folke/tokyonight.nvim' 7 | use 'Mofiqul/vscode.nvim' 8 | use {'akinsho/bufferline.nvim', tag = "v2.*", requires = 'kyazdani42/nvim-web-devicons'} 9 | use { 10 | 'kyazdani42/nvim-tree.lua', 11 | requires = { 12 | 'kyazdani42/nvim-web-devicons', -- optional, for file icons 13 | }, 14 | tag = 'nightly' -- optional, updated every week. (see issue #1193) 15 | } 16 | use { 17 | 'nvim-lualine/lualine.nvim', 18 | requires = { 'kyazdani42/nvim-web-devicons', opt = true } 19 | } 20 | use {'glepnir/dashboard-nvim'} 21 | use {"folke/which-key.nvim"} 22 | use {"akinsho/toggleterm.nvim", tag = 'v2.*'} 23 | use { 24 | 'nvim-telescope/telescope.nvim', tag = '0.1.0', 25 | requires = { {'nvim-lua/plenary.nvim'} , { 26 | 'nvim-treesitter/nvim-treesitter', 27 | run = function() 28 | require('nvim-treesitter.install').update({ with_sync = true }) 29 | end, 30 | }} 31 | } 32 | use { "nvim-telescope/telescope-file-browser.nvim" } 33 | use {'rmagatti/auto-session'} 34 | use {"williamboman/mason.nvim"} 35 | use {"neovim/nvim-lspconfig"} 36 | -- nvim-cmp 37 | use {'hrsh7th/cmp-nvim-lsp'} 38 | use {'hrsh7th/cmp-buffer'} 39 | use {'hrsh7th/cmp-path'} 40 | use {'hrsh7th/cmp-cmdline'} 41 | use {'hrsh7th/nvim-cmp'} 42 | -- vsnip 43 | use {'hrsh7th/cmp-vsnip'} 44 | use {'hrsh7th/vim-vsnip'} 45 | use {'rafamadriz/friendly-snippets'} 46 | -- lspkind 47 | use {'onsails/lspkind-nvim'} 48 | -- lspsaga 49 | use {'glepnir/lspsaga.nvim'} 50 | use {'simrat39/symbols-outline.nvim'} 51 | 52 | -- dap 53 | use {'mfussenegger/nvim-dap'} 54 | use { "rcarriga/nvim-dap-ui", requires = {"mfussenegger/nvim-dap"} } 55 | use {"theHamsta/nvim-dap-virtual-text", requires = {"nvim-treesitter/nvim-treesitter" , "mfussenegger/nvim-dap"}} 56 | use {"sakhnik/nvim-gdb", run = "./install.sh"} 57 | 58 | --git 59 | use {'lewis6991/gitsigns.nvim'} 60 | end) 61 | -------------------------------------------------------------------------------- /c.json: -------------------------------------------------------------------------------- 1 | { 2 | "example": { 3 | "prefix": ["hello"], 4 | "body": [ 5 | "#include ", 6 | "int main(int argc, char* argv[])", 7 | "{", 8 | "\tprintf(\"hello world\");", 9 | "\treturn 0;", 10 | "}" 11 | 12 | ], 13 | "description": "create a hello world" 14 | }, 15 | 16 | 17 | "func": { 18 | "prefix": ["func"], 19 | "body": [ 20 | "${1|int,float,double,char,short,*|} $2()", 21 | "{", 22 | "\treturn $3;", 23 | "}" 24 | 25 | ], 26 | "description": "create a function return int" 27 | }, 28 | 29 | 30 | "doc-header": { 31 | "prefix": ["doc-header"], 32 | "body": [ 33 | "/**", 34 | "* @file ${TM_FILENAME}", 35 | "* @bref ${1}", 36 | "* @details ${2}", 37 | "* @date ${CURRENT_YEAR}/${CURRENT_MONTH}/${CURRENT_DATE}", 38 | "* @commit history:", 39 | "* \t v${3}: ${4}", 40 | "*/${0}" 41 | 42 | ], 43 | "description": "create a doc header" 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /ftplugin/c.lua: -------------------------------------------------------------------------------- 1 | -- 是否将 tab 替换为 space 2 | vim.bo.expandtab = true 3 | vim.bo.shiftwidth = 4 4 | vim.bo.tabstop = 4 5 | vim.bo.softtabstop = 4 6 | 7 | require("lsp/cpp") 8 | require("dap/cpp") 9 | -------------------------------------------------------------------------------- /ftplugin/cpp.lua: -------------------------------------------------------------------------------- 1 | -- 是否将 tab 替换为 space 2 | vim.bo.expandtab = true 3 | vim.bo.shiftwidth = 4 4 | vim.bo.tabstop = 4 5 | vim.bo.softtabstop = 4 6 | 7 | require("lsp/cpp") 8 | require("dap/cpp") 9 | -------------------------------------------------------------------------------- /ftplugin/lua.lua: -------------------------------------------------------------------------------- 1 | -- 是否将 tab 替换为 space 2 | vim.bo.expandtab = true 3 | vim.bo.shiftwidth = 4 4 | vim.bo.tabstop = 4 5 | vim.bo.softtabstop = 4 6 | 7 | -- 取消自动注释,当前行是注释时,按下回车键会默认添加一行注释,这里取消这一行为 8 | vim.opt_local.formatoptions = vim.opt_local.formatoptions - {"r", "c", "o"} 9 | 10 | require('lsp/lua') 11 | 12 | -------------------------------------------------------------------------------- /ftplugin/python.lua: -------------------------------------------------------------------------------- 1 | -- 是否将 tab 替换为 space 2 | vim.bo.expandtab = true 3 | vim.bo.shiftwidth = 4 4 | vim.bo.tabstop = 4 5 | vim.bo.softtabstop = 4 6 | 7 | require('lsp/python') 8 | 9 | require('dap/python') 10 | -------------------------------------------------------------------------------- /init.lua: -------------------------------------------------------------------------------- 1 | -- 配置文件入口,主要负责加载其他配置文件 2 | require("basic") 3 | require("keybindings") 4 | require("autocmd") 5 | require("plugins") 6 | require("plugin-config/tokyonight") 7 | -- require("plugin-config/vscode") 8 | require("plugin-config/buffer") 9 | require("plugin-config/nvimtree") 10 | require("plugin-config/lualine") 11 | require("plugin-config/dashboard") 12 | require("plugin-config/whichkey") 13 | require("plugin-config/toggleterm") 14 | require("plugin-config/telescope") 15 | require("plugin-config/auto_session") 16 | require("plugin-config/treesitter") 17 | require("plugin-config/cmp") 18 | require("plugin-config/lspsaga") 19 | require("plugin-config/symbols_outline") 20 | require("plugin-config/mason") 21 | require("plugin-config/dap-config") 22 | require("plugin-config/dap-ui") 23 | require('plugin-config/nvimgdb') 24 | require('plugin-config/gitsigns') 25 | 26 | -- 启用主题 27 | vim.cmd[[colorscheme tokyonight]] 28 | -- vim.cmd[[colorscheme vscode]] 29 | 30 | -- 自定义状态栏(使用 lualine 插件后,该部分代码取消) 31 | -- function get_mode() 32 | -- local mode = vim.api.nvim_eval([[mode()]]) 33 | -- if mode == "n" then 34 | -- return "Normal" 35 | -- elseif mode == "v" then 36 | -- return "Visual" 37 | -- elseif mode == "i" then 38 | -- return "Insert" 39 | -- else 40 | -- return "" 41 | -- end 42 | -- end 43 | -- 44 | -- vim.o.statusline = "mode|%f%m|%l:%L%=" .. vim.g.encoding .. "|%y" 45 | -- 46 | -- local status_line = vim.api.nvim_create_augroup("SET_STATUS_LINE", {clear = true}) 47 | -- 48 | -- -- 打开时获取当前模式,并初始化 49 | -- vim.api.nvim_create_autocmd({"ModeChanged"}, { 50 | -- pattern = "*", 51 | -- group = status_line, 52 | -- callback = function() 53 | -- local win_id = vim.api.nvim_eval([[win_getid()]]) --获取当前window id 54 | -- vim.wo[win_id].statusline = get_mode() .. "|%f%m|%l:%L%=" .. vim.g.encoding .. "|%y" 55 | -- end 56 | -- }) 57 | -------------------------------------------------------------------------------- /lua/autocmd.lua: -------------------------------------------------------------------------------- 1 | -- 自动命令,自动命令组 2 | 3 | --function save_session() 4 | -- local curdir = vim.api.nvim_eval([[getcwd()]]) 5 | -- local session_file = curdir .. "/Session.vim" 6 | -- vim.cmd([[mksession! ]] .. session_file) 7 | -- local viminfo = curdir .. "/.viminfo" 8 | -- vim.cmd([[wviminfo! ]] .. viminfo) 9 | --end 10 | -- 11 | --function load_session() 12 | -- local curdir = vim.api.nvim_eval([[getcwd()]]) 13 | -- local session_file = curdir .. "/Session.vim" 14 | -- local viminfo = curdir .. "/.viminfo" 15 | -- file, err = io.open(session_file, "r") 16 | -- if err == nil then 17 | -- file:close() 18 | -- vim.cmd([[source ]] .. session_file) 19 | -- end 20 | -- file, err = io.open(viminfo, "r") 21 | -- if err == nil then 22 | -- file:close() 23 | -- vim.cmd([[rviminfo ]] .. viminfo) 24 | -- end 25 | --end 26 | 27 | if vim.fn.has "nvim-0.7" then 28 | -- 保存后自动加载配置文件 29 | local nvimrc = vim.api.nvim_create_augroup("NVIMRC", {clear = true}) 30 | vim.api.nvim_create_autocmd({"BufWritePost"}, { 31 | pattern = "init.lua", 32 | group = nvimrc, 33 | command = [[source %]] 34 | }) 35 | 36 | vim.api.nvim_create_autocmd({"BufReadPost"}, { 37 | pattern = "init.lua", 38 | group = nvimrc, 39 | callback = function() 40 | vim.o.path = vim.o.path .. ",**/*" 41 | end 42 | }) 43 | 44 | local auto_indent = vim.api.nvim_create_augroup("AUTO_INDENT", {clear = true}) 45 | vim.api.nvim_create_autocmd({"BufWritePost"}, { 46 | pattern = "*", 47 | group = auto_indent, 48 | command = 'normal! gg=G``' 49 | }) 50 | -- vim.api.nvim_create_autocmd({"VimEnter"}, { 51 | -- pattern = "*", 52 | -- group = auto_save_session, 53 | -- callback = load_session 54 | -- }) 55 | else 56 | vim.cmd[[ 57 | augroup NVIMRC 58 | autocmd! 59 | autocmd BufWritePost init.lua source $MYVIMRC 60 | autocmd BufReadPost init.lua set path+=**/* 61 | autocmd BufWritePost * normal! gg=G`` 62 | augroup END 63 | ]] 64 | 65 | -- vim.cmd[[ 66 | -- augroup AUTO_SAVE_SESSION 67 | -- autocmd! 68 | -- autocmd ExitPre * lua save_session() 69 | -- autocmd VimEnter * lua load_session() 70 | -- augroup END 71 | -- ]] 72 | end 73 | 74 | -------------------------------------------------------------------------------- /lua/basic.lua: -------------------------------------------------------------------------------- 1 | -- 设置文件编码格式为 utf-8 2 | vim.g.encoding = "utf-8" 3 | -- 设置终端编码格式为 utf-8 4 | vim.o.termencoding = "utf-8" 5 | -- 开启语法高亮 6 | vim.o.syntax = "enable" 7 | -- 显示相对行号 8 | vim.o.relativenumber = true 9 | -- 显示行号 10 | vim.o.number = true 11 | -- 高亮所在行 12 | vim.o.cursorline = true 13 | -- 自动换行 14 | vim.o.wrap = true 15 | -- 显示光标位置 16 | vim.o.ruler = true 17 | -- 边输入边搜索 18 | vim.o.incsearch = true 19 | -- 开启搜索匹配高亮 20 | vim.o.hlsearch = true 21 | -- 搜索时自行判断是否需要忽略大小写 22 | vim.o.smartcase = true 23 | -- 支持鼠标拖拽 24 | -- vim.o.mouse = "a" 25 | -- tab键转换为 4 个空格 26 | vim.o.tabstop = 4 27 | vim.o.softtabstop = 4 28 | vim.o.shiftwidth = 4 29 | -- 新行对齐当前行,tab转换为空格 30 | vim.o.expandtab = true 31 | vim.bo.expandtab = true 32 | vim.o.autoindent = true 33 | vim.bo.autoindent = true 34 | vim.o.smartindent = true 35 | 36 | -- << >> 缩进时移动的长度 37 | vim.o.shiftwidth = 4 38 | vim.bo.shiftwidth = 4 39 | 40 | -- 使用jk移动光标时,上下方保留8行 41 | vim.o.scrolloff = 8 42 | vim.o.sidescrolloff = 8 43 | 44 | -- 设置自动折叠 45 | vim.o.smartindent = true 46 | -- 历史命令最多保存1000条 47 | vim.o.history = 1000 48 | -- 显示空白字符 49 | vim.o.list = true 50 | -- 样式 51 | vim.o.background = "dark" 52 | vim.o.termguicolors = true 53 | vim.opt.termguicolors = true 54 | -------------------------------------------------------------------------------- /lua/dap/cpp.lua: -------------------------------------------------------------------------------- 1 | local dap = require("dap") 2 | 3 | dap.adapters.cppdbg = { 4 | id = "cppdbg", 5 | type = 'executable', 6 | command = "~/.local/share/nvim/mason/bin/OpenDebugAD7", 7 | } 8 | 9 | dap.configurations.cpp = { 10 | { 11 | name = "Launch file", 12 | type = "cppdbg", 13 | request = "launch", 14 | program = function() 15 | return vim.fn.input("Path to executable: ", vim.fn.getcwd() .. "/", "file") 16 | end, 17 | 18 | cwd = "${workspaceFolder}", 19 | stopAtEntry = true, 20 | }, 21 | } 22 | dap.configurations.c = dap.configurations.cpp 23 | -------------------------------------------------------------------------------- /lua/dap/python.lua: -------------------------------------------------------------------------------- 1 | local dap = require('dap') 2 | 3 | dap.adapters.python = { 4 | type = 'executable'; 5 | command = "/usr/bin/python3"; 6 | args = {'-m', 'debugpy.adapter'}; 7 | } 8 | 9 | dap.configurations.python = { 10 | { 11 | type = "python"; 12 | request = "launch"; 13 | name = "launch file"; 14 | 15 | program = "${file}"; 16 | pythonPath = function () 17 | return "/usr/bin/python3" 18 | end 19 | }, 20 | } 21 | -------------------------------------------------------------------------------- /lua/keybindings.lua: -------------------------------------------------------------------------------- 1 | -- 快捷键配置 2 | -- 设置 leader key 和 localleader key 3 | vim.g.mapleader = " " 4 | vim.g.maplocalleader = " " 5 | 6 | -- 翻页操作 7 | vim.api.nvim_set_keymap("n", "", "10jzz", {noremap = true, silent = true}) 8 | vim.api.nvim_set_keymap("n", "", "10kzz", {noremap = true, silent = true}) 9 | 10 | -- 多窗口 11 | -- 窗口操作 12 | vim.api.nvim_set_keymap("n", "sv", ":vsp", {noremap = true, silent = true}) 13 | vim.api.nvim_set_keymap("n", "sh", ":sp", {noremap = true, silent = true}) 14 | vim.api.nvim_set_keymap("n", "sc", ":close", {noremap = true, silent = true}) 15 | vim.api.nvim_set_keymap("n", "so", ":only", {noremap = true, silent = true}) 16 | -- 多窗口跳转 17 | vim.api.nvim_set_keymap("n", "h", "h", {noremap = true, silent = true}) 18 | vim.api.nvim_set_keymap("n", "l", "l", {noremap = true, silent = true}) 19 | vim.api.nvim_set_keymap("n", "j", "j", {noremap = true, silent = true}) 20 | vim.api.nvim_set_keymap("n", "k", "k", {noremap = true, silent = true}) 21 | 22 | -- 其他有用的绑定 23 | -- 使用 将光标所在单词转化为全大写 24 | vim.api.nvim_set_keymap("i", "", "viwUwa", {noremap = true, silent = true}) 25 | -- 使用 将光标所在单词转化为全小写 26 | vim.api.nvim_set_keymap("i", "", "viwuwa", {noremap = true, silent = true}) 27 | -- 快速打开vimrc文件 28 | vim.api.nvim_set_keymap("n", "ee", ":vs $MYVIMRC", {noremap = true, silent = true}) 29 | vim.api.nvim_set_keymap("n", "ss", ":source $MYVIMRC", {noremap = true, silent = true}) 30 | -- 删除当前光标所在单词 31 | vim.api.nvim_set_keymap("n", "dw", "diw", {noremap = true, silent = true}) 32 | -- 可视模式下可以快速移动缩进多行文本 33 | vim.api.nvim_set_keymap("v", ">>", ">>gv", {noremap = true, silent = true}) 34 | vim.api.nvim_set_keymap("v", "<<", "<so", "SymbolsOutline", {silent = true, noremap = true}) 38 | 39 | 40 | -- lsp 快捷键定义 41 | local lsp_keybinds = {} 42 | 43 | lsp_keybinds.set_keymap = function (bufnr) 44 | print("set lsp keymap") 45 | -- 跳转到声明 46 | -- vim.api.nvim_buf_set_keymap(bufnr, "n", "gd", "lua vim.lsp.buf.declaration()", {silent = true, noremap = true}) 47 | vim.api.nvim_buf_set_keymap(bufnr, "n", "gd", "Lspsaga peek_definition", {silent = true, noremap = true}) 48 | 49 | -- 跳转到定义 50 | vim.api.nvim_buf_set_keymap(bufnr, "n", "gD", "lua vim.lsp.buf.definition()", {silent = true, noremap = true}) 51 | -- 显示注释文档 52 | -- vim.api.nvim_buf_set_keymap(bufnr, "n", "gh", "lua vim.lsp.buf.hover()", {silent = true, noremap = true}) 53 | vim.api.nvim_buf_set_keymap(bufnr, "n", "gh", "Lspsaga lsp_finder", {silent = true, noremap = true}) 54 | -- 跳转到实现 55 | vim.api.nvim_buf_set_keymap(bufnr, "n", "gi", "lua vim.lsp.buf.implementation()", {silent = true, noremap = true}) 56 | -- 跳转到引用位置 57 | -- vim.api.nvim_buf_set_keymap(bufnr, "n", "gr", "lua vim.lsp.buf.references()", {silent = true, noremap = true}) 58 | vim.api.nvim_buf_set_keymap(bufnr, "n", "gr", "Lspsaga rename", {silent = true, noremap = true}) 59 | -- 以浮窗形式显示错误 60 | vim.api.nvim_buf_set_keymap(bufnr, "n", "go", "lua vim.diagnostic.open_float()", {silent = true, noremap = true}) 61 | vim.api.nvim_buf_set_keymap(bufnr, "n", "gp", "lua vim.diagnostic.goto_prev()", {silent = true, noremap = true}) 62 | vim.api.nvim_buf_set_keymap(bufnr, "n", "gn", "lua vim.diagnostic.goto_next()", {silent = true, noremap = true}) 63 | 64 | vim.api.nvim_buf_set_keymap(bufnr, "n", "cd", "Lspsaga show_cursor_diagnostics", {silent = true, noremap = true}) 65 | vim.api.nvim_buf_set_keymap(bufnr, "n", "cd", "Lspsaga show_line_diagnostics", {silent = true, noremap = true}) 66 | vim.api.nvim_buf_set_keymap(bufnr, "n", "ca", "Lspsaga code_action", {silent = true, noremap = true}) 67 | vim.api.nvim_buf_set_keymap(bufnr, "v", "ca", "Lspsaga code_action", {silent = true, noremap = true}) 68 | vim.api.nvim_buf_set_keymap(bufnr, "n", "ca", "Lspsaga code_action", {silent = true, noremap = true}) 69 | -- dap 70 | vim.keymap.set({"i", "n", "v"}, "", "lua require'dap'.continue()", {silent = true, noremap = true, buffer = bufnr}) 71 | vim.keymap.set({"i", "n", "v"}, "", "lua require'dap'.step_over()", {silent = true, noremap = true, buffer = bufnr}) 72 | vim.keymap.set({"i", "n", "v"}, "", "lua require'dap'.step_into()", {silent = true, noremap = true, buffer = bufnr}) 73 | vim.keymap.set({"i", "n", "v"}, "", "lua require'dap'.step_over()", {silent = true, noremap = true, buffer = bufnr}) 74 | vim.keymap.set({"i", "n", "v"}, "", "lua require'dap'.toggle_breakpoint()", {silent = true, noremap = true, buffer = bufnr}) 75 | end 76 | vim.cmd[[imap vsnip#jumpable(1) ? '(vsnip-jump-next)' : '']] 77 | vim.cmd[[smap vsnip#jumpable(1) ? '(vsnip-jump-next)' : '']] 78 | vim.cmd[[imap vsnip#jumpable(-1) ? '(vsnip-jump-prev)' : '']] 79 | vim.cmd[[smap vsnip#jumpable(-1) ? '(vsnip-jump-prev)' : '']] 80 | 81 | -- dap keymaps 82 | return lsp_keybinds 83 | -------------------------------------------------------------------------------- /lua/lsp/cpp.lua: -------------------------------------------------------------------------------- 1 | local lspconfig = require('lspconfig') 2 | local lsp_set_keymap = require("keybindings") 3 | local on_attach = function(client, bufnr) 4 | lsp_set_keymap.set_keymap(bufnr) 5 | end 6 | 7 | lspconfig.clangd.setup { 8 | on_attach = on_attach 9 | } 10 | -------------------------------------------------------------------------------- /lua/lsp/lua.lua: -------------------------------------------------------------------------------- 1 | local lsp_set_keymap = require("keybindings") 2 | -- 定义快捷键 3 | -- 根据官方的提示,这里我们使用 on_attach 表示当前缓冲加载服务端完成之后调用 4 | local on_attach = function(_, bufnr) 5 | lsp_set_keymap.set_keymap(bufnr) 6 | end 7 | 8 | require('lspconfig').sumneko_lua.setup { 9 | settings = { 10 | Lua = { 11 | runtime = { 12 | -- Tell the language server which version of Lua you're using (most likely LuaJIT in the case of Neovim) 13 | version = 'LuaJIT', 14 | }, 15 | diagnostics = { 16 | -- Get the language server to recognize the `vim` global 17 | globals = {'vim'}, 18 | }, 19 | workspace = { 20 | -- Make the server aware of Neovim runtime files 21 | library = vim.api.nvim_get_runtime_file("", true), 22 | }, 23 | -- Do not send telemetry data containing a randomized but unique identifier 24 | telemetry = { 25 | enable = false, 26 | }, 27 | }, 28 | }, 29 | 30 | on_attach = on_attach, 31 | } 32 | -------------------------------------------------------------------------------- /lua/lsp/python.lua: -------------------------------------------------------------------------------- 1 | local lsp_set_keymap = require("keybindings") 2 | local util = require 'lspconfig/util' 3 | 4 | require('lspconfig').pyright.setup{ 5 | on_attach = function(_, bufnr) 6 | lsp_set_keymap.set_keymap(bufnr) 7 | -- vim.api.nvim_buf_set_keymap(bufnr, "n", "", "!python %", {noremap = true, silent = true}) 8 | end, 9 | cmd = { "pyright-langserver", "--stdio" }, 10 | 11 | filetypes = { "python" }, 12 | settings = { 13 | python = { 14 | analysis = { 15 | autoSearchPaths = true, 16 | diagnosticMode = "workspace", 17 | useLibraryCodeForTypes = true, 18 | typeCheckingMode = "off" 19 | }, 20 | }, 21 | }, 22 | 23 | root_dir = function(fname) 24 | local root_files = { 25 | 'pyproject.toml', 26 | 'setup.py', 27 | 'setup.cfg', 28 | 'requirements.txt', 29 | 'Pipfile', 30 | 'pyrightconfig.json', 31 | } 32 | return util.root_pattern(unpack(root_files))(fname) or util.find_git_ancestor(fname) or util.path.dirname(fname) 33 | end, 34 | } 35 | -------------------------------------------------------------------------------- /lua/plugin-config/auto_session.lua: -------------------------------------------------------------------------------- 1 | vim.o.sessionoptions="blank,buffers,curdir,folds,help,tabpages,winsize,winpos,terminal" 2 | require("auto-session").setup({ 3 | log_level = "error", 4 | auto_session_suppress_dirs = {"~/", "~/Projects", "~/Downloads", "/", "/ect", "/usr"}, 5 | auto_session_enable_last_session = false, 6 | -- 保存session文件到 ~/.local/share/nvim/sessions目录 7 | auto_session_root_dir = vim.fn.stdpath('data').."/sessions/", 8 | auto_session_enabled = true, 9 | auto_save_enabled = nil, 10 | auto_restore_enabled = nil, 11 | auto_session_use_git_branch = nil, 12 | -- the configs below are lua only 13 | bypass_session_save_file_types = nil 14 | }) 15 | -------------------------------------------------------------------------------- /lua/plugin-config/buffer.lua: -------------------------------------------------------------------------------- 1 | vim.opt.termguicolors = true 2 | require("bufferline").setup{ 3 | options = { 4 | mode = "buffers", 5 | numbers = "ordinal", 6 | -- 左侧让出 nvim-tree 位置 7 | offsets = { 8 | { 9 | filetype = "NvimTree", 10 | text = "File Explorer", 11 | highlight = "Directory", 12 | text_align = "left" 13 | } 14 | } 15 | } 16 | } 17 | -- 快速在buffer间跳转 18 | vim.api.nvim_set_keymap("n", "1", ":BufferLineGoToBuffer 1", {noremap = true, silent = true}) 19 | vim.api.nvim_set_keymap("n", "2", ":BufferLineGoToBuffer 2", {noremap = true, silent = true}) 20 | vim.api.nvim_set_keymap("n", "3", ":BufferLineGoToBuffer 3", {noremap = true, silent = true}) 21 | vim.api.nvim_set_keymap("n", "4", ":BufferLineGoToBuffer 4", {noremap = true, silent = true}) 22 | vim.api.nvim_set_keymap("n", "5", ":BufferLineGoToBuffer 5", {noremap = true, silent = true}) 23 | vim.api.nvim_set_keymap("n", "6", ":BufferLineGoToBuffer 6", {noremap = true, silent = true}) 24 | vim.api.nvim_set_keymap("n", "7", ":BufferLineGoToBuffer 7", {noremap = true, silent = true}) 25 | vim.api.nvim_set_keymap("n", "8", ":BufferLineGoToBuffer 8", {noremap = true, silent = true}) 26 | vim.api.nvim_set_keymap("n", "9", ":BufferLineGoToBuffer 9", {noremap = true, silent = true}) 27 | vim.api.nvim_set_keymap("n", "bg", ":BufferLinePick", {noremap = true, silent = true}) 28 | 29 | -- 关闭当前buffer 30 | vim.api.nvim_set_keymap("n", "bc", ":bdelete %", {noremap = true, silent = true}) 31 | vim.api.nvim_set_keymap("n", "bp", ":BufferLinePickClose", {noremap = true, silent = true}) 32 | 33 | -- 关闭除此外的所有buffer 34 | vim.api.nvim_set_keymap("n", "bo", ":BufferLineCloseLeft:BufferLineCloseRight", {noremap = true, silent = true}) 35 | -------------------------------------------------------------------------------- /lua/plugin-config/cmp.lua: -------------------------------------------------------------------------------- 1 | local cmp = require("cmp") 2 | local lspkind = require("lspkind") 3 | cmp.setup({ 4 | -- 设置代码片段引擎,用于根据代码片段补全 5 | snippet = { 6 | expand = function(args) 7 | vim.fn["vsnip#anonymous"](args.body) 8 | end, 9 | }, 10 | 11 | window = { 12 | }, 13 | 14 | mapping = { 15 | -- 选择上一个 16 | [''] = cmp.mapping.select_prev_item(), 17 | -- 选择下一个 18 | [''] = cmp.mapping.select_next_item(), 19 | -- 出现补全 20 | [''] = cmp.mapping(cmp.mapping.complete(), {'i', 'c'}), 21 | -- 取消补全 22 | [''] = cmp.mapping({ 23 | i = cmp.mapping.abort(), 24 | c = cmp.mapping.close(), 25 | }), 26 | 27 | -- 确认使用某个补全项 28 | [''] = cmp.mapping.confirm({ 29 | select = true, 30 | behavior = cmp.ConfirmBehavior.Replace 31 | }), 32 | 33 | -- 向上翻页 34 | [''] = cmp.mapping(cmp.mapping.scroll_docs(-4), {'i', 'c'}), 35 | -- 向下翻页 36 | [''] = cmp.mapping(cmp.mapping.scroll_docs(4), {'i', 'c'}), 37 | }, 38 | 39 | -- 补全来源 40 | sources = cmp.config.sources({ 41 | {name = 'nvim_lsp'}, 42 | {name = 'vsnip'}, 43 | {name = 'buffer'}, 44 | {name = 'path'} 45 | }), 46 | 47 | --根据文件类型来选择补全来源 48 | cmp.setup.filetype('gitcommit', { 49 | sources = cmp.config.sources({ 50 | {name = 'buffer'} 51 | }) 52 | }), 53 | 54 | -- 命令模式下输入 `/` 启用补全 55 | cmp.setup.cmdline('/', { 56 | mapping = cmp.mapping.preset.cmdline(), 57 | sources = { 58 | { name = 'buffer' } 59 | } 60 | }), 61 | 62 | -- 命令模式下输入 `:` 启用补全 63 | cmp.setup.cmdline(':', { 64 | mapping = cmp.mapping.preset.cmdline(), 65 | sources = cmp.config.sources({ 66 | { name = 'path' } 67 | }, { 68 | { name = 'cmdline' } 69 | }) 70 | }), 71 | 72 | -- 设置补全显示的格式 73 | formatting = { 74 | format = lspkind.cmp_format({ 75 | with_text = true, 76 | maxwidth = 50, 77 | before = function(entry, vim_item) 78 | vim_item.menu = "[" .. string.upper(entry.source.name) .. "]" 79 | return vim_item 80 | end 81 | }), 82 | }, 83 | }) 84 | 85 | -------------------------------------------------------------------------------- /lua/plugin-config/dap-config.lua: -------------------------------------------------------------------------------- 1 | local dap_breakpoint_color = { 2 | breakpoint = { 3 | ctermbg=0, 4 | fg='#993939', 5 | bg='#31353f', 6 | }, 7 | logpoing = { 8 | ctermbg=0, 9 | fg='#61afef', 10 | bg='#31353f', 11 | }, 12 | stopped = { 13 | ctermbg=0, 14 | fg='#98c379', 15 | bg='#31353f' 16 | }, 17 | } 18 | 19 | vim.api.nvim_set_hl(0, 'DapBreakpoint', dap_breakpoint_color.breakpoint) 20 | vim.api.nvim_set_hl(0, 'DapLogPoint', dap_breakpoint_color.logpoing) 21 | vim.api.nvim_set_hl(0, 'DapStopped', dap_breakpoint_color.stopped) 22 | 23 | local dap_breakpoint = { 24 | error = { 25 | text = "", 26 | texthl = "DapBreakpoint", 27 | linehl = "DapBreakpoint", 28 | numhl = "DapBreakpoint", 29 | }, 30 | condition = { 31 | text = 'ﳁ', 32 | texthl = 'DapBreakpoint', 33 | linehl = 'DapBreakpoint', 34 | numhl = 'DapBreakpoint', 35 | }, 36 | rejected = { 37 | text = "", 38 | texthl = "DapBreakpint", 39 | linehl = "DapBreakpoint", 40 | numhl = "DapBreakpoint", 41 | }, 42 | logpoint = { 43 | text = '', 44 | texthl = 'DapLogPoint', 45 | linehl = 'DapLogPoint', 46 | numhl = 'DapLogPoint', 47 | }, 48 | stopped = { 49 | text = '', 50 | texthl = 'DapStopped', 51 | linehl = 'DapStopped', 52 | numhl = 'DapStopped', 53 | }, 54 | } 55 | 56 | vim.fn.sign_define('DapBreakpoint', dap_breakpoint.error) 57 | vim.fn.sign_define('DapBreakpointCondition', dap_breakpoint.condition) 58 | vim.fn.sign_define('DapBreakpointRejected', dap_breakpoint.rejected) 59 | vim.fn.sign_define('DapLogPoint', dap_breakpoint.logpoint) 60 | vim.fn.sign_define('DapStopped', dap_breakpoint.stopped) 61 | -------------------------------------------------------------------------------- /lua/plugin-config/dap-ui.lua: -------------------------------------------------------------------------------- 1 | local dapui = require("dapui") 2 | 3 | dapui.setup({ 4 | icons = { expanded = "", collapsed = "", current_frame = "" }, 5 | mappings = { 6 | -- Use a table to apply multiple mappings 7 | expand = { "", "<2-LeftMouse>" }, 8 | open = "o", 9 | remove = "d", 10 | edit = "e", 11 | repl = "r", 12 | toggle = "t", 13 | }, 14 | layouts = { 15 | { 16 | elements = { 17 | { 18 | id = 'scopes', 19 | size = 0.35 20 | }, 21 | {id = "stacks", size = 0.35}, 22 | {id = "watches", size = 0.15}, 23 | {id = "breakpoints", size = 0.15}, 24 | }, 25 | size = 40, 26 | position = "left", 27 | }, 28 | { 29 | elements = { 30 | "repl" 31 | }, 32 | size = 5, 33 | position = "bottom", 34 | } 35 | }, 36 | 37 | controls = {enabled = false}, 38 | floating = { 39 | max_height = nil, -- These can be integers or a float between 0 and 1. 40 | max_width = nil, -- Floats will be treated as percentage of your screen. 41 | border = "single", -- Border style. Can be "single", "double" or "rounded" 42 | mappings = { 43 | close = { "q", "" }, 44 | }, 45 | }, 46 | windows = { indent = 1 }, 47 | }) 48 | 49 | local dap = require("dap") 50 | dap.listeners.after.event_initialized["dapui_config"] = function() 51 | dapui.open({}) 52 | end 53 | 54 | dap.listeners.before.event_terminated["dapui_config"] = function() 55 | dapui.close({}) 56 | dap.repl.close() 57 | end 58 | 59 | 60 | dap.listeners.before.event_exited["dapui_config"] = function() 61 | dapui.close({}) 62 | dap.repl.close() 63 | end 64 | 65 | require("nvim-dap-virtual-text").setup({ 66 | enabled = true, 67 | enable_commands = true, 68 | highlight_changed_variables = true, 69 | highlight_new_as_changed = false, 70 | show_stop_reason = true, 71 | commented = false, 72 | only_first_definition = true, 73 | all_references = false, 74 | filter_references_pattern = 'gj", "Gitsigns next_hunk", {silent = true, noremap = true}) 47 | vim.api.nvim_set_keymap("n", "gk", "Gitsigns prev_hhunk", {silent = true, noremap = true}) 48 | vim.api.nvim_set_keymap('n', 'hs', ':Gitsigns stage_hunk', {silent = true, noremap = true}) 49 | vim.api.nvim_set_keymap('v', 'hs', ':Gitsigns stage_hunk', {silent = true, noremap = true}) 50 | vim.api.nvim_set_keymap('n', 'hr', ':Gitsigns reset_hunk', {silent = true, noremap = true}) 51 | vim.api.nvim_set_keymap('v', 'hr', ':Gitsigns reset_hunk', {silent = true, noremap = true}) 52 | vim.api.nvim_set_keymap('n', 'hS', 'Gitsigns stage_buffer', {silent = true, noremap = true}) 53 | vim.api.nvim_set_keymap('n', 'hu', 'Gitsigns undo_stage_hunk', {silent = true, noremap = true}) 54 | vim.api.nvim_set_keymap('n', 'hR', 'Gitsigns reset_buffer', {silent = true, noremap = true}) 55 | vim.api.nvim_set_keymap('n', 'hp', 'Gitsigns preview_hunk', {silent = true, noremap = true}) 56 | vim.api.nvim_set_keymap('n', 'hb', 'lua require"gitsigns".blame_line{full=true}', {silent = true, noremap = true}) 57 | vim.api.nvim_set_keymap('n', 'tb', 'Gitsigns toggle_current_line_blame', {silent = true, noremap = true}) 58 | vim.api.nvim_set_keymap('n', 'hd', 'Gitsigns diffthis', {silent = true, noremap = true}) 59 | vim.api.nvim_set_keymap('n', 'hD', 'lua require"gitsigns".diffthis("~")', {silent = true, noremap = true}) 60 | vim.api.nvim_set_keymap('n', 'td', 'Gitsigns toggle_deleted', {silent = true, noremap = true}) 61 | vim.api.nvim_set_keymap('o', 'ih', ':Gitsigns select_hunk', {silent = true, noremap = true}) 62 | vim.api.nvim_set_keymap('x', 'ih', ':Gitsigns select_hunk', {silent = true, noremap = true}) 63 | end 64 | }) 65 | -------------------------------------------------------------------------------- /lua/plugin-config/lspsaga.lua: -------------------------------------------------------------------------------- 1 | local saga = require('lspsaga') 2 | saga.init_lsp_saga() 3 | -------------------------------------------------------------------------------- /lua/plugin-config/lualine.lua: -------------------------------------------------------------------------------- 1 | -- Eviline config for lualine 2 | -- Author: shadmansaleh 3 | -- Credit: glepnir 4 | local lualine = require('lualine') 5 | 6 | -- Color table for highlights 7 | -- stylua: ignore 8 | local colors = { 9 | bg = '#202328', 10 | fg = '#bbc2cf', 11 | yellow = '#ECBE7B', 12 | cyan = '#008080', 13 | darkblue = '#081633', 14 | green = '#98be65', 15 | orange = '#FF8800', 16 | violet = '#a9a1e1', 17 | magenta = '#c678dd', 18 | blue = '#51afef', 19 | red = '#ec5f67', 20 | } 21 | 22 | local conditions = { 23 | buffer_not_empty = function() 24 | return vim.fn.empty(vim.fn.expand('%:t')) ~= 1 25 | end, 26 | hide_in_width = function() 27 | return vim.fn.winwidth(0) > 80 28 | end, 29 | check_git_workspace = function() 30 | local filepath = vim.fn.expand('%:p:h') 31 | local gitdir = vim.fn.finddir('.git', filepath .. ';') 32 | return gitdir and #gitdir > 0 and #gitdir < #filepath 33 | end, 34 | } 35 | 36 | -- Config 37 | local config = { 38 | options = { 39 | -- Disable sections and component separators 40 | component_separators = '', 41 | section_separators = '', 42 | theme = "tokyonight" 43 | }, 44 | sections = { 45 | -- these are to remove the defaults 46 | lualine_a = {}, 47 | lualine_b = {}, 48 | lualine_y = {}, 49 | lualine_z = {}, 50 | -- These will be filled later 51 | lualine_c = {require('auto-session-library').current_session_name}, 52 | lualine_x = {}, 53 | }, 54 | inactive_sections = { 55 | -- these are to remove the defaults 56 | lualine_a = {}, 57 | lualine_b = {}, 58 | lualine_y = {}, 59 | lualine_z = {}, 60 | lualine_c = {}, 61 | lualine_x = {}, 62 | }, 63 | } 64 | 65 | -- Inserts a component in lualine_c at left section 66 | local function ins_left(component) 67 | table.insert(config.sections.lualine_c, component) 68 | end 69 | 70 | -- Inserts a component in lualine_x ot right section 71 | local function ins_right(component) 72 | table.insert(config.sections.lualine_x, component) 73 | end 74 | 75 | ins_left { 76 | function() 77 | return '▊' 78 | end, 79 | color = { fg = colors.blue }, -- Sets highlighting of component 80 | padding = { left = 0, right = 1 }, -- We don't need space before this 81 | } 82 | 83 | ins_left { 84 | -- mode component 85 | function() 86 | return '' 87 | end, 88 | color = function() 89 | -- auto change color according to neovims mode 90 | local mode_color = { 91 | n = colors.red, 92 | i = colors.green, 93 | v = colors.blue, 94 | [''] = colors.blue, 95 | V = colors.blue, 96 | c = colors.magenta, 97 | no = colors.red, 98 | s = colors.orange, 99 | S = colors.orange, 100 | [''] = colors.orange, 101 | ic = colors.yellow, 102 | R = colors.violet, 103 | Rv = colors.violet, 104 | cv = colors.red, 105 | ce = colors.red, 106 | r = colors.cyan, 107 | rm = colors.cyan, 108 | ['r?'] = colors.cyan, 109 | ['!'] = colors.red, 110 | t = colors.red, 111 | } 112 | return { fg = mode_color[vim.fn.mode()] } 113 | end, 114 | padding = { right = 1 }, 115 | } 116 | 117 | ins_left { 118 | -- filesize component 119 | 'filesize', 120 | cond = conditions.buffer_not_empty, 121 | } 122 | 123 | ins_left { 124 | 'filename', 125 | cond = conditions.buffer_not_empty, 126 | color = { fg = colors.magenta, gui = 'bold' }, 127 | } 128 | 129 | ins_left { 'location' } 130 | 131 | ins_left { 'progress', color = { fg = colors.fg, gui = 'bold' } } 132 | 133 | ins_left { 134 | 'diagnostics', 135 | sources = { 'nvim_diagnostic' }, 136 | symbols = { error = ' ', warn = ' ', info = ' ' }, 137 | diagnostics_color = { 138 | color_error = { fg = colors.red }, 139 | color_warn = { fg = colors.yellow }, 140 | color_info = { fg = colors.cyan }, 141 | }, 142 | } 143 | 144 | -- Insert mid section. You can make any number of sections in neovim :) 145 | -- for lualine it's any number greater then 2 146 | ins_left { 147 | function() 148 | return '%=' 149 | end, 150 | } 151 | 152 | ins_left { 153 | -- Lsp server name . 154 | function() 155 | local msg = 'No Active Lsp' 156 | local buf_ft = vim.api.nvim_buf_get_option(0, 'filetype') 157 | local clients = vim.lsp.get_active_clients() 158 | if next(clients) == nil then 159 | return msg 160 | end 161 | for _, client in ipairs(clients) do 162 | local filetypes = client.config.filetypes 163 | if filetypes and vim.fn.index(filetypes, buf_ft) ~= -1 then 164 | return client.name 165 | end 166 | end 167 | return msg 168 | end, 169 | icon = ' LSP:', 170 | color = { fg = '#ffffff', gui = 'bold' }, 171 | } 172 | 173 | -- Add components to right sections 174 | ins_right { 175 | 'o:encoding', -- option component same as &encoding in viml 176 | fmt = string.upper, -- I'm not sure why it's upper case either ;) 177 | cond = conditions.hide_in_width, 178 | color = { fg = colors.green, gui = 'bold' }, 179 | } 180 | 181 | ins_right { 182 | 'fileformat', 183 | fmt = string.upper, 184 | icons_enabled = false, -- I think icons are cool but Eviline doesn't have them. sigh 185 | color = { fg = colors.green, gui = 'bold' }, 186 | } 187 | 188 | ins_right { 189 | 'branch', 190 | icon = '', 191 | color = { fg = colors.violet, gui = 'bold' }, 192 | } 193 | 194 | ins_right { 195 | 'diff', 196 | -- Is it me or the symbol for modified us really weird 197 | symbols = { added = ' ', modified = '柳 ', removed = ' ' }, 198 | diff_color = { 199 | added = { fg = colors.green }, 200 | modified = { fg = colors.orange }, 201 | removed = { fg = colors.red }, 202 | }, 203 | cond = conditions.hide_in_width, 204 | } 205 | 206 | ins_right { 207 | function() 208 | return '▊' 209 | end, 210 | color = { fg = colors.blue }, 211 | padding = { left = 1 }, 212 | } 213 | 214 | -- Now don't forget to initialize lualine 215 | lualine.setup(config) 216 | -------------------------------------------------------------------------------- /lua/plugin-config/mason.lua: -------------------------------------------------------------------------------- 1 | require("mason").setup() 2 | -------------------------------------------------------------------------------- /lua/plugin-config/nvimgdb.lua: -------------------------------------------------------------------------------- 1 | vim.cmd([[ 2 | let w:nvimgdb_termwin_command = "rightbelow vnew" 3 | let w:nvimgdb_codewin_command = "vnew" 4 | let g:nvimgdb_use_find_executables = 0 5 | let g:nvimgdb_use_cmake_to_find_executables = 0 6 | let g:nvimgdb_config_override = { 7 | \ 'sign_breakpoint': [''], 8 | \ 'sign_current_line': '', 9 | \ 'key_next': '', 10 | \ 'key_step': '', 11 | \ 'key_continue': '', 12 | \ } 13 | ]]) 14 | 15 | vim.cmd([[ 16 | nnoremap dd ":GdbStart gdb -q " . input("debug file path: ") . "\" 17 | ]]) 18 | StartGdbSession = function() 19 | vim.api.nvim_command(":belowright GdbCreateWatch backtrace") 20 | vim.api.nvim_command(":wincmd h") 21 | vim.api.nvim_command(":belowright GdbCreateWatch info locals") 22 | vim.api.nvim_command(":set wrap") 23 | vim.api.nvim_command(":wincmd k") 24 | end 25 | 26 | EndGdbSession = function() 27 | vim.api.nvim_command(":bdelete! backtrace info locals") 28 | end 29 | 30 | vim.cmd([[augroup GdbSession 31 | autocmd! 32 | autocmd User NvimGdbStart :lua StartGdbSession() 33 | autocmd User NvimGdbCleanup :lua EndGdbSession() 34 | augroup END]]) 35 | -------------------------------------------------------------------------------- /lua/plugin-config/nvimtree.lua: -------------------------------------------------------------------------------- 1 | require("nvim-tree").setup({ 2 | filters = { 3 | dotfiles = true, 4 | custom = { 5 | ".git/" 6 | }, 7 | 8 | exclude = { 9 | ".gitignore" 10 | }, 11 | }, 12 | git = { 13 | enable = true 14 | }, 15 | -- 仅起到演示作用,不推荐这样设置 16 | -- view = { 17 | -- mappings = { 18 | -- list = { 19 | -- 定义快捷键 20 | -- {key = "%", action = "create"}, 21 | -- {key = "d", action = "create"}, 22 | -- {key = "R", action = "rename"}, 23 | -- {key = "D", action = "remove"} 24 | -- } 25 | -- }, 26 | -- }, 27 | }) 28 | vim.api.nvim_set_keymap("n", "", ":NvimTreeToggle", {noremap = true, silent = true}) 29 | -------------------------------------------------------------------------------- /lua/plugin-config/symbols_outline.lua: -------------------------------------------------------------------------------- 1 | require("symbols-outline").setup() 2 | -------------------------------------------------------------------------------- /lua/plugin-config/telescope.lua: -------------------------------------------------------------------------------- 1 | require('telescope').load_extension "file_browser" 2 | 3 | vim.api.nvim_set_keymap("n", "ff", "Telescope find_files", {noremap = true, silent = true}) 4 | vim.api.nvim_set_keymap("n", "gg", "Telescope live_grep", {noremap = true, silent = true}) 5 | vim.api.nvim_set_keymap("n", "fh", "Telescope oldfiles", {noremap = true, silent = true}) 6 | vim.api.nvim_set_keymap("n", "fb", "Telescope file_browser", {noremap = true, silent = true}) 7 | vim.api.nvim_set_keymap("n", "fm", "Telescope marks", {noremap = true, silent = true}) 8 | vim.api.nvim_set_keymap("n", "fj", "Telescope jumplist", {noremap = true, silent = true}) 9 | -------------------------------------------------------------------------------- /lua/plugin-config/toggleterm.lua: -------------------------------------------------------------------------------- 1 | local opt = require("toggleterm").setup({ 2 | open_mapping = [[]], 3 | -- 以弹出式窗口的形式打开新终端 4 | direction = 'horizontal' 5 | }) 6 | 7 | 8 | -- 快捷键 9 | vim.api.nvim_set_keymap("t", "", "", {noremap = true, silent = true}) 10 | vim.api.nvim_set_keymap("t", "l", " wincmd l", {noremap = true, silent = true}) 11 | vim.api.nvim_set_keymap("t", "h", " wincmd h", {noremap = true, silent = true}) 12 | vim.api.nvim_set_keymap("t", "j", " wincmd j", {noremap = true, silent = true}) 13 | vim.api.nvim_set_keymap("t", "k", " wincmd k", {noremap = true, silent = true}) 14 | 15 | -- 自定义终端 16 | local Terminal = require("toggleterm.terminal").Terminal 17 | local pyterm = Terminal:new({ 18 | cmd = 'python', 19 | direction = 'horizontal' 20 | }) 21 | 22 | local htopterm = Terminal:new({ 23 | cmd = "htop", 24 | direction = "float" 25 | }) 26 | 27 | function python_toggle() 28 | pyterm:toggle() 29 | end 30 | 31 | function htop_toggle() 32 | htopterm:toggle() 33 | end 34 | 35 | local lazygit_term = Terminal:new({ 36 | cmd = 'lazygit', 37 | direction = 'float' 38 | }) 39 | 40 | function lazygit_toggle() 41 | lazygit_term:toggle() 42 | end 43 | 44 | vim.api.nvim_set_keymap("n", "py", "lua python_toggle()", {noremap = true, silent = true}) 45 | vim.api.nvim_set_keymap("n", "ht", "lua htop_toggle()", {noremap = true, silent = true}) 46 | vim.api.nvim_set_keymap("n", "lg", "lua lazygit_toggle()", {noremap = true, silent = true}) 47 | -------------------------------------------------------------------------------- /lua/plugin-config/tokyonight.lua: -------------------------------------------------------------------------------- 1 | -- 配置主题颜色模式为 storm 2 | vim.g.tokyonight_style = "storm" 3 | -- 允许neovim中的终端使用该主题配色 4 | vim.g.tokyonight_terminal_colors = true 5 | -- 注释使用斜体 6 | vim.g.tokyonight_italic_comments = true 7 | -------------------------------------------------------------------------------- /lua/plugin-config/treesitter.lua: -------------------------------------------------------------------------------- 1 | require('nvim-treesitter.configs').setup({ 2 | -- 支持的语言 3 | ensure_installed = {"html", "css", "vim", "lua", "javascript", "typescript", "c", "cpp", "python"}, 4 | -- 启用代码高亮 5 | highlight = { 6 | enable = true, 7 | additional_vim_regex_highlighting = false 8 | }, 9 | 10 | --启用增量选择 11 | incremental_selection = { 12 | enable = true, 13 | keymaps = { 14 | init_selection = '', 15 | node_incremental = '', 16 | node_decremental = '', 17 | scope_incremental = '' 18 | } 19 | }, 20 | 21 | -- 启用基于 Treesitter 的代码格式化(=) 22 | indent = { 23 | enable = true 24 | }, 25 | }) 26 | 27 | -- 开启代码折叠 28 | vim.wo.foldmethod = 'expr' 29 | vim.wo.foldexpr = 'nvim_treesitter#foldexpr()' 30 | 31 | -- 默认不折叠 32 | vim.wo.foldlevel = 99 33 | -------------------------------------------------------------------------------- /lua/plugin-config/vscode.lua: -------------------------------------------------------------------------------- 1 | -- 使用 dark 主题 2 | vim.o.background = 'dark' 3 | 4 | local c = require('vscode.colors') 5 | require('vscode').setup({ 6 | -- 允许透明背景 7 | transparent = true, 8 | -- 注释使用斜体 9 | italic_comments = true, 10 | 11 | -- 禁止使用 nvim-tree 背景色 12 | disable_nvimtree_bg = true, 13 | -- 重写部分元素配色 14 | color_overrides = { 15 | vscLineNumber = '#FFFFFF', 16 | }, 17 | }) 18 | -------------------------------------------------------------------------------- /lua/plugin-config/whichkey.lua: -------------------------------------------------------------------------------- 1 | local wk = require("which-key") 2 | 3 | -- wk.register({ 4 | -- f = { 5 | -- name = "myvimrc", -- 指定该快捷键组的名称 6 | -- f = {":edit $MYVIMRC", "Open vimrc"}, -- 创建新的快捷键绑定 7 | -- s = {":source $MYVIMRC", "reload vimrc", noremap = true}, 8 | -- -- 也可以只显示一个标签而不绑定到具体的快捷键 9 | -- e = {"New File"} 10 | -- } 11 | -- }, {prefix = ""}) 12 | 13 | 14 | -- wk.register({ 15 | -- [""] = { 16 | -- f = { 17 | -- name = "myvimrc", -- 指定该快捷键组的名称 18 | -- f = {":edit $MYVIMRC", "Open vimrc"}, -- 创建新的快捷键绑定 19 | -- s = {":source $MYVIMRC", "reload vimrc", noremap = true}, 20 | -- -- 也可以只显示一个标签而不绑定到具体的快捷键 21 | -- e = {"New File"} 22 | -- } 23 | -- } 24 | -- }, {silent = true, noremap = true}) 25 | wk.register({ 26 | ["s"] = { 27 | name = "split window", 28 | v = { ":vsp", "vertical split window" }, 29 | h = { ":sh", "horizontal split window"}, 30 | c = { ":close", "close this window"}, 31 | o = { ":only", "close all but this window"}, 32 | }, 33 | }) 34 | wk.setup({}) 35 | -------------------------------------------------------------------------------- /lua/plugins.lua: -------------------------------------------------------------------------------- 1 | -- 插件管理文件 2 | return require('packer').startup(function(use) 3 | -- Packer can manage itself 4 | use 'wbthomason/packer.nvim' 5 | -- 主题配置 6 | use 'folke/tokyonight.nvim' 7 | use 'Mofiqul/vscode.nvim' 8 | use {'akinsho/bufferline.nvim', tag = "v2.*", requires = 'kyazdani42/nvim-web-devicons'} 9 | use { 10 | 'kyazdani42/nvim-tree.lua', 11 | requires = { 12 | 'kyazdani42/nvim-web-devicons', -- optional, for file icons 13 | }, 14 | tag = 'nightly' -- optional, updated every week. (see issue #1193) 15 | } 16 | use { 17 | 'nvim-lualine/lualine.nvim', 18 | requires = { 'kyazdani42/nvim-web-devicons', opt = true } 19 | } 20 | use {'glepnir/dashboard-nvim'} 21 | use {"folke/which-key.nvim"} 22 | use {"akinsho/toggleterm.nvim", tag = 'v2.*'} 23 | use { 24 | 'nvim-telescope/telescope.nvim', tag = '0.1.0', 25 | requires = { {'nvim-lua/plenary.nvim'} , { 26 | 'nvim-treesitter/nvim-treesitter', 27 | run = function() 28 | require('nvim-treesitter.install').update({ with_sync = true }) 29 | end, 30 | }} 31 | } 32 | use { "nvim-telescope/telescope-file-browser.nvim" } 33 | use {'rmagatti/auto-session'} 34 | use {"williamboman/mason.nvim"} 35 | use {"neovim/nvim-lspconfig"} 36 | -- nvim-cmp 37 | use {'hrsh7th/cmp-nvim-lsp'} 38 | use {'hrsh7th/cmp-buffer'} 39 | use {'hrsh7th/cmp-path'} 40 | use {'hrsh7th/cmp-cmdline'} 41 | use {'hrsh7th/nvim-cmp'} 42 | -- vsnip 43 | use {'hrsh7th/cmp-vsnip'} 44 | use {'hrsh7th/vim-vsnip'} 45 | use {'rafamadriz/friendly-snippets'} 46 | -- lspkind 47 | use {'onsails/lspkind-nvim'} 48 | -- lspsaga 49 | use {'glepnir/lspsaga.nvim'} 50 | use {'simrat39/symbols-outline.nvim'} 51 | 52 | -- dap 53 | use {'mfussenegger/nvim-dap'} 54 | use { "rcarriga/nvim-dap-ui", requires = {"mfussenegger/nvim-dap"} } 55 | use {"theHamsta/nvim-dap-virtual-text", requires = {"nvim-treesitter/nvim-treesitter" , "mfussenegger/nvim-dap"}} 56 | use {"sakhnik/nvim-gdb", run = "./install.sh"} 57 | 58 | --git 59 | use {'lewis6991/gitsigns.nvim'} 60 | use { 'sindrets/diffview.nvim', requires = 'nvim-lua/plenary.nvim' } 61 | end) 62 | 63 | --------------------------------------------------------------------------------