Skip to content

Commit 80c0f84

Browse files
committed
refactor!: require Neovim v0.10+
1 parent e923a84 commit 80c0f84

File tree

5 files changed

+9
-42
lines changed

5 files changed

+9
-42
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ AstroUI provides a simple API for configuring and setting up the user interface
1010

1111
## ⚡️ Requirements
1212

13-
- Neovim >= 0.9
13+
- Neovim >= 0.10
1414
- [astrocore][astrocore] (_optional_)
1515

1616
## 📦 Installation

lua/astroui/status/condition.lua

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ function M.is_hlsearch() return vim.v.hlsearch ~= 0 end
7575
--- A condition function if showcmdloc is set to statusline
7676
---@return boolean # whether or not statusline showcmd is enabled
7777
-- @usage local heirline_component = { provider = "Example Provider", condition = require("astroui.status").condition.is_statusline_showcmd }
78-
function M.is_statusline_showcmd() return vim.fn.has "nvim-0.9" == 1 and vim.opt.showcmdloc:get() == "statusline" end
78+
function M.is_statusline_showcmd() return vim.opt.showcmdloc:get() == "statusline" end
7979

8080
--- A condition function if the current file is in a git repo
8181
---@param bufnr table|integer a buffer number to check the condition for, a table with bufnr property, or nil to get the current buffer
@@ -134,12 +134,7 @@ function M.has_diagnostics(bufnr)
134134
if type(bufnr) == "table" then bufnr = bufnr.bufnr end
135135
if not bufnr then bufnr = 0 end
136136
if package.loaded["astrocore"] and require("astrocore").config.features.diagnostics_mode == 0 then return false end
137-
-- TODO: remove when dropping support for neovim 0.9
138-
if vim.diagnostic.count then
139-
return vim.tbl_contains(vim.diagnostic.count(bufnr), function(v) return v > 0 end, { predicate = true })
140-
else
141-
return #vim.diagnostic.get(bufnr) > 0
142-
end
137+
return vim.tbl_contains(vim.diagnostic.count(bufnr), function(v) return v > 0 end, { predicate = true })
143138
end
144139

145140
--- A condition function if there is a defined filetype
@@ -182,11 +177,8 @@ function M.lsp_attached(bufnr)
182177
if type(bufnr) == "table" then bufnr = bufnr.bufnr end
183178
if not bufnr then bufnr = 0 end
184179
return (
185-
-- HACK: Check for lsp utilities loaded first, get_active_clients seems to have a bug if called too early (tokyonight colorscheme seems to be a good way to expose this for some reason)
186-
package.loaded["astrolsp"]
187-
-- TODO: remove get_active_clients when dropping support for Neovim 0.9
188-
---@diagnostic disable-next-line: deprecated
189-
and next((vim.lsp.get_clients or vim.lsp.get_active_clients) { bufnr = bufnr }) ~= nil
180+
-- HACK: Check for lsp utilities loaded first, get_clients seems to have a bug if called too early (tokyonight colorscheme seems to be a good way to expose this for some reason)
181+
package.loaded["astrolsp"] and next(vim.lsp.get_clients { bufnr = bufnr }) ~= nil
190182
)
191183
or (package.loaded["conform"] and next(require("conform").list_formatters(bufnr)) ~= nil)
192184
or (package.loaded["lint"] and next(require("lint")._resolve_linter_by_ft(vim.bo[bufnr].filetype or "")) ~= nil)

lua/astroui/status/init.lua

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,7 @@ end
137137
---@return function # The Heirline init function
138138
-- @usage local heirline_component = { init = require("astroui.status").init.update_events { "BufEnter", { "User", pattern = "LspProgressUpdate" } } }
139139
function M.update_events(opts)
140-
-- TODO: remove check after dropping support for Neovim v0.9
141-
if not (vim.islist or vim.tbl_islist)(opts) then opts = { opts } end
140+
if not vim.islist(opts) then opts = { opts } end
142141
---@cast opts AstroUIUpdateEvent[]
143142
return function(self)
144143
if not rawget(self, "once") then

