Skip to content

Commit f431c0b

Browse files
committed
chore: reduce hash lookup
1 parent 8236c3b commit f431c0b

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

lua/strive/init.lua

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
-- A lightweight, feature-rich plugin manager with support for lazy loading,
33
-- dependencies, and asynchronous operations.
44

5-
local api, uv = vim.api, vim.uv
5+
local api, uv, fs, joinpath = vim.api, vim.uv, vim.fs, vim.fs.joinpath
66

77
-- =====================================================================
88
-- 1. Configuration and Constants
@@ -13,11 +13,11 @@ local plugin_map = {}
1313

1414
-- Data paths
1515
local data_dir = vim.fn.stdpath('data')
16-
local START_DIR = vim.fs.joinpath(data_dir, 'site', 'pack', 'strive', 'start')
17-
local OPT_DIR = vim.fs.joinpath(data_dir, 'site', 'pack', 'strive', 'opt')
16+
local START_DIR = joinpath(data_dir, 'site', 'pack', 'strive', 'start')
17+
local OPT_DIR = joinpath(data_dir, 'site', 'pack', 'strive', 'opt')
1818

1919
-- Add to packpath
20-
vim.opt.packpath:prepend(vim.fs.joinpath(data_dir, 'site'))
20+
vim.opt.packpath:prepend(joinpath(data_dir, 'site'))
2121
vim.g.strive_loaded = 0
2222
vim.g.strive_count = 0
2323

@@ -583,7 +583,7 @@ function Plugin.new(spec)
583583
spec = type(spec) == 'string' and { name = spec } or spec
584584

585585
-- Extract plugin name from repo
586-
local name = vim.fs.normalize(spec.name)
586+
local name = fs.normalize(spec.name)
587587
if vim.startswith(name, vim.env.HOME) then
588588
spec.is_local = true
589589
end
@@ -630,8 +630,8 @@ end
630630
-- Get the plugin installation path
631631
function Plugin:get_path()
632632
return (not self.is_local and not self.local_path)
633-
and vim.fs.joinpath(self.is_lazy and OPT_DIR or START_DIR, self.plugin_name)
634-
or (vim.fs.joinpath(self.local_path, self.plugin_name) or self.name)
633+
and joinpath(self.is_lazy and OPT_DIR or START_DIR, self.plugin_name)
634+
or (joinpath(self.local_path, self.plugin_name) or self.name)
635635
end
636636

637637
-- Check if plugin is installed (async version)
@@ -652,7 +652,7 @@ end
652652
function Plugin:load_scripts()
653653
return function(callback)
654654
local plugin_path = self:get_path()
655-
local plugin_dir = vim.fs.joinpath(plugin_path, 'plugin')
655+
local plugin_dir = joinpath(plugin_path, 'plugin')
656656

657657
if not isdir(plugin_dir) then
658658
callback(Result.success(false))
@@ -673,7 +673,7 @@ function Plugin:load_scripts()
673673
break
674674
end
675675
if type == 'file' and (name:match('%.lua$') or name:match('%.vim$')) then
676-
scripts[#scripts + 1] = vim.fs.joinpath(plugin_dir, name)
676+
scripts[#scripts + 1] = joinpath(plugin_dir, name)
677677
end
678678
end
679679

@@ -715,7 +715,7 @@ function Plugin:load()
715715
if self.is_local then
716716
vim.opt.rtp:append(plugin_path)
717717

718-
local after_path = vim.fs.joinpath(plugin_path, 'after')
718+
local after_path = joinpath(plugin_path, 'after')
719719
if isdir(after_path) then
720720
vim.opt.rtp:append(after_path)
721721
end
@@ -928,7 +928,7 @@ end
928928
-- Mark plugin as a development plugin
929929
function Plugin:load_path(path)
930930
self.is_local = true
931-
self.local_path = vim.fs.normalize(path)
931+
self.local_path = fs.normalize(path)
932932
self.is_remote = false
933933
return self
934934
end
@@ -966,7 +966,7 @@ function Plugin:theme(name)
966966
local installed = Async.await(self:is_installed())
967967
if installed then
968968
vim.schedule(function()
969-
vim.opt.rtp:append(vim.fs.joinpath(START_DIR, self.plugin_name))
969+
vim.opt.rtp:append(joinpath(START_DIR, self.plugin_name))
970970
vim.cmd.colorscheme(self.colorscheme)
971971
end)
972972
end
@@ -1513,7 +1513,7 @@ function M.clean()
15131513
end
15141514

15151515
if type == 'directory' then
1516-
local full_path = vim.fs.joinpath(dir, name)
1516+
local full_path = joinpath(dir, name)
15171517
M.log('debug', string.format('Found installed plugin: %s at %s', name, full_path))
15181518
installed_dirs[name] = dir
15191519
end
@@ -1561,7 +1561,7 @@ function M.clean()
15611561
M.log('info', string.format('Found %d unused plugins to clean:', #to_remove))
15621562
ui:open()
15631563
for _, item in ipairs(to_remove) do
1564-
local path = vim.fs.joinpath(item.dir, item.name)
1564+
local path = joinpath(item.dir, item.name)
15651565
M.log('info', string.format('Will remove: %s', path))
15661566
ui:update_entry(item.name, 'PENDING', 'Marked to removal')
15671567
end
@@ -1580,7 +1580,7 @@ function M.clean()
15801580
for _, item in ipairs(to_remove) do
15811581
task_queue:enqueue(function(done)
15821582
Async.async(function()
1583-
local path = vim.fs.joinpath(item.dir, item.name)
1583+
local path = joinpath(item.dir, item.name)
15841584
ui:update_entry(item.name, 'CLEANING', 'Removing...')
15851585

15861586
-- Delete and handle errors

0 commit comments

Comments
 (0)