12
12
local M = {}
13
13
14
14
local utils = require " astronvim.utils"
15
- local notify = utils .notify
16
15
local astroevent = utils .event
16
+ local function mason_notify (msg , type ) utils .notify (msg , type , { title = " Mason" }) end
17
17
18
18
--- Update specified mason packages, or just update the registries if no packages are listed
19
19
--- @param pkg_names ? string | string[] The package names as defined in Mason (Not mason-lspconfig or mason-null-ls ) if the value is nil then it will just update the registries
@@ -32,34 +32,34 @@ function M.update(pkg_names, auto_install)
32
32
if success then
33
33
local count = # updated_registries
34
34
if vim .tbl_count (pkg_names ) == 0 then
35
- notify ((" Successfully updated %d %s." ):format (count , count == 1 and " registry" or " registries" ))
35
+ mason_notify ((" Successfully updated %d %s." ):format (count , count == 1 and " registry" or " registries" ))
36
36
end
37
37
for _ , pkg_name in ipairs (pkg_names ) do
38
38
local pkg_avail , pkg = pcall (registry .get_package , pkg_name )
39
39
if not pkg_avail then
40
- notify ((" Mason: %s is not available" ):format (pkg_name ), vim .log .levels .ERROR )
40
+ mason_notify ((" `%s` is not available" ):format (pkg_name ), vim .log .levels .ERROR )
41
41
else
42
42
if not pkg :is_installed () then
43
43
if auto_install then
44
- notify ((" Mason: Installing %s " ):format (pkg .name ))
44
+ mason_notify ((" Installing `%s` " ):format (pkg .name ))
45
45
pkg :install ()
46
46
else
47
- notify ((" Mason: %s not installed" ):format (pkg .name ), vim .log .levels .WARN )
47
+ mason_notify ((" `%s` not installed" ):format (pkg .name ), vim .log .levels .WARN )
48
48
end
49
49
else
50
50
pkg :check_new_version (function (update_available , version )
51
51
if update_available then
52
- notify ((" Mason: Updating %s to %s" ):format (pkg .name , version .latest_version ))
53
- pkg :install ():on (" closed" , function () notify ((" Mason: Updated %s" ):format (pkg .name )) end )
52
+ mason_notify ((" Updating `%s` to %s" ):format (pkg .name , version .latest_version ))
53
+ pkg :install ():on (" closed" , function () mason_notify ((" Updated %s" ):format (pkg .name )) end )
54
54
else
55
- notify ((" Mason: No updates available for %s " ):format (pkg .name ))
55
+ mason_notify ((" No updates available for `%s` " ):format (pkg .name ))
56
56
end
57
57
end )
58
58
end
59
59
end
60
60
end
61
61
else
62
- notify ((" Failed to update registries: %s" ):format (updated_registries ), vim .log .levels .ERROR )
62
+ mason_notify ((" Failed to update registries: %s" ):format (updated_registries ), vim .log .levels .ERROR )
63
63
end
64
64
end ))
65
65
end
@@ -72,37 +72,37 @@ function M.update_all()
72
72
return
73
73
end
74
74
75
- notify " Mason: Checking for package updates..."
75
+ mason_notify " Checking for package updates..."
76
76
registry .update (vim .schedule_wrap (function (success , updated_registries )
77
77
if success then
78
78
local installed_pkgs = registry .get_installed_packages ()
79
79
local running = # installed_pkgs
80
80
local no_pkgs = running == 0
81
81
82
82
if no_pkgs then
83
- notify " Mason: No updates available"
83
+ mason_notify " No updates available"
84
84
astroevent " MasonUpdateCompleted"
85
85
else
86
86
local updated = false
87
87
for _ , pkg in ipairs (installed_pkgs ) do
88
88
pkg :check_new_version (function (update_available , version )
89
89
if update_available then
90
90
updated = true
91
- notify ((" Mason: Updating %s to %s" ):format (pkg .name , version .latest_version ))
91
+ mason_notify ((" Updating `%s` to %s" ):format (pkg .name , version .latest_version ))
92
92
pkg :install ():on (" closed" , function ()
93
93
running = running - 1
94
94
if running == 0 then
95
- notify " Mason: Update Complete"
95
+ mason_notify " Update Complete"
96
96
astroevent " MasonUpdateCompleted"
97
97
end
98
98
end )
99
99
else
100
100
running = running - 1
101
101
if running == 0 then
102
102
if updated then
103
- notify " Mason: Update Complete"
103
+ mason_notify " Update Complete"
104
104
else
105
- notify " Mason: No updates available"
105
+ mason_notify " No updates available"
106
106
end
107
107
astroevent " MasonUpdateCompleted"
108
108
end
@@ -111,7 +111,7 @@ function M.update_all()
111
111
end
112
112
end
113
113
else
114
- notify ((" Failed to update registries: %s" ):format (updated_registries ), vim .log .levels .ERROR )
114
+ mason_notify ((" Failed to update registries: %s" ):format (updated_registries ), vim .log .levels .ERROR )
115
115
end
116
116
end ))
117
117
end
0 commit comments