Skip to content

Commit

Permalink
Merge pull request #622 from rochala/add-bsp-status
Browse files Browse the repository at this point in the history
Add bsp status support
  • Loading branch information
ckipp01 authored Nov 15, 2023
2 parents 6692a65 + 7a7d183 commit 0626430
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
1 change: 1 addition & 0 deletions lua/metals/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ local metals_init_options = {
inputBoxProvider = true,
quickPickProvider = true,
statusBarProvider = "show-message",
bspStatusBarProvider = "on",
treeViewProvider = true,
}

Expand Down
12 changes: 7 additions & 5 deletions lua/metals/status.lua
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
local log = require("metals.log")

-- @param status (string) a new status to be displayed
local function set_status(status)
local function set_status(status, type)
-- Scaping the status to prevent % characters breaking the statusline
local scaped_status = status:gsub("[%%]", "%%%1")
vim.api.nvim_set_var("metals_status", scaped_status)
local status_var = (type or "metals") .. "_status"
vim.api.nvim_set_var(status_var, scaped_status)
end

local function prompt_command(status)
Expand Down Expand Up @@ -36,11 +37,12 @@ end
-- @param status (table) this is the normal status table as described in the
-- metals docs as well as the bufnr and client_id.
local function handle_status(status)
local type = status.statusType
if status.hide then
set_status("")
set_status("", type)
else
if status.text then
set_status(status.text)
set_status(status.text, type)
end

-- This status actually appears a lot in external sources, but really isn't
Expand All @@ -50,7 +52,7 @@ local function handle_status(status)
local annoyingMessage = "This external library source has compile errors."
if status.command and status.tooltip then
prompt_command(status)
elseif status.tooltip and not string.find(status.tooltip, annoyingMessage) then
elseif status.tooltip and not string.find(status.tooltip, annoyingMessage) and not type == "bsp" then
log.warn_and_show(status.tooltip)
end
end
Expand Down

0 comments on commit 0626430

Please sign in to comment.