diff options
author | Gustaf Rydholm <gustaf.rydholm@gmail.com> | 2021-11-08 23:13:05 +0100 |
---|---|---|
committer | Gustaf Rydholm <gustaf.rydholm@gmail.com> | 2021-11-08 23:13:05 +0100 |
commit | c9e2adbbc8fd7a5398c8c66d21f0e02dc7b60203 (patch) | |
tree | 274263ba15e0197180af8bb681e22c4780d5de05 /.config/nvim/lua/core/info.lua | |
parent | e4ea22e223bbd6b4091610c6fa093862cbd32f75 (diff) |
Add new lunarvin updates
Diffstat (limited to '.config/nvim/lua/core/info.lua')
-rw-r--r-- | .config/nvim/lua/core/info.lua | 148 |
1 files changed, 73 insertions, 75 deletions
diff --git a/.config/nvim/lua/core/info.lua b/.config/nvim/lua/core/info.lua index cf4387e..d448492 100644 --- a/.config/nvim/lua/core/info.lua +++ b/.config/nvim/lua/core/info.lua @@ -17,55 +17,37 @@ local function str_list(list) return fmt("[ %s ]", table.concat(list, ", ")) end -local function get_formatter_suggestion_msg(ft) - local config = require "config" +local function make_formatters_info(ft) local null_formatters = require "lsp.null-ls.formatters" + local registered_formatters = null_formatters.list_registered_providers(ft) local supported_formatters = null_formatters.list_available(ft) local section = { - " HINT ", - "", - fmt("* List of supported formatters: %s", str_list(supported_formatters)), + "Formatters info", + fmt( + "* Active: %s%s", + table.concat(registered_formatters, " , "), + vim.tbl_count(registered_formatters) > 0 and " " or "" + ), + fmt("* Supported: %s", str_list(supported_formatters)), } - if not vim.tbl_isempty(supported_formatters) then - vim.list_extend(section, { - "* Configured formatter needs to be installed and executable.", - fmt("* Enable installed formatter(s) with following config in %s", config.path), - "", - fmt( - " options.lang.%s.formatters = { { exe = '%s' } }", - ft, - table.concat(supported_formatters, "│") - ), - }) - end - return section end -local function get_linter_suggestion_msg(ft) - local config = require "config" +local function make_linters_info(ft) local null_linters = require "lsp.null-ls.linters" local supported_linters = null_linters.list_available(ft) + local registered_linters = null_linters.list_registered_providers(ft) local section = { - " HINT ", - "", - fmt("* List of supported linters: %s", str_list(supported_linters)), + "Linters info", + fmt( + "* Active: %s%s", + table.concat(registered_linters, " , "), + vim.tbl_count(registered_linters) > 0 and " " or "" + ), + fmt("* Supported: %s", str_list(supported_linters)), } - if not vim.tbl_isempty(supported_linters) then - vim.list_extend(section, { - "* Configured linter needs to be installed and executable.", - fmt("* Enable installed linter(s) with following config in %s", config.path), - "", - fmt( - " options.lang.%s.linters = { { exe = '%s' } }", - ft, - table.concat(supported_linters, "│") - ), - }) - end - return section end @@ -79,14 +61,21 @@ local function make_client_info(client) 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 client_info = { - fmt("* Name: %s", name), - fmt("* Id: %s", tostring(id)), - fmt("* Supports formatting: %s", tostring(document_formatting)), + 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)), } if not vim.tbl_isempty(client_enabled_caps) then - local caps_text = "* Capabilities list: " + 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) @@ -100,18 +89,29 @@ end function M.toggle_popup(ft) local clients = lsp_utils.get_active_clients_by_ft(ft) local client_names = {} - + local bufnr = vim.api.nvim_get_current_buf() + local ts_active_buffers = vim.tbl_keys(vim.treesitter.highlighter.active) + local is_treesitter_active = function() + local status = "inactive" + if vim.tbl_contains(ts_active_buffers, bufnr) then + status = "active" + end + return status + end local header = { - fmt("Detected filetype: %s", ft), - fmt( - "Treesitter active: %s", - tostring(next(vim.treesitter.highlighter.active) ~= nil) - ), + 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, ", ")), } local lsp_info = { "Language Server Protocol (LSP) info", - fmt "* Associated server(s):", + fmt "* Active server(s):", } for _, client in pairs(clients) do @@ -119,22 +119,9 @@ function M.toggle_popup(ft) table.insert(client_names, client.name) end - 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", - fmt( - "* Configured providers: %s%s", - table.concat(registered_providers, " , "), - registered_count > 0 and " " or "" - ), - } + local formatters_info = make_formatters_info(ft) + + local linters_info = make_linters_info(ft) local content_provider = function(popup) local content = {} @@ -145,15 +132,13 @@ function M.toggle_popup(ft) { "" }, header, { "" }, - lsp_info, - { "" }, - null_ls_info, - { "" }, + ts_info, { "" }, - get_formatter_suggestion_msg(ft), + lsp_info, { "" }, + formatters_info, { "" }, - get_linter_suggestion_msg(ft), + linters_info, } do vim.list_extend(content, section) end @@ -162,14 +147,27 @@ function M.toggle_popup(ft) 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", "Treesitter info")]] + vim.cmd [[let m=matchadd("NvimInfoHeader", "Language Server Protocol (LSP) info")]] + vim.cmd [[let m=matchadd("NvimInfoHeader", "Formatters info")]] + vim.cmd [[let m=matchadd("NvimInfoHeader", "Linters info")]] + vim.cmd('let m=matchadd("NvimInfoIdentifier", " ' .. ft .. '$")') vim.cmd 'let m=matchadd("string", "true")' + vim.cmd 'let m=matchadd("string", "active")' + vim.cmd 'let m=matchadd("boolean", "inactive")' + vim.cmd 'let m=matchadd("string", "")' vim.cmd 'let m=matchadd("error", "false")' - tbl_set_highlight(registered_providers, "nvimInfoIdentifier") + -- tbl_set_highlight(registered_providers, "NvimInfoIdentifier") + tbl_set_highlight( + require("lsp.null-ls.formatters").list_available(ft), + "NvimInfoIdentifier" + ) + tbl_set_highlight( + require("lsp.null-ls.linters").list_available(ft), + "NvimInfoIdentifier" + ) end local Popup = require("interface.popup"):new { |