mirror of https://github.com/neovim/neovim.git
feat(lsp): use a parameter strategy similar to `enable`
This commit is contained in:
parent
9b028bd64f
commit
409b81b0e7
|
@ -1649,13 +1649,15 @@ get({filter}) *vim.lsp.inlay_hint.get()*
|
||||||
• {client_id} (`integer`)
|
• {client_id} (`integer`)
|
||||||
• {inlay_hint} (`lsp.InlayHint`)
|
• {inlay_hint} (`lsp.InlayHint`)
|
||||||
|
|
||||||
is_enabled({bufnr}) *vim.lsp.inlay_hint.is_enabled()*
|
is_enabled({filter}) *vim.lsp.inlay_hint.is_enabled()*
|
||||||
|
|
||||||
Note: ~
|
Note: ~
|
||||||
• This API is pre-release (unstable).
|
• This API is pre-release (unstable).
|
||||||
|
|
||||||
Parameters: ~
|
Parameters: ~
|
||||||
• {bufnr} (`integer?`) Buffer handle, or 0 for current
|
• {filter} (`table`) Optional filters |kwargs|, or `nil` for all.
|
||||||
|
• {bufnr} (`integer?`) Buffer number, or 0/nil for current
|
||||||
|
buffer.
|
||||||
|
|
||||||
Return: ~
|
Return: ~
|
||||||
(`boolean`)
|
(`boolean`)
|
||||||
|
|
|
@ -146,6 +146,8 @@ BREAKING CHANGES IN HEAD *news-breaking-dev*
|
||||||
The following breaking changes were made during the development cycle to
|
The following breaking changes were made during the development cycle to
|
||||||
unreleased features on Nvim HEAD.
|
unreleased features on Nvim HEAD.
|
||||||
|
|
||||||
|
• Changed the signature of `vim.lsp.inlay_hint.is_enabled()`.
|
||||||
|
|
||||||
• Removed `vim.treesitter.foldtext` as transparent foldtext is now supported
|
• Removed `vim.treesitter.foldtext` as transparent foldtext is now supported
|
||||||
https://github.com/neovim/neovim/pull/20750
|
https://github.com/neovim/neovim/pull/20750
|
||||||
|
|
||||||
|
|
|
@ -353,11 +353,25 @@ api.nvim_set_decoration_provider(namespace, {
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
--- @param bufnr (integer|nil) Buffer handle, or 0 for current
|
--- @param filter vim.lsp.inlay_hint.enable.Filter
|
||||||
--- @return boolean
|
--- @return boolean
|
||||||
--- @since 12
|
--- @since 12
|
||||||
function M.is_enabled(bufnr)
|
function M.is_enabled(filter)
|
||||||
vim.validate({ bufnr = { bufnr, 'number', true } })
|
---@type integer
|
||||||
|
local bufnr
|
||||||
|
if type(filter) == 'number' then
|
||||||
|
vim.deprecate(
|
||||||
|
'vim.lsp.inlay_hint.is_enabled(bufnr:number)',
|
||||||
|
'vim.lsp.inlay_hint.is_enabled(filter:table)',
|
||||||
|
'0.10-dev'
|
||||||
|
)
|
||||||
|
bufnr = filter
|
||||||
|
else
|
||||||
|
vim.validate({ filter = { filter, 'table', true } })
|
||||||
|
filter = filter or {}
|
||||||
|
bufnr = filter.bufnr
|
||||||
|
end
|
||||||
|
|
||||||
if bufnr == nil or bufnr == 0 then
|
if bufnr == nil or bufnr == 0 then
|
||||||
bufnr = api.nvim_get_current_buf()
|
bufnr = api.nvim_get_current_buf()
|
||||||
end
|
end
|
||||||
|
|
|
@ -145,7 +145,7 @@ describe('vim.lsp.inlay_hint', function()
|
||||||
screen:expect({ grid = grid_with_inlay_hints, unchanged = true })
|
screen:expect({ grid = grid_with_inlay_hints, unchanged = true })
|
||||||
|
|
||||||
exec_lua(
|
exec_lua(
|
||||||
[[vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled(bufnr), { bufnr = bufnr })]]
|
[[vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled({ bufnr = bufnr }), { bufnr = bufnr })]]
|
||||||
)
|
)
|
||||||
screen:expect({ grid = grid_without_inlay_hints, unchanged = true })
|
screen:expect({ grid = grid_without_inlay_hints, unchanged = true })
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue