Skip to content

Commit

Permalink
Merge pull request #41 from lukas-reineke/develop
Browse files Browse the repository at this point in the history
  • Loading branch information
lukas-reineke authored Apr 25, 2022
2 parents 2fcb2c9 + b4a5869 commit 204e699
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
6 changes: 5 additions & 1 deletion doc/format.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@


Author: Lukas Reineke <lukas@reineke.jp>
Version: 2.3.2
Version: 2.3.3

==============================================================================
CONTENTS *lsp-format*
Expand Down Expand Up @@ -121,6 +121,10 @@ sync *lsp-format-sync*
==============================================================================
5. CHANGELOG *lsp-format-changelog*

2.3.3
Use "vim.lsp.log" for logging
Don't attach servers that don't support formatting

2.3.2
Continue with the next client when one client has an error

Expand Down
10 changes: 9 additions & 1 deletion lua/lsp-format/init.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
local log = require "vim.lsp.log"

local M = {
format_options = {},
disabled = false,
Expand Down Expand Up @@ -95,6 +97,12 @@ M.toggle = function(options)
end

M.on_attach = function(client)
if not client.supports_method "textDocument/formatting" then
log.warn(
string.format('"textDocument/formatting" is not supported for %s, not attaching lsp-format', client.name)
)
return
end
local bufnr = vim.api.nvim_get_current_buf()
if M.buffers[bufnr] == nil then
M.buffers[bufnr] = {}
Expand Down Expand Up @@ -125,7 +133,7 @@ M._handler = function(err, result, ctx)
if err ~= nil then
local client = vim.lsp.get_client_by_id(ctx.client_id)
local client_name = client and client.name or string.format("client_id=%d", ctx.client_id)
vim.api.nvim_err_write(string.format("%s: %d: %s", client_name, err.code, err.message))
log.error(string.format("%s: %d: %s", client_name, err.code, err.message))
M._next()
return
end
Expand Down

0 comments on commit 204e699

Please sign in to comment.