diff options
Diffstat (limited to 'runtime/lua/vim')
-rw-r--r-- | runtime/lua/vim/diagnostic.lua | 23 | ||||
-rw-r--r-- | runtime/lua/vim/filetype.lua | 6 | ||||
-rw-r--r-- | runtime/lua/vim/lsp/util.lua | 4 | ||||
-rw-r--r-- | runtime/lua/vim/shared.lua | 27 | ||||
-rw-r--r-- | runtime/lua/vim/treesitter/highlighter.lua | 10 |
5 files changed, 56 insertions, 14 deletions
diff --git a/runtime/lua/vim/diagnostic.lua b/runtime/lua/vim/diagnostic.lua index fcb1e61764..1ec66d7c55 100644 --- a/runtime/lua/vim/diagnostic.lua +++ b/runtime/lua/vim/diagnostic.lua @@ -1224,6 +1224,18 @@ function M.open_float(opts, ...) opts = opts or {} bufnr = get_bufnr(bufnr or opts.bufnr) + + do + -- Resolve options with user settings from vim.diagnostic.config + -- Unlike the other decoration functions (e.g. set_virtual_text, set_signs, etc.) `open_float` + -- does not have a dedicated table for configuration options; instead, the options are mixed in + -- with its `opts` table which also includes "keyword" parameters. So we create a dedicated + -- options table that inherits missing keys from the global configuration before resolving. + local t = global_diagnostic_options.float + local float_opts = vim.tbl_extend("keep", opts, type(t) == "table" and t or {}) + opts = get_resolved_options({ float = float_opts }, nil, bufnr).float + end + local scope = ({l = "line", c = "cursor", b = "buffer"})[opts.scope] or opts.scope or "line" local lnum, col if scope == "line" or scope == "cursor" then @@ -1242,17 +1254,6 @@ function M.open_float(opts, ...) error("Invalid value for option 'scope'") end - do - -- Resolve options with user settings from vim.diagnostic.config - -- Unlike the other decoration functions (e.g. set_virtual_text, set_signs, etc.) `open_float` - -- does not have a dedicated table for configuration options; instead, the options are mixed in - -- with its `opts` table which also includes "keyword" parameters. So we create a dedicated - -- options table that inherits missing keys from the global configuration before resolving. - local t = global_diagnostic_options.float - local float_opts = vim.tbl_extend("keep", opts, type(t) == "table" and t or {}) - opts = get_resolved_options({ float = float_opts }, nil, bufnr).float - end - local diagnostics = get_diagnostics(bufnr, opts, true) if scope == "line" then diff --git a/runtime/lua/vim/filetype.lua b/runtime/lua/vim/filetype.lua index b356f5e3dc..927ef36391 100644 --- a/runtime/lua/vim/filetype.lua +++ b/runtime/lua/vim/filetype.lua @@ -21,7 +21,7 @@ end ---@private local function getline(bufnr, lnum) - return api.nvim_buf_get_lines(bufnr, lnum-1, lnum, false)[1] + return api.nvim_buf_get_lines(bufnr, lnum-1, lnum, false)[1] or "" end -- Filetypes based on file extension @@ -438,6 +438,8 @@ local extension = { opam = "opam", ["or"] = "openroad", ora = "ora", + org = "org", + org_archive = "org", pxsl = "papp", papp = "papp", pxml = "papp", @@ -1424,6 +1426,8 @@ local pattern = { return "git" end end, + -- Neovim only + [".*/queries/.*%.scm"] = "query", -- tree-sitter queries -- END PATTERN } -- luacheck: pop diff --git a/runtime/lua/vim/lsp/util.lua b/runtime/lua/vim/lsp/util.lua index cec3891418..401dac9acd 100644 --- a/runtime/lua/vim/lsp/util.lua +++ b/runtime/lua/vim/lsp/util.lua @@ -360,7 +360,7 @@ end --- Applies a list of text edits to a buffer. ---@param text_edits table list of `TextEdit` objects ---@param bufnr number Buffer id ----@param offset_encoding string utf-8|utf-16|utf-32 defaults to encoding of first client of `bufnr` +---@param offset_encoding string utf-8|utf-16|utf-32 ---@see https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textEdit function M.apply_text_edits(text_edits, bufnr, offset_encoding) validate { @@ -1138,7 +1138,7 @@ function M.stylize_markdown(bufnr, contents, opts) block = {nil, "```+([a-zA-Z0-9_]*)", "```+"}, pre = {"", "<pre>", "</pre>"}, code = {"", "<code>", "</code>"}, - text = {"plaintex", "<text>", "</text>"}, + text = {"text", "<text>", "</text>"}, } local match_begin = function(line) diff --git a/runtime/lua/vim/shared.lua b/runtime/lua/vim/shared.lua index 3eb332279a..f0dc34608c 100644 --- a/runtime/lua/vim/shared.lua +++ b/runtime/lua/vim/shared.lua @@ -347,6 +347,33 @@ function vim.tbl_add_reverse_lookup(o) return o end +--- Index into a table (first argument) via string keys passed as subsequent arguments. +--- Return `nil` if the key does not exist. +--_ +--- Examples: +--- <pre> +--- vim.tbl_get({ key = { nested_key = true }}, 'key', 'nested_key') == true +--- vim.tbl_get({ key = {}}, 'key', 'nested_key') == nil +--- </pre> +--- +---@param o Table to index +---@param ... Optional strings (0 or more, variadic) via which to index the table +--- +---@returns nested value indexed by key if it exists, else nil +function vim.tbl_get(o, ...) + local keys = {...} + if #keys == 0 then + return + end + for _, k in ipairs(keys) do + o = o[k] + if o == nil then + return + end + end + return o +end + --- Extends a list-like table with the values of another list-like table. --- --- NOTE: This mutates dst! diff --git a/runtime/lua/vim/treesitter/highlighter.lua b/runtime/lua/vim/treesitter/highlighter.lua index e1ffd42a7f..0ec4ab37ec 100644 --- a/runtime/lua/vim/treesitter/highlighter.lua +++ b/runtime/lua/vim/treesitter/highlighter.lua @@ -38,6 +38,9 @@ local subcapture_fallback = { TSHighlighter.hl_map = setmetatable({ ["error"] = "Error", + ["text.underline"] = "Underlined", + ["todo"] = "Todo", + ["debug"] = "Debug", -- Miscs ["comment"] = "Comment", @@ -49,10 +52,13 @@ TSHighlighter.hl_map = setmetatable({ ["constant"] = "Constant", ["constant.builtin"] = "Special", ["constant.macro"] = "Define", + ["define"] = "Define", + ["macro"] = "Macro", ["string"] = "String", ["string.regex"] = "String", ["string.escape"] = "SpecialChar", ["character"] = "Character", + ["character.special"] = "SpecialChar", ["number"] = "Number", ["boolean"] = "Boolean", ["float"] = "Float", @@ -78,8 +84,12 @@ TSHighlighter.hl_map = setmetatable({ ["type"] = "Type", ["type.builtin"] = "Type", + ["type.qualifier"] = "Type", + ["type.definition"] = "Typedef", + ["storageclass"] = "StorageClass", ["structure"] = "Structure", ["include"] = "Include", + ["preproc"] = "PreProc", }, subcapture_fallback) ---@private |