refactor(lsp): correct enable marker name

This commit is contained in:
Yi Ming
2025-07-21 21:06:13 +08:00
parent 2ace4089f8
commit 050b04384e
2 changed files with 9 additions and 9 deletions

View File

@@ -87,7 +87,7 @@ end
--- Force `foldexpr()` to be re-evaluated, without opening folds. --- Force `foldexpr()` to be re-evaluated, without opening folds.
---@param bufnr integer ---@param bufnr integer
local function foldupdate(bufnr) local function foldupdate(bufnr)
if not api.nvim_buf_is_loaded(bufnr) or not vim.b[bufnr]._lsp_enable_folding_range then if not api.nvim_buf_is_loaded(bufnr) or not vim.b[bufnr]._lsp_enabled_folding_range then
return return
end end
for _, winid in ipairs(vim.fn.win_findbuf(bufnr)) do for _, winid in ipairs(vim.fn.win_findbuf(bufnr)) do
@@ -159,7 +159,7 @@ end
--- `foldupdate()` is scheduled once after the request is completed. --- `foldupdate()` is scheduled once after the request is completed.
---@param client? vim.lsp.Client The client whose server supports `foldingRange`. ---@param client? vim.lsp.Client The client whose server supports `foldingRange`.
function State:refresh(client) function State:refresh(client)
if not vim.b._lsp_enable_folding_range then if not vim.b._lsp_enabled_folding_range then
return return
end end
@@ -252,7 +252,7 @@ function State:new(bufnr)
pattern = 'foldexpr', pattern = 'foldexpr',
callback = function() callback = function()
if vim.v.option_type == 'global' or vim.api.nvim_get_current_buf() == bufnr then if vim.v.option_type == 'global' or vim.api.nvim_get_current_buf() == bufnr then
vim.b[bufnr]._lsp_enable_folding_range = nil vim.b[bufnr]._lsp_enabled_folding_range = nil
end end
end, end,
}) })
@@ -353,8 +353,8 @@ end
function M.foldexpr(lnum) function M.foldexpr(lnum)
local bufnr = api.nvim_get_current_buf() local bufnr = api.nvim_get_current_buf()
local state = State.active[bufnr] local state = State.active[bufnr]
if not vim.b[bufnr]._lsp_enable_folding_range then if not vim.b[bufnr]._lsp_enabled_folding_range then
vim.b[bufnr]._lsp_enable_folding_range = true vim.b[bufnr]._lsp_enabled_folding_range = true
if state then if state then
state:refresh() state:refresh()
end end

View File

@@ -135,25 +135,25 @@ static int foldLevel(linenr_T lnum)
command([[split]]) command([[split]])
end) end)
it('controls the value of `b:_lsp_enable_folding_range`', function() it('controls the value of `b:_lsp_enabled_folding_range`', function()
eq( eq(
true, true,
exec_lua(function() exec_lua(function()
return vim.b._lsp_enable_folding_range return vim.b._lsp_enabled_folding_range
end) end)
) )
command [[setlocal foldexpr=]] command [[setlocal foldexpr=]]
eq( eq(
nil, nil,
exec_lua(function() exec_lua(function()
return vim.b._lsp_enable_folding_range return vim.b._lsp_enabled_folding_range
end) end)
) )
command([[set foldexpr=v:lua.vim.lsp.foldexpr()]]) command([[set foldexpr=v:lua.vim.lsp.foldexpr()]])
eq( eq(
true, true,
exec_lua(function() exec_lua(function()
return vim.b._lsp_enable_folding_range return vim.b._lsp_enabled_folding_range
end) end)
) )
end) end)