-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: deprecate
rocks.api.source_runtime_dir
(#297)
- Loading branch information
Showing
7 changed files
with
39 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,6 +35,7 @@ jobs: | |
fidget.nvim >= 1.1.0 | ||
fzy | ||
nvim-nio | ||
rtp.nvim | ||
labels: | | ||
neovim | ||
detailed_description: | | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,12 +7,11 @@ | |
--- | ||
---@brief ]] | ||
|
||
-- Copyright (C) 2023 Neorocks Org. | ||
-- Copyright (C) 2024 Neorocks Org. | ||
-- | ||
-- Version: 0.1.0 | ||
-- License: GPLv3 | ||
-- Created: 07 Dec 2023 | ||
-- Updated: 07 Dec 2023 | ||
-- Updated: 25 Apr 2024 | ||
-- Homepage: https://github.com/nvim-neorocks/rocks.nvim | ||
-- Maintainers: NTBBloodbath <[email protected]>, Vhyrro <[email protected]>, mrcjkb <[email protected]> | ||
|
||
|
@@ -32,7 +31,6 @@ local luarocks = require("rocks.luarocks") | |
local nio = require("nio") | ||
local state = require("rocks.state") | ||
local operations = require("rocks.operations") | ||
local runtime = require("rocks.runtime") | ||
|
||
---Tries to get the cached rocks. | ||
---Returns an empty list if the cache has not been populated | ||
|
@@ -167,10 +165,10 @@ function api.register_rock_handler(handler) | |
operations.register_handler(handler) | ||
end | ||
|
||
---Source the `plugin` and `ftdetect` directories. | ||
---@param dir string The runtime directory to source | ||
---@deprecated Use the rtp.nvim luarock | ||
function api.source_runtime_dir(dir) | ||
runtime.source_rtp_dir(dir) | ||
vim.deprecate("rocks.api.source_rtp_dir", "the rtp.nvim luarock", "3.0.0", "rocks.nvim") | ||
require("rtp_nvim").source_rtp_dir(dir) | ||
end | ||
|
||
---Invoke ':Rocks install' with a callback | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,7 +10,7 @@ | |
-- | ||
-- License: GPLv3 | ||
-- Created: 25 Dec 2023 | ||
-- Updated: 11 Apr 2024 | ||
-- Updated: 25 Apr 2024 | ||
-- Homepage: https://github.com/nvim-neorocks/rocks.nvim | ||
-- Maintainers: NTBBloodbath <[email protected]>, Vhyrro <[email protected]>, mrcjkb <[email protected]> | ||
|
||
|
@@ -21,69 +21,6 @@ local log = require("rocks.log") | |
|
||
---@alias rock_pattern "*" | rock_name | ||
|
||
---`ftdetect` scripts should only be sourced once. | ||
---@type table<string, boolean|nil> | ||
local _sourced_ftdetect = {} | ||
|
||
---@enum RtpSourceDir Directories to be sourced on packadd | ||
local RtpSourceDir = { | ||
plugin = "plugin", | ||
ftdetect = "ftdetect", | ||
} | ||
|
||
---Recursively iterate over a directory's children | ||
---@param dir string | ||
---@return fun(_:any, path:string):(path: string, name: string, type: string) | ||
---@async | ||
local function iter_children(dir) | ||
return coroutine.wrap(function() | ||
local handle = vim.uv.fs_scandir(dir) | ||
while handle do | ||
local name, ty = vim.uv.fs_scandir_next(handle) | ||
local path = vim.fs.joinpath(dir, name) | ||
ty = ty or vim.uv.fs_stat(path).type | ||
if not name then | ||
return | ||
elseif ty == "directory" then | ||
for child_path, child, child_type in iter_children(path) do | ||
coroutine.yield(child_path, child, child_type) | ||
end | ||
end | ||
coroutine.yield(path, name, ty) | ||
end | ||
end) | ||
end | ||
|
||
---@param rtp_source_dir RtpSourceDir | ||
---@param dir string | ||
local function source(rtp_source_dir, dir) | ||
local rtp_dir = vim.fs.joinpath(dir, rtp_source_dir) | ||
for script, name, ty in iter_children(rtp_dir) do | ||
local ext = name:sub(-3) | ||
if vim.tbl_contains({ "file", "link" }, ty) and vim.tbl_contains({ "lua", "vim" }, ext) then | ||
local ok, err = pcall(vim.cmd.source, script) | ||
if not ok and type(err) == "string" then | ||
log.error(err) | ||
vim.notify(err, vim.log.levels.ERROR) | ||
break | ||
end | ||
end | ||
end | ||
end | ||
|
||
---@param dir string | ||
local function source_plugin(dir) | ||
source(RtpSourceDir.plugin, dir) | ||
end | ||
|
||
---@param dir string | ||
local function source_ftdetect(dir) | ||
if not _sourced_ftdetect[dir] then | ||
source(RtpSourceDir.ftdetect, dir) | ||
_sourced_ftdetect[dir] = true | ||
end | ||
end | ||
|
||
---@class rocks.PackaddOpts | ||
---@field bang? boolean | ||
|
||
|
@@ -106,13 +43,6 @@ function runtime.packadd(rock_name, opts) | |
return true | ||
end | ||
|
||
---Source the `plugin` and `ftdetect` directories | ||
---@param dir string | ||
function runtime.source_rtp_dir(dir) | ||
source_plugin(dir) | ||
source_ftdetect(dir) | ||
end | ||
|
||
---@param rock_spec RockSpec | ||
---@return boolean? | ||
local function is_start_plugin(rock_spec) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,7 @@ | |
fidget-nvim | ||
fzy | ||
nvim-nio | ||
rtp-nvim | ||
]; | ||
|
||
extraPackages = [ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters