Skip to content

Commit

Permalink
feat: introduce black-atom.constants
Browse files Browse the repository at this point in the history
  • Loading branch information
nikbrunner committed Sep 1, 2024
1 parent 3e702fc commit 4f8ff21
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 9 deletions.
11 changes: 4 additions & 7 deletions lua/black-atom/config.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
local Config = {}

-- Escaped plugin name. Used to find its own installation path.
Config.plugin_name = "black%-atom"
local M = {}

---@type BlackAtom.Config
local default_config = {
Expand Down Expand Up @@ -41,7 +38,7 @@ local default_config = {
---Sets options for the BlackAtom.Config during runtime
---@param options BlackAtom.Config
---@return nil
function Config:set(options)
function M:set(options)
local validate = require("black-atom.lib.validate")

local current_config = vim.g.black_atom_core_config or {}
Expand All @@ -55,8 +52,8 @@ end

---Returns the current BlackAtom.Config
---@return BlackAtom.Config | any
function Config:get()
function M:get()
return vim.g.black_atom_core_config
end

return Config
return M
5 changes: 5 additions & 0 deletions lua/black-atom/constants.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---@class BlackAtom.Constants
return {
plugin_name = "black%-atom", -- Escaped plugin name. Used to find its own installation path.
highlights_path = "lua/black-atom/highlights",
}
3 changes: 2 additions & 1 deletion lua/black-atom/lib/files.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@ local M = {}
---Get the install path of the plugin
---@return string
function M.get_plugin_path()
local constants = require("black-atom.constants")
local runtimepaths = vim.api.nvim_list_runtime_paths()

local plugin_path = ""

for _, path in ipairs(runtimepaths) do
if path:find(require("black-atom.config").plugin_name) then
if path:find(constants.plugin_name) then
plugin_path = path
break
end
Expand Down
3 changes: 2 additions & 1 deletion lua/black-atom/lib/highlights.lua
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,10 @@ end
---@param config BlackAtom.Config
---@return BlackAtom.Highlights
function M.build_highlights_map(colors, config)
local constants = require("black-atom.constants")
local default_ignore_pattern = ".*_template.lua$"
local highlight_modules =
require("black-atom.lib.files").get_highlight_modules("lua/black-atom/highlights", default_ignore_pattern)
require("black-atom.lib.files").get_highlight_modules(constants.highlights_path, default_ignore_pattern)

local highlights_map = M.aggregate_highlight_maps(highlight_modules, colors, config)

Expand Down

0 comments on commit 4f8ff21

Please sign in to comment.