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资源系统是一种 独立于平台的机制,用于在应用程序的可执行文件中存储二进制文件。如果您的应用程序总是需要一组特定的文件(图标、翻译文件等)&#x…...
同城组局同城活动找搭子小程序JAVA源码面芽组局的实现方案
功能概述 基于微信小程序开发的一款软件,支持用户动态发布、私信聊天关注、礼物充值打赏、发起活动组局、用户报名参与、支持商家入驻,对接广告功能等。 活动发布:用户可以在平台上发布各种类型的活动,如户外徒步、音乐会观赏、…...
Unable to locate the .NET SDK
问题描述: vs2019 加载项目时,提示如下: Unable to locate the .NET SDK as specified by global.json, please check that the specified version is installed. 项目中没有globan找al.json 文件 先使用: dotnet --list-sdks 命…...
C++STL初阶(1):string的使用及初阶原理
此文作为学习stl的笔记,许多普及、概念性的知识点将不再罗列(如stl的发展、背景等) 便于读者作为复习等方法了解。 0.STL简介(笔记向) STL不是祖师爷本贾尼实现的,是在惠普实验室中实现的。其作为一个数据结…...
Day41-Java基础之反射和动态代理
1. 反射 1.1 反射的概述: 专业的解释(了解一下): 是在运行状态中,对于任意一个类,都能够知道这个类的所有属性和方法; 对于任意一个对象,都能够调用它的任意属性和方法ÿ…...
Tomcat的实现
在一台电脑上启动tomcat,tomcat是server,即服务器。服务器只会被实例化一次,tomcat这只猫就是服务器。服务器下包含多个子节点服务,即service,顾名思义就是对外提供服务。服务器通常只有一个服务,默认是卡特…...
RK3576 Camera:资源介绍
RK3576是RK今年上市的中高端旗舰芯片,定位弱于RK3588。这篇文章主要分享一下RK3576这颗主控芯片的camera资源。 (1)RK3576 camera资源 ①RK3576 camera硬件框图 RK3576的camera硬件框图如图所示,拥有一路4lane的DCPHYÿ…...
Symfony DomCrawler库在反爬虫应对中的应用
在当今信息爆炸的时代,互联网上的数据量巨大,但这也带来了一些问题,比如恶意爬虫可能会对网站造成严重的影响,导致资源浪费和服务不稳定。为了解决这个问题,许多网站采取了反爬虫策略。Symfony DomCrawler库是一个强大…...
1Panel应用推荐:Uptime Kuma
1Panel(github.com/1Panel-dev/1Panel)是一款现代化、开源的Linux服务器运维管理面板,它致力于通过开源的方式,帮助用户简化建站与运维管理流程。为了方便广大用户快捷安装部署相关软件应用,1Panel特别开通应用商店&am…...
传输文件协议FTP与LFTP
目录 一.简介 二. FTP基础 主动模式(Active Mode): 被动模式(Passive Mode): 三. Vsftp 服务器简介 四. Vsftpd配置 1. 安装vsftpd(ftp服务端) 2.编辑配置文件 (…...
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(生成式人工智能)技术加速发展的背景下,一系列权威报道揭示了该领域内市场潜力、行业应用、教育研究、政府监管以及具体应用场景的蓬勃进展。据腾讯网4月19日报道,中国AIGC应用市场规模预计于2024年达到200亿人民币&…...
软件项目验收第三方测试报告如何获取
软件项目验收第三方测试报告是确保软件质量、安全性和稳定性的重要环节。对于企业和开发者来说,获取一份全面、专业的第三方测试报告,对于提升软件产品的竞争力和用户满意度至关重要。本文将介绍如何获取软件项目验收第三方测试报告,以及相关…...
linux下脚本监控mysql主从同步异常时发邮件通知
在MySQL中,同步异常监控通常涉及监控复制的状态。可以通过查询SHOW SLAVE STATUS命令来获取复制的状态信息,并对其进行监控。以下是一个简单的SQL脚本,用于监控MySQL复制状态并输出异常信息: 查mysql slave状态 SHOW SLAVE STAT…...
【MySQL】分组排序取每组第一条数据
需求:MySQL根据某一个字段分组,然后组内排序,最后每组取排序后的第一条数据。 准备表: CREATE TABLE t_student_score (id int(11) NOT NULL AUTO_INCREMENT COMMENT ID,stu_name varchar(32) NOT NULL COMMENT 学生姓名,course…...
滚珠螺杆在精密机械设备中如何维持精度要求?
滚珠螺杆在精密设备领域中的运用非常之广泛,具有精度高、效率高的特点。为了确保滚珠螺杆在生产设备中能够发挥最佳性能,我们必须从多个维度进行深入考量,并采取针对性的措施,以确保其稳定、精准地服务于现代化生产的每一个环节。…...
现代 c++ 三:右值引用与移动语义
c11 为了提高效率,引入了右值引用及移动语义,这个概念不太好理解,需要仔细研究一下,下文会一并讲讲左值、右值、左值引用、右值引用、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”。 关于基于大语言模型的自动驾驶解决方案的最新研究,显示了规划和控制领域的前景。 然而&…...
FFmpeg 低延迟同屏方案
引言 在实时互动需求激增的当下,无论是在线教育中的师生同屏演示、远程办公的屏幕共享协作,还是游戏直播的画面实时传输,低延迟同屏已成为保障用户体验的核心指标。FFmpeg 作为一款功能强大的多媒体框架,凭借其灵活的编解码、数据…...
STM32+rt-thread判断是否联网
一、根据NETDEV_FLAG_INTERNET_UP位判断 static bool is_conncected(void) {struct netdev *dev RT_NULL;dev netdev_get_first_by_flags(NETDEV_FLAG_INTERNET_UP);if (dev RT_NULL){printf("wait netdev internet up...");return false;}else{printf("loc…...
为什么需要建设工程项目管理?工程项目管理有哪些亮点功能?
在建筑行业,项目管理的重要性不言而喻。随着工程规模的扩大、技术复杂度的提升,传统的管理模式已经难以满足现代工程的需求。过去,许多企业依赖手工记录、口头沟通和分散的信息管理,导致效率低下、成本失控、风险频发。例如&#…...
多模态商品数据接口:融合图像、语音与文字的下一代商品详情体验
一、多模态商品数据接口的技术架构 (一)多模态数据融合引擎 跨模态语义对齐 通过Transformer架构实现图像、语音、文字的语义关联。例如,当用户上传一张“蓝色连衣裙”的图片时,接口可自动提取图像中的颜色(RGB值&…...
el-switch文字内置
el-switch文字内置 效果 vue <div style"color:#ffffff;font-size:14px;float:left;margin-bottom:5px;margin-right:5px;">自动加载</div> <el-switch v-model"value" active-color"#3E99FB" inactive-color"#DCDFE6"…...
反射获取方法和属性
Java反射获取方法 在Java中,反射(Reflection)是一种强大的机制,允许程序在运行时访问和操作类的内部属性和方法。通过反射,可以动态地创建对象、调用方法、改变属性值,这在很多Java框架中如Spring和Hiberna…...
零基础设计模式——行为型模式 - 责任链模式
第四部分:行为型模式 - 责任链模式 (Chain of Responsibility Pattern) 欢迎来到行为型模式的学习!行为型模式关注对象之间的职责分配、算法封装和对象间的交互。我们将学习的第一个行为型模式是责任链模式。 核心思想:使多个对象都有机会处…...
Android 之 kotlin 语言学习笔记三(Kotlin-Java 互操作)
参考官方文档:https://developer.android.google.cn/kotlin/interop?hlzh-cn 一、Java(供 Kotlin 使用) 1、不得使用硬关键字 不要使用 Kotlin 的任何硬关键字作为方法的名称 或字段。允许使用 Kotlin 的软关键字、修饰符关键字和特殊标识…...
Linux --进程控制
本文从以下五个方面来初步认识进程控制: 目录 进程创建 进程终止 进程等待 进程替换 模拟实现一个微型shell 进程创建 在Linux系统中我们可以在一个进程使用系统调用fork()来创建子进程,创建出来的进程就是子进程,原来的进程为父进程。…...
python执行测试用例,allure报乱码且未成功生成报告
allure执行测试用例时显示乱码:‘allure’ �����ڲ����ⲿ���Ҳ���ǿ�&am…...
