diff options
author | Squibid <me@zacharyscheiman.com> | 2025-05-31 03:32:58 -0400 |
---|---|---|
committer | Squibid <me@zacharyscheiman.com> | 2025-05-31 03:32:58 -0400 |
commit | e830931ff421e4380d5de8b1926842000ba9be34 (patch) | |
tree | 207584548026db649bc6ab21df3b41b71ebfd830 /lua/core/init.lua | |
parent | ef678f31fdf24c0e6c4eca9a13ad9f63a53447b9 (diff) | |
download | nvim-e830931ff421e4380d5de8b1926842000ba9be34.tar.gz nvim-e830931ff421e4380d5de8b1926842000ba9be34.tar.bz2 nvim-e830931ff421e4380d5de8b1926842000ba9be34.zip |
Diffstat (limited to 'lua/core/init.lua')
-rw-r--r-- | lua/core/init.lua | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/lua/core/init.lua b/lua/core/init.lua new file mode 100644 index 0000000..f8d0c35 --- /dev/null +++ b/lua/core/init.lua @@ -0,0 +1,41 @@ +-- inspired by (and partially yoinked from): github.com/gonstoll/dotfiles + +local M = { + misc = require("core.misc"), + folding = require("core.folding"), + lsp = require("core.lsp"), + color = require("core.color"), + snippets = vim.fs.joinpath(vim.fn.stdpath("config"), "lua/core/snippets.lua"), +} + +--- check if the given table contains an item, and return the key value pair if +--- it does +---@param self table table +---@param item any item to find +---@return boolean, [any, any]? found true if found +table.contains = function(self, item) + for k, v in pairs(self) do + if v == item then + return true, { k, v } + end + end + + return false +end + +M.mason = { + --- Gets a path to a package in the Mason registry. + --- Prefer this to `get_package`, since the package might not always be + --- available yet and trigger errors. + ---@param pkg string + ---@param path? string + get_pkg_path = function(pkg, path) + pcall(require, "mason") -- make sure Mason is loaded. Will fail when generating docs + + local root = vim.env.MASON or vim.fs.joinpath(vim.fn.stdpath("data"), "mason") + path = path or "" + return vim.fs.joinpath(root, "packages", pkg, path) + end +} + +return M |