Skip to content

Latest commit

 

History

History
191 lines (147 loc) · 4.63 KB

File metadata and controls

191 lines (147 loc) · 4.63 KB

🔌 API Reference

Themify provides a public API that allows developers to integrate and interact with Themify using a simplified interface. If you want to do more advanced integration consider using the internal API.

Example

local Themify = require('themify.api')

math.randomseed(os.time())

local colorscheme_id = Themify.Manager.colorschemes[math.random(#Themify.Manager.colorschemes)]
local colorscheme_data = Themify.Manager.get(colorscheme_id)

Themify.set_current(colorscheme_id, colorscheme_data.themes[math.random(#colorscheme_data.themes)])

Content

Themify

local Themify = require('themify.api')

get_current()

--- Get the current colorscheme.
--- @return vim.NIL|{ colorscheme_id: nil|string, theme: string }
Themify.get_current()

set_current()

--- Set the current colorscheme.
--- @param colorscheme_id nil|string
--- @param theme string
--- @return nil
Themify.set_current(<colorscheme_id>, <theme>)

--- Example
Themify.set_current('folke/tokyonight.nvim', 'tokyonight-night')
Themify.set_current(nil, 'default')

Manager

Note

The corresponding module is themify.core.manager.

colorschemes

--- A list of id of the colorschemes in order.
--- @type string[]
Themify.Manager.colorschemes

get()

--- Get a colorscheme.
--- @param colorscheme_id string
--- @return Colorscheme_Data
Themify.Manager.get(<colorscheme_id>)

--- @class Colorscheme_Data
--- @field type 'remote'|'local'
--- @field status 'unknown'|'not_installed'|'installed'|'installing'|'updating'|'failed'
--- @field repository? Repository
--- @field progress number
--- @field info string
--- @field before? function
--- @field after? function
--- @field themes string[]
--- @field whitelist? string[]
--- @field blacklist? string[]
--- @field path string

--- Example
Themify.Manager.get('folke/tokyonight.nvim')

add()

--- Add a colorscheme to manage.
--- @param colorscheme_source string
--- @param colorscheme_info Colorscheme_Info
--- @return nil
Themify.Manager.add(<colorscheme_source>, <colorscheme_info>)

--- @class Colorscheme_Info
--- @field branch? string
--- @field before? function
--- @field after? function
--- @field whitelist? string[]
--- @field blacklist? string[]

--- Example
Themify.Manager.add('folke/tokyonight.nvim', {
  whitelist = {'tokyonight-night', 'tokyonight-day'}
})

clean()

--- Clean unused colorschemes.
--- @return nil
Themify.Manager.clean()

install()

--- Install the colorschemes.
--- @return nil
Themify.Manager.install()

update()

--- Update the colorschemes.
--- @return nil
Themify.Manager.update()

Activity

Note

The corresponding module is themify.core.activity.

get()

--- Get the activity of a skin.
--- @param colorscheme nil|string
--- @param theme string
--- @return nil|{ last_active: number, total_minutes: number, today_minutes: number }
Themify.Activity.get(<colorscheme>, <theme>)

--- Example
Themify.Activity.get('folke/tokyonight.nvim', 'tokyonight-night')
Themify.Activity.get(nil, 'default')

Event

Note

The corresponding module is themify.core.event.

listen()

--- Listen to an event.
--- @param event string
--- @param callback function
--- @return nil
Themify.Event.listen(<event>, <callback>)

List of all the events

Event Description Arguments
colorscheme-loaded When a colorscheme is loaded. (colorscheme_id, theme)
colorscheme-state-updated When the state of a colorscheme is updated. (colorscheme_id)
colorscheme-installed When a colorscheme is installed. (colorscheme_id)
colorscheme-updated When a colorscheme is updated. (colorscheme_id)
activity-update When the activity is updated. ()
interface-opened When an interface is opened. (window)
interface-closed When an interface is closed. ()
interface-update When the interfaces are being updated. ()