update
This commit is contained in:
@@ -25,6 +25,32 @@ return {
|
||||
},
|
||||
},
|
||||
|
||||
-- lspsaga: LSP UI 增强(hover 滚动、智能定位、诊断、重命名等)
|
||||
-- 替代手写 hover 滚动逻辑,自带 VSCode 风格滚动键 <C-d>/<C-u>/<C-f>/<C-b>
|
||||
{
|
||||
"nvimdev/lspsaga.nvim",
|
||||
event = "LspAttach",
|
||||
dependencies = {
|
||||
"nvim-treesitter/nvim-treesitter",
|
||||
"nvim-tree/nvim-web-devicons",
|
||||
},
|
||||
opts = {
|
||||
lightbulb = { enable = false },
|
||||
hover = {
|
||||
max_width = 0.6,
|
||||
max_height = 0.8,
|
||||
},
|
||||
ui = {
|
||||
border = "rounded",
|
||||
code_action = "bulb",
|
||||
},
|
||||
scroll_preview = {
|
||||
scroll_down = "<C-d>",
|
||||
scroll_up = "<C-u>",
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
-- LSP 配置(Neovim 0.11+ vim.lsp.config API)
|
||||
{
|
||||
"neovim/nvim-lspconfig",
|
||||
@@ -33,11 +59,12 @@ return {
|
||||
"williamboman/mason.nvim",
|
||||
"williamboman/mason-lspconfig.nvim",
|
||||
"saghen/blink.cmp",
|
||||
"nvimdev/lspsaga.nvim",
|
||||
},
|
||||
config = function()
|
||||
local caps = require("blink.cmp").get_lsp_capabilities()
|
||||
|
||||
-- LSP 附加时自动开启 inlay hints
|
||||
-- LSP 附加时绑定 keymap + 开 inlay hints
|
||||
vim.api.nvim_create_autocmd("LspAttach", {
|
||||
callback = function(args)
|
||||
local map = function(keys, func, desc)
|
||||
@@ -45,18 +72,27 @@ return {
|
||||
end
|
||||
map("gd", vim.lsp.buf.definition, "跳转到定义")
|
||||
map("gr", vim.lsp.buf.references, "查找引用")
|
||||
map("K", vim.lsp.buf.hover, "悬浮文档")
|
||||
map("<leader>rn", vim.lsp.buf.rename, "重命名")
|
||||
map("<M-CR>", vim.lsp.buf.code_action, "代码操作")
|
||||
map("<leader>d", vim.diagnostic.open_float, "行诊断")
|
||||
map("[d", vim.diagnostic.goto_prev, "上一个诊断")
|
||||
map("]d", vim.diagnostic.goto_next, "下一个诊断")
|
||||
map("K", "<cmd>Lspsaga hover_doc<CR>", "悬浮文档")
|
||||
map("<leader>rn", "<cmd>Lspsaga rename<CR>", "重命名")
|
||||
map("<M-CR>", "<cmd>Lspsaga code_action<CR>", "代码操作")
|
||||
map("<leader>d", "<cmd>Lspsaga show_line_diagnostics<CR>", "行诊断")
|
||||
map("[d", "<cmd>Lspsaga diagnostic_jump_prev<CR>", "上一个诊断")
|
||||
map("]d", "<cmd>Lspsaga diagnostic_jump_next<CR>", "下一个诊断")
|
||||
|
||||
-- 开启 inlay hints
|
||||
vim.lsp.inlay_hint.enable(true, { bufnr = args.buf })
|
||||
end,
|
||||
})
|
||||
|
||||
-- 诊断全局配置
|
||||
vim.diagnostic.config({
|
||||
virtual_text = false,
|
||||
signs = true,
|
||||
underline = true,
|
||||
update_in_insert = false,
|
||||
float = { border = "rounded" },
|
||||
})
|
||||
|
||||
-- Lua
|
||||
vim.lsp.config['lua_ls'] = {
|
||||
cmd = { 'lua-language-server' },
|
||||
|
||||
Reference in New Issue
Block a user