diff options
Diffstat (limited to 'runtime/lua/vim')
-rw-r--r-- | runtime/lua/vim/_meta/api.lua | 4 | ||||
-rw-r--r-- | runtime/lua/vim/_meta/vimfn.lua | 6 | ||||
-rw-r--r-- | runtime/lua/vim/_meta/vvars.lua | 2 | ||||
-rw-r--r-- | runtime/lua/vim/_system.lua | 9 | ||||
-rw-r--r-- | runtime/lua/vim/lsp/semantic_tokens.lua | 72 |
5 files changed, 67 insertions, 26 deletions
diff --git a/runtime/lua/vim/_meta/api.lua b/runtime/lua/vim/_meta/api.lua index 8236cc7cf0..c28af7bbff 100644 --- a/runtime/lua/vim/_meta/api.lua +++ b/runtime/lua/vim/_meta/api.lua @@ -1110,8 +1110,8 @@ function vim.api.nvim_del_var(name) end --- can be omitted for no highlight. --- @param history boolean if true, add to `message-history`. --- @param opts vim.api.keyset.echo_opts Optional parameters. ---- - verbose: Message was printed as a result of 'verbose' option ---- if Nvim was invoked with -V3log_file, the message will be +--- - verbose: Message is printed as a result of 'verbose' option. +--- If Nvim was invoked with -V3log_file, the message will be --- redirected to the log_file and suppressed from direct output. function vim.api.nvim_echo(chunks, history, opts) end diff --git a/runtime/lua/vim/_meta/vimfn.lua b/runtime/lua/vim/_meta/vimfn.lua index 7548d1beb2..5eb15e1eee 100644 --- a/runtime/lua/vim/_meta/vimfn.lua +++ b/runtime/lua/vim/_meta/vimfn.lua @@ -828,7 +828,7 @@ function vim.fn.charclass(string) end --- echo col('.') " returns 7 --- < --- ---- @param expr string|integer[] +--- @param expr string|any[] --- @param winid? integer --- @return integer function vim.fn.charcol(expr, winid) end @@ -956,7 +956,7 @@ function vim.fn.clearmatches(win) end --- imap <F2> <Cmd>echo col(".").."\n"<CR> --- < --- ---- @param expr string|integer[] +--- @param expr string|any[] --- @param winid? integer --- @return integer function vim.fn.col(expr, winid) end @@ -10546,7 +10546,7 @@ function vim.fn.values(dict) end --- echo max(map(range(1, line('$')), "virtcol([v:val, '$'])")) --- < --- ---- @param expr string|integer[] +--- @param expr string|any[] --- @param list? boolean --- @param winid? integer --- @return any diff --git a/runtime/lua/vim/_meta/vvars.lua b/runtime/lua/vim/_meta/vvars.lua index e00402ab3f..733aa965a2 100644 --- a/runtime/lua/vim/_meta/vvars.lua +++ b/runtime/lua/vim/_meta/vvars.lua @@ -166,7 +166,7 @@ vim.v.errors = ... --- inclusive Motion is `inclusive`, else exclusive. --- scope Event-specific scope name. --- operator Current `operator`. Also set for Ex ---- commands (unlike `v:operator`). For +--- commands (unlike `v:operator`). For --- example if `TextYankPost` is triggered --- by the `:yank` Ex command then --- `v:event.operator` is "y". diff --git a/runtime/lua/vim/_system.lua b/runtime/lua/vim/_system.lua index 9e27b4c152..ce5dbffeaa 100644 --- a/runtime/lua/vim/_system.lua +++ b/runtime/lua/vim/_system.lua @@ -230,6 +230,8 @@ local function default_handler(stream, text, bucket) end end +local is_win = vim.fn.has('win32') == 1 + local M = {} --- @param cmd string @@ -238,6 +240,13 @@ local M = {} --- @param on_error fun() --- @return uv.uv_process_t, integer local function spawn(cmd, opts, on_exit, on_error) + if is_win then + local cmd1 = vim.fn.exepath(cmd) + if cmd1 ~= '' then + cmd = cmd1 + end + end + local handle, pid_or_err = uv.spawn(cmd, opts, on_exit) if not handle then on_error() diff --git a/runtime/lua/vim/lsp/semantic_tokens.lua b/runtime/lua/vim/lsp/semantic_tokens.lua index d680522592..f23c694c4b 100644 --- a/runtime/lua/vim/lsp/semantic_tokens.lua +++ b/runtime/lua/vim/lsp/semantic_tokens.lua @@ -380,6 +380,37 @@ function STHighlighter:process_response(response, client, version) api.nvim__redraw({ buf = self.bufnr, valid = true }) end +--- @param bufnr integer +--- @param ns integer +--- @param token STTokenRange +--- @param hl_group string +--- @param priority integer +local function set_mark(bufnr, ns, token, hl_group, priority) + vim.api.nvim_buf_set_extmark(bufnr, ns, token.line, token.start_col, { + hl_group = hl_group, + end_col = token.end_col, + priority = priority, + strict = false, + }) +end + +--- @param lnum integer +--- @param foldend integer? +--- @return boolean, integer? +local function check_fold(lnum, foldend) + if foldend and lnum <= foldend then + return true, foldend + end + + local folded = vim.fn.foldclosed(lnum) + + if folded == -1 then + return false, nil + end + + return folded ~= lnum, vim.fn.foldclosedend(lnum) +end + --- on_win handler for the decoration provider (see |nvim_set_decoration_provider|) --- --- If there is a current result for the buffer and the version matches the @@ -433,13 +464,14 @@ function STHighlighter:on_win(topline, botline) -- finishes, clangd sends a refresh request which lets the client -- re-synchronize the tokens. - local set_mark = function(token, hl_group, delta) - vim.api.nvim_buf_set_extmark(self.bufnr, state.namespace, token.line, token.start_col, { - hl_group = hl_group, - end_col = token.end_col, - priority = vim.hl.priorities.semantic_tokens + delta, - strict = false, - }) + local function set_mark0(token, hl_group, delta) + set_mark( + self.bufnr, + state.namespace, + token, + hl_group, + vim.hl.priorities.semantic_tokens + delta + ) end local ft = vim.bo[self.bufnr].filetype @@ -447,13 +479,19 @@ function STHighlighter:on_win(topline, botline) local first = lower_bound(highlights, topline, 1, #highlights + 1) local last = upper_bound(highlights, botline, first, #highlights + 1) - 1 + --- @type boolean?, integer? + local is_folded, foldend + for i = first, last do local token = highlights[i] - if not token.marked then - set_mark(token, string.format('@lsp.type.%s.%s', token.type, ft), 0) - for modifier, _ in pairs(token.modifiers) do - set_mark(token, string.format('@lsp.mod.%s.%s', modifier, ft), 1) - set_mark(token, string.format('@lsp.typemod.%s.%s.%s', token.type, modifier, ft), 2) + + is_folded, foldend = check_fold(token.line + 1, foldend) + + if not is_folded and not token.marked then + set_mark0(token, string.format('@lsp.type.%s.%s', token.type, ft), 0) + for modifier in pairs(token.modifiers) do + set_mark0(token, string.format('@lsp.mod.%s.%s', modifier, ft), 1) + set_mark0(token, string.format('@lsp.typemod.%s.%s.%s', token.type, modifier, ft), 2) end token.marked = true @@ -745,15 +783,9 @@ function M.highlight_token(token, bufnr, client_id, hl_group, opts) return end - opts = opts or {} - local priority = opts.priority or vim.hl.priorities.semantic_tokens + 3 + local priority = opts and opts.priority or vim.hl.priorities.semantic_tokens + 3 - vim.api.nvim_buf_set_extmark(bufnr, state.namespace, token.line, token.start_col, { - hl_group = hl_group, - end_col = token.end_col, - priority = priority, - strict = false, - }) + set_mark(bufnr, state.namespace, token, hl_group, priority) end --- |lsp-handler| for the method `workspace/semanticTokens/refresh` |