From 47ebd70817c99c657271e399c0b98b920f765f29 Mon Sep 17 00:00:00 2001 From: kylo252 <59826753+kylo252@users.noreply.github.com> Date: Fri, 6 Aug 2021 16:27:19 +0200 Subject: Add LunarVim info panel (Experimental) (#1241) * feat: lunarvim info (Experimental) * Add missing providers info * Use nvim api directly to create the popup * width tweaks --- lua/core/info.lua | 180 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 180 insertions(+) create mode 100644 lua/core/info.lua (limited to 'lua/core/info.lua') diff --git a/lua/core/info.lua b/lua/core/info.lua new file mode 100644 index 00000000..7f8a0a33 --- /dev/null +++ b/lua/core/info.lua @@ -0,0 +1,180 @@ +local M = {} +local u = require "utils" +local null_ls_handler = require "lsp.null-ls" +local indent = " " + +M.banner = { + "", + "", + "⠀⣿⡟⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ ⠀⠀ ⠀⠀⠀ ⠀⠀ ⣺⡿⠀⠀⠀⠀⠀⠀⠀ ⠀⠀⠀", + "⠀⣿⠇⠀⠀⠀⠀⠀⣤⡄⠀⠀⢠⣤⡄⠀.⣠⣤⣤⣤⡀⠀⠀⢀⣤⣤⣤⣤⡄⠀⠀⠀⣤⣄⣤⣤⣤⠀⠀ ⣿⣯ ⣿⡟⠀ ⣤⣤⠀⠀⠀⠀⣠⣤⣤⣤⣄⣤⣤", + "⢠⣿⠀⠀⠀⠀⠀⠀⣿⠃⠀⠀⣸⣿⠁⠀⣿⣿⠉⠀⠈⣿⡇⠀⠀⠛⠋⠀⠀⢹⣿⠀⠀⠀⣿⠏⠀⠸⠿⠃⠀⣿⣿⠀⣰⡟⠀⠀⠀⠀⠀⢸⣿⠀⠀⠀⠀⣿⡟⢸⣿⡇⢀⣿", + "⣸⡇⠀⠀⠀⠀⠀⢸⣿⠀⠀⠀⣿⡟⠀⢠⣿⡇⠀⠀⢰⣿⡇⠀⣰⣾⠟⠛⠛⣻⡇⠀⠀⢸⡿⠀⠀⠀⠀⠀⠀⢻⣿⢰⣿⠀⠀⠀⠀⠀⠀⣾⡇⠀⠀⠀⢸⣿⠇⢸⣿⠀⢸⡏", + "⣿⣧⣤⣤⣤⡄⠀⠘⣿⣤⣤⡤⣿⠇⠀⢸⣿⠁⠀⠀⣼⣿⠀⠀⢿⣿⣤⣤⠔⣿⠃⠀⠀⣾⡇⠀⠀⠀⠀⠀⠀⢸⣿⣿⠋⠀⠀⠀⢠⣤⣤⣿⣥⣤⡄⠀⣼⣿⠀⣸⡏⠀⣿⠃", + "⠉⠉⠉⠉⠉⠁⠀⠀⠈⠉⠉⠀⠉⠀⠀⠈⠉⠀⠀⠀⠉⠉⠀⠀⠀⠉⠉⠁⠈⠉⠀⠀⠀⠉⠀⠀⠀⠀⠀⠀⠀⠈⠉⠉⠀⠀⠀⠀⠈⠉⠉⠉⠉⠉⠁⠀⠉⠁⠀⠉⠁⠀⠉⠀", + "", + "", +} + +local function str_list(list) + return "[ " .. table.concat(list, ", ") .. " ]" +end + +local function get_formatter_suggestion_msg(ft) + local supported_formatters = u.get_supported_formatters_by_filetype(ft) + return { + "-------------------------------------------------------------------", + "", + "  HINT ", + "", + indent .. "* List of supported formatters: " .. str_list(supported_formatters), + "", + indent .. "You can enable a supported formatter by adding this to your config.lua", + "", + indent + .. "lvim.lang." + .. tostring(ft) + .. [[.formatting = { { exe = ']] + .. table.concat(supported_formatters, "|") + .. [[' } }]], + "", + "-------------------------------------------------------------------", + } +end + +local function get_linter_suggestion_msg(ft) + local supported_linters = u.get_supported_linters_by_filetype(ft) + return { + "-------------------------------------------------------------------", + "", + "  HINT ", + "", + indent .. "* List of supported linters: " .. str_list(supported_linters), + "", + indent .. "You can enable a supported linter by adding this to your config.lua", + "", + indent + .. "lvim.lang." + .. tostring(ft) + .. [[.linters = { { exe = ']] + .. table.concat(supported_linters, "|") + .. [[' } }]], + "", + "-------------------------------------------------------------------", + } +end + +---creates an average size popup +---@param buf_lines a list of lines to print +---@param callback could be used to set syntax highlighting rules for example +---@return bufnr buffer number of the created buffer +---@return win_id window ID of the created popup +function M.create_simple_popup(buf_lines, callback) + -- runtime/lua/vim/lsp/util.lua + local bufnr = vim.api.nvim_create_buf(false, true) + local height_percentage = 0.7 + local width_percentage = 0.8 + local row_start_percentage = (1 - height_percentage) / 2 + local col_start_percentage = (1 - width_percentage) / 2 + local opts = {} + opts.relative = "editor" + opts.height = math.ceil(vim.o.lines * height_percentage) + opts.row = math.ceil(vim.o.lines * row_start_percentage) + opts.col = math.floor(vim.o.columns * col_start_percentage) + opts.width = math.floor(vim.o.columns * width_percentage) + opts.border = { + "┌", + "-", + "┐", + "|", + "┘", + "-", + "└", + "|", + } + + local win_id = vim.api.nvim_open_win(bufnr, true, opts) + + vim.api.nvim_win_set_buf(win_id, bufnr) + -- this needs to be window option! + vim.api.nvim_win_set_option(win_id, "number", false) + vim.cmd "setlocal nocursorcolumn" + vim.cmd "setlocal wrap" + -- set buffer options + vim.api.nvim_buf_set_option(bufnr, "filetype", "lspinfo") + vim.lsp.util.close_preview_autocmd({ "BufHidden", "BufLeave" }, win_id) + buf_lines = vim.lsp.util._trim(buf_lines, {}) + vim.api.nvim_buf_set_lines(bufnr, 0, -1, false, buf_lines) + vim.api.nvim_buf_set_option(bufnr, "modifiable", false) + if type(callback) == "function" then + callback() + end + return bufnr, win_id +end + +function M.toggle_popup(ft) + local client = u.get_active_client_by_ft(ft) + local is_client_active = not client.is_stopped() + local client_enabled_caps = require("lsp").get_ls_capabilities(client.id) + local num_caps = vim.tbl_count(client_enabled_caps) + local null_ls_providers = null_ls_handler.get_registered_providers_by_filetype(ft) + + local missing_linters = lvim.lang[ft].linters._failed_requests or {} + local missing_formatters = lvim.lang[ft].formatters._failed_requests or {} + + local buf_lines = {} + vim.list_extend(buf_lines, M.banner) + + local header = { + "Detected filetype is: " .. tostring(ft), + "", + "Treesitter active: " .. tostring(next(vim.treesitter.highlighter.active) ~= nil), + "", + "", + } + vim.list_extend(buf_lines, header) + + local lsp_info = { + "Associated language-server: " .. client.name, + indent .. "* Active: " .. tostring(is_client_active) .. ", id: " .. tostring(client.id), + indent .. "* Formatting support: " .. tostring(client.resolved_capabilities.document_formatting), + indent .. "* Capabilities list: " .. table.concat(vim.list_slice(client_enabled_caps, 1, num_caps / 2), ", "), + indent .. indent .. indent .. table.concat(vim.list_slice(client_enabled_caps, ((num_caps / 2) + 1)), ", "), + "", + } + vim.list_extend(buf_lines, lsp_info) + + local null_ls_info = { + "Configured providers: " .. table.concat(null_ls_providers, "  , ") .. "  ", + "", + } + vim.list_extend(buf_lines, null_ls_info) + + local missing_formatters_status + if vim.tbl_count(missing_formatters) > 0 then + missing_formatters_status = { "Missing formatters: " .. table.concat(missing_formatters, "  , ") .. "  ", "" } + vim.list_extend(buf_lines, missing_formatters_status) + end + + local missing_linters_status + if vim.tbl_count(missing_linters) > 0 then + missing_linters_status = { "Missing linters: " .. table.concat(missing_linters, "  , ") .. "  ", "" } + vim.list_extend(buf_lines, missing_linters_status) + end + + vim.list_extend(buf_lines, get_formatter_suggestion_msg(ft)) + + vim.list_extend(buf_lines, get_linter_suggestion_msg(ft)) + + local function set_syntax_hl() + --TODO: highlighting is either inconsistent or not working :\ + vim.cmd("syntax match Identifier /filetype is: .*\\zs\\<" .. ft .. "\\>/") + vim.cmd("syntax match Identifier /server: .*\\zs\\<" .. client.name .. "\\>/") + vim.cmd("syntax match Identifier /providers: .*\\zs\\<" .. table.concat(null_ls_providers, ", ") .. "\\>/") + vim.cmd("syntax match Identifier /formatters: .*\\zs\\<" .. table.concat(missing_formatters, ", ") .. "\\>/") + vim.cmd("syntax match Identifier /linters: .*\\zs\\<" .. table.concat(missing_linters, ", ") .. "\\>/") + end + + return M.create_simple_popup(buf_lines, set_syntax_hl) +end +return M -- cgit v1.2.3 From 68287877806e1931f4c6f342c3ee0ba47b634737 Mon Sep 17 00:00:00 2001 From: Ahmed Khalf Date: Tue, 10 Aug 2021 18:59:05 +0400 Subject: Fix window borders for lunarvim info (#1280) --- lua/core/info.lua | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'lua/core/info.lua') diff --git a/lua/core/info.lua b/lua/core/info.lua index 7f8a0a33..501f786e 100644 --- a/lua/core/info.lua +++ b/lua/core/info.lua @@ -23,7 +23,7 @@ end local function get_formatter_suggestion_msg(ft) local supported_formatters = u.get_supported_formatters_by_filetype(ft) return { - "-------------------------------------------------------------------", + "───────────────────────────────────────────────────────────────────", "", "  HINT ", "", @@ -35,17 +35,17 @@ local function get_formatter_suggestion_msg(ft) .. "lvim.lang." .. tostring(ft) .. [[.formatting = { { exe = ']] - .. table.concat(supported_formatters, "|") + .. table.concat(supported_formatters, "│") .. [[' } }]], "", - "-------------------------------------------------------------------", + "───────────────────────────────────────────────────────────────────", } end local function get_linter_suggestion_msg(ft) local supported_linters = u.get_supported_linters_by_filetype(ft) return { - "-------------------------------------------------------------------", + "───────────────────────────────────────────────────────────────────", "", "  HINT ", "", @@ -57,10 +57,10 @@ local function get_linter_suggestion_msg(ft) .. "lvim.lang." .. tostring(ft) .. [[.linters = { { exe = ']] - .. table.concat(supported_linters, "|") + .. table.concat(supported_linters, "│") .. [[' } }]], "", - "-------------------------------------------------------------------", + "───────────────────────────────────────────────────────────────────", } end @@ -83,14 +83,14 @@ function M.create_simple_popup(buf_lines, callback) opts.col = math.floor(vim.o.columns * col_start_percentage) opts.width = math.floor(vim.o.columns * width_percentage) opts.border = { - "┌", - "-", - "┐", - "|", - "┘", - "-", - "└", - "|", + "╭", + "─", + "╮", + "│", + "╯", + "─", + "╰", + "│", } local win_id = vim.api.nvim_open_win(bufnr, true, opts) -- cgit v1.2.3 From e7c6275879dfceeedb99b74e3cce9f41e3e22625 Mon Sep 17 00:00:00 2001 From: Pasi Bergman Date: Wed, 11 Aug 2021 08:54:53 +0300 Subject: [Refactor] LunarVim Info UI (#1281) * refactor: lunarvim info ui * refactor: lunarvim info ui - remove close hint, add highlighting * refactor: lunarvim info ui - remove TODO --- lua/core/info.lua | 137 +++++++++++++++++++++++++++++++++--------------------- 1 file changed, 83 insertions(+), 54 deletions(-) (limited to 'lua/core/info.lua') diff --git a/lua/core/info.lua b/lua/core/info.lua index 501f786e..e4c787a2 100644 --- a/lua/core/info.lua +++ b/lua/core/info.lua @@ -4,15 +4,19 @@ local null_ls_handler = require "lsp.null-ls" local indent = " " M.banner = { - "", - "", - "⠀⣿⡟⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ ⠀⠀ ⠀⠀⠀ ⠀⠀ ⣺⡿⠀⠀⠀⠀⠀⠀⠀ ⠀⠀⠀", - "⠀⣿⠇⠀⠀⠀⠀⠀⣤⡄⠀⠀⢠⣤⡄⠀.⣠⣤⣤⣤⡀⠀⠀⢀⣤⣤⣤⣤⡄⠀⠀⠀⣤⣄⣤⣤⣤⠀⠀ ⣿⣯ ⣿⡟⠀ ⣤⣤⠀⠀⠀⠀⣠⣤⣤⣤⣄⣤⣤", - "⢠⣿⠀⠀⠀⠀⠀⠀⣿⠃⠀⠀⣸⣿⠁⠀⣿⣿⠉⠀⠈⣿⡇⠀⠀⠛⠋⠀⠀⢹⣿⠀⠀⠀⣿⠏⠀⠸⠿⠃⠀⣿⣿⠀⣰⡟⠀⠀⠀⠀⠀⢸⣿⠀⠀⠀⠀⣿⡟⢸⣿⡇⢀⣿", - "⣸⡇⠀⠀⠀⠀⠀⢸⣿⠀⠀⠀⣿⡟⠀⢠⣿⡇⠀⠀⢰⣿⡇⠀⣰⣾⠟⠛⠛⣻⡇⠀⠀⢸⡿⠀⠀⠀⠀⠀⠀⢻⣿⢰⣿⠀⠀⠀⠀⠀⠀⣾⡇⠀⠀⠀⢸⣿⠇⢸⣿⠀⢸⡏", - "⣿⣧⣤⣤⣤⡄⠀⠘⣿⣤⣤⡤⣿⠇⠀⢸⣿⠁⠀⠀⣼⣿⠀⠀⢿⣿⣤⣤⠔⣿⠃⠀⠀⣾⡇⠀⠀⠀⠀⠀⠀⢸⣿⣿⠋⠀⠀⠀⢠⣤⣤⣿⣥⣤⡄⠀⣼⣿⠀⣸⡏⠀⣿⠃", - "⠉⠉⠉⠉⠉⠁⠀⠀⠈⠉⠉⠀⠉⠀⠀⠈⠉⠀⠀⠀⠉⠉⠀⠀⠀⠉⠉⠁⠈⠉⠀⠀⠀⠉⠀⠀⠀⠀⠀⠀⠀⠈⠉⠉⠀⠀⠀⠀⠈⠉⠉⠉⠉⠉⠁⠀⠉⠁⠀⠉⠁⠀⠉⠀", - "", + " ", + indent + .. "⠀⣿⡟⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ ⠀⠀ ⠀⠀⠀ ⠀⠀ ⣺⡿⠀⠀⠀⠀⠀⠀⠀ ⠀⠀⠀", + indent + .. "⠀⣿⠇⠀⠀⠀⠀⠀⣤⡄⠀⠀⢠⣤⡄⠀.⣠⣤⣤⣤⡀⠀⠀⢀⣤⣤⣤⣤⡄⠀⠀⠀⣤⣄⣤⣤⣤⠀⠀ ⣿⣯ ⣿⡟⠀ ⣤⣤⠀⠀⠀⠀⣠⣤⣤⣤⣄⣤⣤", + indent + .. "⢠⣿⠀⠀⠀⠀⠀⠀⣿⠃⠀⠀⣸⣿⠁⠀⣿⣿⠉⠀⠈⣿⡇⠀⠀⠛⠋⠀⠀⢹⣿⠀⠀⠀⣿⠏⠀⠸⠿⠃⠀⣿⣿⠀⣰⡟⠀⠀⠀⠀⠀⢸⣿⠀⠀⠀⠀⣿⡟⢸⣿⡇⢀⣿", + indent + .. "⣸⡇⠀⠀⠀⠀⠀⢸⣿⠀⠀⠀⣿⡟⠀⢠⣿⡇⠀⠀⢰⣿⡇⠀⣰⣾⠟⠛⠛⣻⡇⠀⠀⢸⡿⠀⠀⠀⠀⠀⠀⢻⣿⢰⣿⠀⠀⠀⠀⠀⠀⣾⡇⠀⠀⠀⢸⣿⠇⢸⣿⠀⢸⡏", + indent + .. "⣿⣧⣤⣤⣤⡄⠀⠘⣿⣤⣤⡤⣿⠇⠀⢸⣿⠁⠀⠀⣼⣿⠀⠀⢿⣿⣤⣤⠔⣿⠃⠀⠀⣾⡇⠀⠀⠀⠀⠀⠀⢸⣿⣿⠋⠀⠀⠀⢠⣤⣤⣿⣥⣤⡄⠀⣼⣿⠀⣸⡏⠀⣿⠃", + indent + .. "⠉⠉⠉⠉⠉⠁⠀⠀⠈⠉⠉⠀⠉⠀⠀⠈⠉⠀⠀⠀⠉⠉⠀⠀⠀⠉⠉⠁⠈⠉⠀⠀⠀⠉⠀⠀⠀⠀⠀⠀⠀⠈⠉⠉⠀⠀⠀⠀⠈⠉⠉⠉⠉⠉⠁⠀⠉⠁⠀⠉⠁⠀⠉⠀", "", } @@ -23,44 +27,42 @@ end local function get_formatter_suggestion_msg(ft) local supported_formatters = u.get_supported_formatters_by_filetype(ft) return { - "───────────────────────────────────────────────────────────────────", + indent + .. "───────────────────────────────────────────────────────────────────", "", - "  HINT ", + indent .. " HINT ", "", indent .. "* List of supported formatters: " .. str_list(supported_formatters), + indent .. "* Configured formatter needs to be installed and executable.", + indent .. "* Enable installed formatter(s) with following config in ~/.config/lvim/config.lua", "", - indent .. "You can enable a supported formatter by adding this to your config.lua", - "", - indent - .. "lvim.lang." - .. tostring(ft) - .. [[.formatting = { { exe = ']] - .. table.concat(supported_formatters, "│") - .. [[' } }]], + indent .. " lvim.lang." .. tostring(ft) .. [[.formatting = { { exe = ']] .. table.concat( + supported_formatters, + "│" + ) .. [[' } }]], "", - "───────────────────────────────────────────────────────────────────", } end local function get_linter_suggestion_msg(ft) local supported_linters = u.get_supported_linters_by_filetype(ft) return { - "───────────────────────────────────────────────────────────────────", + indent + .. "───────────────────────────────────────────────────────────────────", "", - "  HINT ", + indent .. " HINT ", "", indent .. "* List of supported linters: " .. str_list(supported_linters), - "", - indent .. "You can enable a supported linter by adding this to your config.lua", + indent .. "* Configured linter needs to be installed and executable.", + indent .. "* Enable installed linter(s) with following config in ~/.config/lvim/config.lua", "", indent - .. "lvim.lang." + .. " lvim.lang." .. tostring(ft) .. [[.linters = { { exe = ']] .. table.concat(supported_linters, "│") .. [[' } }]], "", - "───────────────────────────────────────────────────────────────────", } end @@ -72,26 +74,30 @@ end function M.create_simple_popup(buf_lines, callback) -- runtime/lua/vim/lsp/util.lua local bufnr = vim.api.nvim_create_buf(false, true) - local height_percentage = 0.7 + local height_percentage = 0.9 local width_percentage = 0.8 local row_start_percentage = (1 - height_percentage) / 2 local col_start_percentage = (1 - width_percentage) / 2 local opts = {} opts.relative = "editor" - opts.height = math.ceil(vim.o.lines * height_percentage) + opts.height = math.min(math.ceil(vim.o.lines * height_percentage), #buf_lines) opts.row = math.ceil(vim.o.lines * row_start_percentage) opts.col = math.floor(vim.o.columns * col_start_percentage) opts.width = math.floor(vim.o.columns * width_percentage) + opts.style = "minimal" + opts.border = "rounded" + --[[ opts.border = { - "╭", - "─", - "╮", - "│", - "╯", - "─", - "╰", - "│", + lvim.builtin.telescope.defaults.borderchars[5], -- "┌", + lvim.builtin.telescope.defaults.borderchars[3], -- "-", + lvim.builtin.telescope.defaults.borderchars[6], -- "┐", + lvim.builtin.telescope.defaults.borderchars[2], -- "|", + lvim.builtin.telescope.defaults.borderchars[7], -- "┘", + lvim.builtin.telescope.defaults.borderchars[3], -- "-", + lvim.builtin.telescope.defaults.borderchars[8], -- "└", + lvim.builtin.telescope.defaults.borderchars[4], -- "|", } + --]] local win_id = vim.api.nvim_open_win(bufnr, true, opts) @@ -112,6 +118,17 @@ function M.create_simple_popup(buf_lines, callback) return bufnr, win_id end +local function tbl_set_highlight(terms, highlight_group) + if type(terms) ~= "table" then + return + end + + for _, v in pairs(terms) do + print("Add highlight for word: " .. v) + vim.cmd('let m=matchadd("' .. highlight_group .. '", "' .. v .. '")') + end +end + function M.toggle_popup(ft) local client = u.get_active_client_by_ft(ft) local is_client_active = not client.is_stopped() @@ -126,53 +143,65 @@ function M.toggle_popup(ft) vim.list_extend(buf_lines, M.banner) local header = { - "Detected filetype is: " .. tostring(ft), - "", - "Treesitter active: " .. tostring(next(vim.treesitter.highlighter.active) ~= nil), - "", + indent .. "Detected filetype: " .. tostring(ft), + indent .. "Treesitter active: " .. tostring(next(vim.treesitter.highlighter.active) ~= nil), "", } vim.list_extend(buf_lines, header) local lsp_info = { - "Associated language-server: " .. client.name, - indent .. "* Active: " .. tostring(is_client_active) .. ", id: " .. tostring(client.id), - indent .. "* Formatting support: " .. tostring(client.resolved_capabilities.document_formatting), - indent .. "* Capabilities list: " .. table.concat(vim.list_slice(client_enabled_caps, 1, num_caps / 2), ", "), + indent .. "Language Server Protocol (LSP) info", + indent .. "* Associated server: " .. client.name, + indent .. "* Active: " .. tostring(is_client_active) .. " (id: " .. tostring(client.id) .. ")", + indent .. "* Supports formatting: " .. tostring(client.resolved_capabilities.document_formatting), + indent .. "* Capabilities list: " .. table.concat(vim.list_slice(client_enabled_caps, 1, num_caps / 2), ", "), indent .. indent .. indent .. table.concat(vim.list_slice(client_enabled_caps, ((num_caps / 2) + 1)), ", "), "", } vim.list_extend(buf_lines, lsp_info) local null_ls_info = { - "Configured providers: " .. table.concat(null_ls_providers, "  , ") .. "  ", - "", + indent .. "Formatters and linters", + indent .. "* Configured providers: " .. table.concat(null_ls_providers, "  , ") .. "  ", } vim.list_extend(buf_lines, null_ls_info) local missing_formatters_status if vim.tbl_count(missing_formatters) > 0 then - missing_formatters_status = { "Missing formatters: " .. table.concat(missing_formatters, "  , ") .. "  ", "" } + missing_formatters_status = { + indent .. "* Missing formatters: " .. table.concat(missing_formatters, "  , ") .. "  ", + } vim.list_extend(buf_lines, missing_formatters_status) end local missing_linters_status if vim.tbl_count(missing_linters) > 0 then - missing_linters_status = { "Missing linters: " .. table.concat(missing_linters, "  , ") .. "  ", "" } + missing_linters_status = { + indent .. "* Missing linters: " .. table.concat(missing_linters, "  , ") .. "  ", + } vim.list_extend(buf_lines, missing_linters_status) end + vim.list_extend(buf_lines, { "" }) + vim.list_extend(buf_lines, get_formatter_suggestion_msg(ft)) vim.list_extend(buf_lines, get_linter_suggestion_msg(ft)) local function set_syntax_hl() - --TODO: highlighting is either inconsistent or not working :\ - vim.cmd("syntax match Identifier /filetype is: .*\\zs\\<" .. ft .. "\\>/") - vim.cmd("syntax match Identifier /server: .*\\zs\\<" .. client.name .. "\\>/") - vim.cmd("syntax match Identifier /providers: .*\\zs\\<" .. table.concat(null_ls_providers, ", ") .. "\\>/") - vim.cmd("syntax match Identifier /formatters: .*\\zs\\<" .. table.concat(missing_formatters, ", ") .. "\\>/") - vim.cmd("syntax match Identifier /linters: .*\\zs\\<" .. table.concat(missing_linters, ", ") .. "\\>/") + vim.cmd [[highlight LvimInfoIdentifier gui=bold]] + vim.cmd [[highlight link LvimInfoHeader Type]] + vim.cmd [[let m=matchadd("DashboardHeader", "Language Server Protocol (LSP) info")]] + vim.cmd [[let m=matchadd("DashboardHeader", "Formatters and linters")]] + vim.cmd('let m=matchadd("LvimInfoIdentifier", " ' .. ft .. '$")') + vim.cmd 'let m=matchadd("luaString", "true")' + vim.cmd 'let m=matchadd("luaError", "false")' + tbl_set_highlight(null_ls_providers, "LvimInfoIdentifier") + tbl_set_highlight(missing_formatters, "LvimInfoIdentifier") + tbl_set_highlight(missing_linters, "LvimInfoIdentifier") + -- tbl_set_highlight(u.get_supported_formatters_by_filetype(ft), "LvimInfoIdentifier") + -- tbl_set_highlight(u.get_supported_linters_by_filetype(ft), "LvimInfoIdentifier") + vim.cmd('let m=matchadd("LvimInfoIdentifier", "' .. client.name .. '")') end return M.create_simple_popup(buf_lines, set_syntax_hl) -- cgit v1.2.3 From abbde6c138cebe17b354544395525a8e27673565 Mon Sep 17 00:00:00 2001 From: Abouzar Parvan Date: Wed, 11 Aug 2021 11:32:33 +0430 Subject: remove useless print for LunarVim info --- lua/core/info.lua | 1 - 1 file changed, 1 deletion(-) (limited to 'lua/core/info.lua') diff --git a/lua/core/info.lua b/lua/core/info.lua index e4c787a2..825f8fa7 100644 --- a/lua/core/info.lua +++ b/lua/core/info.lua @@ -124,7 +124,6 @@ local function tbl_set_highlight(terms, highlight_group) end for _, v in pairs(terms) do - print("Add highlight for word: " .. v) vim.cmd('let m=matchadd("' .. highlight_group .. '", "' .. v .. '")') end end -- cgit v1.2.3 From cbbaf010f6d872187e08473350ae0ad43d8cad84 Mon Sep 17 00:00:00 2001 From: Abouzar Parvan Date: Wed, 11 Aug 2021 11:36:32 +0430 Subject: luaString highlight group is not always available --- lua/core/info.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lua/core/info.lua') diff --git a/lua/core/info.lua b/lua/core/info.lua index 825f8fa7..087157c4 100644 --- a/lua/core/info.lua +++ b/lua/core/info.lua @@ -193,8 +193,8 @@ function M.toggle_popup(ft) vim.cmd [[let m=matchadd("DashboardHeader", "Language Server Protocol (LSP) info")]] vim.cmd [[let m=matchadd("DashboardHeader", "Formatters and linters")]] vim.cmd('let m=matchadd("LvimInfoIdentifier", " ' .. ft .. '$")') - vim.cmd 'let m=matchadd("luaString", "true")' - vim.cmd 'let m=matchadd("luaError", "false")' + vim.cmd 'let m=matchadd("string", "true")' + vim.cmd 'let m=matchadd("error", "false")' tbl_set_highlight(null_ls_providers, "LvimInfoIdentifier") tbl_set_highlight(missing_formatters, "LvimInfoIdentifier") tbl_set_highlight(missing_linters, "LvimInfoIdentifier") -- cgit v1.2.3 From 333b1034255e0ac38124d814cebaf32ed5cbba8d Mon Sep 17 00:00:00 2001 From: Abouzar Parvan Date: Wed, 11 Aug 2021 14:41:36 +0430 Subject: Fix lunarvim info nil issue (#1289) * fix lunarvim info nil issue * fix num_caps counting issue --- lua/core/info.lua | 34 ++++++++++++++++++++++++---------- 1 file changed, 24 insertions(+), 10 deletions(-) (limited to 'lua/core/info.lua') diff --git a/lua/core/info.lua b/lua/core/info.lua index 087157c4..56fc3ca2 100644 --- a/lua/core/info.lua +++ b/lua/core/info.lua @@ -130,13 +130,27 @@ end function M.toggle_popup(ft) local client = u.get_active_client_by_ft(ft) - local is_client_active = not client.is_stopped() - local client_enabled_caps = require("lsp").get_ls_capabilities(client.id) - local num_caps = vim.tbl_count(client_enabled_caps) + local is_client_active = false + local client_enabled_caps = {} + local client_name = "" + local client_id = 0 + local document_formatting = false + local missing_linters = {} + local missing_formatters = {} + local num_caps = 0 local null_ls_providers = null_ls_handler.get_registered_providers_by_filetype(ft) - - local missing_linters = lvim.lang[ft].linters._failed_requests or {} - local missing_formatters = lvim.lang[ft].formatters._failed_requests or {} + if client ~= nil then + is_client_active = not client.is_stopped() + client_enabled_caps = require("lsp").get_ls_capabilities(client.id) + num_caps = vim.tbl_count(client_enabled_caps) + client_name = client.name + client_id = client.id + document_formatting = client.resolved_capabilities.document_formatting + end + if lvim.lang[ft] ~= nil then + missing_linters = lvim.lang[ft].linters._failed_requests or {} + missing_formatters = lvim.lang[ft].formatters._failed_requests or {} + end local buf_lines = {} vim.list_extend(buf_lines, M.banner) @@ -150,9 +164,9 @@ function M.toggle_popup(ft) local lsp_info = { indent .. "Language Server Protocol (LSP) info", - indent .. "* Associated server: " .. client.name, - indent .. "* Active: " .. tostring(is_client_active) .. " (id: " .. tostring(client.id) .. ")", - indent .. "* Supports formatting: " .. tostring(client.resolved_capabilities.document_formatting), + indent .. "* Associated server: " .. client_name, + indent .. "* Active: " .. tostring(is_client_active) .. " (id: " .. tostring(client_id) .. ")", + indent .. "* Supports formatting: " .. tostring(document_formatting), indent .. "* Capabilities list: " .. table.concat(vim.list_slice(client_enabled_caps, 1, num_caps / 2), ", "), indent .. indent .. indent .. table.concat(vim.list_slice(client_enabled_caps, ((num_caps / 2) + 1)), ", "), "", @@ -200,7 +214,7 @@ function M.toggle_popup(ft) tbl_set_highlight(missing_linters, "LvimInfoIdentifier") -- tbl_set_highlight(u.get_supported_formatters_by_filetype(ft), "LvimInfoIdentifier") -- tbl_set_highlight(u.get_supported_linters_by_filetype(ft), "LvimInfoIdentifier") - vim.cmd('let m=matchadd("LvimInfoIdentifier", "' .. client.name .. '")') + vim.cmd('let m=matchadd("LvimInfoIdentifier", "' .. client_name .. '")') end return M.create_simple_popup(buf_lines, set_syntax_hl) -- cgit v1.2.3