Skip to content

Commit 6ee81cd

Browse files
committed
feat: update to using new treesitter utilities in AstroCore
1 parent 240377e commit 6ee81cd

File tree

2 files changed

+4
-7
lines changed

2 files changed

+4
-7
lines changed

lua/astroui/folding.lua

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,16 @@ local config = require("astroui").config.folding
1212

1313
local is_setup = false
1414
local lsp_bufs = {}
15-
local ts_bufs = {}
1615

1716
local fold_methods = {
1817
lsp = function(lnum, bufnr)
1918
if lsp_bufs[bufnr or vim.api.nvim_get_current_buf()] then return vim.lsp.foldexpr(lnum) end
2019
end,
2120
treesitter = function(lnum, bufnr)
22-
if ts_bufs[bufnr] == nil then
23-
if not require("astrocore").is_available "nvim-treesitter" or package.loaded["nvim-treesitter"] then
24-
ts_bufs[bufnr] = vim.bo.filetype and pcall(vim.treesitter.get_parser, bufnr)
25-
end
21+
local treesitter = require "astrocore.treesitter"
22+
if treesitter.has_parser(bufnr, "folds") and treesitter.is_enabled(bufnr) then
23+
return vim.treesitter.foldexpr(lnum)
2624
end
27-
if ts_bufs[bufnr] then return vim.treesitter.foldexpr(lnum) end
2825
end,
2926
indent = function(lnum, bufnr)
3027
if not lnum then lnum = vim.v.lnum end

lua/astroui/status/condition.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ end
190190
function M.treesitter_available(bufnr)
191191
if type(bufnr) == "table" then bufnr = bufnr.bufnr end
192192
if not bufnr then bufnr = vim.api.nvim_get_current_buf() end
193-
return vim.treesitter.highlighter.active[bufnr] ~= nil
193+
return require("astrocore.treesitter").is_enabled(bufnr)
194194
end
195195

196196
--- A condition function if the foldcolumn is enabled

0 commit comments

Comments
 (0)