-
I'd like to have |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 20 replies
-
Do you mind explaining this more or sending some examples of this? |
Beta Was this translation helpful? Give feedback.
-
https://github.com/jayp0521/mason-null-ls.nvim#setup-handlers-usage Feature Exists. Marking as Solution |
Beta Was this translation helpful? Give feedback.
-
@jayp0521 Sorry for taking so long. I see that you just added the local lspconfig = require("lspconfig")
local augroup = vim.api.nvim_create_augroup("LspFormatting", {})
-- Mason setup
require("mason").setup({})
-- Automatically setup servers installed with mason.nvim
require("mason-lspconfig").setup_handlers({
-- The first entry (without a key) will be the default handler
-- and will be called for each installed server that doesn't have
-- a dedicated handler.
function(server_name) -- default handler (optional)
lspconfig[server_name].setup({})
end,
-- Next, you can provide targeted overrides for specific servers.
["sumneko_lua"] = function()
lspconfig.sumneko_lua.setup({
settings = {
Lua = {
diagnostics = {
globals = { "vim", "minetest" },
},
},
},
})
end,
})
-- null-ls
require("null-ls").setup({
-- Format on save
on_attach = function(client, bufnr)
if client.supports_method("textDocument/formatting") then
vim.api.nvim_clear_autocmds({ group = augroup, buffer = bufnr })
vim.api.nvim_create_autocmd("BufWritePre", {
group = augroup,
buffer = bufnr,
callback = function()
vim.lsp.buf.format({
bufnr = bufnr,
filter = function(client)
return client.name == "null-ls"
end,
})
end,
})
end
end,
})
-- Mason null-ls
require("mason-null-ls").setup({
automatic_setup = true,
})
-- Fix for multiple offset encoding error
local capabilities = vim.lsp.protocol.make_client_capabilities()
capabilities.offsetEncoding = { "utf-16" }
require("lspconfig").clangd.setup({ capabilities = capabilities }) |
Beta Was this translation helpful? Give feedback.
https://github.com/jayp0521/mason-null-ls.nvim#setup-handlers-usage
Feature Exists. Marking as Solution