网站在线咨询代码,论坛空间申请,昆明房地产网站开发,合肥网站商城开发nvim的配置文件路径在#xff5e;/.config/nvim路径下#xff1a;
一、目录如下#xff1a; coc-settings.json文件是配置代码片段路径的文件init.lua配置文件的启动脚本lua/config.lua 全局配置文件lua/keymaps.lua 快捷键映射键文件lua/plugins.lua 插件的安装和配置文件…nvim的配置文件路径在/.config/nvim路径下
一、目录如下 coc-settings.json文件是配置代码片段路径的文件init.lua配置文件的启动脚本lua/config.lua 全局配置文件lua/keymaps.lua 快捷键映射键文件lua/plugins.lua 插件的安装和配置文件packer_compiled.lua 安装packer产生的配置文件该文件中会存在packer安装插件
二、配置
coc-settings.json文件
{snippets.ultisnips.pythonPrompt: false,snippets.ultisnips.directories: [~/.config/coc/ultisnips,~/.local/share/nvim/site/pack/packer/start/vim-snippets.git/UltiSnips]
}init.lua
require plugins
require config
require keymapsconfig.lua
--搜索相关
vim.opt.number true -- 显示行号
vim.opt.showcmd true -- 在底部显示当前命令
vim.opt.wildmenu true -- 启用命令行补全菜单
vim.opt.wildmode longest:full,full -- 优化补全行为
vim.opt.incsearch true -- 启用增量搜索
vim.opt.hlsearch true -- 高亮显示搜索结果
vim.opt.incsearch true -- 增量搜索输入时实时匹配
vim.opt.ignorecase true -- 搜索时忽略大小写
vim.opt.smartcase true -- 如果搜索模式包含大写字母则区分大小写
vim.opt.showmatch true -- 高亮显示匹配的括号--界面相关
vim.opt.laststatus2 -- 总是显示状态栏
vim.opt.showmode true -- 显示当前模式如 INSERT、NORMAL
vim.opt.ruler true -- 显示光标位置行号、列号
vim.opt.scrolloff5 -- 光标距离顶部/底部的最小行数
--vim.opt.guifont Consolas:h12 -- 设置 GUI 字体仅适用于 GUI 版本的 Neovim
vim.opt.guifont FiraCode Nerd Font:h12--缩进相关
vim.opt.autoindent true -- 自动缩进
vim.opt.smartindent true -- 智能缩进
vim.opt.cindent true -- C 语言风格的缩进
vim.opt.tabstop4 -- Tab 键的宽度为 4 个空格
vim.opt.softtabstop4 -- 编辑时 Tab 键的宽度为 4 个空格
vim.opt.shiftwidth4 -- 自动缩进时的宽度为 4 个空格
vim.opt.expandtab true -- 将 Tab 转换为空格--编码相关
vim.opt.encodingutf-8 -- 默认编码为 UTF-8
vim.opt.fileencodingutf-8 -- 文件保存时的编码为 UTF-8
vim.opt.fileencodingsucs-bom,utf-8,cp936,latin1,gb18030,gbk,gb2312,chinese -- 文件编码探测顺序
vim.opt.fileformatsunix,dos -- 文件换行符格式Unix 和 DOS--其他配置
vim.opt.linebreak true -- 在单词边界换行
vim.opt.wrap true -- 自动换行
vim.opt.mouse --禁用鼠标支持
vim.opt.compatible false -- 禁用 Vi 兼容模式
vim.opt.backspace indent,eol,start -- 允许退格键删除缩进、换行符和插入模式前的字符
vim.opt.endofline false -- 不自动添加换行符
vim.opt.list true -- 显示不可见字符如 Tab、空格
--vim.opt.listchars {tab ¦\\}
vim.opt.syntax on -- 启用语法高亮
vim.opt.timeoutlen130 -- 快捷键超时时间毫秒
vim.cmd(filetype plugin on) -- 启用文件类型检测和插件vim.opt.list true -- 启用显示不可见字符
vim.opt.listchars {tab │ , -- 用 │ 表示 Tabtrail ·, -- 用 · 表示行尾空格extends ›, -- 用 › 表示超出屏幕的文本precedes ‹, -- 用 ‹ 表示超出屏幕的文本nbsp ␣, -- 用 ␣ 表示非断行空格
}vim.opt.cursorline true -- 启用光标所在行高亮
vim.opt.cursorcolumn true -- 启用光标所在列高亮
vim.opt.termguicolors true --启用真彩色keymaps.lua
--前进和后退的快捷键
vim.keymap.set({n, v}, fh, ^, {noremaptrue, silenttrue})
vim.keymap.set({n, v}, fl, $, {noremaptrue, silenttrue})--返回normal模式
vim.keymap.set({i, v}, fj, ESC, {noremaptrue, silenttrue})--查看系统函数
vim.keymap.set(n, ?, s-k, {noremaptrue, silenttrue})--写入和保存
vim.keymap.set(n, W, :w!CR, {noremaptrue, silenttrue})
vim.keymap.set(n, Q, :q!CR, {noremaptrue, silenttrue})--输入命令
vim.keymap.set(n, space, :, {noremaptrue})
vim.keymap.set(n, 12, :TagbarToggleCR, {noremaptrue, silenttrue})--分屏的设置快捷键
vim.keymap.set(n, sl, :set splitrightCR:vsplitCR, {noremaptrue, silenttrue})
vim.keymap.set(n, sh, :set nosplitrightCR:vsplitCR, {noremaptrue, silenttrue})
vim.keymap.set(n, sk, :set nosplitbelowCR:splitCR, {noremaptrue, silenttrue})
vim.keymap.set(n, sj, :set splitbelowCR:splitCR, {noremaptrue, silenttrue})--移动分屏的设置快捷键
vim.keymap.set(n, s-l, c-wl, {noremaptrue, silenttrue})
vim.keymap.set(n, s-h, c-wh, {noremaptrue, silenttrue})
vim.keymap.set(n, s-k, c-wk, {noremaptrue, silenttrue})
vim.keymap.set(n, s-j, c-wj, {noremaptrue, silenttrue})--设置函数前进和后退的快捷键
vim.keymap.set(n, s-o, c-o, {noremaptrue, silenttrue})
vim.keymap.set(n, s-i, c-i, {noremaptrue, silenttrue})--调整尺寸的快捷键
vim.keymap.set({n, v}, up, :res 5CR, {noremaptrue, silenttrue})
vim.keymap.set({n, v}, down, :res -5CR, {noremaptrue, silenttrue})
vim.keymap.set({n, v}, left, :vertical resize-5CR, {noremaptrue, silenttrue})
vim.keymap.set({n, v}, right, :vertical resize5CR, {noremaptrue, silenttrue})--ctags插件
vim.keymap.set({n}, ;, gc-], {noremaptrue, silenttrue})plugins.lua
vim.cmd [[packadd packer.nvim]]return require(packer).startup(function(use)use {https://gitee.com/oyaay/nvim-web-devicons.git}use {https://gitee.com/cangmj/lualine.nvim.git,requires { oyaay/nvim-web-devicons, opt true }}use { https://gitee.com/cc906979421/vim-gutentags.git}use { https://gitee.com/trunkMode/nerdtree.git}use { https://gitee.com/HXXH2022/ale.git}use { https://gitee.com/cc906979421/coc.nvim.git, branchrelease}use { https://gitee.com/zgpio/nvim-treesitter.git, run :TSUpdate}use { https://gitee.com/hwyang/vim-snippets.git}use { https://gitee.com/yaozhijin/tagbar.git}use { https://gitee.com/neopack/tokyonight.nvim.git}use { https://gitee.com/dglxlcl/vim-signify.git}use { https://gitee.com/ProVim/vim-easymotion.git }use { https://gitee.com/mirrors_jiangmiao/auto-pairs.git}use { https://gitee.com/rockmanlc/molokai.git}use {https://gitee.com/cc906979421/telescope.nvim, tag 0.1.8,requires { {https://gitee.com/oyaay/plenary.nvim.git} }}-- Packer can manage itselfuse yunduozhai/packer.nvim--***************************---- lualine.nvim ----***************************--require(lualine).setup {options {theme tokyonight, -- 设置主题icons_enabled true, -- 启用图标component_separators { left , right },section_separators { left , right },},sections {lualine_a {mode},lualine_b {branch, diff, diagnostics},lualine_c {filename},lualine_x {encoding, fileformat, filetype},lualine_y {progress},lualine_z {location}}}--***************************---- nerdtree ----***************************---- 打开/关闭 NERDTree 的快捷键vim.api.nvim_set_keymap(n, F12, :NERDTreeToggleCR, { noremap true, silent true })--***************************---- gutentags ----***************************---- 配置 vim-gutentagsvim.g.gutentags_enabled true -- 启用 gutentagsvim.g.gutentags_ctags_executable ctags -- 指定 ctags 可执行文件vim.g.gutentags_cache_dir vim.fn.expand(~/.cache/nvim/tags) -- 设置缓存目录vim.g.gutentags_project_root { .git, .svn, .root } -- 项目根目录标记vim.g.gutentags_generate_on_new true -- 新建文件时生成 tagsvim.g.gutentags_generate_on_missing true -- 缺少 tags 时生成vim.g.gutentags_generate_on_write true -- 保存文件时更新 tags--***************************---- indentline ----***************************----***************************---- coc.nvim ----***************************--vim.opt.backup falsevim.opt.writebackup falsevim.opt.signcolumn yeslocal keyset vim.keymap.setfunction _G.check_back_space()local col vim.fn.col(.) - 1return col 0 or vim.fn.getline(.):sub(col, col):match(%s) ~ nilendlocal opts {silent true, noremap true, expr true, replace_keycodes false}keyset(i, c-j, coc#pum#visible() ? coc#pum#next(1) : v:lua.check_back_space() ? TAB : coc#refresh(), opts)keyset(i, c-k, [[coc#pum#visible() ? coc#pum#prev(1) : \C-h]], opts)keyset(i, cr, [[coc#pum#visible() ? coc#pum#confirm() : \C-gu\CR\c-rcoc#on_enter()\CR]], opts)-- 自动安装 coc 插件vim.g.coc_global_extensions {coc-json,coc-tsserver,coc-clangd,coc-go,coc-html,coc-snippets,coc-highlight,coc-spell-checker,coc-marketplace}--***************************---- vim-snippets ----***************************---- 设置全局变量vim.g.coc_snippet_next C-l -- 使用 Ctrlj 跳转到下一个占位符vim.g.coc_snippet_prev C-h -- 使用 Ctrlk 跳转到上一个占位符--***************************---- treesitter ----***************************--require(nvim-treesitter.configs).setup {-- 启用语法高亮highlight {enable true,additional_vim_regex_highlighting false,},-- 启用代码缩进indent {enable true,},-- 启用增量选择incremental_selection {enable true,keymaps {init_selection gnn, -- 进入增量选择模式node_incremental grn, -- 扩展选择范围scope_incremental grc, -- 扩展选择范围到整个作用域node_decremental grm, -- 缩小选择范围},},-- 启用代码折叠fold {enable false,},-- 启用自动安装语法解析器ensure_installed {bash, c, cpp, css, go, html, java, javascript, json,lua, python, rust, typescript, vim, yaml, markdown,},textobjects {enable true,},}--***************************---- tokyonight ----***************************----require(tokyonight).setup({-- style night, -- 可选值night, storm, day, moon--})--vim.cmd(colorscheme tokyonight)--***************************---- molokai ----***************************-- -- 启用背景透明 vim.g.molokai_original 1vim.g.rehash256 1-- 设置主题 vim.cmd(colorscheme molokai)--***************************---- easymotion.nvim ----***************************---- 配置 easymotionvim.g.EasyMotion_do_mapping 0 -- 禁用默认快捷键vim.g.EasyMotion_smartcase 1 -- 启用智能大小写vim.g.EasyMotion_startofline 0 -- 跳转时保持光标位置-- 设置快捷键vim.api.nvim_set_keymap(n, s, Plug(easymotion-overwin-f2), { noremap true, silent true })--***************************---- telescope ----***************************--local builtin require(telescope.builtin)vim.keymap.set(n, s-p, builtin.find_files, { desc Telescope find files })vim.keymap.set(n, c-f, builtin.live_grep, { desc Telescope live grep })vim.keymap.set(n, s-b, builtin.buffers, { desc Telescope buffers })vim.keymap.set(n, s-f, builtin.current_buffer_fuzzy_find, { desc Telescope current_buffer_fuzzy_find })vim.keymap.set(n, s-m, builtin.marks, { desc Telescope marks })--telescope--获取当前光标下的单词并进行搜索依赖telescope的live grep功能local builtin require(telescope.builtin)local function search_selected_text()local selected_text vim.fn.expand(cword)if selected_text thenprint(No text selected)returnendbuiltin.live_grep({ default_text selected_text })endvim.api.nvim_create_user_command(SearchSelectedText, search_selected_text, {})vim.api.nvim_set_keymap(n, c-k, :SearchSelectedTextCR, { noremap true, silent true })--***************************---- tagbar ----***************************---- 打开/关闭 Tagbar 的快捷键vim.api.nvim_set_keymap(n, F9, :TagbarToggleCR, { noremap true, silent true })-- 设置 Tagbar 宽度vim.g.tagbar_width 30-- 自动聚焦到 Tagbarvim.g.tagbar_autofocus 1--***************************---- signify ----***************************---- 启用 signifyvim.g.signify_enable 1-- 设置 signify 的符号vim.g.signify_sign_add ✚vim.g.signify_sign_change ➜vim.g.signify_sign_delete ✖vim.g.signify_sign_delete_first_line ‾vim.g.signify_sign_change_delete ~_-- 设置 signify 的更新延迟单位毫秒vim.g.signify_update_on_bufenter 1vim.g.signify_update_on_focusgained 1-- 设置 signify 的优先级避免与其他插件冲突vim.g.signify_priority 5-- 设置 signify 的 Git 支持vim.g.signify_vcs_list { git }-- 显示更改的详细信息vim.api.nvim_set_keymap(n, F10, :SignifyDiffCR, { noremap true, silent true })end)三、路径 coc.nvim插件安装其他插件的路径例如coc-go, coc-clangd 等等~/.config/coc 其他插件的下载路径/.local/share/nvim