Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(core): add astronvim.notify for system notifications #604

Merged
merged 1 commit into from
Jun 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 6 additions & 3 deletions lua/core/utils/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,14 @@ local function load_module_file(module)
if status_ok then
found_module = loaded_module
else
vim.notify("Error loading " .. found_module, "error", astronvim.base_notification)
astronvim.notify("Error loading " .. found_module, "error")
end
end
return found_module
end

astronvim.user_settings = load_module_file "user.init"
astronvim.default_compile_path = stdpath "config" .. "/lua/packer_compiled.lua"
astronvim.base_notification = { title = "AstroNvim" }
astronvim.user_terminals = {}
astronvim.url_matcher =
"\\v\\c%(%(h?ttps?|ftp|file|ssh|git)://|[a-z]+[@][a-z]+[.][a-z]+:)%([&:#*@~%_\\-=?!+;/0-9a-z]+%(%([.;/?]|[.][.]+)[&:#*@~%_\\-=?!+/0-9a-z]+|:\\d+|,%(%(%(h?ttps?|ftp|file|ssh|git)://|[a-z]+[@][a-z]+[.][a-z]+:)@![0-9a-z]+))*|\\([&:#*@~%_\\-=?!+;/.0-9a-z]*\\)|\\[[&:#*@~%_\\-=?!+;/.0-9a-z]*\\]|\\{%([&:#*@~%_\\-=?!+;/.0-9a-z]*|\\{[&:#*@~%_\\-=?!+;/.0-9a-z]*})\\})+"
Expand Down Expand Up @@ -56,6 +55,10 @@ function astronvim.trim_or_nil(str)
return type(str) == "string" and vim.trim(str) or nil
end

function astronvim.notify(msg, type, opts)
vim.notify(msg, type, vim.tbl_deep_extend("force", { title = "AstroNvim" }, opts or {}))
end

function astronvim.echo(messages)
messages = messages or { { "\n" } }
if type(messages) == "table" then
Expand Down Expand Up @@ -147,7 +150,7 @@ function astronvim.url_opener()
elseif vim.fn.has "unix" == 1 then
vim.fn.jobstart({ "xdg-open", vim.fn.expand "<cfile>" }, { detach = true })
else
vim.notify("gx is not supported on this OS!", "error", astronvim.base_notification)
astronvim.notify("gx is not supported on this OS!", "error")
end
end

Expand Down
2 changes: 1 addition & 1 deletion lua/core/utils/updater.lua
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ end
function astronvim.updater.version()
local version = git.current_version()
if version then
vim.notify("Version: " .. version, "info", astronvim.base_notification)
astronvim.notify("Version: " .. version)
end
end

Expand Down