@@ -18,33 +18,21 @@ local utils = {}
1818utils .iswin = vim .uv .os_uname ().sysname == " Windows_NT"
1919utils .nvim011 = vim .fn .has " nvim-0.11" == 1
2020
21- --- @param s string
22- --- @param i number
23- --- @param encoding " utf-8" | " utf-16" | " utf-32"
24- --- @return integer
25- utils .str_byteindex = function (s , i , encoding )
26- if utils .nvim011 then
27- return vim .str_byteindex (s , encoding , i , false )
28- else
29- return vim .lsp .util ._str_byteindex_enc (s , i , encoding )
30- end
31- end
32-
33- --- @param t table
34- utils .flatten = function (t )
35- return vim .iter (t ):flatten ():totable ()
36- end
21+ --- TODO(clason): remove when dropping support for Nvim 0.10
22+ utils .str_byteindex = utils .nvim011 and vim .str_byteindex or vim .lsp .util ._str_byteindex_enc
3723
3824--- TODO(clason): remove when dropping support for Nvim 0.10
3925--- @param k string
4026--- @param v any
4127--- @param ty type
42- utils .validate = function (k , v , ty )
43- if utils .nvim011 then
44- vim .validate (k , v , ty )
45- else
46- vim .validate { [k ] = { v , ty } }
47- end
28+ utils .validate = utils .nvim011 and vim .validate or function (k , v , ty )
29+ vim .validate { [k ] = { v , ty } }
30+ end
31+
32+ --- @param t table
33+ --- @return table
34+ utils .flatten = function (t )
35+ return vim .iter (t ):flatten ():totable ()
4836end
4937
5038--- Hybrid of `vim.fn.expand()` and custom `vim.fs.normalize()`
@@ -681,15 +669,12 @@ utils.get_devicons = load_once(function()
681669 end
682670end )
683671
672+ --- TODO(clason): remove when dropping support for Nvim 0.10
684673--- Checks if treesitter parser for language is installed
685- --- @param lang string
686- utils .has_ts_parser = function (lang )
687- if utils .nvim011 then
688- return vim .treesitter .language .add (lang )
689- else
674+ utils .has_ts_parser = utils .nvim011 and vim .treesitter .language .add
675+ or function (lang )
690676 return pcall (vim .treesitter .language .add , lang )
691677 end
692- end
693678
694679--- Telescope Wrapper around vim.notify
695680--- @param funname string : name of the function that will be
0 commit comments