Skip to content

Commit

Permalink
Merge pull request #43 from terra-theme/feature/dev-102-handle-option…
Browse files Browse the repository at this point in the history
…al-fields-in-config

DEV-102 feat: improve type handling
  • Loading branch information
nikbrunner authored Oct 1, 2023
2 parents 210a25c + 0a409f3 commit b0b383b
Show file tree
Hide file tree
Showing 13 changed files with 55 additions and 43 deletions.
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
debug
service.log
check.json
file_Users_nikolausbrunner_Documents_dev_repos_terra-theme_core.nvim_._lua.log
*.log
2 changes: 1 addition & 1 deletion .luarc.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"$schema": "https://raw.githubusercontent.com/sumneko/vscode-lua/master/setting/schema.json",
"Lua.diagnostics.disable": [],
"Lua.diagnostics.disable": ["undefined-global"],
"Lua.diagnostics.globals": ["vim"]
}
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ This is all a work in progress.
Lint whole project with `lua-language-server` while respecting the `.luarc.json`.

```bash
lua-language-server --check ./lua --checklevel=Warning --logpath . --configpath /Users/nikolausbrunner/Documents/dev/repos/terra-theme/core.nvim/.luarc.json
lua-language-server --check ./lua --checklevel=Warning --logpath . --configpath /Users/nikolausbrunner/Documents/dev/repos/terra-theme/terra-core.nvim/.luarc.json
```

> Note: This currently works only with absolute paths. This seems to be a bug in `lua-language-server`, and I commented on a similar issue [here](https://github.com/LuaLS/lua-language-server/issues/2038#issuecomment-1500215468).
Expand Down
5 changes: 4 additions & 1 deletion lua/terra-core/actions/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -114,13 +114,16 @@ function M.select_variant()
icon = vim.g.terra_config.icons[selected_variant],
})

-- construct colorscheme name
local colorscheme_name = "terra_" .. vim.g.terra_config.theme .. "_" .. selected_variant

M.set_options({
variant = selected_variant,
})

M.sync_vim_opt_background_with_terra_variant(vim.g.terra_config.variant)

reload_colorscheme()
reload_colorscheme(colorscheme_name)
end

---@param item unknown
Expand Down
2 changes: 1 addition & 1 deletion lua/terra-core/actions/files.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ local M = {}
---@return string
function M.get_plugin_path()
local runtimepaths = vim.api.nvim_get_option("runtimepath")
local plugin_path = nil
local plugin_path = ""

