feat: lib.lazyvim.ui.foldexpr -> nvim_treesitter#foldexpr
This commit is contained in:
parent
0225b92b5e
commit
f1ba3cfeb6
2 changed files with 1 additions and 20 deletions
|
@ -3,25 +3,6 @@
|
||||||
---@class lib.lazyvim.ui
|
---@class lib.lazyvim.ui
|
||||||
local M = {}
|
local M = {}
|
||||||
|
|
||||||
-- Optimized treesitter foldexpr for Neovim >= 0.10.0
|
|
||||||
function M.foldexpr()
|
|
||||||
local buf = vim.api.nvim_get_current_buf()
|
|
||||||
if vim.b[buf].ts_folds == nil then
|
|
||||||
-- as long as we don't have a filetype, don't bother checking if treesitter
|
|
||||||
-- is available (it won't be)
|
|
||||||
if vim.bo[buf].filetype == '' then
|
|
||||||
return '0'
|
|
||||||
end
|
|
||||||
if vim.bo[buf].filetype:find('dashboard') then
|
|
||||||
vim.b[buf].ts_folds = false
|
|
||||||
else
|
|
||||||
vim.b[buf].ts_folds = pcall(vim.treesitter.get_parser, buf)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
return vim.b[buf].ts_folds and vim.treesitter.foldexpr() or '0'
|
|
||||||
end
|
|
||||||
|
|
||||||
---@return {fg?:string}?
|
---@return {fg?:string}?
|
||||||
function M.fg(name)
|
function M.fg(name)
|
||||||
local hl = vim.api.nvim_get_hl(0, { name = name, link = false })
|
local hl = vim.api.nvim_get_hl(0, { name = name, link = false })
|
||||||
|
|
|
@ -70,7 +70,7 @@ opt.foldcolumn = '1'
|
||||||
opt.foldlevel = 99
|
opt.foldlevel = 99
|
||||||
opt.foldenable = true
|
opt.foldenable = true
|
||||||
opt.foldmethod = 'expr'
|
opt.foldmethod = 'expr'
|
||||||
opt.foldexpr = "v:lua.require'lib.lazyvim.ui'.foldtext()"
|
opt.foldexpr = 'nvim_treesitter#foldexpr()'
|
||||||
opt.foldtext = ''
|
opt.foldtext = ''
|
||||||
|
|
||||||
-- Always keep 4 lines above/below cursor.
|
-- Always keep 4 lines above/below cursor.
|
||||||
|
|
Loading…
Reference in a new issue