├── .gitignore ├── lua ├── conf │ ├── hop.lua │ ├── vim-carbon-now-sh.lua │ ├── impatient.lua │ ├── nvim-hlslens.lua │ ├── nvim-autopairs.lua │ ├── nvim-colorizer.lua │ ├── gitsigns.lua │ ├── nvim-dap-virtual-text.lua │ ├── vim-translator.lua │ ├── spellsitter.lua │ ├── surround.lua │ ├── nvim-lightbulb.lua │ ├── copilot.lua │ ├── fidget.lua │ ├── vim-dadbod-ui.lua │ ├── vim-illuminate.lua │ ├── telescope.lua │ ├── lsp-colors.lua │ ├── which-key.lua │ ├── undotree.lua │ ├── nvim-lastplace.lua │ ├── indent-blankline.lua │ ├── nvim-spectre.lua │ ├── nvim-lspconfig.lua │ ├── nvim-markdown-preview.lua │ ├── vim-multiple-cursors.lua │ ├── neoformat.lua │ ├── nvim-notify.lua │ ├── lsp_signature.lua │ ├── nvim-dap.lua │ ├── AutoSave.lua │ ├── nvim-dap-ui.lua │ ├── nvim-lint.lua │ ├── todo-comments.lua │ ├── switch.lua │ ├── nvim-scrollbar.lua │ ├── lspsaga.lua │ ├── aerial.lua │ ├── nvim-treesitter.lua │ ├── bufferline.lua │ ├── nvim-tree.lua │ ├── Comment.lua │ ├── catppuccin.lua │ ├── toggleterm.lua │ ├── lualine.lua │ ├── nvim-cmp.lua │ └── nvim-lsp-installer.lua ├── lsp │ ├── cssls.lua │ ├── gopls.lua │ ├── html.lua │ ├── vuels.lua │ ├── jsonls.lua │ ├── zeta_note.lua │ ├── tsserver.lua │ ├── pyright.lua │ └── sumneko_lua.lua ├── dap │ ├── python.lua │ └── go.lua └── basic │ ├── settings.lua │ ├── config.lua │ ├── plugins.lua │ └── keybinds.lua ├── spell ├── en.utf-8.add.spl └── en.utf-8.add ├── ftplugin ├── conf.lua ├── css.lua ├── go.lua ├── html.lua ├── json.lua ├── python.lua ├── txt.lua ├── vue.lua ├── javascript.lua ├── markdown.lua ├── typescript.lua ├── sh.lua ├── yaml.lua ├── yml.lua └── lua.lua ├── init.lua ├── undodir ├── %home%askfiy%.config%nvim%init.lua ├── %home%askfiy%.config%nvim%lua%basic%config.lua ├── %home%askfiy%.config%nvim%lua%basic%keybinds.lua ├── %home%askfiy%.config%nvim%lua%basic%plugins.lua ├── %home%askfiy%.config%nvim%lua%conf%catppuccin.lua ├── %home%askfiy%.config%nvim%lua%conf%nvim-cmp.lua ├── %home%askfiy%.config%nvim%lua%conf%nvim-dap.lua ├── %home%askfiy%.config%nvim%lua%conf%nvim-lint.lua └── %home%askfiy%.config%nvim%lua%conf%nvim-lspconfig.lua ├── .luarc.json ├── README.md ├── snippet ├── go.json ├── markdown.json ├── python.json └── html.json ├── docs ├── chinese.md └── english.md └── resource └── alacritty.yml /.gitignore: -------------------------------------------------------------------------------- 1 | plugin 2 | undodir 3 | -------------------------------------------------------------------------------- /lua/conf/hop.lua: -------------------------------------------------------------------------------- 1 | -- https://github.com/phaazon/hop.nvim 2 | 3 | require("hop").setup() 4 | -------------------------------------------------------------------------------- /spell/en.utf-8.add.spl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/askfiy/nvimrc/HEAD/spell/en.utf-8.add.spl -------------------------------------------------------------------------------- /lua/conf/vim-carbon-now-sh.lua: -------------------------------------------------------------------------------- 1 | -- https://github.com/kristijanhusak/vim-carbon-now-sh 2 | 3 | -------------------------------------------------------------------------------- /lua/conf/impatient.lua: -------------------------------------------------------------------------------- 1 | -- https://github.com/lewis6991/impatient.nvim 2 | 3 | require("impatient") 4 | -------------------------------------------------------------------------------- /lua/conf/nvim-hlslens.lua: -------------------------------------------------------------------------------- 1 | -- https://github.com/kevinhwang91/nvim-hlslens 2 | 3 | require("hlslens").setup() 4 | -------------------------------------------------------------------------------- /lua/lsp/cssls.lua: -------------------------------------------------------------------------------- 1 | return { 2 | root_dir = function() 3 | return vim.fn.getcwd() 4 | end 5 | } 6 | -------------------------------------------------------------------------------- /lua/lsp/gopls.lua: -------------------------------------------------------------------------------- 1 | return { 2 | root_dir = function() 3 | return vim.fn.getcwd() 4 | end 5 | } 6 | -------------------------------------------------------------------------------- /lua/lsp/html.lua: -------------------------------------------------------------------------------- 1 | return { 2 | root_dir = function() 3 | return vim.fn.getcwd() 4 | end 5 | } 6 | -------------------------------------------------------------------------------- /lua/lsp/vuels.lua: -------------------------------------------------------------------------------- 1 | return { 2 | root_dir = function() 3 | return vim.fn.getcwd() 4 | end 5 | } 6 | -------------------------------------------------------------------------------- /lua/conf/nvim-autopairs.lua: -------------------------------------------------------------------------------- 1 | -- https://github.com/windwp/nvim-autopairs 2 | 3 | require("nvim-autopairs").setup() 4 | -------------------------------------------------------------------------------- /lua/lsp/jsonls.lua: -------------------------------------------------------------------------------- 1 | return { 2 | root_dir = function() 3 | return vim.fn.getcwd() 4 | end 5 | } 6 | -------------------------------------------------------------------------------- /lua/lsp/zeta_note.lua: -------------------------------------------------------------------------------- 1 | return { 2 | root_dir = function() 3 | return vim.fn.getcwd() 4 | end 5 | } 6 | -------------------------------------------------------------------------------- /ftplugin/conf.lua: -------------------------------------------------------------------------------- 1 | vim.bo.expandtab = true 2 | vim.bo.shiftwidth = 2 3 | vim.bo.tabstop = 2 4 | vim.bo.softtabstop = 2 5 | -------------------------------------------------------------------------------- /ftplugin/css.lua: -------------------------------------------------------------------------------- 1 | vim.bo.expandtab = true 2 | vim.bo.shiftwidth = 2 3 | vim.bo.tabstop = 2 4 | vim.bo.softtabstop = 2 5 | -------------------------------------------------------------------------------- /ftplugin/go.lua: -------------------------------------------------------------------------------- 1 | vim.bo.expandtab = false 2 | vim.bo.shiftwidth = 4 3 | vim.bo.tabstop = 4 4 | vim.bo.softtabstop = 4 5 | -------------------------------------------------------------------------------- /ftplugin/html.lua: -------------------------------------------------------------------------------- 1 | vim.bo.expandtab = true 2 | vim.bo.shiftwidth = 2 3 | vim.bo.tabstop = 2 4 | vim.bo.softtabstop = 2 5 | -------------------------------------------------------------------------------- /ftplugin/json.lua: -------------------------------------------------------------------------------- 1 | vim.bo.expandtab = true 2 | vim.bo.shiftwidth = 2 3 | vim.bo.tabstop = 2 4 | vim.bo.softtabstop = 2 5 | -------------------------------------------------------------------------------- /ftplugin/python.lua: -------------------------------------------------------------------------------- 1 | vim.bo.expandtab = true 2 | vim.bo.shiftwidth = 4 3 | vim.bo.tabstop = 4 4 | vim.bo.softtabstop = 4 5 | -------------------------------------------------------------------------------- /ftplugin/txt.lua: -------------------------------------------------------------------------------- 1 | vim.bo.expandtab = true 2 | vim.bo.shiftwidth = 4 3 | vim.bo.tabstop = 4 4 | vim.bo.softtabstop = 4 5 | -------------------------------------------------------------------------------- /ftplugin/vue.lua: -------------------------------------------------------------------------------- 1 | vim.bo.expandtab = true 2 | vim.bo.shiftwidth = 2 3 | vim.bo.tabstop = 2 4 | vim.bo.softtabstop = 2 5 | -------------------------------------------------------------------------------- /lua/conf/nvim-colorizer.lua: -------------------------------------------------------------------------------- 1 | -- https://github.com/norcalli/nvim-colorizer.lua 2 | 3 | require("colorizer").setup() 4 | -------------------------------------------------------------------------------- /ftplugin/javascript.lua: -------------------------------------------------------------------------------- 1 | vim.bo.expandtab = true 2 | vim.bo.shiftwidth = 2 3 | vim.bo.tabstop = 2 4 | vim.bo.softtabstop = 2 5 | -------------------------------------------------------------------------------- /ftplugin/markdown.lua: -------------------------------------------------------------------------------- 1 | vim.bo.expandtab = true 2 | vim.bo.shiftwidth = 4 3 | vim.bo.tabstop = 4 4 | vim.bo.softtabstop = 4 5 | -------------------------------------------------------------------------------- /ftplugin/typescript.lua: -------------------------------------------------------------------------------- 1 | vim.bo.expandtab = true 2 | vim.bo.shiftwidth = 2 3 | vim.bo.tabstop = 2 4 | vim.bo.softtabstop = 2 5 | -------------------------------------------------------------------------------- /init.lua: -------------------------------------------------------------------------------- 1 | require("basic.settings") 2 | require("basic.config") 3 | require("basic.keybinds") 4 | require("basic.plugins") 5 | -------------------------------------------------------------------------------- /undodir/%home%askfiy%.config%nvim%init.lua: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/askfiy/nvimrc/HEAD/undodir/%home%askfiy%.config%nvim%init.lua -------------------------------------------------------------------------------- /lua/conf/gitsigns.lua: -------------------------------------------------------------------------------- 1 | -- https://github.com/lewis6991/gitsigns.nvim/ 2 | 3 | -- TODO: gitsigns 热键映射 4 | require("gitsigns").setup() 5 | -------------------------------------------------------------------------------- /lua/conf/nvim-dap-virtual-text.lua: -------------------------------------------------------------------------------- 1 | -- https://github.com/theHamsta/nvim-dap-virtual-text 2 | 3 | require("nvim-dap-virtual-text").setup() 4 | -------------------------------------------------------------------------------- /lua/conf/vim-translator.lua: -------------------------------------------------------------------------------- 1 | -- https://github.com/voldikss/vim-translator 2 | 3 | vim.g.translator_default_engines = {"bing", "youdao", "haici"} 4 | -------------------------------------------------------------------------------- /undodir/%home%askfiy%.config%nvim%lua%basic%config.lua: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/askfiy/nvimrc/HEAD/undodir/%home%askfiy%.config%nvim%lua%basic%config.lua -------------------------------------------------------------------------------- /undodir/%home%askfiy%.config%nvim%lua%basic%keybinds.lua: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/askfiy/nvimrc/HEAD/undodir/%home%askfiy%.config%nvim%lua%basic%keybinds.lua -------------------------------------------------------------------------------- /undodir/%home%askfiy%.config%nvim%lua%basic%plugins.lua: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/askfiy/nvimrc/HEAD/undodir/%home%askfiy%.config%nvim%lua%basic%plugins.lua -------------------------------------------------------------------------------- /undodir/%home%askfiy%.config%nvim%lua%conf%catppuccin.lua: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/askfiy/nvimrc/HEAD/undodir/%home%askfiy%.config%nvim%lua%conf%catppuccin.lua -------------------------------------------------------------------------------- /undodir/%home%askfiy%.config%nvim%lua%conf%nvim-cmp.lua: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/askfiy/nvimrc/HEAD/undodir/%home%askfiy%.config%nvim%lua%conf%nvim-cmp.lua -------------------------------------------------------------------------------- /undodir/%home%askfiy%.config%nvim%lua%conf%nvim-dap.lua: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/askfiy/nvimrc/HEAD/undodir/%home%askfiy%.config%nvim%lua%conf%nvim-dap.lua -------------------------------------------------------------------------------- /undodir/%home%askfiy%.config%nvim%lua%conf%nvim-lint.lua: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/askfiy/nvimrc/HEAD/undodir/%home%askfiy%.config%nvim%lua%conf%nvim-lint.lua -------------------------------------------------------------------------------- /lua/conf/spellsitter.lua: -------------------------------------------------------------------------------- 1 | -- https://github.com/lewis6991/spellsitter.nvim 2 | 3 | require("spellsitter").setup( 4 | { 5 | enable = true 6 | } 7 | ) 8 | -------------------------------------------------------------------------------- /lua/conf/surround.lua: -------------------------------------------------------------------------------- 1 | -- https://github.com/ur4ltz/surround.nvim 2 | 3 | require("surround").setup( 4 | { 5 | mappings_style = "surround" 6 | } 7 | ) 8 | -------------------------------------------------------------------------------- /undodir/%home%askfiy%.config%nvim%lua%conf%nvim-lspconfig.lua: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/askfiy/nvimrc/HEAD/undodir/%home%askfiy%.config%nvim%lua%conf%nvim-lspconfig.lua -------------------------------------------------------------------------------- /lua/conf/nvim-lightbulb.lua: -------------------------------------------------------------------------------- 1 | -- https://github.com/kosayoda/nvim-lightbulb 2 | 3 | vim.cmd [[autocmd CursorHold,CursorHoldI * lua require'nvim-lightbulb'.update_lightbulb()]] 4 | -------------------------------------------------------------------------------- /lua/conf/copilot.lua: -------------------------------------------------------------------------------- 1 | -- https://github.com/github/copilot.vim 2 | 3 | vim.g.copilot_no_tab_map = true 4 | -- 由于延迟加载,所以需要在这里删除 tab 的绑定 5 | vim.api.nvim_del_keymap("i", "") 6 | 7 | -------------------------------------------------------------------------------- /ftplugin/sh.lua: -------------------------------------------------------------------------------- 1 | vim.bo.expandtab = true 2 | vim.bo.shiftwidth = 2 3 | vim.bo.tabstop = 2 4 | vim.bo.softtabstop = 2 5 | vim.opt_local.formatoptions = vim.opt_local.formatoptions - {"c", "r", "o"} 6 | -------------------------------------------------------------------------------- /ftplugin/yaml.lua: -------------------------------------------------------------------------------- 1 | vim.bo.expandtab = true 2 | vim.bo.shiftwidth = 2 3 | vim.bo.tabstop = 2 4 | vim.bo.softtabstop = 2 5 | vim.opt_local.formatoptions = vim.opt_local.formatoptions - {"c", "r", "o"} 6 | -------------------------------------------------------------------------------- /ftplugin/yml.lua: -------------------------------------------------------------------------------- 1 | vim.bo.expandtab = true 2 | vim.bo.shiftwidth = 2 3 | vim.bo.tabstop = 2 4 | vim.bo.softtabstop = 2 5 | vim.opt_local.formatoptions = vim.opt_local.formatoptions - {"c", "r", "o"} 6 | -------------------------------------------------------------------------------- /ftplugin/lua.lua: -------------------------------------------------------------------------------- 1 | vim.bo.expandtab = true 2 | vim.bo.shiftwidth = 4 3 | vim.bo.tabstop = 4 4 | vim.bo.softtabstop = 4 5 | vim.opt_local.formatoptions = vim.opt_local.formatoptions - {"c", "r", "o"} 6 | 7 | -------------------------------------------------------------------------------- /lua/conf/fidget.lua: -------------------------------------------------------------------------------- 1 | -- https://github.com/j-hui/fidget.nvim 2 | 3 | require("fidget").setup( 4 | { 5 | window = { 6 | -- 透明度 7 | blend = 0 8 | } 9 | } 10 | ) 11 | -------------------------------------------------------------------------------- /lua/conf/vim-dadbod-ui.lua: -------------------------------------------------------------------------------- 1 | -- https://github.com/kristijanhusak/vim-dadbod-ui 2 | -- https://github.com/abzcoding/lvim 3 | 4 | -- 宽度 5 | vim.g.db_ui_winwidth = 30 6 | 7 | -- 自动执行内置语句 8 | vim.g.db_ui_auto_execute_table_helpers = true 9 | 10 | -------------------------------------------------------------------------------- /lua/conf/vim-illuminate.lua: -------------------------------------------------------------------------------- 1 | -- https://github.com/RRethy/vim-illuminate 2 | 3 | -- HACK: vim-illuminate 词汇高亮类型排除 4 | -- 禁止高亮的文件类型 5 | 6 | vim.g.Illuminate_ftblacklist = { 7 | "NvimTree", 8 | "aerial", 9 | "toggleterm" 10 | } 11 | -------------------------------------------------------------------------------- /lua/lsp/tsserver.lua: -------------------------------------------------------------------------------- 1 | return { 2 | cmd = {"typescript-language-server", "--stdio"}, 3 | init_options = { 4 | hostInfo = "neovim" 5 | }, 6 | root_dir = function() 7 | return vim.fn.getcwd() 8 | end 9 | } 10 | -------------------------------------------------------------------------------- /spell/en.utf-8.add: -------------------------------------------------------------------------------- 1 | gps/! 2 | gps 3 | #equire 4 | require/! 5 | require 6 | #ocal 7 | #ocal/! 8 | local/! 9 | local 10 | #pellsitter/! 11 | #pellsitter 12 | spellsitter/! 13 | spellsitter 14 | #croller 15 | scroller/! 16 | scroller 17 | unmap/! 18 | unmap 19 | -------------------------------------------------------------------------------- /.luarc.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://raw.githubusercontent.com/sumneko/vscode-lua/master/setting/schema.json", 3 | "Lua.diagnostics.disable": [ 4 | "unused-local" 5 | ], 6 | "Lua.diagnostics.globals": [ 7 | "vim", 8 | "use" 9 | ] 10 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | My neovim configuration readme: 2 | 3 | - [中文](./docs/chinese.md) 4 | - [English](./docs/english.md) 5 | 6 | ## It is no longer updated, please check it at [askfiy/nvim](https://github.com/askfiy/nvim). 7 | 8 | ## 它现在不再更新,请到 [askfiy/nvim](https://github.com/askfiy/nvim) 中查看。 9 | -------------------------------------------------------------------------------- /lua/conf/telescope.lua: -------------------------------------------------------------------------------- 1 | -- https://github.com/nvim-telescope/telescope.nvim 2 | 3 | -- WARN: telescope 手动安装依赖 fd 和 repgrep 4 | -- https://github.com/sharkdp/fd 5 | -- https://github.com/BurntSushi/ripgrep 6 | -- 运行: 7 | -- :checkhealth telescope 8 | 9 | require("telescope").setup() 10 | -------------------------------------------------------------------------------- /lua/conf/lsp-colors.lua: -------------------------------------------------------------------------------- 1 | -- https://github.com/folke/lsp-colors.nvim 2 | 3 | -- 当主题不支持 LSP 高亮时,将采用以下默认方案 4 | require("lsp-colors").setup( 5 | { 6 | Error = "#db4b4b", 7 | Warning = "#e0af68", 8 | Information = "#0db9d7", 9 | Hint = "#10B981" 10 | } 11 | ) 12 | -------------------------------------------------------------------------------- /snippet/go.json: -------------------------------------------------------------------------------- 1 | { 2 | "main package code": { 3 | "prefix": "code", 4 | "body": [ 5 | "package main\n", 6 | "import \"fmt\"\n", 7 | "func main() {", 8 | "\tfmt.Printf(\"hi Golang\\n${1}\")", 9 | "}" 10 | ], 11 | "description": "package main code" 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /lua/conf/which-key.lua: -------------------------------------------------------------------------------- 1 | -- https://github.com/folke/which-key.nvim 2 | 3 | require("which-key").setup( 4 | { 5 | plugins = { 6 | spelling = { 7 | -- 是否接管默认 z= 的行为 8 | enabled = true, 9 | suggestions = 20 10 | } 11 | } 12 | } 13 | ) 14 | -------------------------------------------------------------------------------- /lua/conf/undotree.lua: -------------------------------------------------------------------------------- 1 | -- https://github.com/mbbill/undotree 2 | 3 | vim.cmd( 4 | [[ 5 | if has("persistent_undo") 6 | let target_path = expand(undotree_dir) 7 | if !isdirectory(target_path) 8 | call mkdir(target_path, "p", 0700) 9 | endif 10 | let &undodir = target_path 11 | set undofile 12 | ]] 13 | ) 14 | -------------------------------------------------------------------------------- /lua/conf/nvim-lastplace.lua: -------------------------------------------------------------------------------- 1 | -- https://github.com/ethanholz/nvim-lastplace 2 | 3 | require("nvim-lastplace").setup( 4 | { 5 | lastplace_ignore_buftype = {"quickfix", "nofile", "help"}, 6 | lastplace_ignore_filetype = {"gitcommit", "gitrebase", "svn", "hgcommit"}, 7 | lastplace_open_folds = true 8 | } 9 | ) 10 | -------------------------------------------------------------------------------- /lua/conf/indent-blankline.lua: -------------------------------------------------------------------------------- 1 | -- https://github.com/lukas-reineke/indent-blankline.nvim 2 | 3 | require("indent_blankline").setup( 4 | { 5 | -- 显示当前所在区域 6 | show_current_context = true, 7 | -- 显示当前所在区域的开始位置 8 | show_current_context_start = false, 9 | -- 显示行尾符 10 | show_end_of_line = true 11 | } 12 | ) 13 | -------------------------------------------------------------------------------- /lua/conf/nvim-spectre.lua: -------------------------------------------------------------------------------- 1 | -- https://github.com/nvim-pack/nvim-spectre 2 | 3 | -- WARN: spectre 手动安装依赖项 sed 和 ripgrep 4 | -- yay -S sed 5 | -- https://github.com/BurntSushi/ripgrep 6 | 7 | local plugin_key = vim.u.keymap.set.nvim_spectre.plugin_set 8 | 9 | require("spectre").setup( 10 | { 11 | mapping = plugin_key.mapping 12 | } 13 | ) 14 | -------------------------------------------------------------------------------- /lua/conf/nvim-lspconfig.lua: -------------------------------------------------------------------------------- 1 | -- https://github.com/neovim/nvim-lspconfig 2 | 3 | -- 诊断样式定制 4 | vim.diagnostic.config( 5 | { 6 | virtual_text = { 7 | prefix = "●", 8 | source = "always" 9 | }, 10 | float = { 11 | source = "always" 12 | }, 13 | update_in_insert = false 14 | } 15 | ) 16 | -------------------------------------------------------------------------------- /lua/conf/nvim-markdown-preview.lua: -------------------------------------------------------------------------------- 1 | -- https://github.com/davidgranstrom/nvim-markdown-preview 2 | 3 | -- WARN: nvim-markdown-preview 手动安装依赖 : pandoc 和 live-server 4 | -- 通过 apt 或 yay 安装 pandoc 通过 npm 全局安装 live-server 5 | -- yay -S pandoc 6 | -- sudo npm install -g live-server 7 | -- 后续使用 :MarkdownPreview 即可打开预览 8 | 9 | -- 主题:github solarized-light solarized-dark 10 | vim.g.nvim_markdown_preview_theme = "github" 11 | vim.g.nvim_markdown_preview_format = "markdown" 12 | -------------------------------------------------------------------------------- /lua/lsp/pyright.lua: -------------------------------------------------------------------------------- 1 | return { 2 | root_dir = function() 3 | return vim.fn.getcwd() 4 | end, 5 | -- 禁用 Pyright 的诊断信息(使用 pylint) 6 | handlers = { 7 | ---@diagnostic disable-next-line: unused-vararg 8 | ["textDocument/publishDiagnostics"] = function(...) 9 | end 10 | }, 11 | settings = { 12 | python = { 13 | analysis = { 14 | typeCheckingMode = "off" 15 | } 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /snippet/markdown.json: -------------------------------------------------------------------------------- 1 | { 2 | "code block": { 3 | "prefix": "code", 4 | "body": ["```$1\n```"], 5 | "description": "create code block" 6 | }, 7 | "< symbol": { 8 | "prefix": "<", 9 | "body": ["<"], 10 | "description": "<" 11 | }, 12 | "> symbol": { 13 | "prefix": ">", 14 | "body": [">"], 15 | "description": ">" 16 | }, 17 | "| symbol": { 18 | "prefix": "|", 19 | "body": ["|"], 20 | "description": "|" 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /lua/conf/vim-multiple-cursors.lua: -------------------------------------------------------------------------------- 1 | -- https://github.com/terryma/vim-multiple-cursors 2 | 3 | local plugin_key = vim.u.keymap.set.vim_multiple_cursors.plugin_set 4 | 5 | -- 关闭默认键位绑定 6 | vim.g.multi_cursor_use_default_mapping = 0 7 | 8 | vim.g.multi_cursor_start_word_key = plugin_key.start_word_key 9 | vim.g.multi_cursor_next_key = plugin_key.next_key 10 | vim.g.multi_cursor_prev_key = plugin_key.prev_key 11 | vim.g.multi_cursor_skip_key = plugin_key.skip_key 12 | vim.g.multi_cursor_quit_key = plugin_key.quit_key 13 | -------------------------------------------------------------------------------- /lua/dap/python.lua: -------------------------------------------------------------------------------- 1 | -- python3 -m pip install debugpy 2 | 3 | return { 4 | adapters = { 5 | type = "executable", 6 | command = "python3", 7 | args = {"-m", "debugpy.adapter"} 8 | }, 9 | configurations = { 10 | { 11 | type = "python", 12 | request = "launch", 13 | name = "Launch file", 14 | program = "${file}", 15 | pythonPath = function() 16 | return vim.u.platform_python_path 17 | end 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /lua/conf/neoformat.lua: -------------------------------------------------------------------------------- 1 | -- https://github.com/sbdchd/neoformat 2 | 3 | -- WARN: neoformat 手动安装各语言的代码格式化程序 4 | -- https://github.com/sbdchd/neoformat#supported-filetypes 5 | 6 | -- npm install -g lua-fmt 7 | -- npm install -g prettier 8 | -- npm install -g gofmt 9 | -- pip3 install autopep8 10 | -- pip3 install sqlformat 11 | 12 | -- 当没有找到格式化程序时,将按照如下方式自动格式化 13 | 14 | -- 1.自动对齐 15 | vim.g.neoformat_basic_format_align = 1 16 | -- 2.自动删除行尾空格 17 | vim.g.neoformat_basic_format_trim = 1 18 | -- 3.将制表符替换为空格 19 | vim.g.neoformat_basic_format_retab = 0 20 | 21 | -- 只提示错误消息 22 | vim.g.neoformat_only_msg_on_error = 1 23 | -------------------------------------------------------------------------------- /lua/conf/nvim-notify.lua: -------------------------------------------------------------------------------- 1 | -- https://github.com/rcarriga/nvim-notify 2 | 3 | local notify_opts = { 4 | -- 动画样式 5 | -- fade_in_slide_out 6 | -- fade 7 | -- slide 8 | -- static 9 | stages = "fade", 10 | -- 超时时间,默认 5s 11 | timeout = 2000 12 | } 13 | 14 | -- 如果是透明背景,则需要设置背景色 15 | if vim.u.background_transparency then 16 | notify_opts.background_colour = "#ffffff" 17 | end 18 | 19 | vim.notify = require("notify") 20 | 21 | vim.notify.setup(notify_opts) 22 | -- 使用案例: 23 | -- 信息、级别、标题 24 | -- 级别有:info、warn、error、debug、trace 25 | -- 示例: 26 | -- vim.notify("hello world", "info", {title = "info"}) 27 | -------------------------------------------------------------------------------- /lua/conf/lsp_signature.lua: -------------------------------------------------------------------------------- 1 | -- https://github.com/ray-x/lsp_signature.nvim 2 | 3 | local plugin_key = vim.u.keymap.set.lsp_signature.plugin_set 4 | 5 | require("lsp_signature").setup( 6 | { 7 | bind = true, 8 | -- 边框样式 9 | handler_opts = { 10 | -- double、rounded、single、shadow、none 11 | border = "rounded" 12 | }, 13 | -- 自动触发 14 | floating_window = false, 15 | -- 绑定按键 16 | toggle_key = plugin_key.toggle_key, 17 | -- 虚拟提示关闭 18 | hint_enable = false, 19 | -- 正在输入的参数将如何突出显示 20 | hi_parameter = "LspSignatureActiveParameter" 21 | } 22 | ) 23 | -------------------------------------------------------------------------------- /lua/conf/nvim-dap.lua: -------------------------------------------------------------------------------- 1 | -- https://github.com/mfussenegger/nvim-dap 2 | 3 | -- WARN: dap 手动下载调试器 4 | -- https://github.com/mfussenegger/nvim-dap/wiki/Debug-Adapter-installation 5 | 6 | local dap = require("dap") 7 | 8 | -- 设置断点样式 9 | vim.fn.sign_define("DapBreakpoint", {text = "●", texthl = "TodoFgFIX", linehl = "", numhl = ""}) 10 | 11 | -- 加载调试器配置 12 | local dap_config = { 13 | python = require("dap.python"), 14 | go = require("dap.go") 15 | } 16 | 17 | -- 应用调试器配置 18 | for dap_name, dap_options in pairs(dap_config) do 19 | dap.adapters[dap_name] = dap_options.adapters 20 | dap.configurations[dap_name] = dap_options.configurations 21 | end 22 | -------------------------------------------------------------------------------- /lua/conf/AutoSave.lua: -------------------------------------------------------------------------------- 1 | -- https://github.com/Pocco81/AutoSave.nvim 2 | 3 | require("autosave").setup( 4 | { 5 | enabled = true, 6 | -- 触发自动保存的事件 7 | events = {"InsertLeave", "TextChanged"}, 8 | -- 自动保存时的提示信息 9 | execution_message = "", 10 | conditions = { 11 | exists = true, 12 | filename_is_not = {}, 13 | -- 不自动保存的文件类型 14 | filetype_is_not = {"sql", "mysql", "plsql"}, 15 | modifiable = true 16 | }, 17 | write_all_buffers = true, 18 | on_off_commands = false, 19 | clean_command_line_interval = 0, 20 | debounce_delay = 135 21 | } 22 | ) 23 | -------------------------------------------------------------------------------- /lua/conf/nvim-dap-ui.lua: -------------------------------------------------------------------------------- 1 | -- https://github.com/rcarriga/nvim-dap-ui 2 | 3 | local dap = require("dap") 4 | local dapui = require("dapui") 5 | 6 | -- 初始化调试界面 7 | dapui.setup( 8 | { 9 | sidebar = { 10 | -- dapui 的窗口设置在右边 11 | position = "right" 12 | } 13 | } 14 | ) 15 | 16 | -- 如果开启或关闭调试,则自动打开或关闭调试界面 17 | dap.listeners.after.event_initialized["dapui_config"] = function() 18 | dapui.open() 19 | end 20 | dap.listeners.before.event_terminated["dapui_config"] = function() 21 | dapui.close() 22 | dap.repl.close() 23 | end 24 | dap.listeners.before.event_exited["dapui_config"] = function() 25 | dapui.close() 26 | dap.repl.close() 27 | end 28 | -------------------------------------------------------------------------------- /lua/conf/nvim-lint.lua: -------------------------------------------------------------------------------- 1 | -- https://github.com/mfussenegger/nvim-lint 2 | 3 | -- WARN: nvim-lint 手动下载诊断工具,确保工具在环境变量中能够被正确启用 4 | -- pip3 install pylint 5 | 6 | require("lint").linters_by_ft = { 7 | python = {"pylint"} 8 | -- javascript = {"eslint"}, 9 | -- typescript = {"eslint"}, 10 | -- go = {"golangcilint"} 11 | } 12 | 13 | -- 配置 pylint 14 | require("lint.linters.pylint").args = { 15 | "-f", 16 | "json", 17 | "--rcfile=" .. vim.g.nvim_lint_dir .. "/pylint.conf" 18 | } 19 | 20 | -- 何时触发检测: 21 | -- BufEnter : 载入 Buf 后 22 | -- BufWritePost: 写入文件后 23 | -- 由于搭配了 AutoSave,所以其他的事件就不用加了 24 | 25 | vim.cmd([[ 26 | au BufEnter * lua require('lint').try_lint() 27 | au BufWritePost * lua require('lint').try_lint() 28 | ]]) 29 | -------------------------------------------------------------------------------- /lua/conf/todo-comments.lua: -------------------------------------------------------------------------------- 1 | -- https://github.com/folke/todo-comments.nvim 2 | 3 | require("todo-comments").setup( 4 | { 5 | keywords = { 6 | -- alt : 别名 7 | FIX = { 8 | icon = " ", 9 | color = "#DC2626", 10 | alt = {"FIXME", "BUG", "FIXIT", "ISSUE", "!"} 11 | }, 12 | TODO = {icon = " ", color = "#10B981"}, 13 | HACK = {icon = " ", color = "#7C3AED"}, 14 | WARN = {icon = " ", color = "#FBBF24", alt = {"WARNING", "XXX"}}, 15 | PERF = {icon = " ", color = "#FC9868", alt = {"OPTIM", "PERFORMANCE", "OPTIMIZE"}}, 16 | NOTE = {icon = " ", color = "#2563EB", alt = {"INFO"}} 17 | } 18 | } 19 | ) 20 | -------------------------------------------------------------------------------- /lua/basic/settings.lua: -------------------------------------------------------------------------------- 1 | vim.o.encoding = "utf-8" 2 | vim.o.updatetime = 100 3 | vim.o.timeoutlen = 500 4 | vim.o.showcmd = true 5 | vim.o.hidden = true 6 | vim.o.termguicolors = true 7 | vim.o.cursorline = true 8 | vim.o.syntax = "enable" 9 | vim.o.number = true 10 | vim.o.relativenumber = true 11 | vim.o.scrolloff = 10 12 | vim.o.mouse = "a" 13 | vim.o.backup = false 14 | vim.o.swapfile = false 15 | vim.o.list = true 16 | vim.o.autoindent = true 17 | vim.o.filetype = "plugin" 18 | vim.o.hlsearch = true 19 | vim.o.showmatch = true 20 | vim.o.wildmenu = true 21 | vim.o.ignorecase = true 22 | vim.o.smartcase = true 23 | vim.o.spell = true 24 | vim.o.spelllang = "en_us,cjk" 25 | vim.o.foldenable = true 26 | vim.o.foldmethod = "indent" 27 | vim.o.foldlevel = 100 28 | -- vim.o.clipboard = "unnamedplus" 29 | -------------------------------------------------------------------------------- /snippet/python.json: -------------------------------------------------------------------------------- 1 | { 2 | "head file": { 3 | "prefix": "head", 4 | "body": [ 5 | "#!/usr/bin/env python3", 6 | "# -*- coding: utf-8 -*-", 7 | "# author: askfiy", 8 | "# date: $CURRENT_YEAR-$CURRENT_MONTH-$CURRENT_DATE" 9 | ], 10 | "description": "Python head file" 11 | }, 12 | "no param function decorator": { 13 | "prefix": "decorator", 14 | "body": [ 15 | "from functools import wraps\n\n", 16 | "def decorator(func):", 17 | " @wraps(func)", 18 | " def wrapper(*args, **kwargs):", 19 | " print('before')", 20 | " func(*args, **kwargs)", 21 | " print('after')", 22 | " return wrapper" 23 | ], 24 | "description": "Python decorator without parameters" 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /lua/conf/switch.lua: -------------------------------------------------------------------------------- 1 | -- https://github.com/AndrewRadev/switch.vim 2 | 3 | -- NOTE: switch 手动定义需要增加的反意单词 4 | local switch_words = { 5 | {"true", "false"}, 6 | {"on", "off"}, 7 | {"yes", "no"}, 8 | {"disable", "enable"}, 9 | {"+", "-"}, 10 | {">", "<"}, 11 | {"=", "!="} 12 | } 13 | 14 | -- 定义增加单词的容器 15 | local push_words = {} 16 | 17 | for _, value in ipairs(switch_words) do 18 | local w1, w2 = value[1], value[2] 19 | -- 全小写 20 | table.insert(push_words, value) 21 | -- 全大写 22 | table.insert(push_words, {string.upper(w1), string.upper(w2)}) 23 | -- 首字母大写,%l 代表小写字母,只取第一个 24 | w1, _ = string.gsub(w1, "^%l", string.upper) 25 | w2, _ = string.gsub(w2, "^%l", string.upper) 26 | table.insert(push_words, {w1, w2}) 27 | end 28 | 29 | -- 放入全局变量 30 | vim.g.switch_custom_definitions = push_words 31 | -------------------------------------------------------------------------------- /lua/conf/nvim-scrollbar.lua: -------------------------------------------------------------------------------- 1 | -- https://github.com/petertriho/nvim-scrollbar 2 | 3 | local colors = { 4 | color = "#292E42", 5 | Search = "#FC867", 6 | Error = "#FD6883", 7 | Warn = "#FFD886", 8 | Info = "A9DC76", 9 | Hint = "#78DCE8", 10 | Misc = "#AB9DF2" 11 | } 12 | 13 | require("scrollbar").setup( 14 | { 15 | handle = { 16 | -- 滚动条颜色 17 | color = colors.color 18 | }, 19 | marks = { 20 | -- 诊断颜色,需要 LSP 支持 21 | Search = {color = colors.Search}, 22 | Error = {color = colors.Error}, 23 | Warn = {color = colors.Warn}, 24 | Info = {color = colors.Info}, 25 | Hint = {color = colors.Hint}, 26 | Misc = {color = colors.Misc} 27 | } 28 | } 29 | ) 30 | 31 | require("scrollbar.handlers.search").setup() 32 | -------------------------------------------------------------------------------- /lua/lsp/sumneko_lua.lua: -------------------------------------------------------------------------------- 1 | local runtime_path = vim.split(package.path, ";") 2 | table.insert(runtime_path, "lua/?.lua") 3 | table.insert(runtime_path, "lua/?/init.lua") 4 | 5 | return { 6 | cmd = {"lua-language-server", "--locale=zh-CN"}, 7 | filetypes = {"lua"}, 8 | log_level = 2, 9 | root_dir = function() 10 | return vim.fn.getcwd() 11 | end, 12 | settings = { 13 | Lua = { 14 | runtime = { 15 | version = "LuaJIT", 16 | path = runtime_path 17 | }, 18 | diagnostics = { 19 | globals = {"vim"} 20 | }, 21 | workspace = { 22 | library = vim.api.nvim_get_runtime_file("", true) 23 | }, 24 | telemetry = { 25 | enable = false 26 | } 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /lua/conf/lspsaga.lua: -------------------------------------------------------------------------------- 1 | -- https://github.com/tami5/lspsaga.nvim 2 | 3 | local plugin_key = vim.u.keymap.set.lspsaga.plugin_set 4 | local signs = { 5 | Error = {" ", " "}, 6 | Warn = {" ", " "}, 7 | Hint = {" ", " "}, 8 | Info = {" ", " "} 9 | } 10 | 11 | require("lspsaga").setup( 12 | { 13 | -- round、single、double 14 | border_style = "round", 15 | error_sign = signs.Error[1], 16 | warn_sign = signs.Warn[1], 17 | hint_sign = signs.Hint[1], 18 | infor_sign = signs.Info[1], 19 | diagnostic_header_icon = " ", 20 | -- 正在写入的行提示 21 | code_action_icon = " ", 22 | code_action_prompt = { 23 | -- 显示写入行提示 24 | -- 如果为 true ,则写代码时会在左侧行号栏中显示你所定义的图标 25 | enable = false, 26 | sign = true, 27 | sign_priority = 40, 28 | virtual_text = true 29 | }, 30 | code_action_keys = plugin_key.code_action_keys, 31 | rename_action_keys = plugin_key.rename_action_keys 32 | } 33 | ) 34 | -------------------------------------------------------------------------------- /lua/conf/aerial.lua: -------------------------------------------------------------------------------- 1 | -- https://github.com/stevearc/aerial.nvim 2 | 3 | local plugin_key = vim.u.keymap.set.aerial.plugin_set 4 | require("aerial").setup( 5 | { 6 | min_width = 30, 7 | -- 目前 LSP 支持不是很好,所以用 treesitter 来代替解析工作 8 | -- backends = {"lsp", "treesitter", "markdown"} 9 | backends = {"treesitter", "markdown"}, 10 | -- false 是显示所有的图标 11 | filter_kind = false, 12 | nerd_font = "auto", 13 | update_events = "TextChanged,InsertLeave", 14 | on_attach = function(bufnr) 15 | vim.api.nvim_buf_set_keymap(bufnr, "n", plugin_key.aerial_toggle, "AerialToggle!", {}) 16 | vim.api.nvim_buf_set_keymap(bufnr, "n", plugin_key.aerial_prev, "AerialPrev", {}) 17 | vim.api.nvim_buf_set_keymap(bufnr, "n", plugin_key.aerial_next, "AerialNext", {}) 18 | vim.api.nvim_buf_set_keymap(bufnr, "n", plugin_key.aerial_prev_up, "AerialPrevUp", {}) 19 | vim.api.nvim_buf_set_keymap(bufnr, "n", plugin_key.aerial_next_up, "AerialNextUp", {}) 20 | end 21 | } 22 | ) 23 | -------------------------------------------------------------------------------- /lua/basic/config.lua: -------------------------------------------------------------------------------- 1 | --------- 用户设置 --------- 2 | vim.u = {} 3 | 4 | -- Python 解释器 5 | local platform_python = { 6 | MAC = "/usr/local/bin/python3", 7 | UNIX = "/usr/bin/python3", 8 | WINDOWS = "C:\\Python\\python.exe" 9 | } 10 | 11 | -- 平台信息 12 | vim.u.platform_info = vim.bo.fileformat:upper() 13 | -- 解释器路径 14 | vim.u.platform_python_path = platform_python[vim.u.platform_info] 15 | -- 是否开启透明背景 16 | vim.u.background_transparency = true 17 | 18 | --------- 插件设置 --------- 19 | 20 | -- 代码片段存储路径 21 | vim.g.vsnip_snippet_dir = vim.fn.stdpath("config") .. "/snippet" 22 | -- undotree 缓存存放路径 23 | vim.g.undotree_dir = vim.fn.stdpath("config") .. "/undodir" 24 | -- lint 配置文件路径 25 | vim.g.nvim_lint_dir = vim.fn.stdpath("config") .. "/lint" 26 | -- translate 代理服务器 27 | -- vim.g.translator_proxy_url = "socks5://127.0.0.1:7890" 28 | -- 数据库链接地址 29 | vim.g.dbs = { 30 | { 31 | name = "dev", 32 | url = "mysql://askfiy@192.168.0.120/db1" 33 | }, 34 | { 35 | name = "local", 36 | url = "mysql://root@localhost:3306/test" 37 | } 38 | } 39 | 40 | -- 自动切换输入法(Fcitx 框架) 41 | vim.g.FcitxToggleInput = function() 42 | local input_status = tonumber(vim.fn.system("fcitx-remote")) 43 | if input_status == 2 then 44 | vim.fn.system("fcitx-remote -c") 45 | end 46 | end 47 | 48 | vim.cmd("autocmd InsertLeave * call FcitxToggleInput()") 49 | -------------------------------------------------------------------------------- /lua/conf/nvim-treesitter.lua: -------------------------------------------------------------------------------- 1 | -- https://github.com/nvim-treesitter/nvim-treesitter 2 | -- https://github.com/p00f/nvim-ts-rainbow 3 | -- https://github.com/JoosepAlviste/nvim-ts-context-commentstring 4 | 5 | local plugin_key = vim.u.keymap.set.nvim_treesitter.plugin_set 6 | 7 | require("nvim-treesitter.configs").setup( 8 | { 9 | -- 安装的高亮支持来源 10 | ensure_installed = "maintained", 11 | -- 同步下载高亮支持 12 | sync_install = false, 13 | -- 高亮相关 14 | highlight = { 15 | -- 启用高亮支持 16 | enable = true, 17 | -- 使用 treesitter 高亮而不是 neovim 内置的高亮 18 | additional_vim_regex_highlighting = false 19 | }, 20 | -- 范围选择 21 | incremental_selection = { 22 | enable = true, 23 | keymaps = plugin_key.incremental_selection_keymaps 24 | }, 25 | -- 缩进 26 | indent = { 27 | enable = false 28 | }, 29 | -- 彩虹括号,由 nvim-ts-rainbow 插件提供 30 | rainbow = { 31 | enable = true, 32 | extended_mode = true 33 | -- colors = {}, -- table of hex strings 34 | -- termcolors = {} -- table of colour name strings 35 | }, 36 | -- 根据当前上下文定义文件类型,由 nvim-ts-context-commentstring 插件提供 37 | context_commentstring = { 38 | enable = true 39 | } 40 | } 41 | ) 42 | -------------------------------------------------------------------------------- /lua/conf/bufferline.lua: -------------------------------------------------------------------------------- 1 | -- https://github.com/akinsho/bufferline.nvim 2 | 3 | require("bufferline").setup( 4 | { 5 | options = { 6 | -- 为每个 buffer 都配置一个序数 7 | numbers = "ordinal", 8 | -- 使用内置 LSP 进行诊断 9 | diagnostics = "nvim_lsp", 10 | -- 不建议更改图标 11 | indicator_icon = "▎", 12 | buffer_close_icon = "", 13 | modified_icon = "●", 14 | close_icon = "", 15 | left_trunc_marker = "", 16 | right_trunc_marker = "", 17 | -- 分割符样式:"slant" | "thick" | "thin" 18 | separator_style = "thin", 19 | -- 左侧让出 nvim-tree 的位置 20 | offsets = { 21 | { 22 | filetype = "NvimTree", 23 | text = "File Explorer", 24 | highlight = "Directory", 25 | text_align = "left" 26 | } 27 | }, 28 | -- 显示 LSP 报错图标 29 | ---@diagnostic disable-next-line: unused-local 30 | diagnostics_indicator = function(count, level, diagnostics_dict, context) 31 | local s = " " 32 | for e, n in pairs(diagnostics_dict) do 33 | local sym = e == "error" and " " or (e == "warning" and " " or "") 34 | s = s .. n .. sym 35 | end 36 | return s 37 | end 38 | } 39 | } 40 | ) 41 | -------------------------------------------------------------------------------- /lua/conf/nvim-tree.lua: -------------------------------------------------------------------------------- 1 | -- https://github.com/kyazdani42/nvim-tree.lua 2 | 3 | require("nvim-tree").setup( 4 | { 5 | auto_close = true, 6 | view = { 7 | width = 30, 8 | height = 30, 9 | hide_root_folder = false, 10 | auto_resize = true 11 | }, 12 | diagnostics = { 13 | -- 是否启用文件诊断信息 14 | enable = false, 15 | icons = { 16 | hint = "", 17 | info = "", 18 | warning = "", 19 | error = "" 20 | } 21 | }, 22 | git = { 23 | -- 是否启用 git 信息 24 | enable = false, 25 | ignore = true, 26 | timeout = 500 27 | } 28 | } 29 | ) 30 | 31 | vim.g.nvim_tree_icons = { 32 | default = " ", 33 | symlink = " ", 34 | git = { 35 | unstaged = "", 36 | staged = "✓", 37 | unmerged = "", 38 | renamed = "➜", 39 | untracked = "", 40 | deleted = "", 41 | ignored = "" 42 | }, 43 | folder = { 44 | -- arrow_open = "╰─▸", 45 | -- arrow_closed = "├─▸", 46 | arrow_open = "", 47 | arrow_closed = "", 48 | default = "", 49 | open = "", 50 | empty = "", 51 | empty_open = "", 52 | symlink = "", 53 | symlink_open = "" 54 | } 55 | } 56 | 57 | -- 目录后加上反斜杠 / 58 | vim.g.nvim_tree_add_trailing = 1 59 | -------------------------------------------------------------------------------- /docs/chinese.md: -------------------------------------------------------------------------------- 1 | # README 2 | 3 | ## 前言 4 | 5 | 一份自用的 neovim 配置: 6 | 7 | ![](https://images-1302522496.cos.ap-nanjing.myqcloud.com/img/202203041747390.png) 8 | 9 | 启动时间: 10 | 11 | ![](https://images-1302522496.cos.ap-nanjing.myqcloud.com/img/202203041749894.png) 12 | 13 | ## 依赖项目 14 | 15 | 基本的依赖: 16 | 17 | - [neovim > 0.5](https://link.zhihu.com/?target=https%3A//github.com/neovim/neovim/releases/latest) 18 | - [gcc](https://gcc.gnu.org/) 19 | - [nerd font](https://link.zhihu.com/?target=https%3A//www.nerdfonts.com/) 20 | - [fd](https://link.zhihu.com/?target=https%3A//github.com/sharkdp/fd) 21 | - [ripgrep](https://github.com/BurntSushi/ripgrep) 22 | 23 | 其它的依赖 24 | 25 | - tar curl git gzip wget 26 | - node npm 27 | - python3 pip3 pySocks 28 | 29 | ## 支持的语言 30 | 31 | - Python 32 | - Golang 33 | - Node 34 | - HTML 35 | - CSS 36 | - JavaScript 37 | - TypeScript 38 | - Vue 39 | - Json 40 | - SQL 41 | - Markdown 42 | 43 | ## 目录介绍 44 | 45 | 目录结构: 46 | 47 | ``` 48 | . 49 | ├── ftplugin 50 | ├── init.lua 51 | ├── lint 52 | ├── lua 53 | │ ├── basic 54 | │ │ ├── config.lua 55 | │ │ ├── keybinds.lua 56 | │ │ ├── plugins.lua 57 | │ │ └── settings.lua 58 | │ ├── conf 59 | │ ├── dap 60 | │ └── lsp 61 | └── snippet 62 | ``` 63 | 64 | 目录说明: 65 | 66 | - ftplugin:存放不同文件类型的缩进规则 67 | - lint :存放各种语言的代码检查配置文件 68 | - basic :存放基本配置项文件 69 | - conf :存放插件相关配置文件 70 | - dap :存放 DAP 相关配置文件 71 | - lsp :存放 LSP 相关配置文件 72 | - snippet :存放代码片段相关文件 73 | 74 | 文件说明: 75 | 76 | - init.lua :配置入口文件 77 | - config.lua :存放用户自定义配置的文件 78 | - keybinds.lua:存放键位绑定的文件 79 | - plugins.lua :存放依赖插件的文件 80 | - settings.lua:存放 neovim 基本配置项的文件 81 | -------------------------------------------------------------------------------- /lua/conf/Comment.lua: -------------------------------------------------------------------------------- 1 | -- https://github.com/numToStr/Comment.nvim 2 | -- https://github.com/JoosepAlviste/nvim-ts-context-commentstring 3 | 4 | local comment_string = require("ts_context_commentstring") 5 | 6 | local plugin_key = vim.u.keymap.set.comment.plugin_set 7 | 8 | require("Comment").setup( 9 | { 10 | toggler = plugin_key.toggler, 11 | opleader = plugin_key.opleader, 12 | extra = plugin_key.extra, 13 | -- 根据当前光标所在上下文判断不同类别的注释 14 | -- 由 nvim-ts-context-commentstring 提供 15 | pre_hook = function(ctx) 16 | -- Only calculate commentstring for tsx filetypes 17 | if vim.bo.filetype == "typescriptreact" then 18 | local U = require("Comment.utils") 19 | -- Detemine whether to use linewise or blockwise commentstring 20 | local type = ctx.ctype == U.ctype.line and "__default" or "__multiline" 21 | -- Determine the location where to calculate commentstring from 22 | local location = nil 23 | if ctx.ctype == U.ctype.block then 24 | location = comment_string.utils.get_cursor_location() 25 | elseif ctx.cmotion == U.cmotion.v or ctx.cmotion == U.cmotion.V then 26 | location = comment_string.utils.get_visual_start_location() 27 | end 28 | return comment_string.calculate_commentstring( 29 | { 30 | key = type, 31 | location = location 32 | } 33 | ) 34 | end 35 | end 36 | } 37 | ) 38 | -------------------------------------------------------------------------------- /docs/english.md: -------------------------------------------------------------------------------- 1 | # README 2 | 3 | ## Preface 4 | 5 | A self-use neovim configuration: 6 | 7 | ![](https://images-1302522496.cos.ap-nanjing.myqcloud.com/img/202203041747390.png) 8 | 9 | Start Time: 10 | 11 | ![](https://images-1302522496.cos.ap-nanjing.myqcloud.com/img/202203041749894.png) 12 | 13 | ## Dependent projects 14 | 15 | Basic dependencies: 16 | 17 | - [neovim > 0.5](https://link.zhihu.com/?target=https%3A//github.com/neovim/neovim/releases/latest) 18 | - [gcc](https://gcc.gnu.org/) 19 | - [nerd font](https://link.zhihu.com/?target=https%3A//www.nerdfonts.com/) 20 | - [fd](https://link.zhihu.com/?target=https%3A//github.com/sharkdp/fd) 21 | - [ripgrep](https://github.com/BurntSushi/ripgrep) 22 | 23 | other dependencies 24 | 25 | - tar curl git gzip wget 26 | - node npm 27 | - python3 pip3 pySocks 28 | 29 | ## Supported languages 30 | 31 | - Python 32 | - Golang 33 | - Node 34 | - HTML 35 | - CSS 36 | - JavaScript 37 | - TypeScript 38 | - Vue 39 | - Json 40 | - SQL 41 | - Markdown 42 | 43 | ## Directory introduction 44 | 45 | Directory Structure: 46 | 47 | ``` 48 | . 49 | ├── ftplugin 50 | ├── init.lua 51 | ├── lint 52 | ├── lua 53 | │ ├── basic 54 | │ │ ├── config.lua 55 | │ │ ├── keybinds.lua 56 | │ │ ├── plugins.lua 57 | │ │ └── settings.lua 58 | │ ├── conf 59 | │ ├── dap 60 | │ └── lsp 61 | └── snippet 62 | ``` 63 | 64 | Directory Description: 65 | 66 | - ftplugin:Indentation rules for storing different file types 67 | - lint :Stores various code inspection configuration files for languages 68 | - basic:Store basic configuration item files 69 | - conf :Store plugin related configuration files 70 | - dap :Store DAP related configuration files 71 | - lsp :Store LSP related configuration files 72 | - snippet :Store code snippet related files 73 | 74 | file description 75 | 76 | - init.lua : Configuration entry file 77 | - config.lua : The file that stores the user-defined configuration 78 | - keybinds.lua: The file that stores the key bindings 79 | - plugins.lua : Store files that depend on plugins 80 | - settings.lua: The file that stores the basic configuration items of neovim 81 | -------------------------------------------------------------------------------- /snippet/html.json: -------------------------------------------------------------------------------- 1 | { 2 | "jQuery import": { 3 | "prefix": "$", 4 | "body": [ 5 | "" 6 | ], 7 | "description": "快速引入jQuery" 8 | }, 9 | "bootstrap import": { 10 | "prefix": "bootstrap", 11 | "body": [ 12 | "", 13 | "", 14 | "" 15 | ], 16 | "description": "快速引入bootstrap前端UI库" 17 | }, 18 | "vue3": { 19 | "prefix": "vue3", 20 | "body": [ 21 | "" 22 | ], 23 | "description": "快速引入vue3.js" 24 | }, 25 | "vue2": { 26 | "prefix": "vue2", 27 | "body": [ 28 | "" 29 | ], 30 | "description": "快速引入vue2.js" 31 | }, 32 | "axios": { 33 | "prefix": "axios", 34 | "body": [ 35 | "" 36 | ], 37 | "description": "快速引入axios" 38 | }, 39 | "aliyunfonticon": { 40 | "prefix": "aliyunfonticon", 41 | "body": [ 42 | "" 43 | ], 44 | "description": "快速引入阿里云在线图标库" 45 | }, 46 | "layui": { 47 | "prefix": "layui", 48 | "body": [ 49 | "", 50 | "" 51 | ], 52 | "description": "layui前端UI库" 53 | }, 54 | "demo": { 55 | "prefix": "demo", 56 | "body": [ 57 | "", 60 | "", 61 | "", 62 | "", 63 | "", 64 | "", 65 | "", 66 | "" 71 | ], 72 | "description": "demo" 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /lua/conf/catppuccin.lua: -------------------------------------------------------------------------------- 1 | -- https://github.com/catppuccin/nvim 2 | 3 | require("catppuccin").setup( 4 | { 5 | -- 透明背景 6 | transparent_background = vim.u.background_transparency, 7 | -- 使用终端背景色 8 | term_color = false, 9 | -- 代码样式 10 | styles = { 11 | comments = "italic", 12 | functions = "NONE", 13 | keywords = "NONE", 14 | strings = "NONE", 15 | variables = "NONE" 16 | }, 17 | -- 为不同的插件统一样式风格 18 | integrations = { 19 | cmp = true, 20 | gitsigns = true, 21 | telescope = true, 22 | which_key = true, 23 | bufferline = true, 24 | markdown = true, 25 | ts_rainbow = true, 26 | hop = true, 27 | notify = true, 28 | indent_blankline = { 29 | enabled = true, 30 | colored_indent_levels = false 31 | }, 32 | nvimtree = { 33 | enabled = true, 34 | show_root = false, 35 | -- 透明背景 36 | transparent_panel = vim.u.background_transparency 37 | }, 38 | native_lsp = { 39 | enabled = true, 40 | virtual_text = { 41 | errors = "italic", 42 | hints = "italic", 43 | warnings = "italic", 44 | information = "italic" 45 | }, 46 | underlines = { 47 | errors = "underline", 48 | hints = "underline", 49 | warnings = "underline", 50 | information = "underline" 51 | } 52 | }, 53 | -- 手动设置 54 | lsp_saga = false 55 | } 56 | } 57 | ) 58 | 59 | -- 应用主题 60 | vim.cmd([[colorscheme catppuccin]]) 61 | 62 | -- 自定义高亮组 63 | vim.cmd([[ 64 | highlight Lspsaga guifg=#96CDF8 65 | ]]) 66 | 67 | -- 高亮组风格统一 68 | vim.cmd( 69 | [[ 70 | " 重命名边框 71 | highlight link LspSagaRenameBorder Lspsaga 72 | " 悬浮文档边框 73 | highlight link LspSagaHoverBorder Lspsaga 74 | " 悬浮文档分割线 75 | highlight link LspSagaDocTruncateLine Lspsaga 76 | " 代码诊断边框 77 | highlight link LspSagaDiagnosticBorder Lspsaga 78 | " 代码诊断分割线 79 | highlight link LspSagaDiagnosticTruncateLine Lspsaga 80 | ]] 81 | ) 82 | -------------------------------------------------------------------------------- /lua/dap/go.lua: -------------------------------------------------------------------------------- 1 | -- pacman -S delve 2 | -- go install github.com/go-delve/delve/cmd/dlv@latest 3 | 4 | -- gopkgs 5 | -- go-outline 6 | -- gotests 7 | -- gomodifytags 8 | -- impl 9 | -- goplay 10 | -- dlv 11 | -- staticcheck 12 | -- gopls 13 | 14 | return { 15 | adapters = function(callback, _) -- _ = config 16 | local stdout = vim.loop.new_pipe(false) 17 | local handle 18 | local pid_or_err 19 | local port = 38697 20 | local opts = { 21 | stdio = {nil, stdout}, 22 | args = {"dap", "-l", "127.0.0.1:" .. port}, 23 | detached = true 24 | } 25 | handle, pid_or_err = 26 | vim.loop.spawn( 27 | "dlv", 28 | opts, 29 | function(code) 30 | stdout:close() 31 | handle:close() 32 | if code ~= 0 then 33 | print("dlv exited with code", code) 34 | end 35 | end 36 | ) 37 | assert(handle, "Error running dlv: " .. tostring(pid_or_err)) 38 | stdout:read_start( 39 | function(err, chunk) 40 | assert(not err, err) 41 | if chunk then 42 | vim.schedule( 43 | function() 44 | require("dap.repl").append(chunk) 45 | end 46 | ) 47 | end 48 | end 49 | ) 50 | -- Wait for delve to start 51 | vim.defer_fn( 52 | function() 53 | callback({type = "server", host = "127.0.0.1", port = port}) 54 | end, 55 | 100 56 | ) 57 | end, 58 | configurations = { 59 | { 60 | type = "go", 61 | name = "Debug", 62 | request = "launch", 63 | program = "${file}" 64 | }, 65 | { 66 | type = "go", 67 | name = "Debug test", -- configuration for debugging test files 68 | request = "launch", 69 | mode = "test", 70 | program = "${file}" 71 | }, 72 | -- works with go.mod packages and sub packages 73 | { 74 | type = "go", 75 | name = "Debug test (go.mod)", 76 | request = "launch", 77 | mode = "test", 78 | program = "./${relativeFileDirname}" 79 | } 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /lua/conf/toggleterm.lua: -------------------------------------------------------------------------------- 1 | -- https://github.com/akinsho/toggleterm.nvim 2 | 3 | local Toggleterm = require("toggleterm") 4 | local plugin_key = vim.u.keymap.set.toggleterm.plugin_set 5 | 6 | Toggleterm.setup( 7 | { 8 | -- 开启的终端默认进入插入模式 9 | start_in_insert = false, 10 | -- 设置终端打开的大小 11 | size = 6, 12 | -- 打开普通终端时,关闭拼写检查 13 | on_open = function() 14 | vim.cmd("setlocal nospell") 15 | end 16 | } 17 | ) 18 | 19 | -- 新建终端 20 | local Terminal = require("toggleterm.terminal").Terminal 21 | 22 | local function inInsert() 23 | -- 进入插入模式 24 | vim.cmd("startinsert") 25 | -- 删除 Esc 的映射 26 | vim.api.nvim_del_keymap("t", plugin_key.delete_all_exit) 27 | end 28 | 29 | -- 新建浮动终端 30 | local floatTerm = 31 | Terminal:new( 32 | { 33 | hidden = true, 34 | direction = "float", 35 | float_opts = { 36 | border = "double" 37 | }, 38 | on_open = function(term) 39 | inInsert() 40 | -- 浮动终端中 Esc 是退出 41 | vim.api.nvim_buf_set_keymap( 42 | term.bufnr, 43 | "t", 44 | plugin_key.float.float_exit, 45 | ":close", 46 | vim.u.keymap.opt.ns_opt 47 | ) 48 | end, 49 | on_close = function() 50 | -- 重新映射 Esc 51 | vim.api.nvim_set_keymap("t", plugin_key.float.again_exit, "", vim.u.keymap.opt.ns_opt) 52 | end 53 | } 54 | ) 55 | 56 | -- 新建 lazygit 终端 57 | local lazyGit = 58 | Terminal:new( 59 | { 60 | cmd = "lazygit", 61 | hidden = true, 62 | direction = "float", 63 | float_opts = { 64 | border = "double" 65 | }, 66 | on_open = function(term) 67 | inInsert() 68 | -- lazygit 中 q 是退出 69 | vim.api.nvim_buf_set_keymap( 70 | term.bufnr, 71 | "i", 72 | plugin_key.lazygit.lazygit_exit, 73 | "close", 74 | vim.u.keymap.opt.ns_opt 75 | ) 76 | end, 77 | on_close = function() 78 | -- 重新映射 Esc 79 | vim.api.nvim_set_keymap("t", plugin_key.lazygit.again_exit, "", vim.u.keymap.opt.ns_opt) 80 | end 81 | } 82 | ) 83 | 84 | -- 定义新的方法 85 | Toggleterm.float_toggle = function() 86 | floatTerm:toggle() 87 | end 88 | 89 | Toggleterm.lazygit_toggle = function() 90 | lazyGit:toggle() 91 | end 92 | -------------------------------------------------------------------------------- /lua/conf/lualine.lua: -------------------------------------------------------------------------------- 1 | -- https://github.com/nvim-lualine/lualine.nvim 2 | -- https://github.com/SmiteshP/nvim-gps 3 | 4 | local gps = require("nvim-gps") 5 | 6 | local filetype_table = { 7 | "NvimTree", 8 | "aerial" 9 | } 10 | 11 | local function disable_built_component() 12 | local filetype = vim.bo.filetype 13 | for _, ft in ipairs(filetype_table) do 14 | if filetype == ft then 15 | return false 16 | end 17 | end 18 | return true 19 | end 20 | 21 | local function enable_built_component() 22 | local filetype = vim.bo.filetype 23 | for _, ft in ipairs(filetype_table) do 24 | if filetype == ft then 25 | return true 26 | end 27 | end 28 | return false 29 | end 30 | 31 | gps.setup() 32 | require("lualine").setup( 33 | { 34 | options = { 35 | icons_enabled = true, 36 | theme = "auto", 37 | component_separators = {left = "", right = ""}, 38 | section_separators = {left = "", right = ""}, 39 | disabled_filetypes = {}, 40 | always_divide_middle = true 41 | }, 42 | sections = { 43 | lualine_a = { 44 | {"mode", cond = disable_built_component}, 45 | {"filetype", cond = enable_built_component} 46 | }, 47 | lualine_b = { 48 | {"branch", cond = disable_built_component}, 49 | {"diff", cond = disable_built_component}, 50 | {"diagnostics", cond = disable_built_component} 51 | }, 52 | lualine_c = { 53 | {"filename", cond = disable_built_component}, 54 | {gps.get_location, cond = gps.is_available} 55 | }, 56 | lualine_x = { 57 | {"encoding", cond = disable_built_component}, 58 | {"fileformat", cond = disable_built_component}, 59 | {"filetype", cond = disable_built_component} 60 | }, 61 | lualine_y = { 62 | {"progress", cond = disable_built_component} 63 | }, 64 | lualine_z = { 65 | {"location", cond = disable_built_component} 66 | } 67 | }, 68 | inactive_sections = { 69 | lualine_a = {}, 70 | lualine_b = {}, 71 | lualine_c = {"filename"}, 72 | lualine_x = {"location"}, 73 | lualine_y = {}, 74 | lualine_z = {} 75 | }, 76 | tabline = {} 77 | } 78 | ) 79 | -------------------------------------------------------------------------------- /resource/alacritty.yml: -------------------------------------------------------------------------------- 1 | # 实时预览配置项 2 | live_config_reload: true 3 | 4 | # 环境变量 5 | 6 | env: 7 | TERM: alacritty 8 | 9 | # 窗口设置 10 | window: 11 | # 窗口标题 12 | title: Alacritty 13 | 14 | # 是否允许终端应用更改窗口标题 15 | dynamic_title: true 16 | 17 | # 窗口大小 18 | dimensions: 19 | columns: 100 20 | lines: 30 21 | 22 | # 窗口内边距 23 | padding: 24 | x: 0 25 | y: 0 26 | 27 | # 将终端内容平均分配给 padding 28 | dynamic_padding: true 29 | 30 | # 窗口位置(根据屏幕像素来调节) 31 | # 若想水平居中,就先测量出窗体的宽度 32 | # 然后 桌面宽度 /2 - 窗体宽度 / 2 33 | # 垂直居中同理 34 | # 下面是 2560 * 1080 的设置值 35 | position: 36 | x: 730 37 | y: 165 38 | 39 | # 窗口标题栏和边框是否显示(full 或 None) 40 | decorations: full 41 | 42 | # 窗口透明度 43 | opacity: 0.6 44 | 45 | # 滚动设置 46 | scrolling: 47 | # 回滚缓冲区最大保存行数 48 | history: 10000 49 | 50 | # 一次回滚几行 51 | multiplier: 3 52 | 53 | # 字体设置 54 | font: 55 | # 常规字体 56 | normal: 57 | # family: "FiraCode Nerd Font Mono" 58 | family: "agave Nerd Font Mono" 59 | style: Regular 60 | 61 | # 字大小 62 | size: 14.0 63 | 64 | # 字符间距 65 | offset: 66 | x: 0 67 | y: 2 68 | 69 | # 细体字渲染(仅 mac 生效) 70 | use_thin_strokes: true 71 | 72 | # 高亮渲染粗体字 73 | draw_bold_text_with_bright_colors: true 74 | 75 | # 选择相关 76 | selection: 77 | # 语义单词分割符号 78 | semantic_escape_chars: ",│`|:\"' ()[]{}<>\t@=" 79 | 80 | # 选中文本是否复制到系统剪切板 81 | save_to_clipboard: true 82 | 83 | # 光标相关 84 | cursor: 85 | # 光标样式 86 | style: 87 | # 光标形状 88 | shape: Block 89 | 90 | # 是否闪烁 91 | blinking: Always 92 | 93 | # 闪烁间隔 94 | blink_interval: 200 95 | 96 | # 窗口未聚焦时光标变为空心 97 | unfocused_hollow: true 98 | 99 | # 鼠标配置 100 | mouse: 101 | # 打字时隐藏鼠标 102 | hide_when_typing: true 103 | 104 | # 主题设置 105 | # Catppuccin! 106 | colors: 107 | # Default colors 108 | primary: 109 | background: "0x1E1D2F" 110 | foreground: "0xD9E0EE" 111 | 112 | # Colors the cursor will use if `custom_cursor_colors` is true 113 | cursor: 114 | text: "0x1E1D2F" 115 | cursor: "0xF5E0DC" 116 | 117 | # Normal colors 118 | normal: 119 | black: "0x6E6C7E" 120 | red: "0xF28FAD" 121 | green: "0xABE9B3" 122 | yellow: "0xFAE3B0" 123 | blue: "0x96CDFB" 124 | magenta: "0xF5C2E7" 125 | cyan: "0x89DCEB" 126 | white: "0xD9E0EE" 127 | 128 | # Bright colors 129 | bright: 130 | black: "0x988BA2" 131 | red: "0xF28FAD" 132 | green: "0xABE9B3" 133 | yellow: "0xFAE3B0" 134 | blue: "0x96CDFB" 135 | magenta: "0xF5C2E7" 136 | cyan: "0x89DCEB" 137 | white: "0xD9E0EE" 138 | 139 | indexed_colors: 140 | - { index: 16, color: "0xF8BD96" } 141 | - { index: 17, color: "0xF5E0DC" } 142 | 143 | # 键绑定 144 | key_bindings: 145 | # 复制 146 | - { key: C, mods: Control|Shift, action: Copy } 147 | # 粘贴 148 | - { key: V, mods: Control|Shift, action: Paste } 149 | # 新终端 150 | - { key: T, mods: Control|Alt, action: SpawnNewInstance } 151 | # 最小化 152 | - { key: M, mods: Control|Alt, action: Minimize } 153 | -------------------------------------------------------------------------------- /lua/conf/nvim-cmp.lua: -------------------------------------------------------------------------------- 1 | -- https://github.com/hrsh7th/nvim-cmp 2 | -- https://github.com/hrsh7th/vim-vsnip 3 | -- https://github.com/hrsh7th/cmp-vsnip 4 | -- https://github.com/hrsh7th/cmp-nvim-lsp 5 | -- https://github.com/hrsh7th/cmp-path 6 | -- https://github.com/hrsh7th/cmp-buffer 7 | -- https://github.com/hrsh7th/cmp-cmdline 8 | -- https://github.com/f3fora/cmp-spell 9 | -- https://github.com/rafamadriz/friendly-snippets 10 | -- https://github.com/tzachar/cmp-tabnine 11 | -- https://github.com/kristijanhusak/vim-dadbod-completion 12 | 13 | -- FIX: tabline 在某些计算机上有 1 个 BUG 14 | -- 当出现: 15 | -- TabNine is not executable 16 | -- 需手动执行(提前安装 curl 命令): 17 | -- ~/.local/share/nvim/site/pack/packer/opt/cmp-tabnine/install.sh 18 | 19 | local lspkind = require("lspkind") 20 | local cmp = require("cmp") 21 | local plugin_key = vim.u.keymap.set.nvim_cmp.plugin_set 22 | 23 | cmp.setup( 24 | ---@diagnostic disable-next-line: redundant-parameter 25 | { 26 | -- 指定补全引擎 27 | snippet = { 28 | expand = function(args) 29 | -- 使用 vsnip 引擎 30 | vim.fn["vsnip#anonymous"](args.body) 31 | end 32 | }, 33 | -- 指定补全源 34 | sources = cmp.config.sources( 35 | { 36 | {name = "vsnip"}, 37 | {name = "nvim_lsp"}, 38 | {name = "path"}, 39 | {name = "buffer"}, 40 | {name = "cmdline"}, 41 | {name = "spell"}, 42 | {name = "cmp_tabnine"}, 43 | {name = "vim-dadbod-completion"} 44 | } 45 | ), 46 | -- 格式化补全菜单 47 | formatting = { 48 | format = lspkind.cmp_format( 49 | { 50 | with_text = true, 51 | maxwidth = 50, 52 | before = function(entry, vim_item) 53 | vim_item.menu = "[" .. string.upper(entry.source.name) .. "]" 54 | return vim_item 55 | end 56 | } 57 | ) 58 | }, 59 | -- 绑定补全相关的按键 60 | mapping = { 61 | -- [""] = cmp.mapping.select_prev_item({behavior = cmp.SelectBehavior}), 62 | [plugin_key.select_prev_item] = cmp.mapping.select_prev_item(), 63 | -- [""] = cmp.mapping.select_next_item({behavior = cmp.SelectBehavior}), 64 | [plugin_key.select_next_item] = cmp.mapping.select_next_item(), 65 | [plugin_key.confirm_current] = cmp.mapping.confirm(), 66 | [plugin_key.toggle_complete] = cmp.mapping( 67 | { 68 | i = function() 69 | if cmp.visible() then 70 | cmp.abort() 71 | else 72 | cmp.complete() 73 | end 74 | end, 75 | c = function() 76 | if cmp.visible() then 77 | cmp.close() 78 | else 79 | cmp.complete() 80 | end 81 | end 82 | } 83 | ), 84 | [plugin_key.current_or_next] = cmp.mapping( 85 | function(fallback) 86 | if cmp.visible() then 87 | local entry = cmp.get_selected_entry() 88 | if not entry then 89 | cmp.select_next_item({behavior = cmp.SelectBehavior.Select}) 90 | end 91 | cmp.confirm() 92 | else 93 | fallback() 94 | end 95 | end, 96 | {"i", "s", "c"} 97 | ) 98 | } 99 | } 100 | ) 101 | 102 | cmp.setup.cmdline( 103 | "/", 104 | { 105 | sources = { 106 | {name = "buffer"} 107 | } 108 | } 109 | ) 110 | 111 | cmp.setup.cmdline( 112 | ":", 113 | { 114 | sources = cmp.config.sources( 115 | { 116 | {name = "path"} 117 | }, 118 | { 119 | {name = "cmdline"} 120 | } 121 | ) 122 | } 123 | ) 124 | -------------------------------------------------------------------------------- /lua/conf/nvim-lsp-installer.lua: -------------------------------------------------------------------------------- 1 | -- https://github.com/williamboman/nvim-lsp-installer 2 | 3 | local plugin_key = vim.u.keymap.set.nvim_lsp_installer.plugin_set 4 | 5 | local lsp_installer_servers = require("nvim-lsp-installer.servers") 6 | 7 | -- 使用 cmp_nvim_lsp 代替内置 omnifunc,获得更强的补全体验 8 | local capabilities = vim.lsp.protocol.make_client_capabilities() 9 | capabilities = require("cmp_nvim_lsp").update_capabilities(capabilities) 10 | 11 | -- WARN: lsp install 手动书写 LSP 配置文件 12 | -- 名称:https://github.com/williamboman/nvim-lsp-installer#available-lsps 13 | -- 配置:https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md 14 | -- 另外注意安装的 nodejs 和 npm 的版本要新,太久的版本会导致 lsp 无法正常工作 15 | 16 | local servers = { 17 | sumneko_lua = require("lsp.sumneko_lua"), 18 | pyright = require("lsp.pyright"), 19 | tsserver = require("lsp.tsserver"), 20 | html = require("lsp.html"), 21 | cssls = require("lsp.cssls"), 22 | gopls = require("lsp.gopls"), 23 | jsonls = require("lsp.jsonls"), 24 | zeta_note = require("lsp.zeta_note"), 25 | vuels = require("lsp.vuels") 26 | } 27 | 28 | local function attach(client, bufnr) 29 | require("aerial").on_attach(client, bufnr) 30 | vim.api.nvim_buf_set_keymap( 31 | bufnr, 32 | "n", 33 | plugin_key.lsp_definitions, 34 | "Telescope lsp_definitions theme=dropdown", 35 | vim.u.keymap.opt.ns_opt 36 | ) 37 | vim.api.nvim_buf_set_keymap( 38 | bufnr, 39 | "n", 40 | plugin_key.lsp_references, 41 | "Telescope lsp_references theme=dropdown", 42 | vim.u.keymap.opt.ns_opt 43 | ) 44 | vim.api.nvim_buf_set_keymap( 45 | bufnr, 46 | "n", 47 | plugin_key.diagnostics, 48 | "Telescope diagnostics theme=dropdown", 49 | vim.u.keymap.opt.ns_opt 50 | ) 51 | vim.api.nvim_buf_set_keymap( 52 | bufnr, 53 | "n", 54 | plugin_key.lsp_code_actions, 55 | "Telescope lsp_code_actions theme=dropdown", 56 | vim.u.keymap.opt.ns_opt 57 | ) 58 | vim.api.nvim_buf_set_keymap(bufnr, "n", plugin_key.rename, "Lspsaga rename", vim.u.keymap.opt.ns_opt) 59 | vim.api.nvim_buf_set_keymap(bufnr, "n", plugin_key.hover_doc, "Lspsaga hover_doc", vim.u.keymap.opt.ns_opt) 60 | vim.api.nvim_buf_set_keymap( 61 | bufnr, 62 | "n", 63 | plugin_key.diagnostic_jump_prev, 64 | "Lspsaga diagnostic_jump_prev", 65 | vim.u.keymap.opt.ns_opt 66 | ) 67 | vim.api.nvim_buf_set_keymap( 68 | bufnr, 69 | "n", 70 | plugin_key.diagnostic_jump_next, 71 | "Lspsaga diagnostic_jump_next", 72 | vim.u.keymap.opt.ns_opt 73 | ) 74 | vim.api.nvim_buf_set_keymap( 75 | bufnr, 76 | "n", 77 | plugin_key.smart_scroll_with_saga_prev, 78 | "lua require('lspsaga.action').smart_scroll_with_saga(-1)", 79 | vim.u.keymap.opt.ns_opt 80 | ) 81 | vim.api.nvim_buf_set_keymap( 82 | bufnr, 83 | "n", 84 | plugin_key.smart_scroll_with_saga_next, 85 | "lua require('lspsaga.action').smart_scroll_with_saga(1)", 86 | vim.u.keymap.opt.ns_opt 87 | ) 88 | end 89 | 90 | -- 自动安装或启动 LanguageServers 91 | for server_name, server_options in pairs(servers) do 92 | local server_available, server = lsp_installer_servers.get_server(server_name) 93 | -- 判断服务是否可用 94 | if server_available then 95 | -- 判断服务是否准备就绪,若就绪则启动服务 96 | server:on_ready( 97 | function() 98 | -- keybind 99 | server_options.on_attach = attach 100 | -- options config 101 | server_options.flags = { 102 | debounce_text_changes = 150 103 | } 104 | -- 代替内置 omnifunc 105 | server_options.capabilities = capabilities 106 | server:setup(server_options) 107 | end 108 | ) 109 | -- 如果语言服务器未准备就绪,则自动安装 110 | if not server:is_installed() then 111 | vim.notify("Install Language Server : " .. server_name, "WARN", {title = "Language Servers"}) 112 | server:install() 113 | end 114 | end 115 | end 116 | -------------------------------------------------------------------------------- /lua/basic/plugins.lua: -------------------------------------------------------------------------------- 1 | ---@diagnostic disable: undefined-global 2 | -- https://github.com/wbthomason/packer.nvim 3 | 4 | local install_path = vim.fn.stdpath("data") .. "/site/pack/packer/start/packer.nvim" 5 | if vim.fn.empty(vim.fn.glob(install_path)) > 0 then 6 | ---@diagnostic disable-next-line: lowercase-global 7 | packer_bootstrap = 8 | vim.fn.system({"git", "clone", "--depth", "1", "https://github.com/wbthomason/packer.nvim", install_path}) 9 | end 10 | 11 | local install_plugins = { 12 | { 13 | -- packer 包管理器 14 | "wbthomason/packer.nvim" 15 | }, 16 | { 17 | -- 优化启动速度 18 | "lewis6991/impatient.nvim", 19 | load_file = true 20 | }, 21 | { 22 | -- 图标支持 23 | "kyazdani42/nvim-web-devicons", 24 | after = "impatient.nvim" 25 | }, 26 | { 27 | -- 中文文档 28 | "yianwillis/vimcdoc", 29 | event = {"BufRead", "BufNewFile"} 30 | }, 31 | { 32 | -- Lua 依赖 33 | "nvim-lua/plenary.nvim", 34 | event = {"BufRead", "BufNewFile"} 35 | }, 36 | { 37 | -- 字符查找 38 | "BurntSushi/ripgrep", 39 | event = {"BufRead", "BufNewFile"} 40 | }, 41 | { 42 | -- 文件查找 43 | "sharkdp/fd", 44 | event = {"BufRead", "BufNewFile"} 45 | }, 46 | { 47 | -- LSP 基础插件 48 | "neovim/nvim-lspconfig", 49 | load_file = true, 50 | event = {"BufRead", "BufNewFile"} 51 | }, 52 | { 53 | -- view tree 54 | "stevearc/aerial.nvim", 55 | load_file = true, 56 | after = {"nvim-web-devicons", "nvim-lspconfig"} 57 | }, 58 | { 59 | -- 替换内置 omnifunc 补全,获得更多补全 60 | "hrsh7th/cmp-nvim-lsp", 61 | after = "aerial.nvim" 62 | }, 63 | { 64 | -- 自动下载 LSP 65 | "williamboman/nvim-lsp-installer", 66 | load_file = true, 67 | after = "cmp-nvim-lsp" 68 | }, 69 | { 70 | -- LSP 进度提示 71 | "j-hui/fidget.nvim", 72 | load_file = true, 73 | after = "nvim-lsp-installer" 74 | }, 75 | { 76 | -- LSP UI 美化 77 | "tami5/lspsaga.nvim", 78 | load_file = true, 79 | after = "nvim-lsp-installer" 80 | }, 81 | { 82 | -- 扩展 LSP 诊断 83 | "mfussenegger/nvim-lint", 84 | load_file = true, 85 | after = "nvim-lsp-installer" 86 | }, 87 | { 88 | -- 灯泡提示代码行为 89 | "kosayoda/nvim-lightbulb", 90 | load_file = true, 91 | after = "nvim-lsp-installer" 92 | }, 93 | { 94 | -- 插入模式获得函数签名 95 | "ray-x/lsp_signature.nvim", 96 | load_file = true, 97 | event = {"BufRead", "BufNewFile"} 98 | }, 99 | { 100 | -- git copilot 自动补全 101 | "github/copilot.vim", 102 | load_file = true, 103 | event = "InsertCharPre" 104 | }, 105 | { 106 | -- vsnip 引擎,用于获得代码片段支持 107 | "hrsh7th/vim-vsnip", 108 | event = "InsertEnter" 109 | }, 110 | { 111 | -- 为补全添加类似 vscode 的图标 112 | "onsails/lspkind-nvim", 113 | event = "InsertEnter" 114 | }, 115 | { 116 | -- 代码补全 117 | "hrsh7th/nvim-cmp", 118 | load_file = true, 119 | after = "lspkind-nvim" 120 | }, 121 | { 122 | -- 适用于 vsnip 的代码片段源 123 | "hrsh7th/cmp-vsnip", 124 | after = "nvim-cmp" 125 | }, 126 | { 127 | -- 路径补全 128 | "hrsh7th/cmp-path", 129 | after = "nvim-cmp" 130 | }, 131 | { 132 | -- 缓冲区补全 133 | "hrsh7th/cmp-buffer", 134 | after = "nvim-cmp" 135 | }, 136 | { 137 | -- 命令补全 138 | "hrsh7th/cmp-cmdline", 139 | after = "nvim-cmp" 140 | }, 141 | { 142 | -- SQL 补全 143 | "kristijanhusak/vim-dadbod-completion", 144 | after = "nvim-cmp" 145 | }, 146 | { 147 | -- 拼写建议 148 | "f3fora/cmp-spell", 149 | after = "nvim-cmp" 150 | }, 151 | { 152 | -- 提供多种语言的代码片段 153 | "rafamadriz/friendly-snippets", 154 | after = "nvim-cmp" 155 | }, 156 | { 157 | -- tabnine 源,提供基于 AI 的智能补全 158 | "tzachar/cmp-tabnine", 159 | run = "./install.sh", 160 | after = "nvim-cmp", 161 | disable = true 162 | }, 163 | { 164 | -- 代码调试基础插件 165 | "mfussenegger/nvim-dap", 166 | load_file = true, 167 | event = {"BufRead", "BufNewFile"} 168 | }, 169 | { 170 | -- 为代码调试提供内联文本 171 | "theHamsta/nvim-dap-virtual-text", 172 | load_file = true, 173 | after = "nvim-dap" 174 | }, 175 | { 176 | -- 为代码调试提供 UI 界面 177 | "rcarriga/nvim-dap-ui", 178 | load_file = true, 179 | after = "nvim-dap" 180 | }, 181 | { 182 | -- 优秀的暗色主题 183 | "catppuccin/nvim", 184 | as = "catppuccin", 185 | disable = false, 186 | load_file = true 187 | }, 188 | { 189 | -- 删除 buffer 时不影响现有布局 190 | "famiu/bufdelete.nvim", 191 | event = {"BufRead", "BufNewFile"} 192 | }, 193 | { 194 | -- 支持 LSP 状态的 buffer 栏 195 | "akinsho/bufferline.nvim", 196 | load_file = true, 197 | after = {"nvim-web-devicons", "bufdelete.nvim"} 198 | }, 199 | { 200 | -- 为状态栏提供上下文信息 201 | "SmiteshP/nvim-gps", 202 | after = "nvim-treesitter" 203 | }, 204 | { 205 | -- git 插件 206 | "lewis6991/gitsigns.nvim", 207 | load_file = true, 208 | after = { 209 | "nvim-treesitter", 210 | "plenary.nvim" 211 | } 212 | }, 213 | { 214 | -- 轻量级的状态栏插件 215 | "nvim-lualine/lualine.nvim", 216 | disable = false, 217 | load_file = true, 218 | after = {"nvim-gps", "gitsigns.nvim", "nvim-web-devicons"} 219 | }, 220 | { 221 | -- 精美弹窗 222 | "rcarriga/nvim-notify", 223 | load_file = true, 224 | event = {"BufRead", "BufNewFile"} 225 | }, 226 | { 227 | -- 文件树 228 | "kyazdani42/nvim-tree.lua", 229 | load_file = true, 230 | after = "nvim-web-devicons", 231 | cmd = {"NvimTreeToggle", "NvimTreeFindFile"} 232 | }, 233 | { 234 | -- todo tree 235 | "folke/todo-comments.nvim", 236 | load_file = true, 237 | event = {"BufRead", "BufNewFile"} 238 | }, 239 | { 240 | -- undo tree 241 | "mbbill/undotree", 242 | load_file = true, 243 | event = {"BufRead", "BufNewFile"} 244 | }, 245 | { 246 | -- 模糊查找 247 | "nvim-telescope/telescope.nvim", 248 | load_file = true, 249 | cmd = "Telescope" 250 | }, 251 | { 252 | -- 全局替换 253 | "nvim-pack/nvim-spectre", 254 | load_file = true, 255 | after = {"ripgrep", "plenary.nvim"} 256 | }, 257 | { 258 | -- 语法高亮 259 | "nvim-treesitter/nvim-treesitter", 260 | run = ":TSupdate", 261 | load_file = true, 262 | event = {"BufRead", "BufNewFile"} 263 | }, 264 | { 265 | -- 彩虹括号 266 | "p00f/nvim-ts-rainbow", 267 | event = {"BufRead", "BufNewFile"} 268 | }, 269 | { 270 | -- 注释依赖 271 | "JoosepAlviste/nvim-ts-context-commentstring", 272 | event = {"BufRead", "BufNewFile"} 273 | }, 274 | { 275 | -- 代码注释 276 | "numToStr/Comment.nvim", 277 | load_file = true, 278 | after = "nvim-ts-context-commentstring" 279 | }, 280 | { 281 | -- 代码格式化 282 | "sbdchd/neoformat", 283 | load_file = true, 284 | cmd = "Neoformat" 285 | }, 286 | { 287 | -- 自动匹配括号 288 | "windwp/nvim-autopairs", 289 | load_file = true, 290 | event = "InsertEnter" 291 | }, 292 | { 293 | -- 包裹修改 294 | "ur4ltz/surround.nvim", 295 | load_file = true, 296 | event = {"BufRead", "BufNewFile"} 297 | }, 298 | { 299 | -- 快速更改单词 300 | "AndrewRadev/switch.vim", 301 | load_file = true, 302 | event = {"BufRead", "BufNewFile"} 303 | }, 304 | { 305 | -- markdown 预览 306 | "davidgranstrom/nvim-markdown-preview", 307 | load_file = true, 308 | ft = "markdown" 309 | }, 310 | { 311 | -- Python 缩进 312 | "Vimjas/vim-python-pep8-indent", 313 | ft = "python" 314 | }, 315 | { 316 | -- emmet 缩写 317 | "mattn/emmet-vim", 318 | ft = { 319 | "html", 320 | "javascript", 321 | "typescript", 322 | "vue", 323 | "xml" 324 | } 325 | }, 326 | { 327 | -- SQL 链接基础插件 328 | "tpope/vim-dadbod", 329 | cmd = "DBUIToggle" 330 | }, 331 | { 332 | -- SQL 链接 UI 插件 333 | "kristijanhusak/vim-dadbod-ui", 334 | load_file = true, 335 | after = "vim-dadbod" 336 | }, 337 | { 338 | -- 显示滚动条 339 | "petertriho/nvim-scrollbar", 340 | load_file = true, 341 | event = {"BufRead", "BufNewFile"} 342 | }, 343 | { 344 | -- 内置终端 345 | "akinsho/toggleterm.nvim", 346 | load_file = true, 347 | event = {"BufRead", "BufNewFile"} 348 | }, 349 | { 350 | -- 多光标模式 351 | "terryma/vim-multiple-cursors", 352 | load_file = true 353 | }, 354 | { 355 | -- 自动保存 356 | "Pocco81/AutoSave.nvim", 357 | load_file = true, 358 | event = {"TextChanged", "TextChangedI"} 359 | }, 360 | { 361 | -- 自动恢复光标位置 362 | "ethanholz/nvim-lastplace", 363 | load_file = true, 364 | event = {"BufRead", "BufNewFile"} 365 | }, 366 | { 367 | -- 为不支持 LSP 高亮的主题提供默认高亮方案 368 | "folke/lsp-colors.nvim", 369 | load_file = true, 370 | event = {"BufRead", "BufNewFile"} 371 | }, 372 | { 373 | -- 搜索时显示条目 374 | "kevinhwang91/nvim-hlslens", 375 | event = {"BufRead", "BufNewFile"} 376 | }, 377 | { 378 | -- 显示网页色 379 | "norcalli/nvim-colorizer.lua", 380 | load_file = true, 381 | event = {"BufRead", "BufNewFile"} 382 | }, 383 | { 384 | -- 显示缩进线 385 | "lukas-reineke/indent-blankline.nvim", 386 | load_file = true, 387 | event = {"BufRead", "BufNewFile"} 388 | }, 389 | { 390 | -- 显示光标下相同词汇 391 | "RRethy/vim-illuminate", 392 | load_file = true, 393 | event = {"BufRead", "BufNewFile"} 394 | }, 395 | { 396 | -- 快速跳转 397 | "phaazon/hop.nvim", 398 | load_file = true, 399 | cmd = { 400 | "HopWord", 401 | "HopLine", 402 | "HopChar1" 403 | } 404 | }, 405 | { 406 | -- 拼写检查器 407 | "lewis6991/spellsitter.nvim", 408 | load_file = true, 409 | event = {"BufRead", "BufNewFile"} 410 | }, 411 | { 412 | -- 键位绑定器 413 | "folke/which-key.nvim", 414 | load_file = true, 415 | event = {"BufRead", "BufNewFile"} 416 | }, 417 | { 418 | -- 翻译插件 419 | "voldikss/vim-translator", 420 | load_file = true, 421 | cmd = {"Translate", "TranslateR", "TranslateW"} 422 | }, 423 | { 424 | -- 代码长截图 425 | "kristijanhusak/vim-carbon-now-sh", 426 | load_file = true, 427 | cmd = "CarbonNowSh" 428 | }, 429 | { 430 | -- 查询启动时间 431 | "dstein64/vim-startuptime", 432 | cmd = "StartupTime" 433 | } 434 | } 435 | 436 | local packer = 437 | require("packer").startup( 438 | { 439 | function(use) 440 | for _, plugin in ipairs(install_plugins) do 441 | if plugin.load_file then 442 | local require_path 443 | if plugin.as then 444 | require_path = "conf/" .. plugin.as 445 | else 446 | -- require_path = "conf" .. string.match(plugin[1], "(/[%w-_]+).?") 447 | require_path = "conf/" .. string.match(plugin[1], "/([%w-_]+).?") 448 | 449 | end 450 | plugin.config = "require('" .. require_path .. "')" 451 | end 452 | use(plugin) 453 | end 454 | if packer_bootstrap then 455 | require("packer").sync() 456 | end 457 | end, 458 | config = { 459 | display = { 460 | open_fn = require("packer.util").float 461 | } 462 | } 463 | } 464 | ) 465 | 466 | -- 实时生效配置 467 | vim.cmd( 468 | [[ 469 | augroup packer_user_config 470 | autocmd! 471 | autocmd BufWritePost plugins.lua source | PackerCompile 472 | augroup end 473 | ]] 474 | ) 475 | 476 | return packer 477 | -------------------------------------------------------------------------------- /lua/basic/keybinds.lua: -------------------------------------------------------------------------------- 1 | vim.g.mapleader = " " 2 | 3 | vim.u.keymap = { 4 | set = {}, 5 | opt = { 6 | ns_opt = {noremap = true, silent = true}, 7 | se_opt = {silent = true, expr = true} 8 | }, 9 | fn = { 10 | register_key = function(plug_name) 11 | local vim_api_set = vim.u.keymap.set[plug_name].vim_api_set 12 | for _, value in ipairs(vim_api_set) do 13 | vim.api.nvim_set_keymap(value[1], value[2], value[3], vim.u.keymap.opt[value[4]]) 14 | end 15 | end 16 | } 17 | } 18 | 19 | vim.u.keymap.set.base = { 20 | vim_api_set = { 21 | {"n", "\\\\", "qa", "ns_opt"}, 22 | {"n", "", ":nohlsearch", "ns_opt"}, 23 | {"t", "", "", "ns_opt"}, 24 | {"i", "jj", "", "ns_opt"}, 25 | {"n", "H", "^", "ns_opt"}, 26 | {"v", "H", "^", "ns_opt"}, 27 | {"n", "L", "$", "ns_opt"}, 28 | {"v", "L", "$", "ns_opt"}, 29 | {"n", "", "10k", "ns_opt"}, 30 | {"n", "", "10j", "ns_opt"}, 31 | {"i", "", "", "ns_opt"}, 32 | {"i", "", "", "ns_opt"}, 33 | {"i", "", "", "ns_opt"}, 34 | {"i", "", "", "ns_opt"}, 35 | {"n", "", "res +1", "ns_opt"}, 36 | {"n", "", "res -1", "ns_opt"}, 37 | {"n", "", "vertical resize-1", "ns_opt"}, 38 | {"n", "", "vertical resize+1", "ns_opt"}, 39 | {"n", "cs", "set spell!", "ns_opt"}, 40 | {"n", ";;", ";", "ns_opt"}, 41 | {"n", ";y", '"+y', "ns_opt"}, 42 | {"v", ";y", '"+y', "ns_opt"}, 43 | {"n", ";d", '"+d', "ns_opt"}, 44 | {"n", ";D", '"+D', "ns_opt"}, 45 | {"v", ";d", '"+d', "ns_opt"}, 46 | {"v", ";D", '"+D', "ns_opt"}, 47 | {"n", ";p", '"+p', "ns_opt"}, 48 | {"n", ";P", '"+P', "ns_opt"}, 49 | {"v", ";p", '"+p', "ns_opt"}, 50 | {"v", ";P", '"+P', "ns_opt"} 51 | }, 52 | plugin_set = {} 53 | } 54 | 55 | vim.u.keymap.set.bufferline = { 56 | vim_api_set = { 57 | {"n", "", "Bdelete!", "ns_opt"}, 58 | {"n", "", "BufferLineCyclePrev", "ns_opt"}, 59 | {"n", "", "BufferLineCycleNext", "ns_opt"}, 60 | {"n", "bh", "BufferLineCloseLeft", "ns_opt"}, 61 | {"n", "bl", "BufferLineCloseRight", "ns_opt"}, 62 | {"n", "bo", "BufferLineCloseLeftBufferLineCloseRight", "ns_opt"}, 63 | {"n", "b1", "BufferLineGoToBuffer 1", "ns_opt"}, 64 | {"n", "b2", "BufferLineGoToBuffer 2", "ns_opt"}, 65 | {"n", "b3", "BufferLineGoToBuffer 3", "ns_opt"}, 66 | {"n", "b4", "BufferLineGoToBuffer 4", "ns_opt"}, 67 | {"n", "b5", "BufferLineGoToBuffer 5", "ns_opt"}, 68 | {"n", "b6", "BufferLineGoToBuffer 6", "ns_opt"}, 69 | {"n", "b7", "BufferLineGoToBuffer 7", "ns_opt"}, 70 | {"n", "b8", "BufferLineGoToBuffer 8", "ns_opt"}, 71 | {"n", "b9", "BufferLineGoToBuffer 9", "ns_opt"}, 72 | {"n", "bt", "BufferLinePick", "ns_opt"} 73 | }, 74 | plugin_set = {} 75 | } 76 | 77 | vim.u.keymap.set.comment = { 78 | vim_api_set = {}, 79 | plugin_set = { 80 | toggle = { 81 | line = "gcc", 82 | block = "gCC" 83 | }, 84 | opleader = { 85 | line = "gc", 86 | block = "gC" 87 | }, 88 | extra = { 89 | above = "gcO", 90 | below = "gco", 91 | eol = "gcA" 92 | } 93 | } 94 | } 95 | 96 | vim.u.keymap.set.copilot = { 97 | vim_api_set = { 98 | {"i", "", "copilot#Accept('')", "se_opt"} 99 | }, 100 | plugin_set = {} 101 | } 102 | 103 | vim.u.keymap.set.hop = { 104 | vim_api_set = { 105 | {"n", "hw", "HopWord", "ns_opt"}, 106 | {"n", "hl", "HopLine", "ns_opt"}, 107 | {"n", "hc", "HopChar1", "ns_opt"} 108 | }, 109 | plugin_set = {} 110 | } 111 | 112 | vim.u.keymap.set.lsp_signature = { 113 | vim_api_set = {}, 114 | plugin_set = { 115 | toggle_key = "" 116 | } 117 | } 118 | 119 | vim.u.keymap.set.lspsaga = { 120 | vim_api_set = {}, 121 | plugin_set = { 122 | code_action_keys = { 123 | quit = "", 124 | exec = "" 125 | }, 126 | rename_action_keys = { 127 | quit = "", 128 | exec = "" 129 | } 130 | } 131 | } 132 | 133 | vim.u.keymap.set.neoformat = { 134 | vim_api_set = { 135 | {"n", "cf", "Neoformat", "ns_opt"} 136 | }, 137 | plugin_set = {} 138 | } 139 | 140 | vim.u.keymap.set.nvim_cmp = { 141 | vim_api_set = {}, 142 | plugin_set = { 143 | select_prev_item = "", 144 | select_next_item = "", 145 | confirm_current = "", 146 | toggle_complete = "", 147 | current_or_next = "" 148 | } 149 | } 150 | 151 | vim.u.keymap.set.nvim_dap_ui = { 152 | vim_api_set = { 153 | {"n", "du", "lua require'dapui'.toggle()", "ns_opt"} 154 | }, 155 | plugin_set = {} 156 | } 157 | 158 | vim.u.keymap.set.nvim_dap = { 159 | vim_api_set = { 160 | {"n", "db", "lua require'dap'.toggle_breakpoint()", "ns_opt"}, 161 | {"n", "", "lua require'dap'.continue()", "ns_opt"}, 162 | {"n", "", "lua require'dap'.step_into()", "ns_opt"}, 163 | {"n", "", "lua require'dap'.step_over()", "ns_opt"}, 164 | {"n", "", "lua require'dap'.step_out()", "ns_opt"}, 165 | {"n", "", "lua require'dap'.run_last()", "ns_opt"}, 166 | { 167 | "n", 168 | "", 169 | "lua require'dap'.close()lua require'dap.repl'.close()lua require'dapui'.close()DapVirtualTextForceRefresh", 170 | "ns_opt" 171 | } 172 | }, 173 | plugin_set = {} 174 | } 175 | 176 | vim.u.keymap.set.nvim_hlslens = { 177 | vim_api_set = { 178 | { 179 | "n", 180 | "n", 181 | "execute('normal!'.v:count1.'n')lua require('hlslens').start()", 182 | "ns_opt" 183 | }, 184 | { 185 | "n", 186 | "N", 187 | "execute('normal!'.v:count1.'N')lua require('hlslens').start()", 188 | "ns_opt" 189 | }, 190 | {"n", "*", "*lua require('hlslens').start()", "ns_opt"}, 191 | {"n", "#", "#lua require('hlslens').start()", "ns_opt"}, 192 | {"n", "g*", "g*lua require('hlslens').start()", "ns_opt"}, 193 | {"n", "g#", "g#lua require('hlslens').start()", "ns_opt"} 194 | }, 195 | plugin_set = {} 196 | } 197 | 198 | vim.u.keymap.set.nvim_lsp_installer = { 199 | vim_api_set = {}, 200 | plugin_set = { 201 | lsp_definitions = "gd", 202 | lsp_references = "gr", 203 | diagnostics = "go", 204 | lsp_code_actions = "ca", 205 | rename = "cn", 206 | hover_doc = "gh", 207 | diagnostic_jump_prev = "g[", 208 | diagnostic_jump_next = "g]", 209 | smart_scroll_with_saga_prev = "", 210 | smart_scroll_with_saga_next = "" 211 | } 212 | } 213 | 214 | vim.u.keymap.set.nvim_notify = { 215 | vim_api_set = { 216 | { 217 | "n", 218 | "fn", 219 | "lua require('telescope').extensions.notify.notify() theme=dropdown", 220 | "ns_opt" 221 | } 222 | }, 223 | plugin_set = {} 224 | } 225 | 226 | vim.u.keymap.set.nvim_spectre = { 227 | vim_api_set = { 228 | {"n", "rp", "lua require('spectre').open()", "ns_opt"}, 229 | {"n", "rf", "viw:lua require('spectre').open_file_search()", "ns_opt"}, 230 | {"n", "rw", "lua require('spectre').open_visual({select_word=true})", "ns_opt"} 231 | }, 232 | plugin_set = { 233 | mapping = { 234 | ["toggle_line"] = { 235 | map = "dd", 236 | cmd = "lua require('spectre').toggle_line()", 237 | desc = "toggle current item" 238 | }, 239 | ["enter_file"] = { 240 | map = "", 241 | cmd = "lua require('spectre.actions').select_entry()", 242 | desc = "goto current file" 243 | }, 244 | ["show_option_menu"] = { 245 | map = "o", 246 | cmd = "lua require('spectre').show_options()", 247 | desc = "show option" 248 | }, 249 | ["run_replace"] = { 250 | map = "r", 251 | cmd = "lua require('spectre.actions').run_replace()", 252 | desc = "replace all" 253 | }, 254 | ["change_view_mode"] = { 255 | map = "v", 256 | cmd = "lua require('spectre').change_view()", 257 | desc = "change result view mode" 258 | } 259 | } 260 | } 261 | } 262 | 263 | vim.u.keymap.set.nvim_tree = { 264 | vim_api_set = { 265 | {"n", "1", "NvimTreeToggle", "ns_opt"}, 266 | {"n", "fc", "NvimTreeFindFile", "ns_opt"} 267 | -- 默认按键 268 | -- o :打开目录或文件 269 | -- a :新增目录或文件 270 | -- r :重命名目录或文件 271 | -- x :剪切目录或文件 272 | -- c :复制目录或文件 273 | -- d :删除目录或文件 274 | -- y :复制目录或文件名称 275 | -- Y :复制目录或文件相对路径 276 | -- gy :复制目录或文件绝对路径 277 | -- p :粘贴目录或文件 278 | -- s :使用系统默认程序打开目录或文件 279 | -- :将文件添加到缓冲区,但不移动光标 280 | -- :垂直分屏打开文件 281 | -- :水平分屏打开文件 282 | -- :进入光标下的目录 283 | -- :重命名目录或文件,删除已有目录名称 284 | -- - :返回上层目录 285 | -- I :切换隐藏文件/目录的可见性 286 | -- H :切换点文件的可见性 287 | -- R :刷新资源管理器 288 | -- 另外,文件资源管理器操作和操作文档方式一致,可按 / ? 进行搜索 289 | }, 290 | plugin_set = {} 291 | } 292 | 293 | vim.u.keymap.set.nvim_treesitter = { 294 | vim_api_set = {}, 295 | plugin_set = { 296 | incremental_selection_keymaps = { 297 | init_selection = "", 298 | node_incremental = "", 299 | node_decremental = "", 300 | scope_incremental = "" 301 | } 302 | } 303 | } 304 | 305 | vim.u.keymap.set.switch = { 306 | vim_api_set = { 307 | {"n", "gs", ":Switch", "ns_opt"} 308 | }, 309 | plugin_set = {} 310 | } 311 | 312 | vim.u.keymap.set.telescope = { 313 | vim_api_set = { 314 | {"n", "ff", "Telescope find_files theme=dropdown", "ns_opt"}, 315 | {"n", "fg", "Telescope live_grep theme=dropdown", "ns_opt"}, 316 | {"n", "fo", "Telescope oldfiles theme=dropdown", "ns_opt"}, 317 | {"n", "fm", "Telescope marks theme=dropdown", "ns_opt"}, 318 | {"n", "fh", "Telescope resume theme=dropdown", "ns_opt"} 319 | }, 320 | plugin_set = {} 321 | } 322 | 323 | vim.u.keymap.set.todo_comments = { 324 | vim_api_set = { 325 | {"n", "ft", "TodoTelescope theme=dropdown", "ns_opt"} 326 | }, 327 | plugin_set = {} 328 | } 329 | 330 | vim.u.keymap.set.toggleterm = { 331 | vim_api_set = { 332 | {"n", "tt", "exe v:count.'ToggleTerm'", "ns_opt"}, 333 | {"n", "tf", "lua require('toggleterm').float_toggle()", "ns_opt"}, 334 | {"n", "tg", "lua require('toggleterm').lazygit_toggle()", "ns_opt"}, 335 | {"n", "ta", "ToggleTermToggleAll", "ns_opt"} 336 | }, 337 | plugin_set = { 338 | delete_all_exit = "", 339 | lazygit = { 340 | lazygit_exit = "q", 341 | again_exit = "" 342 | }, 343 | float = { 344 | float_exit = "", 345 | again_exit = "" 346 | } 347 | } 348 | } 349 | 350 | vim.u.keymap.set.undotree = { 351 | vim_api_set = { 352 | {"n", "3", ":UndotreeToggle", "ns_opt"} 353 | }, 354 | plugin_set = {} 355 | } 356 | 357 | vim.u.keymap.set.vim_carbon_now_sh = { 358 | vim_api_set = { 359 | {"v", "ch", ":CarbonNowSh", "ns_opt"}, 360 | {"n", "ch", ":CarbonNowSh", "ns_opt"} 361 | }, 362 | plugin_set = {} 363 | } 364 | 365 | vim.u.keymap.set.vim_multiple_cursors = { 366 | vim_api_set = {}, 367 | plugin_set = { 368 | start_word_key = "gb", 369 | next_key = "", 370 | prev_key = "", 371 | skip_key = "", 372 | quit_key = "" 373 | } 374 | } 375 | 376 | vim.u.keymap.set.vim_translator = { 377 | vim_api_set = { 378 | {"n", "tsc", ":Translate --target_lang=zh --source_lang=auto", "ns_opt"}, 379 | {"v", "tsc", ":TranslateW --target_lang=zh --source_lang=auto", "ns_opt"}, 380 | {"n", "tse", ":Translate --target_lang=en --source_lang=auto", "ns_opt"}, 381 | {"v", "tse", ":TranslateW --target_lang=en --source_lang=auto", "ns_opt"}, 382 | {"n", "trc", ":TranslateR --target_lang=zh --source_lang=auto", "ns_opt"}, 383 | {"v", "trc", ":TranslateR --target_lang=zh --source_lang=auto", "ns_opt"}, 384 | {"n", "tre", ":TranslateR --target_lang=en --source_lang=auto", "ns_opt"}, 385 | {"v", "tre", ":TranslateR --target_lang=en --source_lang=auto", "ns_opt"} 386 | }, 387 | plugin_set = {} 388 | } 389 | 390 | vim.u.keymap.set.aerial = { 391 | vim_api_set = {}, 392 | plugin_set = { 393 | aerial_toggle = "2", 394 | aerial_prev = "{", 395 | aerial_next = "}", 396 | aerial_prev_up = "[[", 397 | aerial_next_up = "]]" 398 | } 399 | -- : 移动到下一个项目 400 | -- : 移动到上一个项目 401 | -- { : 移动到上一个类别 402 | -- } : 移动到下一个类别 403 | -- [[ : 移动到上一个类别 404 | -- ]] : 移动到下一个类别 405 | -- o : 打开当前项目 406 | -- za : 切换当前项目 407 | -- zc : 关闭当前项目 408 | -- zo : 打开当前项目 409 | -- zM : 关闭所有项目 410 | -- zR : 关闭所有项目 411 | } 412 | 413 | vim.u.keymap.set.vim_dadbod_ui = { 414 | vim_api_set = { 415 | {"n", "4", ":DBUIToggle", "ns_opt"} 416 | }, 417 | plugin_set = {} 418 | } 419 | 420 | for plug_name, _ in pairs(vim.u.keymap.set) do 421 | vim.u.keymap.fn.register_key(plug_name) 422 | end 423 | --------------------------------------------------------------------------------