csharp-language-server
csharp-language-server copied to clipboard
disable the autoformater
I can't seem to disable the autoformater on the server usually passing
client.server_capabilities.documentFormattingProvider = false
client.server_capabilities.documentRangeFormattingProvider = false
to the server configuration disables the formater in all other servers I use,
Did you ever figure this out? I'm trying to use this with csharpier autoformatter and this LSP keeps overriding csharpier.
Any updates on this? I'd prefer to use Csharpier but have been forced to work with the .editorconfig support that was recently released.
The workaround should be easy, just wrap your formatting keymap/event to skip when current active client is csharp_ls, something like this:
vim.keymap.set('n', [[<leader>k]], function()
local lsp_methods = require('vim.lsp.protocol').Methods
local csharp_ls = vim
.iter(vim.lsp.get_clients {
bufnr = 0,
method = lsp_methods.textDocument_formatting,
})
:find(function(client) return client.name == 'csharp_ls' end)
if not csharp_ls then
vim.lsp.buf.format { async = false, timeout_ms = 5000, bufnr = 0 }
end
end)