test-fix
This commit is contained in:
parent
23bdf74871
commit
7d2ce1c63f
5 changed files with 79 additions and 86 deletions
|
|
@ -10,11 +10,26 @@ return {
|
|||
require("mason").setup()
|
||||
local mason_lspconfig = require("mason-lspconfig")
|
||||
|
||||
-- Register global capabilities for all servers
|
||||
-- 1. Global capabilities registered natively for all servers
|
||||
vim.lsp.config("*", {
|
||||
capabilities = require("cmp_nvim_lsp").default_capabilities(),
|
||||
})
|
||||
|
||||
vim.lsp.config("lua_ls", {
|
||||
settings = {
|
||||
Lua = {
|
||||
diagnostics = {
|
||||
globals = { "vim" },
|
||||
},
|
||||
workspace = {
|
||||
library = vim.env.VIMRUNTIME,
|
||||
checkThirdParty = false,
|
||||
},
|
||||
telemetry = { enable = false },
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
local servers = {
|
||||
"lua_ls",
|
||||
"pyright",
|
||||
|
|
@ -33,51 +48,43 @@ return {
|
|||
ensure_installed = servers,
|
||||
})
|
||||
|
||||
-- Neovim 0.11+ approach: Configure and Enable
|
||||
for _, server_name in ipairs(servers) do
|
||||
if server_name == "lua_ls" then
|
||||
vim.lsp.config("lua_ls", {
|
||||
settings = {
|
||||
Lua = {
|
||||
diagnostics = { globals = { "vim" } },
|
||||
},
|
||||
},
|
||||
})
|
||||
end
|
||||
-- Activate the server
|
||||
if server_name ~= "dartls" then
|
||||
vim.lsp.enable(server_name)
|
||||
end
|
||||
end
|
||||
|
||||
-- Diagnostic display config
|
||||
vim.diagnostic.config({
|
||||
virtual_text = true,
|
||||
signs = true,
|
||||
underline = true,
|
||||
update_in_insert = false,
|
||||
float = { border = "rounded", source = true },
|
||||
severity_sort = true,
|
||||
})
|
||||
|
||||
-- Keybindings & Formatting
|
||||
vim.api.nvim_create_autocmd("LspAttach", {
|
||||
callback = function(ev)
|
||||
local opts = { buffer = ev.buf }
|
||||
-- Neovim 0.11+ provides some defaults like 'grn' (rename),
|
||||
-- but keeping your custom ones is fine.
|
||||
|
||||
vim.keymap.set("n", "gd", vim.lsp.buf.definition, opts)
|
||||
vim.keymap.set("n", "<C-k>", vim.lsp.buf.hover, opts)
|
||||
vim.keymap.set("n", "gr", vim.lsp.buf.references, opts)
|
||||
vim.keymap.set("n", "<leader>rn", vim.lsp.buf.rename, opts)
|
||||
vim.keymap.set({ "n", "v" }, "<leader>ca", vim.lsp.buf.code_action, opts)
|
||||
vim.keymap.set({ "n", "v" }, "<C-.>", vim.lsp.buf.code_action, opts)
|
||||
-- Diagnostic keymaps
|
||||
vim.keymap.set("n", "<leader>e", vim.diagnostic.open_float, opts) -- show error under cursor
|
||||
vim.keymap.set("n", "[d", vim.diagnostic.goto_prev, opts) -- jump to previous error
|
||||
vim.keymap.set("n", "]d", vim.diagnostic.goto_next, opts) -- jump to next error
|
||||
vim.keymap.set("n", "<leader>el", vim.diagnostic.setloclist, opts) -- all errors in quickfix list
|
||||
vim.keymap.set("n", "<leader>af", vim.lsp.buf.format, { desc = "Format file" }) -- manual format
|
||||
-- Format on save (with filter to prevent multi-client conflicts)
|
||||
|
||||
-- Diagnostics
|
||||
vim.keymap.set("n", "<leader>e", vim.diagnostic.open_float, opts)
|
||||
vim.keymap.set("n", "[d", function() vim.diagnostic.jump({ count = -1, float = true }) end, opts)
|
||||
vim.keymap.set("n", "]d", function() vim.diagnostic.jump({ count = 1, float = true }) end, opts)
|
||||
vim.keymap.set("n", "<leader>el", vim.diagnostic.setloclist, opts)
|
||||
|
||||
-- Explicit formatting configuration
|
||||
vim.keymap.set("n", "<leader>af", function()
|
||||
vim.lsp.buf.format({ async = true })
|
||||
end, { buffer = ev.buf, desc = "Format file" })
|
||||
|
||||
-- Safe Format on Save scoped specifically to current buffer
|
||||
vim.api.nvim_create_autocmd("BufWritePre", {
|
||||
buffer = ev.buf,
|
||||
callback = function()
|
||||
|
|
@ -130,13 +137,12 @@ return {
|
|||
{
|
||||
name = "buffer",
|
||||
keyword_length = 2,
|
||||
-- Limit indexing to only the active visible buffer to stop lag on Enter
|
||||
option = {
|
||||
get_bufnrs = function()
|
||||
return { vim.api.nvim_get_current_buf() }
|
||||
end
|
||||
}
|
||||
}, -- Triggers after typing 2 characters of a local word
|
||||
},
|
||||
{ name = "path" },
|
||||
}),
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue