diff options
| author | Christian Clason <c.clason@uni-graz.at> | 2025-08-06 13:16:08 +0200 |
|---|---|---|
| committer | Christian Clason <ch.clason+github@icloud.com> | 2025-08-06 13:22:02 +0200 |
| commit | 37bcfdc6eba87334b58f43a19528751d3fe12f4e (patch) | |
| tree | 19d65bdd7400e22aaba13a4f3879df814db8ff88 | |
| parent | fix(jinja_inline): fix crashing query pattern (diff) | |
| download | nvim-treesitter-37bcfdc6eba87334b58f43a19528751d3fe12f4e.tar nvim-treesitter-37bcfdc6eba87334b58f43a19528751d3fe12f4e.tar.gz nvim-treesitter-37bcfdc6eba87334b58f43a19528751d3fe12f4e.tar.bz2 nvim-treesitter-37bcfdc6eba87334b58f43a19528751d3fe12f4e.tar.lz nvim-treesitter-37bcfdc6eba87334b58f43a19528751d3fe12f4e.tar.xz nvim-treesitter-37bcfdc6eba87334b58f43a19528751d3fe12f4e.tar.zst nvim-treesitter-37bcfdc6eba87334b58f43a19528751d3fe12f4e.zip | |
refactor(config): prefer `vim.list.unique` for normalization
Also fix some emmyluals warnings
| -rw-r--r-- | lua/nvim-treesitter/config.lua | 11 | ||||
| -rw-r--r-- | lua/nvim-treesitter/indent.lua | 3 | ||||
| -rw-r--r-- | lua/nvim-treesitter/install.lua | 2 |
3 files changed, 12 insertions, 4 deletions
diff --git a/lua/nvim-treesitter/config.lua b/lua/nvim-treesitter/config.lua index 09ea2b7dc..8150ad8a8 100644 --- a/lua/nvim-treesitter/config.lua +++ b/lua/nvim-treesitter/config.lua @@ -69,7 +69,7 @@ function M.get_available(tier) languages = vim.tbl_filter( --- @param p string function(p) - return parsers[p].tier == tier + return parsers[p] ~= nil and parsers[p].tier == tier end, languages ) @@ -164,8 +164,13 @@ function M.norm_languages(languages, skip) end end - table.sort(languages) - return vim.fn.uniq(languages) --[=[@as string[]]=] + -- TODO(clason): remove Nvim 0.11 compat + if vim.list then + return vim.list.unique(languages) + else + table.sort(languages) + return vim.fn.uniq(languages) --[=[@as string[] ]=] + end end return M diff --git a/lua/nvim-treesitter/indent.lua b/lua/nvim-treesitter/indent.lua index 13f7b2740..6f8e4d8ff 100644 --- a/lua/nvim-treesitter/indent.lua +++ b/lua/nvim-treesitter/indent.lua @@ -52,7 +52,8 @@ local function find_delimiter(bufnr, node, delimiter) local end_char = { child:end_() } local trimmed_after_delim local escaped_delimiter = delimiter:gsub('[%-%.%+%[%]%(%)%$%^%%%?%*]', '%%%1') - trimmed_after_delim = line:sub(end_char[2] + 1):gsub('[%s' .. escaped_delimiter .. ']*', '') + trimmed_after_delim = + assert(line):sub(end_char[2] + 1):gsub('[%s' .. escaped_delimiter .. ']*', '') return child, #trimmed_after_delim == 0 end end diff --git a/lua/nvim-treesitter/install.lua b/lua/nvim-treesitter/install.lua index 6d672908a..29c91356c 100644 --- a/lua/nvim-treesitter/install.lua +++ b/lua/nvim-treesitter/install.lua @@ -40,6 +40,7 @@ end ---@async ---@param path string +---@return string? err local function rmpath(path) local stat = uv.fs_lstat(path) if not stat then @@ -482,6 +483,7 @@ end ---@async ---@param languages string[] ---@param options? InstallOptions +---@return boolean true if installation successful local function install(languages, options) options = options or {} |
