switch to mini.notify
This commit is contained in:
@@ -24,18 +24,19 @@ local conf = require("telescope.config").values
|
||||
local finders = require("telescope.finders")
|
||||
local global_state = require("telescope.state")
|
||||
local pickers = require("telescope.pickers")
|
||||
local symbols = require("darcula.utils.symbols")
|
||||
local utils = require("darcula.utils")
|
||||
local utils_os = require("darcula.utils.os")
|
||||
|
||||
local M = {}
|
||||
local companion_title = "Flutter Companion"
|
||||
|
||||
local spinner_id = nil
|
||||
local config = {
|
||||
use_coc = true
|
||||
}
|
||||
|
||||
local callbacks = {nil, nil}
|
||||
local flutter_busy = false
|
||||
local spinner_frames = {"⣾", "⣽", "⣻", "⢿", "⡿", "⣟", "⣯", "⣷"}
|
||||
|
||||
local EMULATOR = 1
|
||||
local DEVICE = 2
|
||||
@@ -59,14 +60,10 @@ local flutter_run_device = function(id)
|
||||
vim.api.nvim_command("FlutterRun -d " .. id)
|
||||
return
|
||||
end
|
||||
|
||||
vim.notify(
|
||||
{
|
||||
"Run device requires 'coc-flutter/coc-flutter-tools' if using CoC or 'flutter-tools.nvim' if using native LSP."
|
||||
},
|
||||
"error",
|
||||
{
|
||||
title = companion_title
|
||||
}
|
||||
"Run device requires 'coc-flutter/coc-flutter-tools' if using CoC or 'flutter-tools.nvim' if using native LSP.",
|
||||
vim.log.levels.ERROR
|
||||
)
|
||||
end
|
||||
|
||||
@@ -169,33 +166,36 @@ local function list_emulators(callback)
|
||||
end
|
||||
|
||||
local start_spinner = function(name, get_active)
|
||||
local spinner = 0
|
||||
local record
|
||||
|
||||
local icon_idx = 0
|
||||
local function update_spinner()
|
||||
if get_active() then
|
||||
local next_record =
|
||||
vim.notify(
|
||||
"Detecting " .. name .. "...",
|
||||
"info",
|
||||
local msg =
|
||||
"Detecting " ..
|
||||
name .. "... " .. symbols.spinner[(icon_idx % #symbols.spinner) + 1]
|
||||
|
||||
if spinner_id == nil then
|
||||
spinner_id = MiniNotify.add(msg, "INFO")
|
||||
else
|
||||
MiniNotify.update(
|
||||
spinner_id,
|
||||
{
|
||||
title = companion_title,
|
||||
hide_from_history = true,
|
||||
icon = spinner_frames[(spinner % #spinner_frames) + 1],
|
||||
replace = record
|
||||
msg = msg
|
||||
}
|
||||
)
|
||||
record = next_record
|
||||
spinner = spinner + 1
|
||||
end
|
||||
|
||||
icon_idx = icon_idx + 1
|
||||
vim.defer_fn(update_spinner, 100)
|
||||
end
|
||||
end
|
||||
|
||||
update_spinner()
|
||||
end
|
||||
|
||||
local stop_spinner = function(set_inactive)
|
||||
set_inactive()
|
||||
vim.notify.dismiss()
|
||||
MiniNotify.remove(spinner_id)
|
||||
spinner_id = nil
|
||||
end
|
||||
|
||||
function M.flutter_clear(is_emulator)
|
||||
@@ -250,11 +250,7 @@ function M.flutter_list(is_emulators)
|
||||
)
|
||||
|
||||
if #items == 0 then
|
||||
vim.notify(
|
||||
"No " .. name .. " were found",
|
||||
"error",
|
||||
{title = companion_title}
|
||||
)
|
||||
vim.notify("No " .. name .. " were found", vim.log.levels.ERROR)
|
||||
else
|
||||
global_state.set_global_key("selected_entry", nil)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user