Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add theme config #1

Merged
merged 7 commits into from
May 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 12 additions & 41 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,41 +1,12 @@
# Compiled Lua sources
luac.out

# luarocks build files
*.src.rock
*.zip
*.tar.gz

# Object files
*.o
*.os
*.ko
*.obj
*.elf

# Precompiled Headers
*.gch
*.pch

# Libraries
*.lib
*.a
*.la
*.lo
*.def
*.exp

# Shared objects (inc. Windows DLLs)
*.dll
*.so
*.so.*
*.dylib

# Executables
*.exe
*.out
*.app
*.i*86
*.x86_64
*.hex

### Lua ###
/luarocks
/lua
/lua_modules
/.luarocks

### macOS ###
.DS_Store

### misc ###
/screenshots
/bin
8 changes: 8 additions & 0 deletions .luarc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"diagnostics.globals": [
"vim"
],
"diagnostics.disable": [
"duplicate-doc-field"
]
}
4 changes: 4 additions & 0 deletions .stylua.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
indent_type = "Spaces"
indent_width = 2
collapse_simple_statement = "Always"
column_width = 80
62 changes: 60 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,60 @@
# nightfox-zed
A direct port of the nightfox.nvim theme for Zed
# Nightfox Zed

> A port of [nightfox.nvim](https://github.com/EdenEast/nightfox.nvim) form
> Neovim to Zed

## Available Themes

### Nightfox

![nightfox](./assets/nightfox.png)

### Dayfox

![dayfox](./assets/dayfox.png)

### Dawnfox

![dawnfox](./assets/dawnfox.png)

### Duskfox

![duskfox](./assets/duskfox.png)

### Nordfox

![nordfox](./assets/nordfox.png)

### Terafox

![terafox](./assets/terafox.png)

### Carbonfox

![carbonfox](./assets/carbonfox.png)

## Development

### Setup

Run the following command to install the required dependencies:

```sh
luarocks install nightfox-zed
```

### Build

Run the following command to build the theme:

```sh
lua lib/build.lua
```

It generates the appropriate zed theme config file.

## Acknowledgements

- [nightfox.nvim] original theme

[nightfox.nvim]: https://github.com/EdenEast/nightfox.nvim
Binary file added assets/carbonfox.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/dawnfox.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/dayfox.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/duskfox.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/nightfox.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/nordfox.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/terafox.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions extension.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
id = "nightfox-zed"
name = "Nightfox for Zed"
version = "0.1.0"
schema_version = 1
authors = ["Christian Angermann <[email protected]>"]
description = "Nightfox theme is a direct Nvim port to Zed"
repository = "https://github.com/cange/nightfox.zed"
52 changes: 52 additions & 0 deletions lib/build.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
local dkjson = require("dkjson")
local toml = require("toml")

---@class ZedBuild
---@field private _ns string Namespace
local M = {}
M._ns = "nightfox-zed"

---Reads data from extension file
---@return Metadata
function M.fetch_metadata()
local filename = "extension.toml"
print(string.format("[%s] ⚙ Fetch metadata %q", M._ns, filename))
local file = assert(io.open(filename, "r"))
if file then
local file_content = assert(file:read("*all"))
local data = toml.parse(file_content)
print(string.format("[%s] ✓ Metadata fetched", M._ns))
return data
else
error(string.format("[%s] Error reading file: %q", M._ns, filename))
end
end

function M.build()
local metadata = M.fetch_metadata()
local filename = "themes/nightfox.json"
local file = assert(io.open(filename, "w"))
M._ns = metadata.id or M._ns
local content =
dkjson.encode(require("lib.theme").generate(metadata, M._ns), {
indent = true,
keyorder = { "$schema", "name", "author", "description", "url", "themes" },
})

if file then
file:write(content)
file:close()
print(string.format("[%s] ✓ %q file created", M._ns, filename))
else
error(string.format("[%s] Error opening file: %q", M._ns, filename))
end
end

M.build()

---@class Metadata
---@field id string
---@field name string
---@field authors table
---@field description string
---@field repository string
Loading