summaryrefslogtreecommitdiff
path: root/.config/nvim/lua/core/info.lua
diff options
context:
space:
mode:
authorGustaf Rydholm <gustaf.rydholm@gmail.com>2021-10-05 08:46:35 +0200
committerGustaf Rydholm <gustaf.rydholm@gmail.com>2021-10-05 08:46:35 +0200
commit77cdf208765ad351e48724ed5ad57e55703eca61 (patch)
tree7f19757b255ab66895d9240a5aca77a35cef8aac /.config/nvim/lua/core/info.lua
parent4fd170aa9d55b7bcd1f0a9445c9e136b560e3220 (diff)
Add major update to LSP from lunarvim
Diffstat (limited to '.config/nvim/lua/core/info.lua')
-rw-r--r--.config/nvim/lua/core/info.lua107
1 files changed, 45 insertions, 62 deletions
diff --git a/.config/nvim/lua/core/info.lua b/.config/nvim/lua/core/info.lua
index 83e3542..bb53644 100644
--- a/.config/nvim/lua/core/info.lua
+++ b/.config/nvim/lua/core/info.lua
@@ -10,6 +10,7 @@ local M = {
}
local fmt = string.format
+local text = require "interface.text"
local function str_list(list)
return fmt("[ %s ]", table.concat(list, ", "))
@@ -73,21 +74,32 @@ local function tbl_set_highlight(terms, highlight_group)
end
end
+local function make_client_info(client)
+ local client_enabled_caps = require("lsp.utils").get_ls_capabilities(client.id)
+ local name = client.name
+ local id = client.id
+ local document_formatting = client.resolved_capabilities.document_formatting
+ local client_info = {
+ fmt("* Name: %s", name),
+ fmt("* Id: %s", tostring(id)),
+ fmt("* Supports formatting: %s", tostring(document_formatting)),
+ }
+ if not vim.tbl_isempty(client_enabled_caps) then
+ local caps_text = "* Capabilities list: "
+ local caps_text_len = caps_text:len()
+ local enabled_caps = text.format_table(client_enabled_caps, 3, " | ")
+ enabled_caps = text.shift_right(enabled_caps, caps_text_len)
+ enabled_caps[1] = fmt("%s%s", caps_text, enabled_caps[1]:sub(caps_text_len + 1))
+ vim.list_extend(client_info, enabled_caps)
+ end
+
+ return client_info
+end
+
function M.toggle_popup(ft)
local lsp_utils = require "lsp.utils"
- local client = lsp_utils.get_active_client_by_ft(ft)
- local is_client_active = false
- local client_enabled_caps = {}
- local client_name = ""
- local client_id = 0
- local document_formatting = false
- if client ~= nil then
- is_client_active = not client.is_stopped()
- client_enabled_caps = require("lsp").get_ls_capabilities(client.id)
- client_name = client.name
- client_id = client.id
- document_formatting = client.resolved_capabilities.document_formatting
- end
+ local clients = lsp_utils.get_active_client_by_ft(ft)
+ local client_names = {}
local header = {
fmt("Detected filetype: %s", ft),
@@ -97,23 +109,23 @@ function M.toggle_popup(ft)
),
}
- local text = require "interface.text"
local lsp_info = {
"Language Server Protocol (LSP) info",
- fmt("* Associated server: %s", client_name),
- fmt("* Active: %s (id: %d)", tostring(is_client_active), client_id),
- fmt("* Supports formatting: %s", tostring(document_formatting)),
+ fmt "* Associated server(s):",
}
- if not vim.tbl_isempty(client_enabled_caps) then
- local caps_text = "* Capabilities list: "
- local caps_text_len = caps_text:len()
- local enabled_caps = text.format_table(client_enabled_caps, 3, " | ")
- enabled_caps = text.shift_left(enabled_caps, caps_text_len)
- enabled_caps[1] = fmt("%s%s", caps_text, enabled_caps[1]:sub(caps_text_len + 1))
- vim.list_extend(lsp_info, enabled_caps)
+
+ for _, client in pairs(clients) do
+ vim.list_extend(lsp_info, make_client_info(client))
+ table.insert(client_names, client.name)
end
- local null_ls = require "lsp.null-ls"
- local registered_providers = null_ls.list_supported_provider_names(ft)
+
+ local null_formatters = require "lsp.null-ls.formatters"
+ local null_linters = require "lsp.null-ls.linters"
+ local registered_formatters = null_formatters.list_supported_names(ft)
+ local registered_linters = null_linters.list_supported_names(ft)
+ local registered_providers = {}
+ vim.list_extend(registered_providers, registered_formatters)
+ vim.list_extend(registered_providers, registered_linters)
local registered_count = vim.tbl_count(registered_providers)
local null_ls_info = {
"Formatters and linters",
@@ -124,30 +136,6 @@ function M.toggle_popup(ft)
),
}
- local null_formatters = require "lsp.null-ls.formatters"
- local missing_formatters = null_formatters.list_unsupported_names(ft)
- local missing_formatters_status = {}
- if not vim.tbl_isempty(missing_formatters) then
- missing_formatters_status = {
- fmt(
- "* Missing formatters: %s",
- table.concat(missing_formatters, "  , ") .. "  "
- ),
- }
- end
-
- local null_linters = require "lsp.null-ls.linters"
- local missing_linters = null_linters.list_unsupported_names(ft)
- local missing_linters_status = {}
- if not vim.tbl_isempty(missing_linters) then
- missing_linters_status = {
- fmt(
- "* Missing linters: %s",
- table.concat(missing_linters, "  , ") .. "  "
- ),
- }
- end
-
local content_provider = function(popup)
local content = {}
@@ -160,8 +148,6 @@ function M.toggle_popup(ft)
lsp_info,
{ "" },
null_ls_info,
- missing_formatters_status,
- missing_linters_status,
{ "" },
{ "" },
get_formatter_suggestion_msg(ft),
@@ -172,21 +158,18 @@ function M.toggle_popup(ft)
vim.list_extend(content, section)
end
- return text.align(popup, content, 0.5)
+ return text.align_left(popup, content, 0.5)
end
local function set_syntax_hl()
- vim.cmd [[highlight NvimInfoIdentifier gui=bold]]
- vim.cmd [[highlight link NvimInfoHeader Type]]
- vim.cmd [[let m=matchadd("NvimInfoHeader", "Language Server Protocol (LSP) info")]]
- vim.cmd [[let m=matchadd("NvimInfoHeader", "Formatters and linters")]]
- vim.cmd('let m=matchadd("NvimInfoIdentifier", " ' .. ft .. '$")')
+ vim.cmd [[highlight nvimInfoIdentifier gui=bold]]
+ vim.cmd [[highlight link nvimInfoHeader Type]]
+ vim.cmd [[let m=matchadd("nvimInfoHeader", "Language Server Protocol (LSP) info")]]
+ vim.cmd [[let m=matchadd("nvimInfoHeader", "Formatters and linters")]]
+ vim.cmd('let m=matchadd("nvimInfoIdentifier", " ' .. ft .. '$")')
vim.cmd 'let m=matchadd("string", "true")'
vim.cmd 'let m=matchadd("error", "false")'
- tbl_set_highlight(registered_providers, "NvimInfoIdentifier")
- tbl_set_highlight(missing_formatters, "NvimInfoIdentifier")
- tbl_set_highlight(missing_linters, "NvimInfoIdentifier")
- vim.cmd('let m=matchadd("NvimInfoIdentifier", "' .. client_name .. '")')
+ tbl_set_highlight(registered_providers, "nvimInfoIdentifier")
end
local Popup = require("interface.popup"):new {