mirror of
https://github.com/LunarVim/LunarVim.git
synced 2025-09-01 16:26:16 +02:00
feat: full compatibility with neovim v0.6 (#2037)
This commit is contained in:
parent
38a1724340
commit
6770808bec
6 changed files with 69 additions and 65 deletions
|
@ -4,16 +4,31 @@ return {
|
||||||
signs = {
|
signs = {
|
||||||
active = true,
|
active = true,
|
||||||
values = {
|
values = {
|
||||||
{ name = "LspDiagnosticsSignError", text = "" },
|
{ name = "DiagnosticSignError", text = "" },
|
||||||
{ name = "LspDiagnosticsSignWarning", text = "" },
|
{ name = "DiagnosticSignWarn", text = "" },
|
||||||
{ name = "LspDiagnosticsSignHint", text = "" },
|
{ name = "DiagnosticSignHint", text = "" },
|
||||||
{ name = "LspDiagnosticsSignInformation", text = "" },
|
{ name = "DiagnosticSignInfo", text = "" },
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
virtual_text = true,
|
virtual_text = true,
|
||||||
update_in_insert = false,
|
update_in_insert = false,
|
||||||
underline = true,
|
underline = true,
|
||||||
severity_sort = true,
|
severity_sort = true,
|
||||||
|
float = {
|
||||||
|
focusable = false,
|
||||||
|
style = "minimal",
|
||||||
|
border = "rounded",
|
||||||
|
source = "always",
|
||||||
|
header = "",
|
||||||
|
prefix = "",
|
||||||
|
format = function(d)
|
||||||
|
local t = vim.deepcopy(d)
|
||||||
|
if d.code then
|
||||||
|
t.message = string.format("%s [%s]", t.message, t.code):gsub("1. ", "")
|
||||||
|
end
|
||||||
|
return t.message
|
||||||
|
end,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
document_highlight = true,
|
document_highlight = true,
|
||||||
code_lens_refresh = true,
|
code_lens_refresh = true,
|
||||||
|
|
|
@ -9,42 +9,10 @@ function M.setup()
|
||||||
underline = lvim.lsp.diagnostics.underline,
|
underline = lvim.lsp.diagnostics.underline,
|
||||||
update_in_insert = lvim.lsp.diagnostics.update_in_insert,
|
update_in_insert = lvim.lsp.diagnostics.update_in_insert,
|
||||||
severity_sort = lvim.lsp.diagnostics.severity_sort,
|
severity_sort = lvim.lsp.diagnostics.severity_sort,
|
||||||
|
float = lvim.lsp.diagnostics.float,
|
||||||
}
|
}
|
||||||
if vim.fn.has "nvim-0.5.1" > 0 then
|
if vim.fn.has "nvim-0.6" == 1 then
|
||||||
vim.lsp.handlers["textDocument/publishDiagnostics"] = function(_, result, ctx, _)
|
vim.diagnostic.config(config)
|
||||||
local uri = result.uri
|
|
||||||
local bufnr = vim.uri_to_bufnr(uri)
|
|
||||||
if not bufnr then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
local diagnostics = result.diagnostics
|
|
||||||
local ok, vim_diag = pcall(require, "vim.diagnostic")
|
|
||||||
if ok then
|
|
||||||
-- FIX: why can't we just use vim.diagnostic.get(buf_id)?
|
|
||||||
config.signs = true
|
|
||||||
for i, diagnostic in ipairs(diagnostics) do
|
|
||||||
local rng = diagnostic.range
|
|
||||||
diagnostics[i].lnum = rng["start"].line
|
|
||||||
diagnostics[i].end_lnum = rng["end"].line
|
|
||||||
diagnostics[i].col = rng["start"].character
|
|
||||||
diagnostics[i].end_col = rng["end"].character
|
|
||||||
end
|
|
||||||
local namespace = vim.lsp.diagnostic.get_namespace(ctx.client_id)
|
|
||||||
|
|
||||||
vim_diag.set(namespace, bufnr, diagnostics, config)
|
|
||||||
if not vim.api.nvim_buf_is_loaded(bufnr) then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
vim_diag.show(namespace, bufnr, diagnostics, config)
|
|
||||||
else
|
|
||||||
vim.lsp.diagnostic.save(diagnostics, bufnr, ctx.client_id)
|
|
||||||
if not vim.api.nvim_buf_is_loaded(bufnr) then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
vim.lsp.diagnostic.display(diagnostics, bufnr, ctx.client_id, config)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
else
|
else
|
||||||
vim.lsp.handlers["textDocument/publishDiagnostics"] = function(_, _, params, client_id, _)
|
vim.lsp.handlers["textDocument/publishDiagnostics"] = function(_, _, params, client_id, _)
|
||||||
local uri = params.uri
|
local uri = params.uri
|
||||||
|
@ -60,27 +28,29 @@ function M.setup()
|
||||||
end
|
end
|
||||||
vim.lsp.diagnostic.display(diagnostics, bufnr, client_id, config)
|
vim.lsp.diagnostic.display(diagnostics, bufnr, client_id, config)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
vim.lsp.handlers["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, {
|
||||||
|
border = lvim.lsp.popup_border,
|
||||||
|
})
|
||||||
|
|
||||||
|
vim.lsp.handlers["textDocument/signatureHelp"] = vim.lsp.with(vim.lsp.handlers.signature_help, {
|
||||||
|
border = lvim.lsp.popup_border,
|
||||||
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
vim.lsp.handlers["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, {
|
|
||||||
border = lvim.lsp.popup_border,
|
|
||||||
})
|
|
||||||
|
|
||||||
vim.lsp.handlers["textDocument/signatureHelp"] = vim.lsp.with(vim.lsp.handlers.signature_help, {
|
|
||||||
border = lvim.lsp.popup_border,
|
|
||||||
})
|
|
||||||
end
|
|
||||||
|
|
||||||
local function split_by_chunk(text, chunkSize)
|
|
||||||
local s = {}
|
|
||||||
for i = 1, #text, chunkSize do
|
|
||||||
s[#s + 1] = text:sub(i, i + chunkSize - 1)
|
|
||||||
end
|
|
||||||
return s
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function M.show_line_diagnostics()
|
function M.show_line_diagnostics()
|
||||||
-- TODO: replace all this with vim.diagnostic.show_position_diagnostics()
|
if vim.fn.has "nvim-0.6" == 1 then
|
||||||
|
return vim.diagnostic.open_float(0, { scope = "line" })
|
||||||
|
end
|
||||||
|
|
||||||
|
local function split_by_chunk(text, chunkSize)
|
||||||
|
local s = {}
|
||||||
|
for i = 1, #text, chunkSize do
|
||||||
|
s[#s + 1] = text:sub(i, i + chunkSize - 1)
|
||||||
|
end
|
||||||
|
return s
|
||||||
|
end
|
||||||
local diagnostics = vim.lsp.diagnostic.get_line_diagnostics()
|
local diagnostics = vim.lsp.diagnostic.get_line_diagnostics()
|
||||||
local severity_highlight = {
|
local severity_highlight = {
|
||||||
"LspDiagnosticsFloatingError",
|
"LspDiagnosticsFloatingError",
|
||||||
|
|
|
@ -137,10 +137,10 @@ function M.get_common_opts()
|
||||||
end
|
end
|
||||||
|
|
||||||
local LSP_DEPRECATED_SIGN_MAP = {
|
local LSP_DEPRECATED_SIGN_MAP = {
|
||||||
["LspDiagnosticsSignError"] = "DiagnosticSignError",
|
["DiagnosticSignError"] = "LspDiagnosticsSignError",
|
||||||
["LspDiagnosticsSignWarning"] = "DiagnosticSignWarn",
|
["DiagnosticSignWarn"] = "LspDiagnosticsSignWarning",
|
||||||
["LspDiagnosticsSignHint"] = "DiagnosticSignHint",
|
["DiagnosticSignHint"] = "LspDiagnosticsSignHint",
|
||||||
["LspDiagnosticsSignInformation"] = "DiagnosticSignInfo",
|
["DiagnosticSignInfo"] = "LspDiagnosticsSignInformation",
|
||||||
}
|
}
|
||||||
|
|
||||||
function M.setup()
|
function M.setup()
|
||||||
|
@ -151,11 +151,11 @@ function M.setup()
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local is_neovim_nightly = vim.fn.has "nvim-0.5.1" > 0
|
local is_neovim_5 = vim.fn.has "nvim-0.6" ~= 1
|
||||||
|
|
||||||
for _, sign in ipairs(lvim.lsp.diagnostics.signs.values) do
|
for _, sign in ipairs(lvim.lsp.diagnostics.signs.values) do
|
||||||
local lsp_sign_name = LSP_DEPRECATED_SIGN_MAP[sign.name]
|
local lsp_sign_name = LSP_DEPRECATED_SIGN_MAP[sign.name]
|
||||||
if is_neovim_nightly and lsp_sign_name then
|
if is_neovim_5 and lsp_sign_name then
|
||||||
vim.fn.sign_define(lsp_sign_name, { texthl = lsp_sign_name, text = sign.text, numhl = lsp_sign_name })
|
vim.fn.sign_define(lsp_sign_name, { texthl = lsp_sign_name, text = sign.text, numhl = lsp_sign_name })
|
||||||
end
|
end
|
||||||
vim.fn.sign_define(sign.name, { texthl = sign.name, text = sign.text, numhl = sign.name })
|
vim.fn.sign_define(sign.name, { texthl = sign.name, text = sign.text, numhl = sign.name })
|
||||||
|
|
|
@ -134,7 +134,7 @@ return {
|
||||||
{
|
{
|
||||||
"nvim-treesitter/nvim-treesitter",
|
"nvim-treesitter/nvim-treesitter",
|
||||||
commit = commit.treesitter,
|
commit = commit.treesitter,
|
||||||
branch = "0.5-compat",
|
branch = vim.fn.has "nvim-0.6" == 1 and "master" or "0.5-compat",
|
||||||
-- run = ":TSUpdate",
|
-- run = ":TSUpdate",
|
||||||
config = function()
|
config = function()
|
||||||
require("lvim.core.treesitter").setup()
|
require("lvim.core.treesitter").setup()
|
||||||
|
|
|
@ -7,7 +7,9 @@ local in_headless = #vim.api.nvim_list_uis() == 0
|
||||||
function M.run_pre_update()
|
function M.run_pre_update()
|
||||||
Log:debug "Starting pre-update hook"
|
Log:debug "Starting pre-update hook"
|
||||||
_G.__luacache.clear_cache()
|
_G.__luacache.clear_cache()
|
||||||
vim.cmd "LspStop"
|
if package.loaded["lspconfig"] then
|
||||||
|
vim.cmd [[ LspStop ]]
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
---Reset any startup cache files used by Packer and Impatient
|
---Reset any startup cache files used by Packer and Impatient
|
||||||
|
@ -34,9 +36,14 @@ function M.run_post_update()
|
||||||
|
|
||||||
if not in_headless then
|
if not in_headless then
|
||||||
vim.schedule(function()
|
vim.schedule(function()
|
||||||
|
if package.loaded["nvim-treesitter"] then
|
||||||
|
vim.cmd [[ TSUpdateSync ]]
|
||||||
|
end
|
||||||
-- TODO: add a changelog
|
-- TODO: add a changelog
|
||||||
vim.notify("Update complete", vim.log.levels.INFO)
|
vim.notify("Update complete", vim.log.levels.INFO)
|
||||||
vim.cmd "LspRestart"
|
if package.loaded["lspconfig"] then
|
||||||
|
vim.cmd [[ LspRestart ]]
|
||||||
|
end
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -174,6 +174,17 @@ function print_missing_dep_msg() {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function check_neovim_min_version() {
|
||||||
|
# TODO: consider locking the requirement to 0.6+
|
||||||
|
local verify_version_cmd='if !has("nvim-0.5.1") | cquit | else | quit | endif'
|
||||||
|
|
||||||
|
# exit with an error if min_version not found
|
||||||
|
if ! nvim --headless -u NONE -c "$verify_version_cmd"; then
|
||||||
|
echo "[ERROR]: LunarVim requires at least Neovim v0.5.1 or higher"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
function check_system_deps() {
|
function check_system_deps() {
|
||||||
if ! command -v git &>/dev/null; then
|
if ! command -v git &>/dev/null; then
|
||||||
print_missing_dep_msg "git"
|
print_missing_dep_msg "git"
|
||||||
|
@ -183,6 +194,7 @@ function check_system_deps() {
|
||||||
print_missing_dep_msg "neovim"
|
print_missing_dep_msg "neovim"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
check_neovim_min_version
|
||||||
}
|
}
|
||||||
|
|
||||||
function __install_nodejs_deps_npm() {
|
function __install_nodejs_deps_npm() {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue