wip neovim port

This commit is contained in:
Ava Gaiety W 2025-09-24 18:53:46 -06:00
parent 1363787086
commit aa0cd250d7
15 changed files with 132 additions and 39 deletions

BIN
bun.lockb

Binary file not shown.

View file

@ -42,12 +42,12 @@ program
const timer = process.hrtime()
if (options.verbose) console.info('Building Direct Exports...')
log(options.verbose, await buildTOML(), timer)
log(options.verbose, await buildYAML(), timer)
log(options.verbose, await buildTOML(options.verbose), timer)
log(options.verbose, await buildYAML(options.verbose), timer)
if (options.verbose) console.info('Building Ports...')
log(options.verbose, await buildKitty(), timer)
// log(options.verbose, await buildNeovim(), timer)
log(options.verbose, await buildKitty(options.verbose), timer)
log(options.verbose, await buildNeovim(options.verbose), timer)
});
program.parse();

View file

@ -2,7 +2,6 @@ import { name, version } from '../info.toml'
import { license, url } from '../../../package.json'
import colors from '../../../src/palette'
import type { Colors } from '../../../src/palette'
import Color from '../../../src/helpers/color'
export default function(): any {
return {

18
ports/neovim/dist/verdigris/colors.lua vendored Normal file
View file

@ -0,0 +1,18 @@
local M = {}
M.palette = {
pit = "#00040B"
depths = "#19323B"
stope = "#4E6872"
text = "#C6E4F0"
orange = "#FF9F6F"
teal = "#23DBC1"
red = "#E8ADA9"
yellow = "#E1B392"
green = "#98CCAC"
blue = "#8CC8E0"
purple = "#BEB6E8"
}
return M

14
ports/neovim/dist/verdigris/groups.lua vendored Normal file
View file

@ -0,0 +1,14 @@
local M = {}
function M.apply()
local p = require("verdigris.colors").apply()
vim.cmd("highlight clear")
if vim.fn.exists("syntax_on") then
vim.cmd("syntax reset")
end
vim.o.background = "dark"
vim.g.colors_name = "verdigris"
end
return M

3
ports/neovim/info.toml Normal file
View file

@ -0,0 +1,3 @@
name = "verdigris for neovim"
version = "0.0.1"

View file

@ -1,38 +1,21 @@
import appRoot from 'app-root-path'
import { rmFile, mkFilePath, appendToFile } from "../../../src/helpers/file"
import { common } from '../../../dist/palette.yml'
import { spawn } from 'bun'
import { copyFiles, renderToFile } from '../../../src/helpers/file'
import getData from './data'
const file = appRoot + '/ports/neovim/estilos/palettes/verdigris.yml'
const appendToEstilosPalette = async (content: string) => await appendToFile(file, content)
const nonTemplateFiles = appRoot + '/ports/neovim/src/templates/**/*.lua'
const templateFile = appRoot + '/ports/neovim/src/templates/palette.lua.hbs'
const outputDir = appRoot + '/ports/neovim/dist/verdigris/'
const outputFile = outputDir + 'colors.lua'
export default async function(isVerbose = false) {
if (isVerbose) console.info('Neovim: Removing previous build', file)
try {
await rmFile(file)
let results: Array<string> = await copyFiles(nonTemplateFiles, outputDir, isVerbose)
await renderToFile(templateFile, outputFile, getData(), isVerbose)
results.push(outputFile)
return results.join('\n')
} catch (error) {
console.info('Neovim: Previous build already removed')
throw error
}
if (isVerbose) console.info('Neovim: Ensuring path and file exist', file)
await mkFilePath(file)
if (isVerbose) console.info('Neovim: Writing color palette into file', file)
await appendToEstilosPalette(colors())
if (isVerbose) console.info('Neovim: Running estilo to compile `.vim`', file)
await runEstilo(isVerbose)
return appRoot + '/ports/neovim/colors/verdigris.vim'
}
function colors(): string {
return Object
.keys(common)
.reduce((acc, key) => acc += `${key}: "${common[key]}"\n`, '')
}
async function runEstilo(isVerbose: boolean) {
const proc = spawn(['bun', 'estilo', 'render', appRoot + '/ports/neovim/'], {
cwd: appRoot.toString(),
});
const output = await proc.stdout.text();
if (isVerbose) console.info(output)
}

23
ports/neovim/src/data.ts Normal file
View file

@ -0,0 +1,23 @@
import { name, version } from '../info.toml'
import { license, url } from '../../../package.json'
import colors from '../../../src/palette'
import type { Colors } from '../../../src/palette'
export default function(): any {
return {
name,
version,
license,
url,
...flattenColorsToHex(),
}
}
function flattenColorsToHex(): Colors {
return colors.reduce((acc, color) => {
return {
[color.nameSnakeCase]: color.toHex(),
...acc,
}
}, {})
}

View file

@ -0,0 +1,14 @@
local M = {}
function M.apply()
local p = require("verdigris.colors").apply()
vim.cmd("highlight clear")
if vim.fn.exists("syntax_on") then
vim.cmd("syntax reset")
end
vim.o.background = "dark"
vim.g.colors_name = "verdigris"
end
return M

View file

@ -0,0 +1,18 @@
local M = {}
M.palette = {
pit = "{{pit}}"
depths = "{{depths}}"
stope = "{{stope}}"
text = "{{text}}"
orange = "{{orange}}"
teal = "{{teal}}"
red = "{{red}}"
yellow = "{{yellow}}"
green = "{{green}}"
blue = "{{blue}}"
purple = "{{purple}}"
}
return M

View file

@ -4,7 +4,7 @@ import { renderToFile } from "../helpers/file"
import colors from '../palette'
import Color from '../helpers/color'
const templateFile = appRoot + '/src/build/templates/toml.hbs'
const templateFile = appRoot + '/src/build/templates/palette.toml.hbs'
const outputFile = appRoot + '/dist/palette.toml'
export default async function(isVerbose = false): Promise<string> {

View file

@ -4,7 +4,7 @@ import colors from '../palette'
import Color from '../helpers/color'
import { renderToFile } from '../helpers/file'
const templateFile = appRoot + '/src/build/templates/yaml.hbs'
const templateFile = appRoot + '/src/build/templates/palette.yaml.hbs'
const outputFile = appRoot + '/dist/palette.yml'
export default async function(isVerbose = false): Promise<string> {

View file

@ -1,6 +1,6 @@
import { compile } from 'handlebars';
import { appendFile, mkdir, rm, readFile, writeFile } from 'node:fs/promises';
import { dirname } from 'node:path'
import { mkdir, readFile, writeFile, glob, copyFile } from 'node:fs/promises';
import { dirname, basename, join } from 'node:path'
const log = (isVerbose = true, ...rest: any[]) => {
if (isVerbose) console.info(...rest)
@ -36,3 +36,24 @@ export async function renderToFile(
}
}
export async function copyFiles(
filesGlob: string, destDir: string, isVerbose = false
): Promise<string[] | []> {
let results: Array<string> = []
try {
log(isVerbose, 'Finding files by glob', filesGlob)
for await (const file of glob(filesGlob)) {
const outputFile = join(destDir, basename(file))
results.push(outputFile)
log(isVerbose, 'Copying', file, 'to', outputFile)
await copyFile(file, outputFile)
}
} catch (error) {
throw error
}
return results
}