pull/117/head
ray-x 2 years ago
parent 9143b3a4b9
commit cf3915c331

@ -21,11 +21,13 @@ local on_attach = function(client, bufnr)
local opts = { noremap = true, silent = true }
if _GO_NVIM_CFG.lsp_document_formatting == false then
client.resolved_capabilities.document_formatting = false
-- client.resolved_capabilities.document_formatting = false
client.server_capabilities.documentFormattingProvider = false
end
if _GO_NVIM_CFG.lsp_codelens then
codelens_enabled = client.resolved_capabilities["code_lens"]
-- codelens_enabled = client.resolved_capabilities["code_lens"]
codelens_enabled = client.server_capabilities.codeLensProvider
if not codelens_enabled then
vim.notify("codelens not support by your gopls", vim.lsp.log_levels.WARN)
end
@ -49,6 +51,9 @@ local on_attach = function(client, bufnr)
buf_set_keymap("n", "]d", "<cmd>lua vim.lsp.diagnostic.goto_next()<CR>", opts)
buf_set_keymap("n", "<space>q", "<cmd>lua vim.lsp.diagnostic.set_loclist()<CR>", opts)
if client.server_capabilities.documentFormattingProvider then
buf_set_keymap("n", "<space>ff", "<cmd>lua vim.lsp.buf.formatting()<CR>", opts)
end
if client.resolved_capabilities.document_formatting then
buf_set_keymap("n", "<space>ff", "<cmd>lua vim.lsp.buf.formatting()<CR>", opts)
end

@ -358,29 +358,31 @@ function util.load_plugin(name, modulename)
end
-- deprecated
function util.check_capabilities(feature, client_id)
local clients = vim.lsp.buf_get_clients(client_id or 0)
local supported_client = false
for _, client in pairs(clients) do
util.log(client.resolved_capabilities)
supported_client = client.resolved_capabilities[feature]
if supported_client then
break
end
end
if supported_client then
return true
else
if #clients == 0 then
util.log("LSP: no client attached")
else
util.log("LSP: server does not support " .. feature)
end
return false
end
end
-- function util.check_capabilities(feature, client_id)
-- local clients = vim.lsp.buf_get_clients(client_id or 0)
--
-- local supported_client = false
-- for _, client in pairs(clients) do
-- -- util.log(client.resolved_capabilities)
-- util.log(client.server_capabilities)
-- supported_client = client.resolved_capabilities[feature]
-- supported_client = client.resolved_capabilities[feature]
-- if supported_client then
-- break
-- end
-- end
--
-- if supported_client then
-- return true
-- else
-- if #clients == 0 then
-- util.log("LSP: no client attached")
-- else
-- util.log("LSP: server does not support " .. feature)
-- end
-- return false
-- end
-- end
function util.relative_to_cwd(name)
local rel = vim.fn.isdirectory(name) == 0 and vim.fn.fnamemodify(name, ":h:.") or vim.fn.fnamemodify(name, ":.")

@ -126,7 +126,7 @@ describe("should run gofmt", function()
require("go.format").goimport()
print("workspaces:", vim.inspect(vim.lsp.buf.list_workspace_folders()))
vim.wait(400, function() end)
vim.wait(500, function() end)
vim.cmd([[w]])
local fmt = vim.fn.join(vim.fn.readfile(path), "\n")
print(vim.inspect(fmt))

Loading…
Cancel
Save