diff options
Diffstat (limited to 'runtime/lua')
-rw-r--r-- | runtime/lua/vim/_editor.lua | 23 | ||||
-rw-r--r-- | runtime/lua/vim/_meta.lua | 2 | ||||
-rw-r--r-- | runtime/lua/vim/diagnostic.lua | 4 | ||||
-rw-r--r-- | runtime/lua/vim/hl.lua (renamed from runtime/lua/vim/highlight.lua) | 14 | ||||
-rw-r--r-- | runtime/lua/vim/lsp/handlers.lua | 2 | ||||
-rw-r--r-- | runtime/lua/vim/lsp/semantic_tokens.lua | 6 | ||||
-rw-r--r-- | runtime/lua/vim/lsp/util.lua | 5 | ||||
-rw-r--r-- | runtime/lua/vim/shared.lua | 26 | ||||
-rw-r--r-- | runtime/lua/vim/treesitter/highlighter.lua | 2 |
9 files changed, 59 insertions, 25 deletions
diff --git a/runtime/lua/vim/_editor.lua b/runtime/lua/vim/_editor.lua index f0b8cf6a52..7aba7498f9 100644 --- a/runtime/lua/vim/_editor.lua +++ b/runtime/lua/vim/_editor.lua @@ -32,7 +32,7 @@ for k, v in pairs({ func = true, F = true, lsp = true, - highlight = true, + hl = true, diagnostic = true, keymap = true, ui = true, @@ -1149,16 +1149,22 @@ function vim.deprecate(name, alternative, version, plugin, backtrace) if plugin == 'Nvim' then require('vim.deprecated.health').add(name, version, traceback(), alternative) - -- Only issue warning if feature is hard-deprecated as specified by MAINTAIN.md. - -- Example: if removal_version is 0.12 (soft-deprecated since 0.10-dev), show warnings starting at - -- 0.11, including 0.11-dev + -- Show a warning only if feature is hard-deprecated (see MAINTAIN.md). + -- Example: if removal `version` is 0.12 (soft-deprecated since 0.10-dev), show warnings + -- starting at 0.11, including 0.11-dev. local major, minor = version:match('(%d+)%.(%d+)') major, minor = tonumber(major), tonumber(minor) + local nvim_major = 0 --- Current Nvim major version. + + -- We can't "subtract" from a major version, so: + -- * Always treat `major > nvim_major` as soft-deprecation. + -- * Compare `minor - 1` if `major == nvim_major`. + if major > nvim_major then + return -- Always soft-deprecation (see MAINTAIN.md). + end local hard_deprecated_since = string.format('nvim-%d.%d', major, minor - 1) - -- Assume there will be no next minor version before bumping up the major version - local is_hard_deprecated = minor == 0 or vim.fn.has(hard_deprecated_since) == 1 - if not is_hard_deprecated then + if major == nvim_major and vim.fn.has(hard_deprecated_since) == 0 then return end @@ -1191,4 +1197,7 @@ require('vim._options') ---@deprecated vim.loop = vim.uv +-- Deprecated. Remove at Nvim 2.0 +vim.highlight = vim._defer_deprecated_module('vim.highlight', 'vim.hl') + return vim diff --git a/runtime/lua/vim/_meta.lua b/runtime/lua/vim/_meta.lua index c9f207cb20..f8672d1f1f 100644 --- a/runtime/lua/vim/_meta.lua +++ b/runtime/lua/vim/_meta.lua @@ -15,7 +15,7 @@ vim.fs = require('vim.fs') vim.func = require('vim.func') vim.glob = require('vim.glob') vim.health = require('vim.health') -vim.highlight = require('vim.highlight') +vim.hl = require('vim.hl') vim.iter = require('vim.iter') vim.keymap = require('vim.keymap') vim.loader = require('vim.loader') diff --git a/runtime/lua/vim/diagnostic.lua b/runtime/lua/vim/diagnostic.lua index 99fcfd57e7..3570956efd 100644 --- a/runtime/lua/vim/diagnostic.lua +++ b/runtime/lua/vim/diagnostic.lua @@ -1498,13 +1498,13 @@ M.handlers.underline = { end end - vim.highlight.range( + vim.hl.range( bufnr, underline_ns, higroup, { diagnostic.lnum, diagnostic.col }, { diagnostic.end_lnum, diagnostic.end_col }, - { priority = vim.highlight.priorities.diagnostics } + { priority = vim.hl.priorities.diagnostics } ) end save_extmarks(underline_ns, bufnr) diff --git a/runtime/lua/vim/highlight.lua b/runtime/lua/vim/hl.lua index a8d88db372..49bbaa3cc6 100644 --- a/runtime/lua/vim/highlight.lua +++ b/runtime/lua/vim/hl.lua @@ -17,7 +17,7 @@ M.priorities = { user = 200, } ---- @class vim.highlight.range.Opts +--- @class vim.hl.range.Opts --- @inlinedoc --- --- Type of range. See [getregtype()] @@ -28,8 +28,8 @@ M.priorities = { --- (default: `false`) --- @field inclusive? boolean --- ---- Indicates priority of highlight ---- (default: `vim.highlight.priorities.user`) +--- Highlight priority +--- (default: `vim.hl.priorities.user`) --- @field priority? integer --- Apply highlight group to range of text. @@ -39,7 +39,7 @@ M.priorities = { ---@param higroup string Highlight group to use for highlighting ---@param start integer[]|string Start of region as a (line, column) tuple or string accepted by |getpos()| ---@param finish integer[]|string End of region as a (line, column) tuple or string accepted by |getpos()| ----@param opts? vim.highlight.range.Opts +---@param opts? vim.hl.range.Opts function M.range(bufnr, ns, higroup, start, finish, opts) opts = opts or {} local regtype = opts.regtype or 'v' @@ -124,7 +124,7 @@ local yank_cancel --- @type fun()? --- Add the following to your `init.vim`: --- --- ```vim ---- autocmd TextYankPost * silent! lua vim.highlight.on_yank {higroup='Visual', timeout=300} +--- autocmd TextYankPost * silent! lua vim.hl.on_yank {higroup='Visual', timeout=300} --- ``` --- --- @param opts table|nil Optional parameters @@ -133,7 +133,7 @@ local yank_cancel --- @type fun()? --- - on_macro highlight when executing macro (default false) --- - on_visual highlight when yanking visual selection (default true) --- - event event structure (default vim.v.event) ---- - priority integer priority (default |vim.highlight.priorities|`.user`) +--- - priority integer priority (default |vim.hl.priorities|`.user`) function M.on_yank(opts) vim.validate({ opts = { @@ -145,7 +145,7 @@ function M.on_yank(opts) return type(t) == 'table' end end, - 'a table or nil to configure options (see `:h highlight.on_yank`)', + 'a table or nil to configure options (see `:h vim.hl.on_yank`)', }, }) opts = opts or {} diff --git a/runtime/lua/vim/lsp/handlers.lua b/runtime/lua/vim/lsp/handlers.lua index c87cf94b98..37cb07025c 100644 --- a/runtime/lua/vim/lsp/handlers.lua +++ b/runtime/lua/vim/lsp/handlers.lua @@ -437,7 +437,7 @@ function M.signature_help(_, result, ctx, config) local fbuf, fwin = util.open_floating_preview(lines, 'markdown', config) -- Highlight the active parameter. if hl then - vim.highlight.range( + vim.hl.range( fbuf, sig_help_ns, 'LspSignatureActiveParameter', diff --git a/runtime/lua/vim/lsp/semantic_tokens.lua b/runtime/lua/vim/lsp/semantic_tokens.lua index 2c7958b0d5..0f6e45c330 100644 --- a/runtime/lua/vim/lsp/semantic_tokens.lua +++ b/runtime/lua/vim/lsp/semantic_tokens.lua @@ -443,7 +443,7 @@ function STHighlighter:on_win(topline, botline) 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.highlight.priorities.semantic_tokens + delta, + priority = vim.hl.priorities.semantic_tokens + delta, strict = false, }) end @@ -723,7 +723,7 @@ end --- @inlinedoc --- --- Priority for the applied extmark. ---- (Default: `vim.highlight.priorities.semantic_tokens + 3`) +--- (Default: `vim.hl.priorities.semantic_tokens + 3`) --- @field priority? integer --- Highlight a semantic token. @@ -752,7 +752,7 @@ function M.highlight_token(token, bufnr, client_id, hl_group, opts) end opts = opts or {} - local priority = opts.priority or vim.highlight.priorities.semantic_tokens + 3 + local priority = 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, diff --git a/runtime/lua/vim/lsp/util.lua b/runtime/lua/vim/lsp/util.lua index 2c28633e3c..2e9c71cf38 100644 --- a/runtime/lua/vim/lsp/util.lua +++ b/runtime/lua/vim/lsp/util.lua @@ -2,7 +2,6 @@ local protocol = require('vim.lsp.protocol') local validate = vim.validate local api = vim.api local list_extend = vim.list_extend -local highlight = vim.highlight local uv = vim.uv local M = {} @@ -1716,13 +1715,13 @@ do --[[ References ]] [protocol.DocumentHighlightKind.Write] = 'LspReferenceWrite', } local kind = reference['kind'] or protocol.DocumentHighlightKind.Text - highlight.range( + vim.hl.range( bufnr, reference_ns, document_highlight_kind[kind], { start_line, start_idx }, { end_line, end_idx }, - { priority = vim.highlight.priorities.user } + { priority = vim.hl.priorities.user } ) end end diff --git a/runtime/lua/vim/shared.lua b/runtime/lua/vim/shared.lua index d11489b539..fd6a37001d 100644 --- a/runtime/lua/vim/shared.lua +++ b/runtime/lua/vim/shared.lua @@ -1164,6 +1164,32 @@ function vim._defer_require(root, mod) }) end +--- @private +--- Creates a module alias/shim that lazy-loads a target module. +--- +--- Unlike `vim.defaulttable()` this also: +--- - implements __call +--- - calls vim.deprecate() +--- +--- @param old_name string Name of the deprecated module, which will be shimmed. +--- @param new_name string Name of the new module, which will be loaded by require(). +function vim._defer_deprecated_module(old_name, new_name) + return setmetatable({}, { + ---@param _ table<string, any> + ---@param k string + __index = function(_, k) + vim.deprecate(old_name, new_name, '2.0.0', nil, false) + local target = require(new_name) + return target[k] + end, + __call = function(self) + vim.deprecate(old_name, new_name, '2.0.0', nil, false) + local target = require(new_name) + return target(self) + end, + }) +end + --- @nodoc --- @class vim.context.mods --- @field bo? table<string, any> diff --git a/runtime/lua/vim/treesitter/highlighter.lua b/runtime/lua/vim/treesitter/highlighter.lua index a94c408f4e..7bdcdc774a 100644 --- a/runtime/lua/vim/treesitter/highlighter.lua +++ b/runtime/lua/vim/treesitter/highlighter.lua @@ -328,7 +328,7 @@ local function on_line_impl(self, buf, line, is_spell_nav) -- The "priority" attribute can be set at the pattern level or on a particular capture local priority = ( tonumber(metadata.priority or metadata[capture] and metadata[capture].priority) - or vim.highlight.priorities.treesitter + or vim.hl.priorities.treesitter ) + spell_pri_offset -- The "conceal" attribute can be set at the pattern level or on a particular capture |