summaryrefslogtreecommitdiff
path: root/lua
diff options
context:
space:
mode:
Diffstat (limited to 'lua')
-rw-r--r--lua/lvim/core/info.lua72
-rw-r--r--lua/lvim/interface/popup.lua4
-rw-r--r--lua/lvim/lsp/utils.lua8
3 files changed, 57 insertions, 27 deletions
diff --git a/lua/lvim/core/info.lua b/lua/lvim/core/info.lua
index 7577f296..da295b95 100644
--- a/lua/lvim/core/info.lua
+++ b/lua/lvim/core/info.lua
@@ -14,7 +14,7 @@ local text = require "lvim.interface.text"
local lsp_utils = require "lvim.lsp.utils"
local function str_list(list)
- return fmt("[ %s ]", table.concat(list, ", "))
+ return #list == 1 and list[1] or fmt("[%s]", table.concat(list, ", "))
end
local function make_formatters_info(ft)
@@ -73,21 +73,23 @@ local function tbl_set_highlight(terms, highlight_group)
end
local function make_client_info(client)
+ if client.name == "null-ls" then
+ return
+ end
local client_enabled_caps = lsp_utils.get_client_capabilities(client.id)
local name = client.name
local id = client.id
local filetypes = lsp_utils.get_supported_filetypes(name)
- local document_formatting = client.resolved_capabilities.document_formatting
- local attached_buffers_list = table.concat(vim.lsp.get_buffers_by_client_id(client.id), ", ")
+ local attached_buffers_list = str_list(vim.lsp.get_buffers_by_client_id(client.id))
local client_info = {
- fmt("* Name: %s", name),
- fmt("* Id: [%s]", tostring(id)),
- fmt("* filetype(s): [%s]", table.concat(filetypes, ", ")),
- fmt("* Attached buffers: [%s]", tostring(attached_buffers_list)),
- fmt("* Supports formatting: %s", tostring(document_formatting)),
+ fmt("* name: %s", name),
+ fmt("* id: %s", tostring(id)),
+ fmt("* supported filetype(s): %s", str_list(filetypes)),
+ fmt("* attached buffers: %s", tostring(attached_buffers_list)),
+ fmt("* root_dir pattern: %s", tostring(attached_buffers_list)),
}
if not vim.tbl_isempty(client_enabled_caps) then
- local caps_text = "* Capabilities list: "
+ local caps_text = "* capabilities: "
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)
@@ -98,8 +100,27 @@ local function make_client_info(client)
return client_info
end
+local function make_override_info(ft)
+ local available = lsp_utils.get_supported_servers_per_filetype(ft)
+ local overridden = vim.tbl_filter(function(name)
+ return vim.tbl_contains(available, name)
+ end, lvim.lsp.override)
+
+ local info_lines = { "" }
+ if #overridden == 0 then
+ return info_lines
+ end
+
+ info_lines = {
+ fmt("Overridden %s server(s)", ft),
+ fmt("* list: %s", str_list(overridden)),
+ }
+
+ return info_lines
+end
+
function M.toggle_popup(ft)
- local clients = lsp_utils.get_active_clients_by_ft(ft)
+ local clients = vim.lsp.get_active_clients(ft)
local client_names = {}
local bufnr = vim.api.nvim_get_current_buf()
local ts_active_buffers = vim.tbl_keys(vim.treesitter.highlighter.active)
@@ -111,26 +132,26 @@ function M.toggle_popup(ft)
return status
end
local header = {
- fmt("Detected filetype: %s", ft),
- fmt("Current buffer number: [%s]", bufnr),
- }
-
- local ts_info = {
- "Treesitter info",
- fmt("* current buffer: %s", is_treesitter_active()),
- fmt("* list: [%s]", table.concat(ts_active_buffers, ", ")),
+ "Buffer info",
+ fmt("* filetype: %s", ft),
+ fmt("* bufnr: %s", bufnr),
+ fmt("* treesitter status: %s", is_treesitter_active()),
}
local lsp_info = {
- "Language Server Protocol (LSP) info",
- fmt "* Active server(s):",
+ "Active client(s)",
}
for _, client in pairs(clients) do
- vim.list_extend(lsp_info, make_client_info(client))
+ local client_info = make_client_info(client)
+ if client_info then
+ vim.list_extend(lsp_info, client_info)
+ end
table.insert(client_names, client.name)
end
+ local override_info = make_override_info(ft)
+
local formatters_info = make_formatters_info(ft)
local linters_info = make_linters_info(ft)
@@ -146,10 +167,10 @@ function M.toggle_popup(ft)
{ "" },
header,
{ "" },
- ts_info,
- { "" },
lsp_info,
{ "" },
+ override_info,
+ { "" },
formatters_info,
{ "" },
linters_info,
@@ -165,8 +186,9 @@ function M.toggle_popup(ft)
local function set_syntax_hl()
vim.cmd [[highlight LvimInfoIdentifier gui=bold]]
vim.cmd [[highlight link LvimInfoHeader Type]]
- vim.fn.matchadd("LvimInfoHeader", "Treesitter info")
- vim.fn.matchadd("LvimInfoHeader", "Language Server Protocol (LSP) info")
+ vim.fn.matchadd("LvimInfoHeader", "Buffer info")
+ vim.fn.matchadd("LvimInfoHeader", "Active client(s)")
+ vim.fn.matchadd("LvimInfoHeader", fmt("Overridden %s server(s)", ft))
vim.fn.matchadd("LvimInfoHeader", "Formatters info")
vim.fn.matchadd("LvimInfoHeader", "Linters info")
vim.fn.matchadd("LvimInfoHeader", "Code actions info")
diff --git a/lua/lvim/interface/popup.lua b/lua/lvim/interface/popup.lua
index 6587f5d4..b767f609 100644
--- a/lua/lvim/interface/popup.lua
+++ b/lua/lvim/interface/popup.lua
@@ -48,11 +48,11 @@ function Popup:display(content_provider)
)
local lines = content_provider(self.layout)
- vim.api.nvim_buf_set_lines(self.bufnr, 0, -1, false, lines)
+ vim.api.nvim_buf_set_lines(self.bufnr or 0, 0, -1, false, lines)
-- window options
for key, value in pairs(self.win_opts) do
- vim.api.nvim_win_set_option(self.win_id, key, value)
+ vim.api.nvim_win_set_option(self.win_id or 0, key, value)
end
-- buffer options
diff --git a/lua/lvim/lsp/utils.lua b/lua/lvim/lsp/utils.lua
index 47b1c8ba..ebc682e5 100644
--- a/lua/lvim/lsp/utils.lua
+++ b/lua/lvim/lsp/utils.lua
@@ -66,6 +66,14 @@ function M.get_supported_filetypes(server_name)
return requested_server:get_supported_filetypes()
end
+---Get supported servers per filetype
+---@param filetype string
+---@return table list of names of supported servers
+function M.get_supported_servers_per_filetype(filetype)
+ local filetype_server_map = require "nvim-lsp-installer._generated.filetype_map"
+ return filetype_server_map[filetype]
+end
+
---Get all supported filetypes by nvim-lsp-installer
---@return table supported filestypes as a list of strings
function M.get_all_supported_filetypes()