Check lsp client capabilties before formatting
This commit is contained in:
parent
030f887734
commit
a351ad691b
2 changed files with 6 additions and 2 deletions
|
|
@ -18,7 +18,11 @@
|
|||
- common
|
||||
tasks:
|
||||
- import_tasks: 'tasks/dotfiles.yml'
|
||||
- import_tasks: 'tasks/neovim.yml'
|
||||
|
||||
- name: Include neovim tasks
|
||||
import_tasks: 'tasks/neovim.yml'
|
||||
tags: neovim
|
||||
|
||||
- name: gather package facts
|
||||
package_facts:
|
||||
manager: pacman
|
||||
|
|
|
|||
|
|
@ -159,7 +159,6 @@ vim.diagnostic.config({
|
|||
|
||||
local enable_formatting = os.getenv("ENABLE_FORMATTING", False)
|
||||
|
||||
-- TODO: fix error message: [LSP] Format request failed, no matching language servers.
|
||||
-- format buffers before saving for specific LSPs
|
||||
if (enable_formatting) then
|
||||
local excluded_clients = { 'pyright' }
|
||||
|
|
@ -172,6 +171,7 @@ if (enable_formatting) then
|
|||
callback = function()
|
||||
vim.lsp.buf.format {
|
||||
filter = function(client)
|
||||
if not client.supports_method('textDocument/formatting') then return end
|
||||
return not vim.list_contains(excluded_clients, client.name)
|
||||
end,
|
||||
async = false,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue