mirror of
https://github.com/cap153/nvim.git
synced 2026-01-12 01:28:16 +08:00
适配neovim 0.11
1. 更改使用的主题 2. 更改底部状态栏样式 3. 更换彩虹括号插件适配neovim 0.11 4. 更换彩虹缩进样式 5. 添加lock文件
This commit is contained in:
parent
1a430bf24b
commit
38bedd3beb
17 changed files with 259 additions and 425 deletions
|
|
@ -1,63 +1,66 @@
|
|||
return {
|
||||
'VonHeikemen/lsp-zero.nvim',
|
||||
branch = 'v3.x',
|
||||
"neovim/nvim-lspconfig",
|
||||
dependencies = {
|
||||
{ 'neovim/nvim-lspconfig' },
|
||||
{ 'saghen/blink.cmp' },
|
||||
{ 'williamboman/mason.nvim' },
|
||||
{ 'williamboman/mason-lspconfig.nvim' },
|
||||
{ "saghen/blink.cmp" },
|
||||
{ "williamboman/mason.nvim" },
|
||||
{
|
||||
"MysticalDevil/inlay-hints.nvim",
|
||||
event = "LspAttach",
|
||||
config = function()
|
||||
require("inlay-hints").setup()
|
||||
end
|
||||
}
|
||||
end,
|
||||
},
|
||||
},
|
||||
config = function()
|
||||
-- 打算启用的语言服务列表
|
||||
local servers = {
|
||||
'marksman', -- 任意标题<space>aw打开code action可以开头生成目录;超链接可以链接到同一个git项目的其他markdown文件#指定标题<space>h可以预览
|
||||
'lua_ls',
|
||||
'rust_analyzer',
|
||||
'pylsp', -- Mason对应的安装名称是python-lsp-server
|
||||
-- 'gopls',
|
||||
markdown = { "marksman" }, -- 任意标题<space>aw打开code action可以开头生成目录;超链接可以链接到同一个git项目的其他markdown文件#指定标题<space>h可以预览
|
||||
lua = { "lua_ls", "lua-language-server" }, -- Mason对应的安装名称是lua-language-server
|
||||
rust = { "rust_analyzer", "rust-analyzer" },
|
||||
python = { "pylsp", "python-lsp-server" },
|
||||
-- golang={'gopls'},
|
||||
}
|
||||
-- lsp_zero的相关配置
|
||||
local lsp_zero = require('lsp-zero')
|
||||
lsp_zero.on_attach(function(client, bufnr)
|
||||
lsp_zero.default_keymaps({ buffer = bufnr })
|
||||
local opts = { buffer = bufnr }
|
||||
vim.keymap.set('n', '<leader>h', vim.lsp.buf.hover, opts) -- <space>h显示提示文档
|
||||
vim.keymap.set('n', 'gd', vim.lsp.buf.definition, opts) -- gd跳转到定义的位置
|
||||
vim.keymap.set('n', 'go', vim.lsp.buf.type_definition, opts) -- go跳转到变量类型定义的位置
|
||||
vim.keymap.set('n', 'gr', vim.lsp.buf.references, opts) -- gr跳转到引用了对应变量或函数的位置
|
||||
vim.keymap.set('n', '<leader>rn', vim.lsp.buf.rename, opts) -- <space>rn变量重命名
|
||||
-- vim.keymap.set({ 'n', 'x' }, '<leader>f', function() vim.lsp.buf.format({ async = true }) end, opts) -- <space>f进行代码格式化
|
||||
vim.keymap.set('n', '<leader>aw', vim.lsp.buf.code_action, opts) -- <space>aw可以在出现警告或错误的地方打开建议的修复方法
|
||||
vim.keymap.set('n', '<leader>d', vim.diagnostic.open_float, opts) -- <space>d浮动窗口显示所在行警告或错误信息
|
||||
vim.keymap.set('n', '<leader>-', vim.diagnostic.goto_prev, opts) -- <space>-跳转到上一处警告或错误的地方
|
||||
vim.keymap.set('n', '<leader>=', vim.diagnostic.goto_next, opts) -- <space>+跳转到下一处警告或错误的地方
|
||||
end)
|
||||
-- “符号栏”是行号旁边的装订线中的一个空格。当一行中出现警告或错误时,Neovim 会向您显示一个字母
|
||||
lsp_zero.set_sign_icons({
|
||||
error = '✘',
|
||||
warn = '▲',
|
||||
hint = '⚑',
|
||||
info = '»'
|
||||
})
|
||||
vim.keymap.set("n", "<leader>h", vim.lsp.buf.hover, opts) -- <space>h显示提示文档
|
||||
vim.keymap.set("n", "gd", vim.lsp.buf.definition, opts) -- gd跳转到定义的位置
|
||||
vim.keymap.set("n", "go", vim.lsp.buf.type_definition, opts) -- go跳转到变量类型定义的位置
|
||||
vim.keymap.set("n", "gr", vim.lsp.buf.references, opts) -- gr跳转到引用了对应变量或函数的位置
|
||||
vim.keymap.set("n", "<leader>rn", vim.lsp.buf.rename, opts) -- <space>rn变量重命名
|
||||
vim.keymap.set("n", "<leader>aw", vim.lsp.buf.code_action, opts) -- <space>aw可以在出现警告或错误的地方打开建议的修复方法
|
||||
vim.keymap.set("n", "<leader>d", vim.diagnostic.open_float, opts) -- <space>d浮动窗口显示所在行警告或错误信息
|
||||
vim.keymap.set("n", "<leader>-", vim.diagnostic.goto_prev, opts) -- <space>-跳转到上一处警告或错误的地方
|
||||
vim.keymap.set("n", "<leader>=", vim.diagnostic.goto_next, opts) -- <space>+跳转到下一处警告或错误的地方
|
||||
-- vim.keymap.set({ 'n', 'x' }, '<leader>f', function() vim.lsp.buf.format({ async = true }) end, opts) -- <space>f进行代码格式化
|
||||
|
||||
-- 通过mason来自动安装语言服务器,可以在对应的代码运行LspIstall来安装可用的语言服务器
|
||||
require('mason').setup({})
|
||||
require('mason-lspconfig').setup({
|
||||
ensure_installed = servers -- 直接把前面的servers列表传递过来
|
||||
})
|
||||
-- cmp相关配置,通过for读取servers列表循环批量激活语言服务
|
||||
local lspconfig = require('lspconfig')
|
||||
for _, lsp in ipairs(servers) do
|
||||
lspconfig[lsp].setup {
|
||||
capabilities = require('blink.cmp').get_lsp_capabilities(),
|
||||
require("mason").setup({})
|
||||
local mr = require("mason-registry")
|
||||
local capabilities = require("blink.cmp").get_lsp_capabilities()
|
||||
|
||||
-- cmp相关配置
|
||||
local lspconfig = require("lspconfig")
|
||||
for lang_group_name, server_names_arr in pairs(servers) do
|
||||
-- 使用Mason批量安装语言服务器
|
||||
local mason_name = server_names_arr[2] or server_names_arr[1] -- Second for Mason, or fallback to first
|
||||
local p = mr.get_package(mason_name)
|
||||
if p then -- Check if package actually exists in mason-registry
|
||||
if not p:is_installed() then
|
||||
vim.notify(
|
||||
"Installing Mason package: " .. mason_name .. " (for language: " .. lang_group_name .. ")",
|
||||
vim.log.levels.INFO
|
||||
)
|
||||
p:install() -- This is synchronous
|
||||
vim.notify(mason_name .. " installed successfully.", vim.log.levels.INFO)
|
||||
end
|
||||
else
|
||||
vim.notify("Mason package not found: " .. mason_name, vim.log.levels.WARN)
|
||||
end
|
||||
|
||||
-- 批量激活语言服务
|
||||
local lsp = server_names_arr[1] -- First element is for lspconfig
|
||||
lspconfig[lsp].setup({
|
||||
capabilities = capabilities, -- Use the memoized capabilities
|
||||
settings = {
|
||||
gopls = {
|
||||
["gopls"] = {
|
||||
hints = { -- gopls开启hints
|
||||
rangeVariableTypes = true,
|
||||
parameterNames = true,
|
||||
|
|
@ -66,23 +69,23 @@ return {
|
|||
compositeLiteralFields = true,
|
||||
compositeLiteralTypes = true,
|
||||
functionTypeParameters = true,
|
||||
}
|
||||
},
|
||||
},
|
||||
Lua = {
|
||||
hint = { -- Lua开启hints
|
||||
["Lua"] = {
|
||||
hint = { -- Lua开启hints
|
||||
enable = true, -- necessary
|
||||
},
|
||||
diagnostics = {
|
||||
-- 忽略掉vim配置时一些全局变量语言服务器找不到的警告
|
||||
globals = {
|
||||
'vim',
|
||||
'require',
|
||||
'opts',
|
||||
"vim",
|
||||
"require",
|
||||
"opts",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
})
|
||||
end
|
||||
end
|
||||
end,
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue