feat(LSP): Add support for autoformatting in C#
Make the omnisharp language server format C# files on write.
This commit is contained in:
parent
c898cad0df
commit
40eeea3bd9
|
|
@ -22,6 +22,25 @@ modules["mason-lspconfig"].setup_handlers {
|
|||
modules["lspconfig"][server_name].setup {
|
||||
capabilities = capabilities
|
||||
}
|
||||
end,
|
||||
["omnisharp"] = function ()
|
||||
modules["lspconfig"]["omnisharp"].setup {
|
||||
capabilities = capabilities,
|
||||
on_attach = function (client,buffnr)
|
||||
vim.notify("attaching to CS buffer {" .. buffnr .. "}")
|
||||
local gr = vim.api.nvim_create_augroup("CS-OnAttach",{})
|
||||
vim.api.nvim_create_autocmd({"BufWritePre"}, {
|
||||
group = gr,
|
||||
pattern = {"*.cs"},
|
||||
desc = "(C#) Format before write",
|
||||
callback = function ()
|
||||
vim.lsp.buf.format()
|
||||
end
|
||||
}
|
||||
)
|
||||
vim.notify("Attached to CS buffer")
|
||||
end
|
||||
}
|
||||
end
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user