当前位置: 首页 > news >正文

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,}
}

相关文章:

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 lazypa…...

Qt学习笔记1.3.4 QtCore-Qt资源系统

文章目录 资源收集文件(.qrc)外部二进制资源内编译(compiled-in)资源压缩使用应用程序中的资源使用库中的资源 Qt资源系统是一种 独立于平台的机制&#xff0c;用于在应用程序的可执行文件中存储二进制文件。如果您的应用程序总是需要一组特定的文件(图标、翻译文件等)&#x…...

同城组局同城活动找搭子小程序JAVA源码面芽组局的实现方案

功能概述 基于微信小程序开发的一款软件&#xff0c;支持用户动态发布、私信聊天关注、礼物充值打赏、发起活动组局、用户报名参与、支持商家入驻&#xff0c;对接广告功能等。 活动发布&#xff1a;用户可以在平台上发布各种类型的活动&#xff0c;如户外徒步、音乐会观赏、…...

Unable to locate the .NET SDK

问题描述&#xff1a; vs2019 加载项目时&#xff0c;提示如下&#xff1a; Unable to locate the .NET SDK as specified by global.json, please check that the specified version is installed. 项目中没有globan找al.json 文件 先使用&#xff1a; dotnet --list-sdks 命…...

C++STL初阶(1):string的使用及初阶原理

此文作为学习stl的笔记&#xff0c;许多普及、概念性的知识点将不再罗列&#xff08;如stl的发展、背景等&#xff09; 便于读者作为复习等方法了解。 0.STL简介&#xff08;笔记向&#xff09; STL不是祖师爷本贾尼实现的&#xff0c;是在惠普实验室中实现的。其作为一个数据结…...

Day41-Java基础之反射和动态代理

1. 反射 1.1 反射的概述&#xff1a; 专业的解释&#xff08;了解一下&#xff09;&#xff1a; 是在运行状态中&#xff0c;对于任意一个类&#xff0c;都能够知道这个类的所有属性和方法&#xff1b; 对于任意一个对象&#xff0c;都能够调用它的任意属性和方法&#xff…...

Tomcat的实现

在一台电脑上启动tomcat&#xff0c;tomcat是server&#xff0c;即服务器。服务器只会被实例化一次&#xff0c;tomcat这只猫就是服务器。服务器下包含多个子节点服务&#xff0c;即service&#xff0c;顾名思义就是对外提供服务。服务器通常只有一个服务&#xff0c;默认是卡特…...

RK3576 Camera:资源介绍

RK3576是RK今年上市的中高端旗舰芯片&#xff0c;定位弱于RK3588。这篇文章主要分享一下RK3576这颗主控芯片的camera资源。 &#xff08;1&#xff09;RK3576 camera资源 ①RK3576 camera硬件框图 RK3576的camera硬件框图如图所示&#xff0c;拥有一路4lane的DCPHY&#xff…...

Symfony DomCrawler库在反爬虫应对中的应用

在当今信息爆炸的时代&#xff0c;互联网上的数据量巨大&#xff0c;但这也带来了一些问题&#xff0c;比如恶意爬虫可能会对网站造成严重的影响&#xff0c;导致资源浪费和服务不稳定。为了解决这个问题&#xff0c;许多网站采取了反爬虫策略。Symfony DomCrawler库是一个强大…...

1Panel应用推荐:Uptime Kuma

1Panel&#xff08;github.com/1Panel-dev/1Panel&#xff09;是一款现代化、开源的Linux服务器运维管理面板&#xff0c;它致力于通过开源的方式&#xff0c;帮助用户简化建站与运维管理流程。为了方便广大用户快捷安装部署相关软件应用&#xff0c;1Panel特别开通应用商店&am…...

传输文件协议FTP与LFTP

目录 一.简介 二. FTP基础 主动模式&#xff08;Active Mode&#xff09;&#xff1a; 被动模式&#xff08;Passive Mode&#xff09;&#xff1a; 三. Vsftp 服务器简介 四. Vsftpd配置 1. 安装vsftpd&#xff08;ftp服务端&#xff09; 2.编辑配置文件 &#xff08;…...

expdp和impdp 实战

