Skip to content

Commit

Permalink
add minimal data model to config so that palette param gets completio…
Browse files Browse the repository at this point in the history
…ns (#162)

Co-authored-by: 5-pebbles <[email protected]>
  • Loading branch information
jameswalls and 5-pebbles authored Jan 15, 2025
1 parent 11cf48e commit 78387ba
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lua/nordic/colors/init.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
local U = require('nordic.utils')
local P = require('nordic.colors.nordic')

---@class NordicPalette: NordicColors
---@class ExtendedPalette: BasePalette
local C = {}

function C.build_palette()
Expand Down
1 change: 1 addition & 0 deletions lua/nordic/colors/nordic.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
-- This file has a bunch of added colors.

-- NOTE: All hex codes must be uppercase (for testing)
---@class BasePalette
local palette = {

none = 'NONE',
Expand Down
5 changes: 5 additions & 0 deletions lua/nordic/config.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
local M = {}

---@class NordicOptions
---@field on_palette fun(palette: BasePalette)
---@field after_palette fun(palette: ExtendedPalette)
---@field on_highlight fun(highlights: Highlights, palette: ExtendedPalette)
local defaults = {
-- This callback can be used to override the colors used in the base palette.
on_palette = function(palette) end,
Expand Down Expand Up @@ -56,6 +60,7 @@ local defaults = {
M.options = defaults

-- called automatically by load
---@type fun(options: NordicOptions)
function M.setup(options)
-- backwards compatibility
options = require('nordic.compatibility')(options)
Expand Down
1 change: 1 addition & 0 deletions lua/nordic/groups/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ function M.get_groups()
local native = require('nordic.groups.native').get_groups()
local integrations = require('nordic.groups.integrations').get_groups()

---@class Highlights: IntegrationHighlights, NativeHighlights
local groups = {}
merge_inplace(groups, native)
merge_inplace(groups, integrations)
Expand Down
1 change: 1 addition & 0 deletions lua/nordic/groups/integrations.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ function M.get_groups()
local C = require('nordic.colors')
local O = require('nordic.config').options

---@class IntegrationHighlights
local G = {}

-- Dashboard.lua
Expand Down
1 change: 1 addition & 0 deletions lua/nordic/groups/native.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ function M.get_groups()
local C = require('nordic.colors')
local O = require('nordic.config').options

---@class NativeHighlights
local G = {}

-- SYNTAX
Expand Down
1 change: 1 addition & 0 deletions lua/nordic/groups/terminal.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ local M = {}

function M.get_groups()
local C = require('nordic.colors')
---@class TerminalHighlights
local G = {}

G.terminal_color_0 = C.black0
Expand Down
5 changes: 3 additions & 2 deletions lua/nordic/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@ local U = require('nordic.utils')

local M = {}

function M.load(opts)
---@type fun(options: NordicOptions)
function M.load(options)
if not U.loaded() then
vim.api.nvim_command('hi clear')
vim.o.termguicolors = true
vim.g.colors_name = U.NAME
end

if opts then require('nordic.config').setup(opts) end
if options then require('nordic.config').setup(options) end

-- Setup colors
require('nordic.colors').build_palette()
Expand Down

0 comments on commit 78387ba

Please sign in to comment.