aboutsummaryrefslogtreecommitdiffstats
path: root/lua
diff options
context:
space:
mode:
authorWilliam Boman <william@redwill.se>2021-08-12 22:36:23 +0200
committerWilliam Boman <william@redwill.se>2021-08-12 22:40:24 +0200
commit86423357aecf77069e5544ce613dbe0925cabce4 (patch)
treee362c62e54be5fc864bee3a60d911306f1d56f89 /lua
parentuse vim.notify (diff)
downloadmason-86423357aecf77069e5544ce613dbe0925cabce4.tar
mason-86423357aecf77069e5544ce613dbe0925cabce4.tar.gz
mason-86423357aecf77069e5544ce613dbe0925cabce4.tar.bz2
mason-86423357aecf77069e5544ce613dbe0925cabce4.tar.lz
mason-86423357aecf77069e5544ce613dbe0925cabce4.tar.xz
mason-86423357aecf77069e5544ce613dbe0925cabce4.tar.zst
mason-86423357aecf77069e5544ce613dbe0925cabce4.zip
vim.notify: provide extra options for better interop with nvim-notify
Diffstat (limited to 'lua')
-rw-r--r--lua/nvim-lsp-installer.lua12
-rw-r--r--lua/nvim-lsp-installer/adapters/nvim-tree.lua7
-rw-r--r--lua/nvim-lsp-installer/installers/zx.lua3
-rw-r--r--lua/nvim-lsp-installer/notify.lua8
-rw-r--r--lua/nvim-lsp-installer/server.lua7
-rw-r--r--lua/nvim-lsp-installer/servers/eslintls/init.lua7
6 files changed, 30 insertions, 14 deletions
diff --git a/lua/nvim-lsp-installer.lua b/lua/nvim-lsp-installer.lua
index 96e53fa9..a9ed77f2 100644
--- a/lua/nvim-lsp-installer.lua
+++ b/lua/nvim-lsp-installer.lua
@@ -1,3 +1,5 @@
+local notify = require("nvim-lsp-installer.notify")
+
local M = {}
-- :'<,'>!sort | column -t
@@ -78,26 +80,26 @@ end
function M.install(server_name)
local ok, server = M.get_server(server_name)
if not ok then
- return vim.notify(("Unable to find LSP server %s. Error=%s"):format(server_name, server), vim.log.levels.ERROR)
+ return notify(("Unable to find LSP server %s. Error=%s"):format(server_name, server), vim.log.levels.ERROR)
end
local success, error = pcall(server.install, server)
if not success then
pcall(server.uninstall, server)
- return vim.notify(("Failed to install %s. Error=%s"):format(server_name, vim.inspect(error)), vim.log.levels.ERROR)
+ return notify(("Failed to install %s. Error=%s"):format(server_name, vim.inspect(error)), vim.log.levels.ERROR)
end
end
function M.uninstall(server_name)
local ok, server = M.get_server(server_name)
if not ok then
- return vim.notify(("Unable to find LSP server %s. Error=%s"):format(server_name, server), vim.log.levels.ERROR)
+ return notify(("Unable to find LSP server %s. Error=%s"):format(server_name, server), vim.log.levels.ERROR)
end
local success, error = pcall(server.uninstall, server)
if not success then
- vim.notify(("Unable to uninstall %s. Error=%s"):format(server_name, vim.inspect(error)), vim.log.levels.ERROR)
+ notify(("Unable to uninstall %s. Error=%s"):format(server_name, vim.inspect(error)), vim.log.levels.ERROR)
return success
end
- vim.notify(("Successfully uninstalled %s"):format(server_name))
+ notify(("Successfully uninstalled %s"):format(server_name))
end
return M
diff --git a/lua/nvim-lsp-installer/adapters/nvim-tree.lua b/lua/nvim-lsp-installer/adapters/nvim-tree.lua
index c2a39997..851f5ea8 100644
--- a/lua/nvim-lsp-installer/adapters/nvim-tree.lua
+++ b/lua/nvim-lsp-installer/adapters/nvim-tree.lua
@@ -1,11 +1,12 @@
-local M = {}
-
+local notify = require("nvim-lsp-installer.notify")
local tsserverExtras = require("nvim-lsp-installer.extras.tsserver")
+local M = {}
+
function M.connect()
local ok, events = pcall(require, "nvim-tree.events")
if not ok then
- return vim.notify("Unable to import nvim-tree module when connecting nvim-lsp-installer adapter.", vim.log.levels.ERROR)
+ return notify("Unable to import nvim-tree module when connecting nvim-lsp-installer adapter.", vim.log.levels.ERROR)
end
events.on_node_renamed(function (payload)
diff --git a/lua/nvim-lsp-installer/installers/zx.lua b/lua/nvim-lsp-installer/installers/zx.lua
index 0928c478..5d50651b 100644
--- a/lua/nvim-lsp-installer/installers/zx.lua
+++ b/lua/nvim-lsp-installer/installers/zx.lua
@@ -1,5 +1,6 @@
local fs = require("nvim-lsp-installer.fs")
local path = require("nvim-lsp-installer.path")
+local notify = require("nvim-lsp-installer.notify")
local installers = require("nvim-lsp-installer.installers")
local shell = require("nvim-lsp-installer.installers.shell")
local npm = require("nvim-lsp-installer.installers.npm")
@@ -30,7 +31,7 @@ local function zx_installer(force)
local is_zx_already_installed = fs.file_exists(ZX_EXECUTABLE)
local npm_command = is_zx_already_installed and "update" or "install"
- vim.notify(("Preparing for :LspInstall, please wait… ($ npm %s zx)"):format(npm_command))
+ notify(("Preparing for :LspInstall, please wait… ($ npm %s zx)"):format(npm_command))
fs.mkdirp(INSTALL_DIR)
diff --git a/lua/nvim-lsp-installer/notify.lua b/lua/nvim-lsp-installer/notify.lua
new file mode 100644
index 00000000..ef6db61b
--- /dev/null
+++ b/lua/nvim-lsp-installer/notify.lua
@@ -0,0 +1,8 @@
+local TITLE = "nvim-lsp-installer"
+
+return function(msg, level)
+ level = level or vim.log.levels.INFO
+ vim.notify(("%s: %s"):format(TITLE, msg), level, {
+ title = TITLE,
+ })
+end
diff --git a/lua/nvim-lsp-installer/server.lua b/lua/nvim-lsp-installer/server.lua
index a49c751a..5747f39e 100644
--- a/lua/nvim-lsp-installer/server.lua
+++ b/lua/nvim-lsp-installer/server.lua
@@ -1,3 +1,4 @@
+local notify = require("nvim-lsp-installer.notify")
local fs = require("nvim-lsp-installer.fs")
local path = require("nvim-lsp-installer.path")
@@ -67,12 +68,14 @@ function M.Server:install()
self:create_root_dir()
+ notify(("Installing %s…"):format(self.name))
+
self._installer(self, function (success, result)
if not success then
- vim.notify(("Server installation failed for %s. %s"):format(self.name, result), vim.log.levels.ERROR)
+ notify(("Server installation failed for %s. %s"):format(self.name, result), vim.log.levels.ERROR)
pcall(self.uninstall, self)
else
- vim.notify(("Successfully installed %s"):format(self.name))
+ notify(("Successfully installed %s"):format(self.name))
end
end)
end
diff --git a/lua/nvim-lsp-installer/servers/eslintls/init.lua b/lua/nvim-lsp-installer/servers/eslintls/init.lua
index 943936fa..194f3e28 100644
--- a/lua/nvim-lsp-installer/servers/eslintls/init.lua
+++ b/lua/nvim-lsp-installer/servers/eslintls/init.lua
@@ -1,6 +1,7 @@
local lspconfig = require("lspconfig")
local configs = require("lspconfig/configs")
+local notify = require("nvim-lsp-installer.notify")
local server = require("nvim-lsp-installer.server")
local path = require("nvim-lsp-installer.path")
local shell = require("nvim-lsp-installer.installers.shell")
@@ -78,15 +79,15 @@ return server.Server:new {
return ConfirmExecutionResult.approved
end,
["eslint/probeFailed"] = function ()
- vim.notify("ESLint probe failed.", vim.log.levels.ERROR)
+ notify("ESLint probe failed.", vim.log.levels.ERROR)
return {id = nil, result = true}
end,
["eslint/noLibrary"] = function ()
- vim.notify("Unable to find ESLint library.", vim.log.levels.ERROR)
+ notify("Unable to find ESLint library.", vim.log.levels.ERROR)
return {id = nil, result = true}
end,
["eslint/noConfig"] = function ()
- vim.notify("Unable to find ESLint configuration.", vim.log.levels.ERROR)
+ notify("Unable to find ESLint configuration.", vim.log.levels.ERROR)
return {id = nil, result = true}
end,
},