fixtures
ray-x 8 months ago
parent f26a053776
commit 1d720412aa

@ -3,7 +3,8 @@ local fn = vim.fn
local os_name = vim.loop.os_uname().sysname local os_name = vim.loop.os_uname().sysname
local is_windows = os_name == 'Windows' or os_name == 'Windows_NT' local is_windows = os_name == 'Windows' or os_name == 'Windows_NT'
local is_git_shell = is_windows and (vim.fn.exists('$SHELL') and vim.fn.expand('$SHELL'):find('bash.exe') ~= nil) local is_git_shell = is_windows
and (vim.fn.exists('$SHELL') and vim.fn.expand('$SHELL'):find('bash.exe') ~= nil)
local HASNVIM0_9 = vim.fn.has('nvim-0.9') == 1 local HASNVIM0_9 = vim.fn.has('nvim-0.9') == 1
util.get_node_text = vim.treesitter.get_node_text util.get_node_text = vim.treesitter.get_node_text
@ -293,8 +294,7 @@ util.log = function(...)
end end
end end
util.trace = function(...) util.trace = function(...) end
end
local rhs_options = {} local rhs_options = {}
@ -378,7 +378,7 @@ function util.nvim_load_mapping(mapping)
end end
end end
end end
util.loaded = {}
function util.load_plugin(name, modulename) function util.load_plugin(name, modulename)
assert(name ~= nil, 'plugin should not empty') assert(name ~= nil, 'plugin should not empty')
modulename = modulename or name modulename = modulename or name
@ -386,6 +386,10 @@ function util.load_plugin(name, modulename)
if has then if has then
return plugin return plugin
end end
if util.loaded[name] then
return nil -- already loaded/tried
end
util.loaded[name] = true
local pkg = packer_plugins local pkg = packer_plugins
local has_packer = pcall(require, 'packer') local has_packer = pcall(require, 'packer')
@ -401,9 +405,13 @@ function util.load_plugin(name, modulename)
loader(name) loader(name)
end end
end end
else
if not require('lazy.core.config').plugins[name] then
util.log('lazy loader failed not installed ' .. name)
else else
require('lazy').load({ plugins = name }) require('lazy').load({ plugins = name })
end end
end
else else
util.log('packadd ' .. name) util.log('packadd ' .. name)
local paths = vim.o.runtimepath local paths = vim.o.runtimepath
@ -922,7 +930,7 @@ util.goenv_mode = function()
return false return false
end end
local cmd = "command -v goenv > /dev/null 2>&1" local cmd = 'command -v goenv > /dev/null 2>&1'
local status = os.execute(cmd) local status = os.execute(cmd)
return status == 0 return status == 0
end end

Loading…
Cancel
Save