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