Skip to content

Commit

Permalink
docs: use correct param notation
Browse files Browse the repository at this point in the history
  • Loading branch information
mehalter committed Sep 19, 2024
1 parent a496538 commit b3e5f85
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 17 deletions.
4 changes: 2 additions & 2 deletions lua/astrocore/buffer.lua
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ M.sessions = astro.config.sessions
M.current_buf, M.last_buf = nil, nil

--- Check if a buffer is valid
---@param bufnr integer? The buffer to check, default to current buffer
---@param bufnr? integer The buffer to check, default to current buffer
---@return boolean # Whether the buffer is valid or not
function M.is_valid(bufnr)
if not bufnr then bufnr = 0 end
return vim.api.nvim_buf_is_valid(bufnr) and vim.bo[bufnr].buflisted
end

--- Check if a buffer has a filetype
---@param bufnr integer? The buffer to check, default to current buffer
---@param bufnr? integer The buffer to check, default to current buffer
---@return boolean # Whether the buffer has a filetype or not
function M.has_filetype(bufnr)
if not bufnr then bufnr = 0 end
Expand Down
8 changes: 4 additions & 4 deletions lua/astrocore/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ end

--- Trigger an AstroNvim user event
---@param event string|vim.api.keyset_exec_autocmds The event pattern or full autocmd options (pattern always prepended with "Astro")
---@param instant boolean? Whether or not to execute instantly or schedule
---@param instant? boolean Whether or not to execute instantly or schedule
function M.event(event, instant)
if type(event) == "string" then event = { pattern = event } end
event = M.extend_tbl({ modeline = false }, event)
Expand Down Expand Up @@ -298,7 +298,7 @@ M.url_matcher =
"\\v\\c%(%(h?ttps?|ftp|file|ssh|git)://|[a-z]+[@][a-z]+[.][a-z]+:)%([&:#*@~%_\\-=?!+;/0-9a-z]+%(%([.;/?]|[.][.]+)[&:#*@~%_\\-=?!+/0-9a-z]+|:\\d+|,%(%(%(h?ttps?|ftp|file|ssh|git)://|[a-z]+[@][a-z]+[.][a-z]+:)@![0-9a-z]+))*|\\([&:#*@~%_\\-=?!+;/.0-9a-z]*\\)|\\[[&:#*@~%_\\-=?!+;/.0-9a-z]*\\]|\\{%([&:#*@~%_\\-=?!+;/.0-9a-z]*|\\{[&:#*@~%_\\-=?!+;/.0-9a-z]*})\\})+"

--- Delete the syntax matching rules for URLs/URIs if set
---@param win integer? the window id to remove url highlighting in (default: current window)
---@param win? integer the window id to remove url highlighting in (default: current window)
function M.delete_url_match(win)
if not win then win = vim.api.nvim_get_current_win() end
for _, match in ipairs(vim.fn.getmatches(win)) do
Expand All @@ -308,7 +308,7 @@ function M.delete_url_match(win)
end

--- Add syntax matching rules for highlighting URLs/URIs
---@param win integer? the window id to remove url highlighting in (default: current window)
---@param win? integer the window id to remove url highlighting in (default: current window)
function M.set_url_match(win)
if not win then win = vim.api.nvim_get_current_win() end
M.delete_url_match(win)
Expand All @@ -334,7 +334,7 @@ function M.cmd(cmd, show_error)
end

--- Get the first worktree that a file belongs to
---@param file string? the file to check, defaults to the current file
---@param file? string the file to check, defaults to the current file
---@param worktrees table<string, string>[]? an array like table of worktrees with entries `toplevel` and `gitdir`, default retrieves from `vim.g.git_worktrees`
---@return table<string, string>|nil # a table specifying the `toplevel` and `gitdir` of a worktree or nil if not found
function M.file_worktree(file, worktrees)
Expand Down
22 changes: 11 additions & 11 deletions lua/astrocore/rooter.lua
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ end
local function resolve_config() return require("astrocore").config.rooter or {} end

--- Create a detect workspace folders from active language servers
---@param config AstroCoreRooterOpts? a rooter configuration (defaults to global configuration)
---@param config? AstroCoreRooterOpts a rooter configuration (defaults to global configuration)
---@return AstroCoreRooterDetectorFunc
function M.detectors.lsp(config)
if not config then config = resolve_config() end
Expand Down Expand Up @@ -88,7 +88,7 @@ end
function M.bufpath(bufnr) return M.realpath(vim.api.nvim_buf_get_name(bufnr)) end

--- Resolve a given path
---@param path string? the path to resolve
---@param path? string the path to resolve
---@return string? the resolved path
function M.realpath(path)
if not path or path == "" then return nil end
Expand All @@ -115,7 +115,7 @@ end

--- Resolve the root detection function for a given spec
---@param spec AstroCoreRooterSpec the root detector specification
---@param config AstroCoreRooterOpts? the root configuration
---@param config? AstroCoreRooterOpts the root configuration
---@return function
function M.resolve(spec, config)
if M.detectors[spec] then
Expand All @@ -128,9 +128,9 @@ function M.resolve(spec, config)
end

--- Detect roots in a given buffer
---@param bufnr integer? the buffer to detect
---@param all boolean? whether to return all roots or just one
---@param config AstroCoreRooterOpts? a rooter configuration (defaults to global configuration)
---@param bufnr? integer the buffer to detect
---@param all? boolean whether to return all roots or just one
---@param config? AstroCoreRooterOpts a rooter configuration (defaults to global configuration)
---@return AstroCoreRooterRoot[] detected roots
function M.detect(bufnr, all, config)
if not config then config = resolve_config() end
Expand Down Expand Up @@ -164,7 +164,7 @@ function M.detect(bufnr, all, config)
end

--- Get information information about the current root
---@param config AstroCoreRooterOpts? a rooter configuration (defaults to global configuration)
---@param config? AstroCoreRooterOpts a rooter configuration (defaults to global configuration)
function M.info(config)
if not config then config = resolve_config() end
local lines = {}
Expand Down Expand Up @@ -207,7 +207,7 @@ end

--- Set the current directory to a given root
---@param root AstroCoreRooterRoot the root to set the pwd to
---@param config AstroCoreRooterOpts? a rooter configuration (defaults to global configuration)
---@param config? AstroCoreRooterOpts a rooter configuration (defaults to global configuration)
---@return boolean success whether or not the pwd was successfully set
function M.set_pwd(root, config)
if not config then config = resolve_config() end
Expand Down Expand Up @@ -235,7 +235,7 @@ end

--- Check if a path is excluded
---@param path string the path
---@param config AstroCoreRooterOpts? a rooter configuration (defaults to global configuration)
---@param config? AstroCoreRooterOpts a rooter configuration (defaults to global configuration)
---@return boolean excluded whether or not the path is excluded
function M.is_excluded(path, config)
if not config then config = resolve_config() end
Expand All @@ -246,8 +246,8 @@ function M.is_excluded(path, config)
end

--- Run the root detection and set the current working directory if a new root is detected
---@param bufnr integer? the buffer to detect
---@param config AstroCoreRooterOpts? a rooter configuration (defaults to global configuration)
---@param bufnr? integer the buffer to detect
---@param config? AstroCoreRooterOpts a rooter configuration (defaults to global configuration)
function M.root(bufnr, config)
-- add `autochdir` protection
local autochdir = vim.opt.autochdir:get()
Expand Down

0 comments on commit b3e5f85

Please sign in to comment.