From 15e071f203f4d0b66058ff89a2ef11a533250764 Mon Sep 17 00:00:00 2001 From: Steven Arcangeli Date: Sat, 1 Jun 2024 16:13:36 -0700 Subject: [PATCH] ci: typechecking no longer requires neodev --- .github/workflows/tests.yml | 2 +- doc/api.md | 18 +++++++++--------- doc/oil.txt | 12 ++++++------ lua/oil/actions.lua | 3 --- lua/oil/cache.lua | 6 ++++++ lua/oil/init.lua | 15 ++++++--------- lua/oil/keymap_util.lua | 4 ++-- lua/oil/view.lua | 2 +- 8 files changed, 31 insertions(+), 31 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 5861d1b..08957e5 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -42,7 +42,7 @@ jobs: runs-on: ubuntu-22.04 steps: - uses: actions/checkout@v4 - - uses: stevearc/nvim-typecheck-action@v1 + - uses: stevearc/nvim-typecheck-action@v2 with: path: lua diff --git a/doc/api.md b/doc/api.md index 521b985..40503f8 100644 --- a/doc/api.md +++ b/doc/api.md @@ -134,15 +134,15 @@ Preview the entry under the cursor in a split `select(opts, callback)` \ Select the entry under the cursor -| Param | Type | Desc | | -| -------- | ---------------------------- | -------------------------------------------------- | ---------------------------------------------------- | -| opts | `nil\|oil.SelectOpts` | | | -| | vertical | `boolean` | Open the buffer in a vertical split | -| | horizontal | `boolean` | Open the buffer in a horizontal split | -| | split | `"aboveleft"\|"belowright"\|"topleft"\|"botright"` | Split modifier | -| | tab | `boolean` | Open the buffer in a new tab | -| | close | `boolean` | Close the original oil buffer once selection is made | -| callback | `nil\|fun(err: nil\|string)` | Called once all entries have been opened | | +| Param | Type | Desc | | +| -------- | ---------------------------- | ------------------------------------------------------- | ---------------------------------------------------- | +| opts | `nil\|oil.SelectOpts` | | | +| | vertical | `nil\|boolean` | Open the buffer in a vertical split | +| | horizontal | `nil\|boolean` | Open the buffer in a horizontal split | +| | split | `nil\|"aboveleft"\|"belowright"\|"topleft"\|"botright"` | Split modifier | +| | tab | `nil\|boolean` | Open the buffer in a new tab | +| | close | `nil\|boolean` | Close the original oil buffer once selection is made | +| callback | `nil\|fun(err: nil\|string)` | Called once all entries have been opened | | ## save(opts, cb) diff --git a/doc/oil.txt b/doc/oil.txt index 6485a04..b8ba7bf 100644 --- a/doc/oil.txt +++ b/doc/oil.txt @@ -312,13 +312,13 @@ select({opts}, {callback}) *oil.selec Parameters: {opts} `nil|oil.SelectOpts` - {vertical} `boolean` Open the buffer in a vertical split - {horizontal} `boolean` Open the buffer in a horizontal split - {split} `"aboveleft"|"belowright"|"topleft"|"botright"` Split + {vertical} `nil|boolean` Open the buffer in a vertical split + {horizontal} `nil|boolean` Open the buffer in a horizontal split + {split} `nil|"aboveleft"|"belowright"|"topleft"|"botright"` Split modifier - {tab} `boolean` Open the buffer in a new tab - {close} `boolean` Close the original oil buffer once selection is - made + {tab} `nil|boolean` Open the buffer in a new tab + {close} `nil|boolean` Close the original oil buffer once + selection is made {callback} `nil|fun(err: nil|string)` Called once all entries have been opened diff --git a/lua/oil/actions.lua b/lua/oil/actions.lua index cebd6b1..7b75505 100644 --- a/lua/oil/actions.lua +++ b/lua/oil/actions.lua @@ -1,9 +1,6 @@ local oil = require("oil") local util = require("oil.util") --- TODO remove after https://github.com/folke/neodev.nvim/pull/163 lands ----@diagnostic disable: inject-field - local M = {} M.show_help = { diff --git a/lua/oil/cache.lua b/lua/oil/cache.lua index 09ed44f..ef78246 100644 --- a/lua/oil/cache.lua +++ b/lua/oil/cache.lua @@ -124,6 +124,7 @@ end ---@return nil|oil.InternalEntry M.get_entry_by_url = function(url) local scheme, path = util.parse_url(url) + assert(path) local parent_url = scheme .. vim.fn.fnamemodify(path, ":h") local basename = vim.fn.fnamemodify(path, ":t") return M.list_url(parent_url)[basename] @@ -150,11 +151,13 @@ end M.perform_action = function(action) if action.type == "create" then local scheme, path = util.parse_url(action.url) + assert(path) local parent_url = util.addslash(scheme .. vim.fn.fnamemodify(path, ":h")) local name = vim.fn.fnamemodify(path, ":t") M.create_and_store_entry(parent_url, name, action.entry_type) elseif action.type == "delete" then local scheme, path = util.parse_url(action.url) + assert(path) local parent_url = util.addslash(scheme .. vim.fn.fnamemodify(path, ":h")) local name = vim.fn.fnamemodify(path, ":t") local entry = url_directory[parent_url][name] @@ -163,11 +166,13 @@ M.perform_action = function(action) parent_url_by_id[entry[FIELD_ID]] = nil elseif action.type == "move" then local src_scheme, src_path = util.parse_url(action.src_url) + assert(src_path) local src_parent_url = util.addslash(src_scheme .. vim.fn.fnamemodify(src_path, ":h")) local src_name = vim.fn.fnamemodify(src_path, ":t") local entry = url_directory[src_parent_url][src_name] local dest_scheme, dest_path = util.parse_url(action.dest_url) + assert(dest_path) local dest_parent_url = util.addslash(dest_scheme .. vim.fn.fnamemodify(dest_path, ":h")) local dest_name = vim.fn.fnamemodify(dest_path, ":t") @@ -185,6 +190,7 @@ M.perform_action = function(action) util.update_moved_buffers(action.entry_type, action.src_url, action.dest_url) elseif action.type == "copy" then local scheme, path = util.parse_url(action.dest_url) + assert(path) local parent_url = util.addslash(scheme .. vim.fn.fnamemodify(path, ":h")) local name = vim.fn.fnamemodify(path, ":t") M.create_and_store_entry(parent_url, name, action.entry_type) diff --git a/lua/oil/init.lua b/lua/oil/init.lua index 04bd1b7..8e7fe10 100644 --- a/lua/oil/init.lua +++ b/lua/oil/init.lua @@ -19,6 +19,7 @@ local M = {} ---@field list fun(path: string, column_defs: string[], cb: fun(err?: string, entries?: oil.InternalEntry[], fetch_more?: fun())) Async function to list a directory. ---@field is_modifiable fun(bufnr: integer): boolean Return true if this directory is modifiable (allows for directories with read-only permissions). ---@field get_column fun(name: string): nil|oil.ColumnDefinition If the adapter has any adapter-specific columns, return them when fetched by name. +---@field get_parent? fun(bufname: string): string Get the parent url of the given buffer ---@field normalize_url fun(url: string, callback: fun(url: string)) Before oil opens a url it will be normalized. This allows for link following, path normalizing, and converting an oil file url to the actual path of a file. ---@field get_entry_path? fun(url: string, entry: oil.Entry, callback: fun(path: string)) Similar to normalize_url, but used when selecting an entry ---@field render_action? fun(action: oil.Action): string Render a mutation action for display in the preview window. Only needed if adapter is modifiable. @@ -29,10 +30,6 @@ local M = {} ---@field filter_action? fun(action: oil.Action): boolean When present, filter out actions as they are created ---@field filter_error? fun(action: oil.ParseError): boolean When present, filter out errors from parsing a buffer --- TODO remove after https://github.com/folke/neodev.nvim/pull/163 lands ----@diagnostic disable: undefined-field ----@diagnostic disable: inject-field - ---Get the entry on a specific line (1-indexed) ---@param bufnr integer ---@param lnum integer @@ -540,11 +537,11 @@ M.open_preview = function(opts, callback) end ---@class (exact) oil.SelectOpts ----@field vertical boolean Open the buffer in a vertical split ----@field horizontal boolean Open the buffer in a horizontal split ----@field split "aboveleft"|"belowright"|"topleft"|"botright" Split modifier ----@field tab boolean Open the buffer in a new tab ----@field close boolean Close the original oil buffer once selection is made +---@field vertical? boolean Open the buffer in a vertical split +---@field horizontal? boolean Open the buffer in a horizontal split +---@field split? "aboveleft"|"belowright"|"topleft"|"botright" Split modifier +---@field tab? boolean Open the buffer in a new tab +---@field close? boolean Close the original oil buffer once selection is made ---Select the entry under the cursor ---@param opts nil|oil.SelectOpts diff --git a/lua/oil/keymap_util.lua b/lua/oil/keymap_util.lua index 095d971..988a9d8 100644 --- a/lua/oil/keymap_util.lua +++ b/lua/oil/keymap_util.lua @@ -99,8 +99,8 @@ M.show_help = function(keymaps) end vim.keymap.set("n", "q", "close", { buffer = bufnr }) vim.keymap.set("n", "", "close", { buffer = bufnr }) - vim.api.nvim_buf_set_option(bufnr, "modifiable", false) - vim.api.nvim_buf_set_option(bufnr, "bufhidden", "wipe") + vim.bo[bufnr].modifiable = false + vim.bo[bufnr].bufhidden = "wipe" local editor_width = vim.o.columns local editor_height = layout.get_editor_height() diff --git a/lua/oil/view.lua b/lua/oil/view.lua index ec43353..3af948c 100644 --- a/lua/oil/view.lua +++ b/lua/oil/view.lua @@ -331,7 +331,7 @@ M.initialize = function(bufnr) vim.b[bufnr].EditorConfig_disable = 1 session[bufnr] = session[bufnr] or {} for k, v in pairs(config.buf_options) do - vim.api.nvim_buf_set_option(bufnr, k, v) + vim.bo[bufnr][k] = v end M.set_win_options() vim.api.nvim_create_autocmd("BufHidden", {