for _, path in ipairs(vim.split(runtimepaths, ",")) do
if path:find("terra%-core") then
Expand Down
2 changes: 2 additions & 0 deletions lua/terra-core/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ M.themes = {

---@type TerraConfig
M.default_config = {
loaded = false,
debug = false,

theme = M.themes[1],
Expand All @@ -44,6 +45,7 @@ M.default_config = {
},
keywords = {
bold = true,
italic = true,
},
functions = {
bold = true,
Expand Down
1 change: 1 addition & 0 deletions lua/terra-core/themes/control/day.lua
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ M.semantics = {
light = M.primaries[6],
},
active = M.palette.yellow,
invert = M.primaries[11],
neutral = M.primaries[5],
diff = {
add = M.palette.green,
Expand Down
1 change: 1 addition & 0 deletions lua/terra-core/themes/fall/day.lua
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ M.semantics = {
light = M.primaries[6],
},
active = M.palette.yellow,
invert = M.primaries[11],
neutral = M.primaries[5],
diff = {
add = M.palette.green,
Expand Down
1 change: 1 addition & 0 deletions lua/terra-core/themes/kurzgesagt/day.lua
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ M.semantics = {
light = M.primaries[6],
},
active = M.palette.yellow,
invert = M.primaries[11],
neutral = M.primaries[5],
diff = {
add = M.palette.green,
Expand Down
1 change: 1 addition & 0 deletions lua/terra-core/themes/spring/day.lua
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ M.semantics = {
light = M.primaries[6],
},
active = M.palette.yellow,
invert = M.primaries[11],
neutral = M.primaries[5],
diff = {
add = M.palette.green,
Expand Down
1 change: 1 addition & 0 deletions lua/terra-core/themes/summer/day.lua
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ M.semantics = {
light = M.primaries[6],
},
active = M.palette.yellow,
invert = M.primaries[11],
neutral = M.primaries[5],
diff = {
add = M.palette.green,
Expand Down
1 change: 1 addition & 0 deletions lua/terra-core/themes/winter/day.lua
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ M.semantics = {
light = M.primaries[6],
},
active = M.palette.yellow,
invert = M.primaries[11],
neutral = M.primaries[5],
diff = {
add = M.palette.green,
Expand Down
76 changes: 39 additions & 37 deletions lua/terra-core/types.lua
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
----------------------------------------Highlight

---@class TerraHighlightDefinition
---@field fg string
---@field bg string
---@field sp string
---@field bold boolean
---@field italic boolean
---@field blend integer
---@field standout boolean
---@field underline boolean
---@field undercurl boolean
---@field underdouble boolean
---@field underdotted boolean
---@field underdashed boolean
---@field strikethrough boolean
---@field reverse boolean
---@field link string
---@field fg? string
---@field bg? string
---@field sp? string
---@field bold? boolean
---@field italic? boolean
---@field blend? integer
---@field standout? boolean
---@field underline? boolean
---@field undercurl? boolean
---@field underdouble? boolean
---@field underdotted? boolean
---@field underdashed? boolean
---@field strikethrough? boolean
---@field reverse? boolean
---@field link? string

---@alias TerraHighlights table<string, TerraHighlightDefinition>>

Expand All @@ -25,10 +25,11 @@
---@alias TerraHighlightMapExtension.map fun(colors: TerraColors, config: TerraConfig): TerraHighlights

---@class TerraHighlightsSpec
---@field enabled boolean Whether or not the highlight map should be enabled
---@field enabled? boolean Default: true
---@field map TerraHighlightMapExtension.map

-------------------------------------------Colors

---@class TerraColors.Debug
---@field neon_pink string
---@field electric_lime string
Expand Down Expand Up @@ -96,32 +97,33 @@
---@field semantics TerraColors.Semantics

-------------------------------------------Config

---@alias TerraConfig.Variant "day" | "night"
---@alias TerraConfig.Theme "spring" | "summer" | "fall" | "winter" | "control" | "kurzgesagt"

---@class TerraConfig.CodeStyle
---@field comments TerraHighlightDefinition
---@field keywords TerraHighlightDefinition
---@field functions TerraHighlightDefinition
---@field strings TerraHighlightDefinition
---@field variables TerraHighlightDefinition
---@field messages TerraHighlightDefinition Affects: `WarningMsg`, `ErrorMsg`, `MoreMsg`, `ModeMsg`
---@field comments? TerraHighlightDefinition
---@field keywords? TerraHighlightDefinition
---@field functions? TerraHighlightDefinition
---@field strings? TerraHighlightDefinition
---@field variables? TerraHighlightDefinition
---@field messages? TerraHighlightDefinition Affects: `WarningMsg`, `ErrorMsg`, `MoreMsg`, `ModeMsg`

---@class TerraConfig.Diagnostics
---@field darker boolean Wether to use darker colors for diagnostics
---@field undercurl boolean Wether to use undercurls for diagnostics
---@field background boolean Wether to use background color for virtual text
---@field darker boolean Wether to use darker colors for diagnostics (Default: false)
---@field undercurl boolean Wether to use undercurls for diagnostics (Default: false)
---@field background boolean Wether to use background color for virtual text (Default: false)

---@class TerraConfig
---@field loaded boolean Wether the config has been loaded
---@field debug boolean Enables the Debug Mode (Enables various debug messages)
---@field theme TerraConfig.Theme Currently set theme
---@field variant TerraConfig.Variant Currently set variant
---@field icons table<TerraConfig.Theme, string> Icons associated with each theme
---@field transparent boolean Wether to render the background color
---@field dim_inactive_panes boolean Wether to dim inactive panes
---@field term_colors boolean Wether to enable terminal colors
---@field ending_tildes boolean Wether to show the end-of-buffer tildes
---@field code_style TerraConfig.CodeStyle Code styling options
---@field colors table<string, string> Override default colors
---@field diagnostics TerraConfig.Diagnostics Diagnostics related settings
---@field loaded? boolean Wether the config has been loaded. (Default: false)
---@field debug? boolean Enables the Debug Mode (Enables various debug messages) (Default: false)
---@field theme? TerraConfig.Theme Currently set theme (Default: "spring")
---@field variant? TerraConfig.Variant Currently set variant (Default: "night")
---@field icons? table<TerraConfig.Theme, string> Icons associated with each theme
---@field transparent? boolean Wether to render the background color (Default: false)
---@field dim_inactive_panes? boolean Wether to dim inactive panes (Default: false)
---@field term_colors? boolean Wether to enable terminal colors (Default: true)
---@field ending_tildes? boolean Wether to show the end-of-buffer tildes (Default: false)
---@field code_style? TerraConfig.CodeStyle Code styling options (Default: See Documentation)
---@field colors? table<string, string> Override default colors (Default: {})
---@field diagnostics? TerraConfig.Diagnostics Diagnostics related settings (Default: See Documentation)

0 comments on commit b0b383b

Please sign in to comment.