-- This plugin enables simple, safe, and reusable project-level settings. This -- plugin contains much configuration that is unlikely to be useful outside the -- context of the rest of this repository, aside from `./init.lua` and -- `./health.lua`. -- Configurations loaded into `init.lua` should contain a table of either -- configuration functions or the names of configuration functions (as strings). -- The keys of these tables must be globally unique, except for `default`, which -- is a special item that must be a table of zero or more configuration function -- names. These configurations will be aggregated and executed (in no particular -- order). -- If a file called `.proj-conf.neovim` is found in Neovim's working directory, -- then each line of that file will be parsed as the name of a configuration -- function. If no such file exists, then `default` will be used as the root -- setting. This allows composing project-specific settings. -- The appeal of this hack is enabling composable settings without needing to -- navigate the security challenges of `set exrc`. -- local filename = ".proj-conf.neovim" local map = { default = {} } local status = { initial = {}, found = {}, failed = {}, loaded = false } for _, i in pairs({ require("proj-conf.lsp"), require("proj-conf.save-formatter"), require("proj-conf.projects.deno_typescript_monorepo"), require("proj-conf.projects.ruff_pyright") }) do map.default = vim.list_extend(map.default, i.default) i.default = nil map = vim.tbl_deep_extend("error", map, i) end local setup = function() if status.loaded then return end status.initial = {} status.found = {} status.failed = {} status.loaded = false local settings = {} local add_to_settings add_to_settings = function(item) if type(map[item]) == "table" then for _, key in pairs(map[item]) do add_to_settings(key) end table.insert(status.initial, item) else settings[item] = true end end if vim.fn.filereadable(filename) == 1 then for line in io.lines(filename) do if map[line] then add_to_settings(line) end end else add_to_settings("default") table.insert(status.initial, "default") end for item, _ in pairs(settings) do if pcall(map[item]) then table.insert(status.found, item) else table.insert(status.failed, item) end end status.loaded = true end return { setup = setup, map = map, status = function() return status end }