mirror of
https://github.com/LazyVim/LazyVim.git
synced 2025-06-24 17:58:51 +02:00
fix(ui): better fallback for foldtext when buffer does not have TreeSitter
This commit is contained in:
parent
afbe2043a7
commit
762017dc35
1 changed files with 2 additions and 1 deletions
|
@ -22,7 +22,8 @@ function M.icon(sign, len)
|
||||||
end
|
end
|
||||||
|
|
||||||
function M.foldtext()
|
function M.foldtext()
|
||||||
local ret = vim.treesitter.foldtext and vim.treesitter.foldtext()
|
local ok = pcall(vim.treesitter.get_parser, vim.api.nvim_get_current_buf())
|
||||||
|
local ret = ok and vim.treesitter.foldtext and vim.treesitter.foldtext()
|
||||||
if not ret then
|
if not ret then
|
||||||
ret = { { vim.api.nvim_buf_get_lines(0, vim.v.lnum - 1, vim.v.lnum, false)[1], {} } }
|
ret = { { vim.api.nvim_buf_get_lines(0, vim.v.lnum - 1, vim.v.lnum, false)[1], {} } }
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue