weather.nvim brings real-time weather and earthquake alerts to Neovim without the need for any API keys, making it easy to set up and use. Using data from Open-Meteo for weather and USGS for earthquakes, it provides notifications about significant events based on your location—keeping you informed without leaving your workflow.
Stay updated on the world around you with weather.nvim
. This plugin fetches weather and earthquake data periodically, displaying alerts via Neovim’s notification system. Whether you’re tracking a storm or monitoring seismic activity, weather.nvim
integrates seamlessly into your editing environment—all with no API key required, a standout feature that simplifies your setup.
nvim-notify
(optional dependency).lualine.nvim
).lazy
in this case)Install weather.nvim
with lazy.nvim using this example:
{
"athar-qadri/weather.nvim",
dependencies = {
"nvim-lua/plenary.nvim", -- Required for HTTP requests
"rcarriga/nvim-notify", -- Optional, for notifications
},
config = function()
local weather = require("weather")
weather:setup({
settings = {
update_interval = 60 * 10 * 1000, -- 10 minutes
minimum_magnitude = 5,
location = { lat = 34.0787, lon = 74.7659 },
temperature_unit = "celsius",
},
})
require("weather.notify").start() -- Start notifications
end,
}
Alternatively, use packer.nvim:
use {
'athar-qadri/weather.nvim',
requires = {
{'nvim-lua/plenary.nvim'}, -- Required for HTTP requests
{'rcarriga/nvim-notify'}, -- Optional, for notifications
{'nvim-lualine/lualine.nvim'}, -- Optional, for status line integration
}
}
plenary.nvim
for HTTP requests.nvim-notify
for alert notifications.lualine.nvim
for status line weather display.Configure weather.nvim
by calling the setup
function with a configuration table. Here’s an example with default values:
require('weather'):setup({
settings = {
update_interval = 15 * 60 * 1000, -- 15 minutes in milliseconds
temperature_unit = "celsius", -- "celsius" or "fahrenheit"
location = { lat = 37.7749, lon = -122.4194 }, -- Optional fixed location
},
default = {
minimum_magnitude = 4.0, -- Minimum earthquake magnitude for alerts
minimum_radius = 20, -- Minimum radius in km for earthquake alerts
default_sources = { "meteo", "usgs" }, -- Data sources
},
})
Option | Type | Description | Default |
---|---|---|---|
settings.update_interval |
number |
Data fetch interval (milliseconds) | 15 * 60 * 1000 (15 min) |
settings.temperature_unit |
string |
Temperature unit ("celsius" or "fahrenheit" ) |
"celsius" |
settings.location |
table |
Fixed location {lat, lon} (optional) |
nil (IP-based) |
default.minimum_magnitude |
number |
Minimum earthquake magnitude for alerts | 4.0 |
default.minimum_radius |
number |
Minimum radius in km for earthquake alerts | 20 |
default.default_sources |
table |
List of data sources | {"meteo", "usgs"} |
If settings.location
is not set, the plugin uses ip-api.com to detect your location.
After installation and configuration, weather.nvim
starts fetching data automatically based on your settings.
:WeatherNow
to trigger an immediate update.nvim-notify
(if installed). Examples:Display current weather in your status line with lualine.nvim. Here’s an excerpt from a custom configuration:
require('lualine').setup({
options = {
theme = {
normal = {
a = { bg = "#65D1FF", fg = "#112638", gui = "bold" },
b = { bg = "#112638", fg = "#c3ccdc" },
c = { bg = "#112638", fg = "#c3ccdc" },
},
-- Other modes defined...
},
},
sections = {
lualine_x = {
{ require("weather.lualine").default_c() },
{
require("lazy.status").updates,
cond = require("lazy.status").has_updates,
color = { fg = "#ff9e64" },
},
{ "lsp_status" },
{ "filesize" },
{ "filetype" },
},
},
})
For the full configuration including all modes and additional components, refer to the repository and my dotfiles.
Contributions are welcome! Please submit issues or pull requests on the GitHub repository.
Released under the GPL-3.0 license.