diff options
| author | beeb5k <beebeeb5k@gmail.com> | 2026-06-05 16:20:33 +0530 |
|---|---|---|
| committer | beeb5k <beebeeb5k@gmail.com> | 2026-06-05 16:20:33 +0530 |
| commit | 511492f6e1ab66957a37aaccffe748bb0f8e3d65 (patch) | |
| tree | d7341b26db8d627fd339ea6f494fb83b8d62c760 /lua/bee/utils | |
| parent | fe1c8a1c340903de0d44a1f3bc590b426f1d3810 (diff) | |
formamt files and perf improvements
Diffstat (limited to 'lua/bee/utils')
| -rw-r--r-- | lua/bee/utils/init.lua | 118 |
1 files changed, 59 insertions, 59 deletions
diff --git a/lua/bee/utils/init.lua b/lua/bee/utils/init.lua index 4296561..49be80e 100644 --- a/lua/bee/utils/init.lua +++ b/lua/bee/utils/init.lua @@ -1,77 +1,77 @@ local M = {} local nixInfo = _G.nixInfo or function(default, ...) - return 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 + 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 {} + 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, + 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, + 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 |
