-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit.lua.in
More file actions
55 lines (44 loc) · 1.91 KB
/
init.lua.in
File metadata and controls
55 lines (44 loc) · 1.91 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
-- vim:ft=lua
vim.g.loaded_node_provider = 0
vim.g.loaded_perl_provider = 0
vim.g.loaded_python_provider = 0
vim.g.loaded_python3_provider = 0
vim.g.loaded_ruby_provider = 0
vim.loader.enable()
local argv0 = vim.v.argv[1]
if string.match(argv0, "snv%-profile$") then vim.g.snv_profile = true end
if vim.g.snv_profile or string.match(argv0, "snv%-dev$") then vim.g.snv_dev = true end
local whitelist = {
"^/run/current%-system/sw/share/",
"^/etc/profiles/per%-user/[^/]+/share/",
"^/nix/store/",
"^" .. vim.pesc(vim.fn.stdpath("data")),
}
if vim.g.snv_dev then table.insert(whitelist, "^" .. vim.pesc(vim.fn.stdpath("config"))) end
local function keep_path(path)
local matches_whitelist = vim.iter(whitelist):any(function(pattern) return string.find(path, pattern) ~= nil end)
return matches_whitelist and vim.uv.fs_stat(path) ~= nil
end
local function clean(paths) return vim.iter(paths):filter(keep_path):totable() end
local pp = clean(vim.opt.packpath:get())
local rtp = clean(vim.opt.runtimepath:get())
table.insert(pp, 1, "@plugins@")
-- Save this path in a global for use with ts_query_ls
vim.g.treesitter_runtime_dir = "@plugins@/pack/plugins/opt/nvim-treesitter-runtime"
-- Insert treesitter parsers and queries to runtimepath before $VIMRUNTIME, but after config
-- This prioritizes nvim-treesitter above $VIMRUNTIME, but below custom queries in this repo
local idx = vim.iter(rtp):enumerate():find(function(_, path) return string.find(path, "share/nvim/runtime$") ~= nil end)
table.insert(rtp, idx, vim.g.treesitter_runtime_dir)
if not vim.g.snv_dev then
table.insert(rtp, 1, "@out@/share/snv/site")
table.insert(rtp, "@out@/share/snv/site/after")
end
vim.opt.packpath = pp
vim.opt.runtimepath = rtp
if vim.g.snv_profile then
vim.cmd.packadd("snacks.nvim")
require("snacks.profiler").startup({
startup = { event = "User", pattern = "MiniDepsComplete" },
presets = { startup = { min_time = 0.1 } },
})
end