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
73
74
75
76
77
|
local M = {}
local nixInfo = _G.nixInfo or function(default, ...)
return default
end
function M.get_nix_plugin_path(name)
if vim.g.nix_info_plugin_name then
return nixInfo(nil, "plugins", "lazy", name) or nixInfo(nil, "plugins", "start", name)
else
return vim.api.nvim_get_runtime_file("pack/*/*/" .. name, false)[1]
end
end
function M.lsp_ft_fallback(name)
local nvimlspcfg = M.get_nix_plugin_path("nvim-lspconfig")
if not nvimlspcfg then
local matches = vim.api.nvim_get_runtime_file("pack/*/*/nvim-lspconfig", false)
nvimlspcfg = assert(matches[1], "nvim-lspconfig not found!")
end
vim.api.nvim_create_user_command("LspGetFiletypesToClipboard", function(opts)
local lspname =
assert(opts.fargs[1] or vim.fn.getreg("+") or name, "no name to search for provided or in clipboard")
local ok, lspcfg = pcall(dofile, nvimlspcfg .. "/lsp/" .. lspname .. ".lua")
if not ok or not lspcfg then
error("failed to get config for lsp: " .. lspname)
end
vim.fn.setreg("+", "filetypes = " .. vim.inspect(lspcfg.filetypes or {}) .. ",")
end, { nargs = "?" })
vim.schedule(function()
vim.notify((name or "lsp") .. " not provided filetype", vim.log.levels.WARN)
end)
return name and dofile(nvimlspcfg .. "/lsp/" .. name .. ".lua").filetypes or {}
end
M.auto_enable_handler = {
spec_field = "auto_enable",
set_lazy = false,
modify = function(plugin)
if vim.g.nix_info_plugin_name then
if type(plugin.auto_enable) == "table" then
for _, name in pairs(plugin.auto_enable) do
if not M.get_nix_plugin_path(name) then
plugin.enabled = false
break
end
end
elseif type(plugin.auto_enable) == "string" then
if not M.get_nix_plugin_path(plugin.auto_enable) then
plugin.enabled = false
end
elseif type(plugin.auto_enable) == "boolean" and plugin.auto_enable then
if not M.get_nix_plugin_path(plugin.name) then
plugin.enabled = false
end
end
end
return plugin
end,
}
M.for_cat_handler = {
spec_field = "for_cat",
set_lazy = false,
modify = function(plugin)
if vim.g.nix_info_plugin_name then
if type(plugin.for_cat) == "table" then
plugin.enabled = nixInfo(plugin.for_cat.default, "settings", "cats", plugin.for_cat.cat)
elseif type(plugin.for_cat) == "string" then
plugin.enabled = nixInfo(false, "settings", "cats", plugin.for_cat)
end
end
return plugin
end,
}
return M
|