From 6bdbcbcbd33f3ab441d3271a9619cfc087413118 Mon Sep 17 00:00:00 2001 From: "Scott E. Graves" Date: Fri, 29 Jul 2022 13:17:05 -0500 Subject: [PATCH] error notifications --- lua/nvim-flutter-companion/init.lua | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/lua/nvim-flutter-companion/init.lua b/lua/nvim-flutter-companion/init.lua index 3139566..6867477 100644 --- a/lua/nvim-flutter-companion/init.lua +++ b/lua/nvim-flutter-companion/init.lua @@ -8,6 +8,7 @@ local global_state = require("telescope.state") local utils = require("nvim-flutter-companion.utils") local M = {} +local companion_title = "Flutter Companion" local config = { use_coc = true } @@ -34,7 +35,19 @@ local flutter_run_device = function(id) return end - vim.api.nvim_command("FlutterRun -d " .. id) + if vim.fn.exists(":FlutterRun") ~= 0 then + 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 + } + ) end local load_table = function(path) @@ -142,11 +155,11 @@ local start_spinner = function(name, get_active) local function update_spinner() if get_active() then local next_record = - require("notify").notify( + vim.notify( "Detecting " .. name .. "...", "info", { - title = "Flutter Action", + title = companion_title, hide_from_history = true, icon = spinner_frames[(spinner % #spinner_frames) + 1], replace = record @@ -201,7 +214,7 @@ function M.flutter_list(is_emulators) ) if #items == 0 then - vim.notify("No " .. name .. " were found", "error", {title = "Flutter Action"}) + vim.notify("No " .. name .. " were found", "error", {title = companion_title}) else global_state.set_global_key("selected_entry", nil)