Repository navigation
Expand file tree
/
Copy pathinit.lua
More file actions
72 lines (67 loc) · 2.64 KB
/
Copy pathinit.lua
File metadata and controls
72 lines (67 loc) · 2.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
vim.loader.enable()
require("config.options")
require("config.autocmds")
require("config.keymaps")
require("config.highlights")
require("config.diagnostics")
require("config.cursorline")
-- Locate a plugin's install directory on disk. vim.pack stores plugins
-- under <data>/site/pack/<pack_name>/{opt,start}/<plugin>/, where
-- <pack_name> is typically "core". We glob across all pack names so
-- this stays resilient to future changes in the directory layout.
local function find_plugin_path(name)
local base = vim.fn.stdpath("data") .. "/site/pack/"
for _, subdir in ipairs({ "opt", "start" }) do
local paths = vim.fn.glob(base .. "*/" .. subdir .. "/" .. name, false, true)
if #paths > 0 then
return paths[1]
end
end
end
-- Check for plugin updates asynchronously after startup — runs
-- git ls-remote for each plugin in a background thread pool — and
-- again whenever vim.pack finishes applying updates
vim.api.nvim_create_autocmd("VimEnter", {
once = true,
callback = function()
local pack_updates = require("plugins.pack-updates")
pack_updates.check()
pack_updates.recheck_on_update()
end,
})
-- Some plugins ship native code that must be compiled after cloning.
-- vim.pack fires PackChanged once per plugin on install or update —
-- we hook into it here to run the appropriate build step for each.
vim.api.nvim_create_autocmd("PackChanged", {
callback = function(ev)
local name = ev.data.spec.name
if ev.data.kind ~= "install" and ev.data.kind ~= "update" then
return
end
if name == "nvim-treesitter" then
-- Ensure treesitter is loaded so :TSUpdate can find parsers
if not ev.data.active then
vim.cmd.packadd("nvim-treesitter")
end
vim.cmd("TSUpdate")
elseif name == "blink.cmp" then
-- Build the Rust fuzzy-matching backend asynchronously.
-- blink.cmp falls back to a pure-Lua implementation until
-- the binary is available, so this won't block startup.
-- blink.cmp loads the library from <plugin>/target/release/, but our
-- global ~/.cargo/config.toml redirects every build to a shared cache
-- dir, so pin CARGO_TARGET_DIR back in-tree (env wins over config.toml).
local path = find_plugin_path("blink.cmp")
if path then
local opts = { cwd = path, env = { CARGO_TARGET_DIR = path .. "/target" } }
vim.system({ "cargo", "build", "--release" }, opts, function(result)
vim.schedule(function()
if result.code ~= 0 then
vim.notify("blink.cmp build failed: " .. (result.stderr or ""), vim.log.levels.ERROR)
end
end)
end)
end
end
end,
})