fix: add shim for vim.lsp.util._str_byteindex() (#3338)

Will be removed in Nvim 0.11: https://github.com/neovim/neovim/pull/30915
This commit is contained in:
Tristan Knight
2024-10-26 15:33:10 +01:00
committed by GitHub
parent df534c3042
commit 37dc9233a4
2 changed files with 13 additions and 1 deletions

View File

@@ -17,6 +17,18 @@ local utils = {}
utils.iswin = vim.loop.os_uname().sysname == "Windows_NT"
---@param s string
---@param i number
---@param encoding "utf-8" | "utf-16" | "utf-32"
---@return integer
utils.str_byteindex = function(s, i, encoding)
if vim.fn.has "nvim-0.11" == 1 then
return vim.str_byteindex(s, encoding, i, false)
else
return vim.lsp.util._str_byteindex_enc(s, i, encoding)
end
end
--TODO(clason): Remove when dropping support for Nvim 0.9
utils.islist = vim.fn.has "nvim-0.10" == 1 and vim.islist or vim.tbl_islist
local flatten = function(t)