lua/astroui/status/provider.lua

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ local M = {}
1212
local astro = require "astrocore"
1313
local extend_tbl = astro.extend_tbl
1414
local is_available = astro.is_available
15-
local luv = vim.uv or vim.loop -- TODO: REMOVE WHEN DROPPING SUPPORT FOR Neovim v0.9
1615

1716
local ui = require "astroui"
1817
local config = assert(ui.config.status)
@@ -38,14 +37,6 @@ end
3837
-- local function to resolve the first sign in the signcolumn
3938
-- specifically for usage when `signcolumn=number`
4039
local function resolve_sign(bufnr, lnum)
41-
--- TODO: remove when dropping support for Neovim v0.9
42-
if vim.fn.has "nvim-0.10" == 0 then
43-
for _, sign in ipairs(vim.fn.sign_getplaced(bufnr, { group = "*", lnum = lnum })[1].signs) do
44-
local defined = vim.fn.sign_getdefined(sign.name)[1]
45-
if defined then return defined end
46-
end
47-
end
48-
4940
local row = lnum - 1
5041
local extmarks = vim.api.nvim_buf_get_extmarks(bufnr, -1, { row, 0 }, { row, -1 }, { details = true, type = "sign" })
5142
local ret
@@ -462,13 +453,7 @@ function M.diagnostics(opts)
462453
if not opts or not opts.severity then return end
463454
return function(self)
464455
local bufnr = self and self.bufnr or 0
465-
local count
466-
-- TODO: remove when dropping support for neovim 0.9
467-
if vim.diagnostic.count then
468-
count = vim.diagnostic.count(bufnr)[vim.diagnostic.severity[opts.severity]] or 0
469-
else
470-
count = #vim.diagnostic.get(bufnr, opts.severity and { severity = vim.diagnostic.severity[opts.severity] })
471-
end
456+
local count = vim.diagnostic.count(bufnr)[vim.diagnostic.severity[opts.severity]] or 0
472457
return status_utils.stylize(count ~= 0 and tostring(count) or "", opts)
473458
end
474459
end
@@ -486,7 +471,7 @@ function M.lsp_progress(opts)
486471
if astrolsp_avail and astrolsp.lsp_progress then
487472
_, status = next(astrolsp.lsp_progress)
488473
end
489-
return status_utils.stylize(status and (spinner[math.floor(luv.hrtime() / 12e7) % #spinner + 1] .. table.concat({
474+
return status_utils.stylize(status and (spinner[math.floor(vim.uv.hrtime() / 12e7) % #spinner + 1] .. table.concat({
490475
status.title or "",
491476
status.message or "",
492477
status.percentage and "(" .. status.percentage .. "%)" or "",
@@ -512,9 +497,7 @@ function M.lsp_client_names(opts)
512497
return function(self)
513498
local bufnr = self and self.bufnr or 0
514499
local buf_client_names = {}
515-
-- TODO: remove get_active_clients when dropping support for Neovim 0.9
516-
---@diagnostic disable-next-line: deprecated
517-
for _, client in pairs((vim.lsp.get_clients or vim.lsp.get_active_clients) { bufnr = bufnr }) do
500+
for _, client in pairs(vim.lsp.get_clients { bufnr = bufnr }) do
518501
if client.name == "null-ls" and opts.integrations.null_ls then
519502
local null_ls_sources = {}
520503
local ft = vim.bo[bufnr].filetype

lua/astroui/status/utils.lua

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -255,13 +255,6 @@ function M.statuscolumn_clickargs(self, minwid, clicks, button, mods)
255255
if not self.signs then self.signs = {} end
256256
args.sign = self.signs[args.char]
257257
if not args.sign then -- update signs if not found on first click
258-
---TODO: remove when dropping support for Neovim v0.9
259-
if vim.fn.has "nvim-0.10" == 0 then
260-
for _, sign_def in ipairs(assert(vim.fn.sign_getdefined())) do
261-
if sign_def.text then self.signs[sign_def.text:gsub("%s", "")] = sign_def end
262-
end
263-
end
264-
265258
if not self.bufnr then self.bufnr = vim.api.nvim_get_current_buf() end
266259
local row = args.mousepos.line - 1
267260
for _, extmark in

0 commit comments

Comments
 (0)