Skip to content

Commit

Permalink
docs(README): document neovim colorscheme generation
Browse files Browse the repository at this point in the history
  • Loading branch information
Iron-E committed Apr 27, 2023
1 parent a98d294 commit e6e2e77
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 0 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -496,6 +496,8 @@ vim.api.nvim_command 'colorscheme <name>'
This plugin has the ability to export _any_ colorscheme (not just ours!) to various formats, including:

* Neovim Lua theme
* NOTE: this particular exporter has special functionality. Since exporting requires an input colorscheme, you can create a `colors/.foo.vim`/`lua` file, and the leading `.` will be stripped. For example, `colors/.foo.lua` will become `colors/foo.lua`. This way, you can continually bootstrap generation of a custom colorscheme into a standalone colorscheme without the source file standing out.
* `wezterm` theme

To make use of this, just run this after installing the plugin:
Expand Down
57 changes: 57 additions & 0 deletions doc/highlite.txt
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,8 @@ This plugin has the ability to export _any_ colorscheme (not just ours!) to
various formats, including:


- Neovim Lua theme
- NOTE: this particular exporter has special functionality. Since exporting requires an input colorscheme, you can create a `colors/.foo.vim`/`lua` file, and the leading `.` will be stripped. For example, `colors/.foo.lua` will become `colors/foo.lua`. This way, you can continually bootstrap generation of a custom colorscheme into a standalone colorscheme without the source file standing out.
- `wezterm` theme

To make use of this, just run this after installing the plugin:
Expand Down Expand Up @@ -1365,6 +1367,61 @@ FEATURES *highlite-features*
This section is about contributing new features to `nvim-highlite`.


EXPORT TARGETS ~

`nvim-highlite` has an internal string formatting library that allows you to
easily write a template for whatever you need, and all the logic will be
handled behind the scenes:

>lua
function Fmt.string(format: string, opts?: highlite.Fmt.string.opts)
-> formatted: string, count: integer
<

The `opts` are as follows:

>lua
--- @class highlite.Fmt.string.opts
--- @field convert_int_attributes? false|'hex_literal'|'hex_string' if `Foo.bar` is an integer (e.g. when `Normal.fg == 16777215`), convert it to a hex string (e.g. `'#FFFFFF'`) or a hex literal (e.g. `0xFFFFFF`)
--- @field default? true|{[string]: highlite.Fmt.string.substitution} if `true`, use default values when formatting returns `nil` for a highlight group
--- @field loadstring_compat? boolean if `true`, enable compatability for `loadstring`ing the returned value
--- @field map? fun(attribute: string, value: highlite.Fmt.string.substitution): highlite.Fmt.string.substitution
local FMT_STRING_DEFUALT_OPTS = {
convert_int_attributes = 'hex_string',
default = true,
}
<

For example, you can do this:

>lua
local Fmt = require 'highlite.fmt' --- @type highlite.Fmt
local formatted = Fmt.string [[
normal_bg = ${Normal.bg}
fallback_bg = ${undefined_group.bg | defined_group.underline}
terminal_idx_1 = ${1}
]]
<


- The `Import` <../lua/highlite/import.lua> and `Export` <../lua/highlite/export.lua> modules have more examples.

The `Fs` <../lua/highlite/fs.lua> module will be of use for writing the end
result.


IMPORT TARGETS ~

Depending on the format, you might have to write a custom parser. Neovim
supports JSON with `vim.json`, Lua can be read with `loadstring`, and VimScript
can be parsed with `nvim_parse_expression`.

Considering the open-ended nature of this topic, open an issue if you have
trouble working on what you would like to do.

The `Fs` <../lua/highlite/fs.lua> module might be of interest.


PALETTES ~


Expand Down

0 comments on commit e6e2e77

Please sign in to comment.