1 查询需要导出数据的用户 select username,default_tablespace from dba_users where username like %USERNAME%; 2 查看原来表空间大小 set linesize 9999 pagesize 9999 SELECT total.tablespace_name, Round(total.MB, 2) AS Total_MB, Round(t…...

知了汇智引领未来:全新AIGC系列课程,打造数字时代人才新标杆

在全球AIGC&#xff08;生成式人工智能&#xff09;技术加速发展的背景下&#xff0c;一系列权威报道揭示了该领域内市场潜力、行业应用、教育研究、政府监管以及具体应用场景的蓬勃进展。据腾讯网4月19日报道&#xff0c;中国AIGC应用市场规模预计于2024年达到200亿人民币&…...

软件项目验收第三方测试报告如何获取

软件项目验收第三方测试报告是确保软件质量、安全性和稳定性的重要环节。对于企业和开发者来说&#xff0c;获取一份全面、专业的第三方测试报告&#xff0c;对于提升软件产品的竞争力和用户满意度至关重要。本文将介绍如何获取软件项目验收第三方测试报告&#xff0c;以及相关…...

linux下脚本监控mysql主从同步异常时发邮件通知

在MySQL中&#xff0c;同步异常监控通常涉及监控复制的状态。可以通过查询SHOW SLAVE STATUS命令来获取复制的状态信息&#xff0c;并对其进行监控。以下是一个简单的SQL脚本&#xff0c;用于监控MySQL复制状态并输出异常信息&#xff1a; 查mysql slave状态 SHOW SLAVE STAT…...

【MySQL】分组排序取每组第一条数据

需求&#xff1a;MySQL根据某一个字段分组&#xff0c;然后组内排序&#xff0c;最后每组取排序后的第一条数据。 准备表&#xff1a; CREATE TABLE t_student_score (id int(11) NOT NULL AUTO_INCREMENT COMMENT ID,stu_name varchar(32) NOT NULL COMMENT 学生姓名,course…...

滚珠螺杆在精密机械设备中如何维持精度要求?

滚珠螺杆在精密设备领域中的运用非常之广泛&#xff0c;具有精度高、效率高的特点。为了确保滚珠螺杆在生产设备中能够发挥最佳性能&#xff0c;我们必须从多个维度进行深入考量&#xff0c;并采取针对性的措施&#xff0c;以确保其稳定、精准地服务于现代化生产的每一个环节。…...

现代 c++ 三:右值引用与移动语义

c11 为了提高效率&#xff0c;引入了右值引用及移动语义&#xff0c;这个概念不太好理解&#xff0c;需要仔细研究一下&#xff0c;下文会一并讲讲左值、右值、左值引用、右值引用、const 引用、移动构造、移动赋值运行符 … 这些概念。 左值和右值 左值和右值是表达式的属性。…...

Java学习【类与对象—封装】

Java学习【类与对象—封装】 封装的概念封装的实现包的概念import 导包导包中*的介绍import static 导入包中的静态方法和字段 static关键字的使用static 修饰成员变量static修饰方法静态成员变量的初始化 代码块静态代码块非静态代码块/实例化代码块/构造代码块加载顺序 封装的…...

Co-Driver:基于 VLM 的自动驾驶助手,具有类人行为并能理解复杂的道路场景

24年5月来自俄罗斯莫斯科研究机构的论文“Co-driver: VLM-based Autonomous Driving Assistant with Human-like Behavior and Understanding for Complex Road Scenes”。 关于基于大语言模型的自动驾驶解决方案的最新研究&#xff0c;显示了规划和控制领域的前景。 然而&…...

C++_核心编程_多态案例二-制作饮品

#include <iostream> #include <string> using namespace std;/*制作饮品的大致流程为&#xff1a;煮水 - 冲泡 - 倒入杯中 - 加入辅料 利用多态技术实现本案例&#xff0c;提供抽象制作饮品基类&#xff0c;提供子类制作咖啡和茶叶*//*基类*/ class AbstractDr…...

基于服务器使用 apt 安装、配置 Nginx

&#x1f9fe; 一、查看可安装的 Nginx 版本 首先&#xff0c;你可以运行以下命令查看可用版本&#xff1a; apt-cache madison nginx-core输出示例&#xff1a; nginx-core | 1.18.0-6ubuntu14.6 | http://archive.ubuntu.com/ubuntu focal-updates/main amd64 Packages ng…...

C++中string流知识详解和示例

一、概览与类体系 C 提供三种基于内存字符串的流&#xff0c;定义在 <sstream> 中&#xff1a; std::istringstream&#xff1a;输入流&#xff0c;从已有字符串中读取并解析。std::ostringstream&#xff1a;输出流&#xff0c;向内部缓冲区写入内容&#xff0c;最终取…...

Docker 本地安装 mysql 数据库

Docker: Accelerated Container Application Development 下载对应操作系统版本的 docker &#xff1b;并安装。 基础操作不再赘述。 打开 macOS 终端&#xff0c;开始 docker 安装mysql之旅 第一步 docker search mysql 》〉docker search mysql NAME DE…...

Caliper 配置文件解析:fisco-bcos.json

config.yaml 文件 config.yaml 是 Caliper 的主配置文件,通常包含以下内容: test:name: fisco-bcos-test # 测试名称description: Performance test of FISCO-BCOS # 测试描述workers:type: local # 工作进程类型number: 5 # 工作进程数量monitor:type: - docker- pro…...

stm32wle5 lpuart DMA数据不接收

配置波特率9600时&#xff0c;需要使用外部低速晶振...

数据结构:递归的种类(Types of Recursion)

目录 尾递归&#xff08;Tail Recursion&#xff09; 什么是 Loop&#xff08;循环&#xff09;&#xff1f; 复杂度分析 头递归&#xff08;Head Recursion&#xff09; 树形递归&#xff08;Tree Recursion&#xff09; 线性递归&#xff08;Linear Recursion&#xff09;…...

车载诊断架构 --- ZEVonUDS(J1979-3)简介第一篇

我是穿拖鞋的汉子,魔都中坚持长期主义的汽车电子工程师。 老规矩,分享一段喜欢的文字,避免自己成为高知识低文化的工程师: 做到欲望极简,了解自己的真实欲望,不受外在潮流的影响,不盲从,不跟风。把自己的精力全部用在自己。一是去掉多余,凡事找规律,基础是诚信;二是…...

计算机系统结构复习-名词解释2

1.定向&#xff1a;在某条指令产生计算结果之前&#xff0c;其他指令并不真正立即需要该计算结果&#xff0c;如果能够将该计算结果从其产生的地方直接送到其他指令中需要它的地方&#xff0c;那么就可以避免停顿。 2.多级存储层次&#xff1a;由若干个采用不同实现技术的存储…...

基于Python的气象数据分析及可视化研究

目录 一.&#x1f981;前言二.&#x1f981;开源代码与组件使用情况说明三.&#x1f981;核心功能1. ✅算法设计2. ✅PyEcharts库3. ✅Flask框架4. ✅爬虫5. ✅部署项目 四.&#x1f981;演示效果1. 管理员模块1.1 用户管理 2. 用户模块2.1 登录系统2.2 查看实时数据2.3 查看天…...