mirror of
https://github.com/neovim/neovim
synced 2025-07-16 09:11:51 +00:00
fix(lsp): advertise supported fold kinds (#34461)
This commit also makes it so that folds which have an unsupported fold
kind have their `kind` ignored.
(cherry picked from commit 35756022cb
)
This commit is contained in:
committed by
github-actions[bot]
parent
3d5be364bc
commit
1077374380
@ -3,6 +3,13 @@ local log = require('vim.lsp.log')
|
|||||||
local ms = require('vim.lsp.protocol').Methods
|
local ms = require('vim.lsp.protocol').Methods
|
||||||
local api = vim.api
|
local api = vim.api
|
||||||
|
|
||||||
|
---@type table<lsp.FoldingRangeKind, true>
|
||||||
|
local supported_fold_kinds = {
|
||||||
|
['comment'] = true,
|
||||||
|
['imports'] = true,
|
||||||
|
['region'] = true,
|
||||||
|
}
|
||||||
|
|
||||||
local M = {}
|
local M = {}
|
||||||
|
|
||||||
---@class (private) vim.lsp.folding_range.BufState
|
---@class (private) vim.lsp.folding_range.BufState
|
||||||
@ -49,9 +56,14 @@ local function renew(bufnr)
|
|||||||
|
|
||||||
local kind = range.kind
|
local kind = range.kind
|
||||||
if kind then
|
if kind then
|
||||||
local kinds = row_kinds[start_row] or {}
|
-- Ignore unsupported fold kinds.
|
||||||
kinds[kind] = true
|
if supported_fold_kinds[kind] then
|
||||||
row_kinds[start_row] = kinds
|
local kinds = row_kinds[start_row] or {}
|
||||||
|
kinds[kind] = true
|
||||||
|
row_kinds[start_row] = kinds
|
||||||
|
else
|
||||||
|
log.info(('Received unsupported fold kind: "%s"'):format(kind))
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
for row = start_row, end_row do
|
for row = start_row, end_row do
|
||||||
|
@ -440,6 +440,9 @@ function protocol.make_client_capabilities()
|
|||||||
foldingRange = {
|
foldingRange = {
|
||||||
dynamicRegistration = false,
|
dynamicRegistration = false,
|
||||||
lineFoldingOnly = true,
|
lineFoldingOnly = true,
|
||||||
|
foldingRangeKind = {
|
||||||
|
valueSet = { 'comment', 'imports', 'region' },
|
||||||
|
},
|
||||||
foldingRange = {
|
foldingRange = {
|
||||||
collapsedText = true,
|
collapsedText = true,
|
||||||
},
|
},
|
||||||
|
Reference in New Issue
Block a user