NeoVim配置文件基本的

init.lua 文件

require('options') 
require('keymaps')
require('plugins')
require('colorscheme')
require('lsp')-- 插件
require("config.lualine")
require("config.nvim-tree")
require("config.treesitter")

~\lua\plugins.lua 文件

local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not (vim.uv or vim.loop).fs_stat(lazypath) thenvim.fn.system({"git","clone","--filter=blob:none","https://github.com/folke/lazy.nvim.git","--branch=stable", -- latest stable releaselazypath,})
end
vim.opt.rtp:prepend(lazypath)require("lazy").setup({-- LSP manager"williamboman/mason.nvim","williamboman/mason-lspconfig.nvim","neovim/nvim-lspconfig",-- Vscode-like pictograms{"onsails/lspkind.nvim",event = { "VimEnter" },},-- Auto-completion engine{"hrsh7th/nvim-cmp",dependencies = {"lspkind.nvim","hrsh7th/cmp-nvim-lsp", -- lsp auto-completion"hrsh7th/cmp-buffer", -- buffer auto-completion"hrsh7th/cmp-path", -- path auto-completion"hrsh7th/cmp-cmdline", -- cmdline auto-completion},config = function()require("config.nvim-cmp")end,},-- Code snippet engine{"L3MON4D3/LuaSnip",version = "v2.*",},"navarasu/onedark.nvim","nvim-lualine/lualine.nvim",  -- 状态栏"nvim-tree/nvim-tree.lua",  -- 文档树"nvim-tree/nvim-web-devicons", -- 文档树图标"nvim-treesitter/nvim-treesitter", -- 语法高亮
})

~\lua\options.lua 文件

-- Hint: use `:h <option>` to figure out the meaning if needed
vim.opt.clipboard = 'unnamedplus' -- use system clipboard
vim.opt.completeopt = { 'menu', 'menuone', 'noselect' }
vim.opt.mouse = 'a' -- allow the mouse to be used in Nvim-- Tab
vim.opt.tabstop = 4 -- number of visual spaces per TAB
vim.opt.softtabstop = 4 -- number of spacesin tab when editing
vim.opt.shiftwidth = 4 -- insert 4 spaces on a tab
vim.opt.expandtab = true -- tabs are spaces, mainly because of python-- UI config
vim.opt.number = true -- show absolute number
vim.opt.relativenumber = true -- add numbers to each line on the left side
vim.opt.cursorline = true -- highlight cursor line underneath the cursor horizontally
vim.opt.splitbelow = true -- open new vertical split bottom
vim.opt.splitright = true -- open new horizontal splits right
-- vim.opt.termguicolors = true        -- enabl 24-bit RGB color in the TUI
vim.opt.showmode = false -- we are experienced, wo don't need the "-- INSERT --" mode hint-- Searching
vim.opt.incsearch = true -- search as characters are entered
vim.opt.hlsearch = false -- do not highlight matches
vim.opt.ignorecase = true -- ignore case in searches by default
vim.opt.smartcase = true -- but make it case sensitive if an uppercase is entered

~\lua\lsp.lua 文件

