Skip to content

Commit

Permalink
feat: add type safety and lua language server integration (#104)
Browse files Browse the repository at this point in the history
* feat: add type safety and lua language server integration

* docs: add descriptions to API and start adding descriptions for types
  • Loading branch information
mehalter authored Dec 8, 2023
1 parent 30098ac commit 3f2b6de
Show file tree
Hide file tree
Showing 42 changed files with 188 additions and 85 deletions.
82 changes: 0 additions & 82 deletions lua/astrotheme/colors.lua

This file was deleted.

1 change: 1 addition & 0 deletions lua/astrotheme/groups/astronvim.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---@type AstroThemeCallback
local function callback()
return {
HighlightURL = { underline = true },
Expand Down
1 change: 1 addition & 0 deletions lua/astrotheme/groups/base.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---@type AstroThemeCallback
local function callback(opts)
return {
--------------------
Expand Down
1 change: 1 addition & 0 deletions lua/astrotheme/groups/lsp.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---@type AstroThemeCallback
local function callback(opts)
local error = C.ui.red
local hint = C.ui.cyan
Expand Down
1 change: 1 addition & 0 deletions lua/astrotheme/groups/plugins/aerial.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---@type AstroThemeCallback
local function callback()
return {
AerialNormal = { fg = C.ui.text },
Expand Down
1 change: 1 addition & 0 deletions lua/astrotheme/groups/plugins/beacon.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---@type AstroThemeCallback
local function callback() return { Beacon = { bg = C.syntax.blue } } end

return callback
1 change: 1 addition & 0 deletions lua/astrotheme/groups/plugins/bufferline.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---@type AstroThemeCallback
local function callback()
return {
BufferLineBufferVisible = { fg = C.ui.text_inactive, bg = C.ui.base },
Expand Down
1 change: 1 addition & 0 deletions lua/astrotheme/groups/plugins/dashboard-nvim.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---@type AstroThemeCallback
local function callback()
return {
DashboardHeader = { fg = C.syntax.cyan },
Expand Down
1 change: 1 addition & 0 deletions lua/astrotheme/groups/plugins/flash.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
-- this is a test to see what i like
---@type AstroThemeCallback
local function callback()
return {
FlashBackdrop = { fg = C.syntax.mute },
Expand Down
1 change: 1 addition & 0 deletions lua/astrotheme/groups/plugins/gitsigns.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---@type AstroThemeCallback
local function callback()
return {
GitSignsAdd = { fg = C.ui.green, bg = C.none },
Expand Down
1 change: 1 addition & 0 deletions lua/astrotheme/groups/plugins/hop.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---@type AstroThemeCallback
local function callback()
return {
HopNextKey = { fg = C.ui.red, bold = true },
Expand Down
1 change: 1 addition & 0 deletions lua/astrotheme/groups/plugins/indent-blankline.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---@type AstroThemeCallback
local function callback()
return {
IndentBlanklineChar = { fg = C.ui.none_text },
Expand Down
1 change: 1 addition & 0 deletions lua/astrotheme/groups/plugins/lazy.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---@type AstroThemeCallback
local function callback()
return {
LazyH1 = { fg = C.ui.base, bg = C.ui.accent, bold = true }, -- home button
Expand Down
1 change: 1 addition & 0 deletions lua/astrotheme/groups/plugins/lightspeed.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---@type AstroThemeCallback
local function callback()
return {
LightspeedLabel = { fg = C.ui.red, underline = true },
Expand Down
1 change: 1 addition & 0 deletions lua/astrotheme/groups/plugins/mason.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---@type AstroThemeCallback
local function callback()
return {
MasonNormal = { link = "NormalFloat" },
Expand Down
1 change: 1 addition & 0 deletions lua/astrotheme/groups/plugins/ministarter.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---@type AstroThemeCallback
local function callback()
return {
MiniStarterItem = { fg = C.ui.text },
Expand Down
1 change: 1 addition & 0 deletions lua/astrotheme/groups/plugins/neo-tree.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---@type AstroThemeCallback
local function callback(opts)
return {
NeoTreeDirectoryIcon = { fg = C.ui.blue },
Expand Down
1 change: 1 addition & 0 deletions lua/astrotheme/groups/plugins/neogit.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---@type AstroThemeCallback
local function callback()
return {
NeogitDiffDelete = {
Expand Down
1 change: 1 addition & 0 deletions lua/astrotheme/groups/plugins/noice.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---@type AstroThemeCallback
local function callback()
return {
NoiceCursor = { link = "Cursor" },
Expand Down
1 change: 1 addition & 0 deletions lua/astrotheme/groups/plugins/nvim-cmp.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---@type AstroThemeCallback
local function callback()
return {
CmpItemAbbr = { fg = C.ui.text },
Expand Down
1 change: 1 addition & 0 deletions lua/astrotheme/groups/plugins/nvim-dap-ui.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---@type AstroThemeCallback
local function callback()
return {
DapUIVariable = { link = "Identifier" },
Expand Down
1 change: 1 addition & 0 deletions lua/astrotheme/groups/plugins/nvim-notify.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---@type AstroThemeCallback
local function callback(opts)
local bg = (opts.transparent and C.none) or C.ui.tool

Expand Down
1 change: 1 addition & 0 deletions lua/astrotheme/groups/plugins/nvim-tree.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---@type AstroThemeCallback
local function callback()
return {
NvimTreeFolderIcon = { fg = C.syntax.blue },
Expand Down
1 change: 1 addition & 0 deletions lua/astrotheme/groups/plugins/nvim-treesitter.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---@type AstroThemeCallback
local function callback(opts)
return {

Expand Down
1 change: 1 addition & 0 deletions lua/astrotheme/groups/plugins/nvim-ts-rainbow.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---@type AstroThemeCallback
local function callback()
return {
rainbowcol1 = { fg = "Gold" },
Expand Down
1 change: 1 addition & 0 deletions lua/astrotheme/groups/plugins/nvim-ts-rainbow2.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---@type AstroThemeCallback
local function callback()
return {
TSRainbowRed = { fg = C.syntax.red },
Expand Down
1 change: 1 addition & 0 deletions lua/astrotheme/groups/plugins/nvim-web-devicons.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---@type AstroThemeCallback
local function callback()
return {
DevIconC = { fg = C.icon.c },
Expand Down
1 change: 1 addition & 0 deletions lua/astrotheme/groups/plugins/nvim-window-picker.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---@type AstroThemeCallback
local function callback()
return {
WindowPickerStatusLine = { fg = C.ui.red, bg = C.none },
Expand Down
1 change: 1 addition & 0 deletions lua/astrotheme/groups/plugins/rainbow-delimiters.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---@type AstroThemeCallback
local function callback()
return {
RainbowDelimiterRed = { fg = C.syntax.red },
Expand Down
1 change: 1 addition & 0 deletions lua/astrotheme/groups/plugins/spotlight.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---@type AstroThemeCallback
local function callback(opts)
local bg = (opts.float and C.ui.base) or (opts.transparent and C.none) or C.ui.base
local blend = vim.o.winblend or 0
Expand Down
1 change: 1 addition & 0 deletions lua/astrotheme/groups/plugins/symbols-outline.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---@type AstroThemeCallback
local function callback() return { FocusedSymbol = { fg = C.ui.yellow, bg = C.none } } end

return callback
1 change: 1 addition & 0 deletions lua/astrotheme/groups/plugins/telescope.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---@type AstroThemeCallback
local function callback(opts)
local title = {
fg = (opts.title_invert and C.ui.float) or C.ui.title,
Expand Down
1 change: 1 addition & 0 deletions lua/astrotheme/groups/plugins/vimwiki.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---@type AstroThemeCallback
local function callback()
return {
VimwikiLink = { fg = C.syntax.cyan, bg = C.none },
Expand Down
1 change: 1 addition & 0 deletions lua/astrotheme/groups/plugins/which-key.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---@type AstroThemeCallback
local function callback()
return {
WhichKey = { fg = C.ui.cyan },
Expand Down
1 change: 1 addition & 0 deletions lua/astrotheme/groups/syntax.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
-- - Character (Subgroup)
--
-- Ref: :help group-name
---@type AstroThemeCallback
local function callback(opts)
return {
-- Comment
Expand Down
4 changes: 4 additions & 0 deletions lua/astrotheme/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ local util = require "astrotheme.lib.util"

local M = { config = {} }

--- Load a specific theme given a palette name
---@param theme string?
function M.load(theme)
if
not theme
Expand Down Expand Up @@ -32,6 +34,8 @@ function M.load(theme)
if M.config.terminal_colors then util.set_terminal_colors() end
end

--- Set up AstroTheme with provided user configured options
---@param opts AstroThemeOpts
function M.setup(opts)
M.config = require("astrotheme.lib.config").user_config(opts)
M.config.plugins = util.get_plugin_list(M.config)
Expand Down
9 changes: 8 additions & 1 deletion lua/astrotheme/lib/config.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
M = {}

---@type AstroThemeOpts
M.default = {
palette = "astrodark",
termguicolors = true,
Expand Down Expand Up @@ -35,6 +36,12 @@ M.default = {
plugins = {},
}

function M.user_config(opts) return vim.tbl_deep_extend("force", M.default, opts or {}) end
---@param opts AstroThemeOpts
---@return AstroThemeOpts
function M.user_config(opts)
local new_config = vim.tbl_deep_extend("force", M.default, opts or {})
---@cast new_config AstroThemeOpts
return new_config
end

return M
Loading

0 comments on commit 3f2b6de

Please sign in to comment.