Compare commits

...

3 Commits

Author SHA1 Message Date
glepnir de795b5b49
Merge 57f43bd1da into efb44e0cad 2024-05-05 10:04:15 -04:00
Maria José Solano efb44e0cad
docs: fix lua type warnings (#28633) 2024-05-05 06:08:17 +08:00
glepnir 57f43bd1da fix(highlight): update screen highlight
Problem: Some highlight not update when changed in event callback

Solution: call update_screen first.
2024-04-15 20:46:51 +08:00
8 changed files with 51 additions and 6 deletions

View File

@ -124,7 +124,7 @@ error('Cannot require a meta file')
--- @field commalist boolean
--- @field flaglist boolean
--- @field was_set boolean
--- @field last_set_id integer
--- @field last_set_sid integer
--- @field last_set_linenr integer
--- @field last_set_chan integer
--- @field type 'string'|'boolean'|'number'

View File

@ -127,3 +127,11 @@
--- @field skipcol integer
--- @field topfill integer
--- @field topline integer
--- @class vim.fn.getscriptinfo.ret
--- @field autoload false
--- @field functions? string[]
--- @field name string
--- @field sid string
--- @field variables? table<string, any>
--- @field version 1

View File

@ -3632,7 +3632,7 @@ function vim.fn.getregtype(regname) end
--- <
---
--- @param opts? table
--- @return any
--- @return vim.fn.getscriptinfo.ret[]
function vim.fn.getscriptinfo(opts) end
--- If {tabnr} is not specified, then information about all the

View File

@ -310,6 +310,7 @@ local function is_empty_or_default(bufnr, option)
end
local info = api.nvim_get_option_info2(option, { buf = bufnr })
---@param e vim.fn.getscriptinfo.ret
local scriptinfo = vim.tbl_filter(function(e)
return e.sid == info.last_set_sid
end, vim.fn.getscriptinfo())
@ -515,7 +516,7 @@ local function buf_attach(bufnr)
textDocument = {
uri = uri,
},
reason = protocol.TextDocumentSaveReason.Manual,
reason = protocol.TextDocumentSaveReason.Manual, ---@type integer
}
if vim.tbl_get(client.server_capabilities, 'textDocumentSync', 'willSave') then
client.notify(ms.textDocument_willSave, params)
@ -899,7 +900,7 @@ end
--- a `client_id:result` map.
---@return function cancel Function that cancels all requests.
function lsp.buf_request_all(bufnr, method, params, handler)
local results = {} --- @type table<integer,{error:string, result:any}>
local results = {} --- @type table<integer,{error:lsp.ResponseError, result:any}>
local result_count = 0
local expected_result_count = 0
@ -940,7 +941,7 @@ end
---@return table<integer, {err: lsp.ResponseError, result: any}>? result Map of client_id:request_result.
---@return string? err On timeout, cancel, or error, `err` is a string describing the failure reason, and `result` is nil.
function lsp.buf_request_sync(bufnr, method, params, timeout_ms)
local request_results
local request_results ---@type table
local cancel = lsp.buf_request_all(bufnr, method, params, function(it)
request_results = it

View File

@ -327,7 +327,7 @@ function M.get_captures_at_cursor(winnr)
end
--- Optional keyword arguments:
--- @class vim.treesitter.get_node.Opts
--- @class vim.treesitter.get_node.Opts : vim.treesitter.LanguageTree.tree_for_range.Opts
--- @inlinedoc
---
--- Buffer number (nil or 0 for current buffer)

View File

@ -4475,6 +4475,7 @@ M.funcs = {
]=],
name = 'getscriptinfo',
params = { { 'opts', 'table' } },
returns = 'vim.fn.getscriptinfo.ret[]',
signature = 'getscriptinfo([{opts}])',
},
gettabinfo = {

View File

@ -800,6 +800,7 @@ static uint8_t *command_line_enter(int firstc, int count, int indent, bool clear
tl_ret = true;
}
may_trigger_modechanged();
update_screen();
init_history();
s->hiscnt = get_hislen(); // set hiscnt to impossible history value

View File

@ -2386,6 +2386,40 @@ describe('highlight namespaces', function()
}
end)
it('#update screen when highlight changed in event callback', function ()
command('set cursorline number')
exec_lua[[
vim.api.nvim_create_autocmd('ModeChanged', {
callback = function()
vim.api.nvim_set_hl(0, 'CursorLineNr', { bg = 'red' })
vim.api.nvim_set_hl(0, 'CursorLine', { bg = 'green' })
end,
})
]]
feed(':')
screen:expect({
grid = [[
{11: 1 }{12: }|
{1:~ }|*8
:^ |
]],
attr_ids = {
[1] = { foreground = Screen.colors.Blue, bold = true },
[2] = { background = Screen.colors.DarkGrey },
[3] = { italic = true, background = Screen.colors.DarkOrange4, foreground = Screen.colors.DarkCyan },
[4] = { background = Screen.colors.Magenta4 },
[5] = { background = Screen.colors.Magenta4, foreground = Screen.colors.Crimson },
[6] = { bold = true, reverse = true },
[7] = { reverse = true },
[8] = { foreground = Screen.colors.Grey20 },
[9] = { foreground = Screen.colors.Blue },
[10] = { bold = true, foreground = Screen.colors.SeaGreen },
[11] = { background = Screen.colors.Red },
[12] = { background = Screen.colors.Green },
},
})
end)
it('winhl does not accept invalid value #24586', function()
local res = exec_lua([[
local curwin = vim.api.nvim_get_current_win()