-- Note: The order matters: mason -> mason-lspconfig -> lspconfig
require("mason").setup({ui = {icons = {package_installed = "✓",package_pending = "➜",package_uninstalled = "✗",},},
})require("mason-lspconfig").setup({-- A list of servers to automatically install if they're not already installedensure_installed = { "lua_ls", "clangd" },
})-- Set different settings for different languages' LSP
-- LSP list: https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md
-- How to use setup({}): https://github.com/neovim/nvim-lspconfig/wiki/Understanding-setup-%7B%7D
--     - the settings table is sent to the LSP
--     - on_attach: a lua callback function to run after LSP attaches to a given buffer
local lspconfig = require("lspconfig")-- Customized on_attach function
-- See `:help vim.diagnostic.*` for documentation on any of the below functions
local opts = { noremap = true, silent = true }
vim.keymap.set("n", "<space>e", vim.diagnostic.open_float, opts)
vim.keymap.set("n", "[d", vim.diagnostic.goto_prev, opts)
vim.keymap.set("n", "]d", vim.diagnostic.goto_next, opts)
vim.keymap.set("n", "<space>q", vim.diagnostic.setloclist, opts)-- Use an on_attach function to only map the following keys
-- after the language server attaches to the current buffer
local on_attach = function(client, bufnr)-- Enable completion triggered by <c-x><c-o>vim.api.nvim_buf_set_option(bufnr, "omnifunc", "v:lua.vim.lsp.omnifunc")-- See `:help vim.lsp.*` for documentation on any of the below functionslocal bufopts = { noremap = true, silent = true, buffer = bufnr }vim.keymap.set("n", "gD", vim.lsp.buf.declaration, bufopts)vim.keymap.set("n", "gd", vim.lsp.buf.definition, bufopts)vim.keymap.set("n", "K", vim.lsp.buf.hover, bufopts)vim.keymap.set("n", "gi", vim.lsp.buf.implementation, bufopts)vim.keymap.set("n", "<C-k>", vim.lsp.buf.signature_help, bufopts)vim.keymap.set("n", "<space>wa", vim.lsp.buf.add_workspace_folder, bufopts)vim.keymap.set("n", "<space>wr", vim.lsp.buf.remove_workspace_folder, bufopts)vim.keymap.set("n", "<space>wl", function()print(vim.inspect(vim.lsp.buf.list_workspace_folders()))end, bufopts)vim.keymap.set("n", "<space>D", vim.lsp.buf.type_definition, bufopts)vim.keymap.set("n", "<space>rn", vim.lsp.buf.rename, bufopts)vim.keymap.set("n", "<space>ca", vim.lsp.buf.code_action, bufopts)vim.keymap.set("n", "gr", vim.lsp.buf.references, bufopts)vim.keymap.set("n", "<space>f", function()vim.lsp.buf.format({async = true,-- Only request null-ls for formattingfilter = function(client)return client.name == "null-ls"end,})end, bufopts)
end-- How to add a LSP for a specific language?
-- 1. Use `:Mason` to install the corresponding LSP.
-- 2. Add configuration below.
lspconfig.gopls.setup({on_attach = on_attach,
})lspconfig.lua_ls.setup({on_attach = on_attach,settings = {Lua = {runtime = {-- Tell the language server which version of Lua you're using (most likely LuaJIT in the case of Neovim)version = "LuaJIT",},diagnostics = {-- Get the language server to recognize the `vim` globalglobals = { "vim" },},workspace = {-- Make the server aware of Neovim runtime fileslibrary = vim.api.nvim_get_runtime_file("", true),},-- Do not send telemetry data containing a randomized but unique identifiertelemetry = {enable = false,},},},
})-- source: https://rust-analyzer.github.io/manual.html#nvim-lsp
lspconfig.clangd.setup({on_attach = on_attach,
})lspconfig.ocamllsp.setup({on_attach = on_attach,
})

~\lua\keymaps.lua 文件

-- define common options
local opts = {noremap = true, -- non-recursivesilent = true, -- do not show message
}-----------------
-- Normal mode --
------------------- Hint: see `:h vim.map.set()`
-- Better window navigation
vim.keymap.set("n", "<C-h>", "<C-w>h", opts)
vim.keymap.set("n", "<C-j>", "<C-w>j", opts)
vim.keymap.set("n", "<C-k>", "<C-w>k", opts)
vim.keymap.set("n", "<C-l>", "<C-w>l", opts)-- Resize with arrows
-- delta: 2 lines
vim.keymap.set("n", "<C-Up>", ":resize -2<CR>", opts)
vim.keymap.set("n", "<C-Down>", ":resize +2<CR>", opts)
vim.keymap.set("n", "<C-Left>", ":vertical resize -2<CR>", opts)
vim.keymap.set("n", "<C-Right>", ":vertical resize +2<CR>", opts)-- for nvim-tree
-- default leader key: \
vim.keymap.set("n", "<leader>e", ":NvimTreeToggle<CR>", opts)-----------------
-- Visual mode --
------------------- Hint: start visual mode with the same area as the previous area and the same mode
vim.keymap.set("v", "<", "<gv", opts)
vim.keymap.set("v", ">", ">gv", opts)-- 插入模式
vim.keymap.set("i", "jk", "<ESC>")-- 可视模式
vim.keymap.set("v", "J", ":m '>+1<CR>gv=gv")
vim.keymap.set("v", "K", ":m '<-2<CR>gv=gv")

~\lua\colorscheme.lua 文件

-- define your colorscheme here
local colorscheme = 'onedark'local is_ok, _ = pcall(vim.cmd, "colorscheme " .. colorscheme)
if not is_ok thenvim.notify('colorscheme ' .. colorscheme .. ' not found!')return
end

~\lua\conifg\lualine.lua 文件

require('lualine').setup({options = {theme = 'onedark'}
})

~\lua\conifg\nvim-cmp.lua 文件

local has_words_before = function()unpack = unpack or table.unpacklocal line, col = unpack(vim.api.nvim_win_get_cursor(0))return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil
endlocal luasnip = require("luasnip")
local cmp = require("cmp")cmp.setup({snippet = {-- REQUIRED - you must specify a snippet engineexpand = function(args)require('luasnip').lsp_expand(args.body) -- For `luasnip` users.end,},mapping = cmp.mapping.preset.insert({-- Use <C-b/f> to scroll the docs['<C-b>'] = cmp.mapping.scroll_docs( -4),['<C-f>'] = cmp.mapping.scroll_docs(4),-- Use <C-k/j> to switch in items['<C-k>'] = cmp.mapping.select_prev_item(),['<C-j>'] = cmp.mapping.select_next_item(),-- Use <CR>(Enter) to confirm selection-- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items.['<CR>'] = cmp.mapping.confirm({ select = true }),-- A super tab-- sourc: https://github.com/hrsh7th/nvim-cmp/wiki/Example-mappings#luasnip["<Tab>"] = cmp.mapping(function(fallback)-- Hint: if the completion menu is visible select next oneif cmp.visible() thencmp.select_next_item()elseif has_words_before() thencmp.complete()elsefallback()endend, { "i", "s" }), -- i - insert mode; s - select mode["<S-Tab>"] = cmp.mapping(function(fallback)if cmp.visible() thencmp.select_prev_item()elseif luasnip.jumpable( -1) thenluasnip.jump( -1)elsefallback()endend, { "i", "s" }),}),-- Let's configure the item's appearance-- source: https://github.com/hrsh7th/nvim-cmp/wiki/Menu-Appearanceformatting = {-- Set order from left to right-- kind: single letter indicating the type of completion-- abbr: abbreviation of "word"; when not empty it is used in the menu instead of "word"-- menu: extra text for the popup menu, displayed after "word" or "abbr"fields = { 'abbr', 'menu' },-- customize the appearance of the completion menuformat = function(entry, vim_item)vim_item.menu = ({nvim_lsp = '[Lsp]',luasnip = '[Luasnip]',buffer = '[File]',path = '[Path]',})[entry.source.name]return vim_itemend,},-- Set source precedencesources = cmp.config.sources({{ name = 'nvim_lsp' },    -- For nvim-lsp{ name = 'luasnip' },     -- For luasnip user{ name = 'buffer' },      -- For buffer word completion{ name = 'path' },        -- For path completion})
})

~\lua\conifg\nvim-tree.lua 文件

-- 默认不开启nvim-tree
vim.g.loaded_netrw = 1
vim.g.loaded_netrwPlugin = 1require("nvim-tree").setup()

~\lua\conifg\treesitter.lua 文件

require'nvim-treesitter.configs'.setup {-- 添加不同语言ensure_installed = { "vim", "vimdoc", "c", "cpp", "javascript", "json", "lua", "typescript", "tsx", "css", "markdown", "markdown_inline" }, -- one of "all" or a list of languageshighlight = { enable = true },indent = { enable = true },-- 不同括号颜色区分rainbow = {enable = true,extended_mode = true,max_file_lines = nil,}
}

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/diannao/11555.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

基于SSM的“基于协同过滤的在线通用旅游平台网站”的设计与实现(源码+数据库+文档)

基于SSM的“基于协同过滤的在线通用旅游平台网站”的设计与实现&#xff08;源码数据库文档) 开发语言&#xff1a;Java 数据库&#xff1a;MySQL 技术&#xff1a;SSM 工具&#xff1a;IDEA/Ecilpse、Navicat、Maven 系统展示 系统主界面 景点信息界面 后台界面 部分源码…

【每日刷题】Day39

【每日刷题】Day39 &#x1f955;个人主页&#xff1a;开敲&#x1f349; &#x1f525;所属专栏&#xff1a;每日刷题&#x1f34d; &#x1f33c;文章目录&#x1f33c; 1. 622. 设计循环队列 - 力扣&#xff08;LeetCode&#xff09; 2. 387. 字符串中的第一个唯一字符 - …

百度云防护502 Bad Gateway原因总结和处理方法

最近&#xff0c;随着原百度云加速用户新接入百度云防护后&#xff0c;很多站长反馈网站打不开&#xff0c;出现了502 Bad Gateway的情况。 为此&#xff0c;百度云这里给大家总结下&#xff0c;出现502的大概几个原因&#xff1a; 1.服务器防火墙拦截了百度云防护的IP节点请求…

vivado Kintex UltraScale+ 配置存储器器件

Kintex UltraScale 配置存储器器件 下表所示闪存器件支持通过 Vivado 软件对 Kintex UltraScale 器件执行擦除、空白检查、编程和验证等配置操作。 本附录中的表格所列赛灵思系列非易失性存储器将不断保持更新 &#xff0c; 并支持通过 Vivado 软件对其中所列非易失性存…

【VUE.js】前端框架——未完成

基于脚手架创建前端工程 环境 当安装node.js时&#xff0c;它本身就携带有npm命令。&#xff08;-v 查版本号&#xff09;安装VUE CLI npm i vue/cli -g&#xff08;全局&#xff09; 创建 vue create 【project name】 镜像源解决方案 输入创建命令后&#xff0c;提示检查更…

【JAVA】JAVA的垃圾回收机制详解

对于Java的垃圾回收机制&#xff0c;它是Java虚拟机&#xff08;JVM&#xff09;提供的一种自动内存管理机制&#xff0c;主要负责回收不再使用的对象以释放内存空间。垃圾回收机制主要包括以下几个方面的内容&#xff1a; 垃圾对象的识别&#xff1a;Java虚拟机通过一些算法&…

Taro@3.x+Vue@3.x+TS开发微信小程序,网络请求封装

参考文档 Taro.request(option) 在 src/http 下创建 request.ts, 写入如下配置&#xff1a; import Taro from tarojs/taro import { encryptData } from ./encrypt // 请求数据加密&#xff0c;可选console.log(NODE_ENV, process.env.NODE_ENV) console.log(TARO_APP_PROX…

C++学习笔记3

A. 求出那个数 题目描述 喵喵是一个爱睡懒觉的姑娘&#xff0c;所以每天早上喵喵的妈妈都花费很大的力气才能把喵喵叫起来去上学。 在放学的路上&#xff0c;喵喵看到有一家店在打折卖闹钟&#xff0c;她就准备买个闹钟回家叫自己早晨起床&#xff0c;以便不让妈妈这么的辛苦…

Leetcode 3143. Maximum Points Inside the Square

Leetcode 3143. Maximum Points Inside the Square 1. 解题思路2. 代码实现 题目链接&#xff1a;3143. Maximum Points Inside the Square 1. 解题思路 这一题由于都是从中心开始的正方形&#xff0c;因此&#xff0c;我们只要找到所有tag下的点距离中心的位置最小的点&…

Caddy2使用阿里云DNS申请https证书,利用阿里云DNS境内外不同解析给Gone文档做一个同域名的国内镜像站点

我从头到尾实现了一个Golang的依赖注入框架&#xff0c;并且集成了gin、xorm、redis、cron、消息中间件等功能&#xff1b;自己觉得还挺好用的&#xff0c;并且打算长期维护&#xff01; github地址&#xff1a;https://github.com/gone-io/gone 文档原地址&#xff1a;https:/…

2024CCPC郑州站超详细题解(含题面)ABFHJLM(河南全国邀请赛)

文章目录 前言A Once In My LifeB 扫雷 1F 优秀字符串H 随机栈J 排列与合数L Toxel 与 PCPC IIM 有效算法 前言 这是大一博主第一次参加xcpc比赛&#xff0c;虽然只取得了铜牌&#xff0c;但是收获满满&#xff0c;在了解了和别人的差距后会更加激励自己去学习&#xff0c;下面…

MySQL变量的定义与应用

DQL #MySQL变量的定义与应用 set userName小可爱; select userName; # 定义数值类型整数小数 set x5,y7; select xy, x-y, x*y,x/y; #1、字符串查询 set cityNameHaag; SELECT * FROM city where Name cityName; #2、数值类型 set popvalue105819; select * from city where P…

Python Pandas 数据分析快速入门

Python Pandas 数据分析快速入门 Pandas 是一个开源的 Python 数据分析库&#xff0c;它提供了高效的 DataFrame 结构来处理大型数据集&#xff0c;常用于数据清洗和分析工作。在本教程中&#xff0c;我们将介绍如何使用 Pandas 进行基本的数据分析操作&#xff0c;以及如何处…

34岁2个娃的女程序真的要回归家庭了吗?

我34岁已婚已育&#xff0c;家里两个娃。在去年年末的裁员大潮中被裁了。目前已经找工作2个月&#xff0c;本来被裁我还挺开心的&#xff0c;我老二还在哺乳期&#xff0c;妥妥的4n的工资。赶紧裁了要我好好玩玩吧。抱着这种兴高采烈的心态那这赔偿跑路了。刚好被裁之后紧接着就…

Python从0到POC编写--函数

数学函数&#xff1a; 1. len len() 函数返回对象&#xff08;字符、列表、元组等&#xff09;长度或项目个数&#xff0c; 例如&#xff1a; str "python" len(str)2. range range() 函数返回的是一个可迭代对象&#xff08;类型是对象&#xff09;&#xff0c;…

并行执行的4种类别——《OceanBase 并行执行》系列 4

OceanBase 支持多种类型语句的并行执行。在本篇博客中&#xff0c;我们将根据并行执行的不同类别&#xff0c;分别详细阐述&#xff1a;并行查询、并行数据操作语言&#xff08;DML&#xff09;、并行数据定义语言&#xff08;DDL&#xff09;以及并行 LOAD DATA 。 《并行执行…

对Whisper模型的静音攻击

针对Whisper模型的静音攻击方法主要针对基于Transformer的自动语音识别系统&#xff0c;特别是Whisper系列模型。其有效性主要基于Whisper模型使用了一些“特殊标记”来指导语言生成过程&#xff0c;如标记表示转录结束。我们可以通过在目标语音信号前添加一个通用短音频段&…

vue项目通过点击文字上传html文件,查看html文件

上传html文件 解决思路&#xff1a;新建一个上传组件&#xff0c;将它挪到页面之外。当点击文字时&#xff0c;手动触发上传组件&#xff0c;打开上传文件框。 <template><BasicTable register"registerTable"><template #bodyCell"{ column, …

UIButton案例之添加动画

需求 基于上一节代码进行精简&#xff0c;降低了冗余性。添加动画&#xff0c;使得坐标变化自然&#xff0c;同时使用了bounds属性和center属性&#xff0c;使得UIView变化以中心点为基准。 此外&#xff0c;使用两种方式添加动画&#xff1a;1.原始方式。 2.block方式。 代码…

vm虚拟机扩容centos磁盘内存

1.查看虚拟机扩展前磁盘内存 df -h 2.关机情况下扩展磁盘内存 3.对扩容的磁盘分区 fdisk /dev/sda 输入n新增分区&#xff0c;回车&#xff0c;选择p&#xff0c;回车 为分区设置分区格式&#xff0c;在Fdisk命令处输入&#xff1a;t 分区号用默认 3&#xff08;或回车&…