push gopls and lsp changes for nvim 0.7

pull/117/head
ray-x 2 years ago
parent 97f0d7e620
commit 5bebe38de0

@ -106,7 +106,8 @@ end
function M.version()
local cache_dir = vim.fn.stdpath("cache")
local path = string.format("%s%sversion.txt", cache_dir, utils.sep())
local gopls = _GO_NVIM_CFG.gopls_cmd or { "gopls" }
local cfg = _GO_NVIM_CFG or {}
local gopls = cfg.gopls_cmd or { "gopls" }
if vim.fn.executable(gopls[1]) == 0 then
vim.notify("gopls not found", vim.log.levels.WARN)

@ -8,13 +8,11 @@ end
if vim.lsp.buf.format == nil then
-- neovim < 0.7 only
log.error("LSP: format is not available")
vim.lsp.buf.format = vim.lsp.buf.formatting
end
local codelens_enabled = false
local on_attach = function(client, bufnr)
local function buf_set_keymap(...)
vim.api.nvim_buf_set_keymap(bufnr, ...)
end
@ -62,8 +60,10 @@ local on_attach = function(client, bufnr)
if client.server_capabilities.documentFormattingProvider then
buf_set_keymap("n", "<space>ff", "<cmd>lua vim.lsp.buf.format({async = true})<CR>", opts)
end
if client.resolved_capabilities.document_formatting then
buf_set_keymap("n", "<space>ff", "<cmd>lua vim.lsp.buf.format({async = true})<CR>", opts)
local vim_version = vim.version().major * 100 + vim.version().minor * 10 + vim.version().patch
if vim_version < 80 and client.resolved_capabilities.document_formatting then
buf_set_keymap("n", "<space>ff", "<cmd>lua vim.lsp.buf.formatting()<CR>", opts)
end
elseif type(_GO_NVIM_CFG.lsp_keymaps) == "function" then
_GO_NVIM_CFG.lsp_keymaps(bufnr)
@ -141,7 +141,7 @@ function M.setup()
return
end
local vim_version = vim.version().minor * 10 + vim.version().patch
local vim_version = vim.version().major * 100 + vim.version().minor * 10 + vim.version().patch
if vim_version < 61 then
vim.notify("LSP: go.nvim requires neovim 0.6.1 or later", vim.log.levels.WARN)

@ -206,6 +206,9 @@ end
local cache_dir = vim.fn.stdpath("cache")
util.log = function(...)
if not _GO_NVIM_CFG then
return
end
if not _GO_NVIM_CFG.verbose then
return
end

Loading…
Cancel
Save