summaryrefslogtreecommitdiff
path: root/lua/lvim
diff options
context:
space:
mode:
authorkylo252 <[email protected]>2022-10-06 08:55:06 +0200
committerGitHub <[email protected]>2022-10-06 06:55:06 +0000
commit9def60f1dd09ac2244672b8570092229977b43b4 (patch)
tree44bf396deaa7ce20ebc789f95bd03494d2393488 /lua/lvim
parent0d578ab152708019ad10cb7b21fc4a1cb0105a1a (diff)
feat: lock new installations to nvim 0.8+ (#3111)
Diffstat (limited to 'lua/lvim')
-rw-r--r--lua/lvim/bootstrap.lua4
-rw-r--r--lua/lvim/lsp/utils.lua57
-rw-r--r--lua/lvim/utils/hooks.lua4
3 files changed, 10 insertions, 55 deletions
diff --git a/lua/lvim/bootstrap.lua b/lua/lvim/bootstrap.lua
index b803cfa6..5d980498 100644
--- a/lua/lvim/bootstrap.lua
+++ b/lua/lvim/bootstrap.lua
@@ -1,7 +1,7 @@
local M = {}
-if vim.fn.has "nvim-0.7" ~= 1 then
- vim.notify("Please upgrade your Neovim base installation. Lunarvim requires v0.7+", vim.log.levels.WARN)
+if vim.fn.has "nvim-0.8" ~= 1 then
+ vim.notify("Please upgrade your Neovim base installation. Lunarvim requires v0.8+", vim.log.levels.WARN)
vim.wait(5000, function()
return false
end)
diff --git a/lua/lvim/lsp/utils.lua b/lua/lvim/lsp/utils.lua
index 53571f20..44e4f5f7 100644
--- a/lua/lvim/lsp/utils.lua
+++ b/lua/lvim/lsp/utils.lua
@@ -23,25 +23,14 @@ function M.get_active_clients_by_ft(filetype)
end
function M.get_client_capabilities(client_id)
- local client
- if not client_id then
- local buf_clients = vim.lsp.buf_get_clients()
- for _, buf_client in pairs(buf_clients) do
- if buf_client.name ~= "null-ls" then
- client = buf_client
- break
- end
- end
- else
- client = vim.lsp.get_client_by_id(tonumber(client_id))
- end
+ local client = vim.lsp.get_client_by_id(tonumber(client_id))
if not client then
- error "Unable to determine client_id"
+ Log:warn("Unable to determine client from client_id: " .. client_id)
return
end
local enabled_caps = {}
- for capability, status in pairs(client.server_capabilities or client.resolved_capabilities) do
+ for capability, status in pairs(client.server_capabilities) do
if status == true then
table.insert(enabled_caps, capability)
end
@@ -178,47 +167,13 @@ function M.format_filter(client)
end
end
----Provide vim.lsp.buf.format for nvim <0.8
----@param opts table
+---Simple wrapper for vim.lsp.buf.format() to provide defaults
+---@param opts table|nil
function M.format(opts)
opts = opts or {}
opts.filter = opts.filter or M.format_filter
- if vim.lsp.buf.format then
- return vim.lsp.buf.format(opts)
- end
-
- local bufnr = opts.bufnr or vim.api.nvim_get_current_buf()
-
- ---@type table|nil
- local clients = vim.lsp.get_active_clients {
- id = opts.id,
- bufnr = bufnr,
- name = opts.name,
- }
-
- if opts.filter then
- clients = vim.tbl_filter(opts.filter, clients)
- end
-
- clients = vim.tbl_filter(function(client)
- return client.supports_method "textDocument/formatting"
- end, clients)
-
- if #clients == 0 then
- vim.notify_once "[LSP] Format request failed, no matching language servers."
- end
-
- local timeout_ms = opts.timeout_ms or 1000
- for _, client in pairs(clients) do
- local params = vim.lsp.util.make_formatting_params(opts.formatting_options)
- local result, err = client.request_sync("textDocument/formatting", params, timeout_ms, bufnr)
- if result and result.result then
- vim.lsp.util.apply_text_edits(result.result, bufnr, client.offset_encoding)
- elseif err then
- vim.notify(string.format("[LSP][%s] %s", client.name, err), vim.log.levels.WARN)
- end
- end
+ return vim.lsp.buf.format(opts)
end
return M
diff --git a/lua/lvim/utils/hooks.lua b/lua/lvim/utils/hooks.lua
index 4101c573..ce4335a9 100644
--- a/lua/lvim/utils/hooks.lua
+++ b/lua/lvim/utils/hooks.lua
@@ -52,8 +52,8 @@ end
function M.run_post_update()
Log:debug "Starting post-update hook"
- if vim.fn.has "nvim-0.7" ~= 1 then
- local compat_tag = "1.1.3"
+ if vim.fn.has "nvim-0.8" ~= 1 then
+ local compat_tag = "1.1.4"
vim.notify(
"Please upgrade your Neovim base installation. Newer version of Lunarvim requires v0.7+",
vim.log.levels.WARN