diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 20f2adf..ebd7266 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -52,6 +52,7 @@ jobs: include: - nvim_tag: v0.8.3 - nvim_tag: v0.9.4 + - nvim_tag: v0.10.0 name: Run tests runs-on: ubuntu-22.04 diff --git a/lua/oil/adapters/ssh.lua b/lua/oil/adapters/ssh.lua index 40275a7..c52f5a9 100644 --- a/lua/oil/adapters/ssh.lua +++ b/lua/oil/adapters/ssh.lua @@ -364,7 +364,9 @@ M.read_file = function(bufnr) local url = M.parse_url(bufname) local scp_url = url_to_scp(url) local basename = pathutil.basename(bufname) - local tmpdir = fs.join(vim.fn.stdpath("cache"), "oil") + local cache_dir = vim.fn.stdpath("cache") + assert(type(cache_dir) == "string") + local tmpdir = fs.join(cache_dir, "oil") fs.mkdirp(tmpdir) local fd, tmpfile = vim.loop.fs_mkstemp(fs.join(tmpdir, "ssh_XXXXXX")) if fd then @@ -402,7 +404,9 @@ M.write_file = function(bufnr) local bufname = vim.api.nvim_buf_get_name(bufnr) local url = M.parse_url(bufname) local scp_url = url_to_scp(url) - local tmpdir = fs.join(vim.fn.stdpath("cache"), "oil") + local cache_dir = vim.fn.stdpath("cache") + assert(type(cache_dir) == "string") + local tmpdir = fs.join(cache_dir, "oil") local fd, tmpfile = vim.loop.fs_mkstemp(fs.join(tmpdir, "ssh_XXXXXXXX")) if fd then vim.loop.fs_close(fd) diff --git a/lua/oil/init.lua b/lua/oil/init.lua index f334729..737f21c 100644 --- a/lua/oil/init.lua +++ b/lua/oil/init.lua @@ -349,7 +349,7 @@ M.open_float = function(dir) vim.cmd.edit({ args = { util.escape_filename(parent_url) }, mods = { keepalt = true } }) -- :edit will set buflisted = true, but we may not want that if config.buf_options.buflisted ~= nil then - vim.api.nvim_buf_set_option(0, "buflisted", config.buf_options.buflisted) + vim.api.nvim_set_option_value("buflisted", config.buf_options.buflisted, { buf = 0 }) end if vim.fn.has("nvim-0.9") == 0 then @@ -400,7 +400,7 @@ M.open = function(dir) vim.cmd.edit({ args = { util.escape_filename(parent_url) }, mods = { keepalt = true } }) -- :edit will set buflisted = true, but we may not want that if config.buf_options.buflisted ~= nil then - vim.api.nvim_buf_set_option(0, "buflisted", config.buf_options.buflisted) + vim.api.nvim_set_option_value("buflisted", config.buf_options.buflisted, { buf = 0 }) end -- If preview window exists, update its content @@ -835,8 +835,11 @@ local function set_colors() end -- TODO can remove this call once we drop support for Neovim 0.8. FloatTitle was introduced as a -- built-in highlight group in 0.9, and we can start to rely on colorschemes setting it. - if not pcall(vim.api.nvim_get_hl_by_name, "FloatTitle", true) then + ---@diagnostic disable-next-line: deprecated + if vim.fn.has("nvim-0.9") == 0 and not pcall(vim.api.nvim_get_hl_by_name, "FloatTitle", true) then + ---@diagnostic disable-next-line: deprecated local border = vim.api.nvim_get_hl_by_name("FloatBorder", true) + ---@diagnostic disable-next-line: deprecated local normal = vim.api.nvim_get_hl_by_name("Normal", true) vim.api.nvim_set_hl( 0, diff --git a/lua/oil/lsp/_types.lua b/lua/oil/lsp/_types.lua deleted file mode 100644 index f4603fb..0000000 --- a/lua/oil/lsp/_types.lua +++ /dev/null @@ -1,224 +0,0 @@ --- LSP types copied from Neovim core to make typechecking pass - ----@alias lsp.null nil ----@alias uinteger integer ----@alias lsp.decimal number ----@alias lsp.DocumentUri string ----@alias lsp.URI string ----@alias lsp.LSPObject table ----@alias lsp.LSPArray lsp.LSPAny[] ----@alias lsp.LSPAny lsp.LSPObject|lsp.LSPArray|string|number|boolean|nil - ----An identifier to refer to a change annotation stored with a workspace edit. ----@alias lsp.ChangeAnnotationIdentifier string - ----A pattern kind describing if a glob pattern matches a file a folder or ----both. ---- ----@since 3.16.0 ----@alias lsp.FileOperationPatternKind ----| "file" # file ----| "folder" # folder - ----Matching options for the file operation pattern. ---- ----@since 3.16.0 ----@class lsp.FileOperationPatternOptions ----The pattern should be matched ignoring casing. ----@field ignoreCase? boolean - ----Describes textual changes on a text document. A TextDocumentEdit describes all changes ----on a document version Si and after they are applied move the document to version Si+1. ----So the creator of a TextDocumentEdit doesn't need to sort the array of edits or do any ----kind of ordering. However the edits must be non overlapping. ----@class lsp.TextDocumentEdit ----The text document to change. ----@field textDocument lsp.OptionalVersionedTextDocumentIdentifier ----The edits to be applied. ---- ----@since 3.16.0 - support for AnnotatedTextEdit. This is guarded using a ----client capability. ----@field edits lsp.TextEdit|lsp.AnnotatedTextEdit[] - ----A literal to identify a text document in the client. ----@class lsp.TextDocumentIdentifier ----The text document's uri. ----@field uri lsp.DocumentUri - ----A text document identifier to optionally denote a specific version of a text document. ----@class lsp.OptionalVersionedTextDocumentIdentifier: lsp.TextDocumentIdentifier ----The version number of this document. If a versioned text document identifier ----is sent from the server to the client and the file is not open in the editor ----(the server has not received an open notification before) the server can send ----`null` to indicate that the version is unknown and the content on disk is the ----truth (as specified with document content ownership). ----@field version integer|lsp.null - ----A special text edit with an additional change annotation. ---- ----@since 3.16.0. ----@class lsp.AnnotatedTextEdit: lsp.TextEdit ----The actual identifier of the change annotation ----@field annotationId lsp.ChangeAnnotationIdentifier - ----A workspace edit represents changes to many resources managed in the workspace. The edit ----should either provide `changes` or `documentChanges`. If documentChanges are present ----they are preferred over `changes` if the client can handle versioned document edits. ---- ----Since version 3.13.0 a workspace edit can contain resource operations as well. If resource ----operations are present clients need to execute the operations in the order in which they ----are provided. So a workspace edit for example can consist of the following two changes: ----(1) a create file a.txt and (2) a text document edit which insert text into file a.txt. ---- ----An invalid sequence (e.g. (1) delete file a.txt and (2) insert text into file a.txt) will ----cause failure of the operation. How the client recovers from the failure is described by ----the client capability: `workspace.workspaceEdit.failureHandling` ----@class lsp.WorkspaceEdit ----Holds changes to existing resources. ----@field changes? table ----Depending on the client capability `workspace.workspaceEdit.resourceOperations` document changes ----are either an array of `TextDocumentEdit`s to express changes to n different text documents ----where each text document edit addresses a specific version of a text document. Or it can contain ----above `TextDocumentEdit`s mixed with create, rename and delete file / folder operations. ---- ----Whether a client supports versioned document edits is expressed via ----`workspace.workspaceEdit.documentChanges` client capability. ---- ----If a client neither supports `documentChanges` nor `workspace.workspaceEdit.resourceOperations` then ----only plain `TextEdit`s using the `changes` property are supported. ----@field documentChanges? (lsp.TextDocumentEdit|lsp.CreateFile|lsp.RenameFile|lsp.DeleteFile)[] ----A map of change annotations that can be referenced in `AnnotatedTextEdit`s or create, rename and ----delete file / folder operations. ---- ----Whether clients honor this property depends on the client capability `workspace.changeAnnotationSupport`. ---- ----@since 3.16.0 ----@field changeAnnotations? table - ----Additional information that describes document changes. ---- ----@since 3.16.0 ----@class lsp.ChangeAnnotation ----A human-readable string describing the actual change. The string ----is rendered prominent in the user interface. ----@field label string ----A flag which indicates that user confirmation is needed ----before applying the change. ----@field needsConfirmation? boolean ----A human-readable string which is rendered less prominent in ----the user interface. ----@field description? string - ----A text edit applicable to a text document. ----@class lsp.TextEdit ----The range of the text document to be manipulated. To insert ----text into a document create a range where start === end. ----@field range lsp.Range ----The string to be inserted. For delete operations use an ----empty string. ----@field newText string - ----Options to create a file. ----@class lsp.CreateFileOptions ----Overwrite existing file. Overwrite wins over `ignoreIfExists` ----@field overwrite? boolean ----Ignore if exists. ----@field ignoreIfExists? boolean - ----Rename file options ----@class lsp.RenameFileOptions ----Overwrite target if existing. Overwrite wins over `ignoreIfExists` ----@field overwrite? boolean ----Ignores if target exists. ----@field ignoreIfExists? boolean - ----Delete file options ----@class lsp.DeleteFileOptions ----Delete the content recursively if a folder is denoted. ----@field recursive? boolean ----Ignore the operation if the file doesn't exist. ----@field ignoreIfNotExists? boolean - ----A generic resource operation. ----@class lsp.ResourceOperation ----The resource operation kind. ----@field kind string ----An optional annotation identifier describing the operation. ---- ----@since 3.16.0 ----@field annotationId? lsp.ChangeAnnotationIdentifier - ----Create file operation. ----@class lsp.CreateFile: lsp.ResourceOperation ----A create ----@field kind "create" ----The resource to create. ----@field uri lsp.DocumentUri ----Additional options ----@field options? lsp.CreateFileOptions - ----Rename file operation ----@class lsp.RenameFile: lsp.ResourceOperation ----A rename ----@field kind "rename" ----The old (existing) location. ----@field oldUri lsp.DocumentUri ----The new location. ----@field newUri lsp.DocumentUri ----Rename options. ----@field options? lsp.RenameFileOptions - ----Delete file operation ----@class lsp.DeleteFile: lsp.ResourceOperation ----A delete ----@field kind "delete" ----The file to delete. ----@field uri lsp.DocumentUri ----Delete options. ----@field options? lsp.DeleteFileOptions - ----A pattern to describe in which file operation requests or notifications ----the server is interested in receiving. ---- ----@since 3.16.0 ----@class lsp.FileOperationPattern ----The glob pattern to match. Glob patterns can have the following syntax: ----- `*` to match one or more characters in a path segment ----- `?` to match on one character in a path segment ----- `**` to match any number of path segments, including none ----- `{}` to group sub patterns into an OR expression. (e.g. `**​/*.{ts,js}` matches all TypeScript and JavaScript files) ----- `[]` to declare a range of characters to match in a path segment (e.g., `example.[0-9]` to match on `example.0`, `example.1`, …) ----- `[!...]` to negate a range of characters to match in a path segment (e.g., `example.[!0-9]` to match on `example.a`, `example.b`, but not `example.0`) ----@field glob string ----Whether to match files or folders with this pattern. ---- ----Matches both if undefined. ----@field matches? lsp.FileOperationPatternKind ----Additional options used during matching. ----@field options? lsp.FileOperationPatternOptions - ----A filter to describe in which file operation requests or notifications ----the server is interested in receiving. ---- ----@since 3.16.0 ----@class lsp.FileOperationFilter ----A Uri scheme like `file` or `untitled`. ----@field scheme? string ----The actual file operation pattern. ----@field pattern lsp.FileOperationPattern - ---- @class vim.lpeg.Pattern ---- @operator unm: vim.lpeg.Pattern ---- @operator add(vim.lpeg.Pattern): vim.lpeg.Pattern ---- @operator sub(vim.lpeg.Pattern): vim.lpeg.Pattern ---- @operator mul(vim.lpeg.Pattern): vim.lpeg.Pattern ---- @operator mul(vim.lpeg.Capture): vim.lpeg.Pattern ---- @operator div(string): vim.lpeg.Capture ---- @operator div(number): vim.lpeg.Capture ---- @operator div(table): vim.lpeg.Capture ---- @operator div(function): vim.lpeg.Capture ---- @operator pow(number): vim.lpeg.Pattern ---- @operator mod(function): nil ---- @field match fun(pattern: vim.lpeg.Pattern, subject: string, init?: integer): integer|vim.lpeg.Capture|nil - ---- @alias vim.lpeg.Capture vim.lpeg.Pattern diff --git a/lua/oil/lsp/workspace.lua b/lua/oil/lsp/workspace.lua index 9879e72..79ab784 100644 --- a/lua/oil/lsp/workspace.lua +++ b/lua/oil/lsp/workspace.lua @@ -14,11 +14,12 @@ end local M = {} ---@param method string ----@return lsp.Client[] +---@return vim.lsp.Client[] local function get_clients(method) if vim.fn.has("nvim-0.10") == 1 then return vim.lsp.get_clients({ method = method }) else + ---@diagnostic disable-next-line: deprecated local clients = vim.lsp.get_active_clients() return vim.tbl_filter(function(client) return client.supports_method(method) @@ -47,7 +48,7 @@ local function match_glob(glob, path) return match >= 0 end ----@param client lsp.Client +---@param client vim.lsp.Client ---@param filters nil|lsp.FileOperationFilter[] ---@param paths string[] ---@return nil|string[]