vim2bat 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- vim2bat-0.1.0/.github/dependabot.yml +22 -0
- vim2bat-0.1.0/.github/workflows/ci.yml +54 -0
- vim2bat-0.1.0/.github/workflows/release.yml +105 -0
- vim2bat-0.1.0/.gitignore +16 -0
- vim2bat-0.1.0/.pre-commit-config.yaml +19 -0
- vim2bat-0.1.0/CHANGELOG.md +35 -0
- vim2bat-0.1.0/CONTRIBUTING.md +137 -0
- vim2bat-0.1.0/LICENSE +21 -0
- vim2bat-0.1.0/PKG-INFO +231 -0
- vim2bat-0.1.0/README.md +204 -0
- vim2bat-0.1.0/formula/vim2bat.rb +30 -0
- vim2bat-0.1.0/pyproject.toml +60 -0
- vim2bat-0.1.0/src/vim2bat/__init__.py +0 -0
- vim2bat-0.1.0/src/vim2bat/__main__.py +5 -0
- vim2bat-0.1.0/src/vim2bat/cli.py +761 -0
- vim2bat-0.1.0/src/vim2bat/share/loose.tsv +84 -0
- vim2bat-0.1.0/src/vim2bat/share/strict.tsv +37 -0
- vim2bat-0.1.0/src/vim2bat/share/vim-groups.vim +58 -0
- vim2bat-0.1.0/src/vim2bat/share/vim-slots.vim +80 -0
- vim2bat-0.1.0/tests/fixtures/colors/testbroken.vim +4 -0
- vim2bat-0.1.0/tests/fixtures/colors/testdark.vim +24 -0
- vim2bat-0.1.0/tests/fixtures/colors/testdual.vim +34 -0
- vim2bat-0.1.0/tests/fixtures/colors/testhex.vim +25 -0
- vim2bat-0.1.0/tests/fixtures/colors/testsilent.vim +6 -0
- vim2bat-0.1.0/tests/fixtures/samples/plain.sample +2 -0
- vim2bat-0.1.0/tests/fixtures/samples/sample.rb +16 -0
- vim2bat-0.1.0/tests/golden/vim-testdark.tmTheme +497 -0
- vim2bat-0.1.0/tests/golden/vim-testdual-dark.tmTheme +497 -0
- vim2bat-0.1.0/tests/golden/vim-testdual-light.tmTheme +497 -0
- vim2bat-0.1.0/tests/golden/vim-testhex.tmTheme +497 -0
- vim2bat-0.1.0/tests/test_integration.py +571 -0
- vim2bat-0.1.0/tests/test_vim2bat.py +220 -0
- vim2bat-0.1.0/uv.lock +536 -0
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
version: 2
|
|
2
|
+
updates:
|
|
3
|
+
- package-ecosystem: "github-actions"
|
|
4
|
+
directory: "/"
|
|
5
|
+
schedule:
|
|
6
|
+
interval: "weekly"
|
|
7
|
+
cooldown:
|
|
8
|
+
default-days: 7
|
|
9
|
+
|
|
10
|
+
- package-ecosystem: "uv"
|
|
11
|
+
directory: "/"
|
|
12
|
+
schedule:
|
|
13
|
+
interval: "weekly"
|
|
14
|
+
cooldown:
|
|
15
|
+
default-days: 7
|
|
16
|
+
|
|
17
|
+
- package-ecosystem: "pre-commit"
|
|
18
|
+
directory: "/"
|
|
19
|
+
schedule:
|
|
20
|
+
interval: "weekly"
|
|
21
|
+
cooldown:
|
|
22
|
+
default-days: 7
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
pull_request:
|
|
7
|
+
|
|
8
|
+
permissions:
|
|
9
|
+
contents: read
|
|
10
|
+
|
|
11
|
+
jobs:
|
|
12
|
+
lint:
|
|
13
|
+
runs-on: ubuntu-latest
|
|
14
|
+
steps:
|
|
15
|
+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
16
|
+
with:
|
|
17
|
+
persist-credentials: false
|
|
18
|
+
|
|
19
|
+
- uses: astral-sh/setup-uv@68559e99cc807c1eb7e9238fd43a15bba460eec2 # v10.3.3
|
|
20
|
+
|
|
21
|
+
- run: uv lock --check
|
|
22
|
+
- run: uv run ruff check
|
|
23
|
+
- run: uv run ruff format --check
|
|
24
|
+
- run: uv run mypy
|
|
25
|
+
|
|
26
|
+
test:
|
|
27
|
+
strategy:
|
|
28
|
+
matrix:
|
|
29
|
+
os: [macos-latest, ubuntu-latest]
|
|
30
|
+
python: ["3.11", "3.12", "3.13", "3.14", "3.15"]
|
|
31
|
+
runs-on: ${{ matrix.os }}
|
|
32
|
+
steps:
|
|
33
|
+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
34
|
+
with:
|
|
35
|
+
persist-credentials: false
|
|
36
|
+
|
|
37
|
+
- uses: astral-sh/setup-uv@68559e99cc807c1eb7e9238fd43a15bba460eec2 # v10.3.3
|
|
38
|
+
with:
|
|
39
|
+
python-version: ${{ matrix.python }}
|
|
40
|
+
|
|
41
|
+
- name: Install Vim and bat (macOS)
|
|
42
|
+
if: runner.os == 'macOS'
|
|
43
|
+
run: brew install vim bat
|
|
44
|
+
|
|
45
|
+
- name: Install Vim and bat (Linux)
|
|
46
|
+
if: runner.os == 'Linux'
|
|
47
|
+
# Debian and Ubuntu name bat's binary batcat.
|
|
48
|
+
run: |
|
|
49
|
+
sudo apt-get update
|
|
50
|
+
sudo apt-get install -y vim bat
|
|
51
|
+
sudo ln -s /usr/bin/batcat /usr/local/bin/bat
|
|
52
|
+
|
|
53
|
+
- run: uv sync --locked
|
|
54
|
+
- run: uv run pytest
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
name: Release
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
tags: ["v*"]
|
|
6
|
+
|
|
7
|
+
permissions: {}
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
build:
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
permissions:
|
|
13
|
+
contents: read
|
|
14
|
+
steps:
|
|
15
|
+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
16
|
+
with:
|
|
17
|
+
persist-credentials: false
|
|
18
|
+
|
|
19
|
+
- uses: astral-sh/setup-uv@68559e99cc807c1eb7e9238fd43a15bba460eec2 # v10.3.3
|
|
20
|
+
|
|
21
|
+
- name: Check that the tag matches the package version
|
|
22
|
+
run: |
|
|
23
|
+
VERSION="$(uv version --short)"
|
|
24
|
+
if [ "$GITHUB_REF_NAME" != "v$VERSION" ]; then
|
|
25
|
+
echo "::error::Tag $GITHUB_REF_NAME does not match package version $VERSION"
|
|
26
|
+
exit 1
|
|
27
|
+
fi
|
|
28
|
+
|
|
29
|
+
- run: uv build
|
|
30
|
+
|
|
31
|
+
- uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
|
|
32
|
+
with:
|
|
33
|
+
name: dist
|
|
34
|
+
path: dist/
|
|
35
|
+
|
|
36
|
+
publish:
|
|
37
|
+
needs: build
|
|
38
|
+
runs-on: ubuntu-latest
|
|
39
|
+
environment:
|
|
40
|
+
name: pypi
|
|
41
|
+
url: https://pypi.org/p/vim2bat
|
|
42
|
+
permissions:
|
|
43
|
+
id-token: write
|
|
44
|
+
steps:
|
|
45
|
+
- uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
|
|
46
|
+
with:
|
|
47
|
+
name: dist
|
|
48
|
+
path: dist/
|
|
49
|
+
|
|
50
|
+
- uses: pypa/gh-action-pypi-publish@7245906fb61fa33a13554f9d5fb856fe61758086 # v1.14.3
|
|
51
|
+
|
|
52
|
+
github-release:
|
|
53
|
+
needs: publish
|
|
54
|
+
runs-on: ubuntu-latest
|
|
55
|
+
permissions:
|
|
56
|
+
contents: write
|
|
57
|
+
steps:
|
|
58
|
+
- uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
|
|
59
|
+
with:
|
|
60
|
+
name: dist
|
|
61
|
+
path: dist/
|
|
62
|
+
|
|
63
|
+
- name: Create release
|
|
64
|
+
env:
|
|
65
|
+
GH_TOKEN: ${{ github.token }}
|
|
66
|
+
GH_REPO: ${{ github.repository }}
|
|
67
|
+
run: |
|
|
68
|
+
gh release create "$GITHUB_REF_NAME" dist/* \
|
|
69
|
+
--title "$GITHUB_REF_NAME" \
|
|
70
|
+
--generate-notes
|
|
71
|
+
|
|
72
|
+
homebrew:
|
|
73
|
+
needs: github-release
|
|
74
|
+
runs-on: ubuntu-latest
|
|
75
|
+
permissions:
|
|
76
|
+
contents: read
|
|
77
|
+
env:
|
|
78
|
+
HOMEBREW_TAP_TOKEN: ${{ secrets.HOMEBREW_TAP_TOKEN }}
|
|
79
|
+
steps:
|
|
80
|
+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
81
|
+
with:
|
|
82
|
+
persist-credentials: false
|
|
83
|
+
|
|
84
|
+
- name: Update Homebrew formula
|
|
85
|
+
# secrets context is not available in `if` expressions, so we check
|
|
86
|
+
# the job-level env var instead.
|
|
87
|
+
if: env.HOMEBREW_TAP_TOKEN != ''
|
|
88
|
+
run: |
|
|
89
|
+
VERSION="${GITHUB_REF_NAME#v}"
|
|
90
|
+
|
|
91
|
+
TARBALL_URL="https://github.com/$GITHUB_REPOSITORY/archive/refs/tags/$GITHUB_REF_NAME.tar.gz"
|
|
92
|
+
curl -fsSL "$TARBALL_URL" -o /tmp/source.tar.gz
|
|
93
|
+
SHA=$(sha256sum /tmp/source.tar.gz | awk '{print $1}')
|
|
94
|
+
|
|
95
|
+
sed -e "s/VERSION_PLACEHOLDER/$VERSION/g" \
|
|
96
|
+
-e "s/SHA_PLACEHOLDER/$SHA/g" \
|
|
97
|
+
formula/vim2bat.rb > /tmp/vim2bat.rb
|
|
98
|
+
|
|
99
|
+
git clone "https://x-access-token:${HOMEBREW_TAP_TOKEN}@github.com/redodson01/homebrew-tap.git" /tmp/tap
|
|
100
|
+
cd /tmp/tap
|
|
101
|
+
cp /tmp/vim2bat.rb vim2bat.rb
|
|
102
|
+
git config user.name "github-actions[bot]"
|
|
103
|
+
git config user.email "github-actions[bot]@users.noreply.github.com"
|
|
104
|
+
git add vim2bat.rb
|
|
105
|
+
git diff --cached --quiet || { git commit -m "vim2bat ${VERSION}" && git push; }
|
vim2bat-0.1.0/.gitignore
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
repos:
|
|
2
|
+
- repo: https://github.com/pre-commit/pre-commit-hooks
|
|
3
|
+
rev: v6.0.0
|
|
4
|
+
hooks:
|
|
5
|
+
- id: trailing-whitespace
|
|
6
|
+
- id: end-of-file-fixer
|
|
7
|
+
- id: check-yaml
|
|
8
|
+
- id: check-toml
|
|
9
|
+
- id: check-added-large-files
|
|
10
|
+
- repo: https://github.com/astral-sh/ruff-pre-commit
|
|
11
|
+
rev: v0.17.3
|
|
12
|
+
hooks:
|
|
13
|
+
- id: ruff-check
|
|
14
|
+
args: [--fix]
|
|
15
|
+
- id: ruff-format
|
|
16
|
+
- repo: https://github.com/astral-sh/uv-pre-commit
|
|
17
|
+
rev: 0.13.7
|
|
18
|
+
hooks:
|
|
19
|
+
- id: uv-lock
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [Unreleased]
|
|
9
|
+
|
|
10
|
+
## [0.1.0] - 2026-11-05
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
|
|
14
|
+
- `vim2bat SCHEME` builds bat themes from a Vim colorscheme as Vim shows it with
|
|
15
|
+
your vimrc: `vim-SCHEME-dark` and `vim-SCHEME-light`, or `vim-SCHEME` for a
|
|
16
|
+
scheme with one background
|
|
17
|
+
- `--all` builds every colorscheme Vim lists, several at a time
|
|
18
|
+
- `--strict`, `--truecolor`, `--palette 16|256` and `--clean`
|
|
19
|
+
- `vim2bat compare THEME FILE...` measures a theme against Vim
|
|
20
|
+
- Support for Python 3.11 or newer
|
|
21
|
+
- Homebrew install via `brew install redodson01/tap/vim2bat`
|
|
22
|
+
- PyPI package, installed with `uv tool install vim2bat` or
|
|
23
|
+
`pipx install vim2bat`
|
|
24
|
+
- Source install via `uv tool install .`
|
|
25
|
+
- CI that runs ruff, the format check and mypy, and runs the tests on macOS
|
|
26
|
+
and Linux for Python 3.11 through 3.15
|
|
27
|
+
- pre-commit hooks for ruff, the uv lockfile and basic file checks
|
|
28
|
+
- Release workflow that, on tag push, checks the tag against the package
|
|
29
|
+
version, publishes to PyPI through trusted publishing, creates a GitHub
|
|
30
|
+
release with the built files and updates the redodson01/homebrew-tap formula
|
|
31
|
+
- Dependabot config for keeping GitHub Actions, uv dependencies and pre-commit
|
|
32
|
+
hooks current
|
|
33
|
+
|
|
34
|
+
[Unreleased]: https://github.com/redodson01/vim2bat/compare/v0.1.0...HEAD
|
|
35
|
+
[0.1.0]: https://github.com/redodson01/vim2bat/releases/tag/v0.1.0
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
# Contributing to vim2bat
|
|
2
|
+
|
|
3
|
+
## Development
|
|
4
|
+
|
|
5
|
+
vim2bat is a Python package that uses only the standard library. The code is in
|
|
6
|
+
`src/vim2bat/cli.py`, and `src/vim2bat/share/` holds two Vim scripts and two
|
|
7
|
+
tables. You need Vim, bat and [uv](https://docs.astral.sh/uv/) (`brew install
|
|
8
|
+
uv`). uv uses Python 3.11 or newer and downloads one if none is installed, and
|
|
9
|
+
it installs the dev tools (pytest, mypy, ruff and pre-commit) at the versions in
|
|
10
|
+
`uv.lock`.
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
uv sync # creates .venv with an editable install of vim2bat and the dev tools
|
|
14
|
+
uv run pre-commit install # installs the git hook described below
|
|
15
|
+
uv run pytest # unit tests, plus integration tests when vim and bat are installed
|
|
16
|
+
uv run mypy # type checks src and tests in strict mode
|
|
17
|
+
uv run ruff check # lints (add --fix to apply the safe fixes)
|
|
18
|
+
uv run ruff format # formats
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
`uv run` brings `.venv` up to date with `uv.lock` before it runs a command, and
|
|
22
|
+
because the install is editable, changes under `src/` take effect without
|
|
23
|
+
reinstalling.
|
|
24
|
+
|
|
25
|
+
The pre-commit hook runs on the files you commit. It lints them with
|
|
26
|
+
`ruff check --fix`, formats them with `ruff format`, runs `uv lock` when
|
|
27
|
+
`pyproject.toml` or `uv.lock` changes, trims trailing whitespace, fixes final
|
|
28
|
+
newlines, checks YAML and TOML syntax, and rejects large files. It doesn't run
|
|
29
|
+
mypy or the tests.
|
|
30
|
+
|
|
31
|
+
The integration tests build themes from the test colorschemes in
|
|
32
|
+
`tests/fixtures/colors`, in a scratch home, bat config and cache, and compare
|
|
33
|
+
the strict themes with the files in `tests/golden`. After an intended change to
|
|
34
|
+
the output, regenerate those files and check their diff:
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
UPDATE_GOLDEN=1 uv run pytest
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Measuring a change
|
|
41
|
+
|
|
42
|
+
`uv run vim2bat compare THEME FILE...` measures a theme against Vim. Before and
|
|
43
|
+
after a change to the tables, rebuild the theme with `uv run vim2bat SCHEME`,
|
|
44
|
+
which uses your checkout, and measure it on a representative set of your own
|
|
45
|
+
code. Keep those files out of the repository.
|
|
46
|
+
|
|
47
|
+
## The tables
|
|
48
|
+
|
|
49
|
+
`src/vim2bat/share/strict.tsv` maps each of Vim's standard groups to the
|
|
50
|
+
TextMate scopes with the same meaning, one row per group: `GROUP<TAB>SCOPES`.
|
|
51
|
+
|
|
52
|
+
`src/vim2bat/share/loose.tsv` adds language-specific rows:
|
|
53
|
+
`FILETYPE<TAB>GROUP<TAB>SCOPES`. vim-solarized8's language-specific coloring
|
|
54
|
+
decides which languages and tokens are in scope. A new row follows these rules:
|
|
55
|
+
|
|
56
|
+
1. Map scopes that bat already assigns to the Vim group that Vim gives the same
|
|
57
|
+
tokens, by meaning.
|
|
58
|
+
2. Use the first group in the token's link chain (as `vim2bat compare` lists
|
|
59
|
+
it) that exists in Table 1 (the groups vim2bat records from Vim), or
|
|
60
|
+
`Normal` for tokens that Vim leaves plain. When one scope covers tokens with
|
|
61
|
+
different chains, use the first group they all share.
|
|
62
|
+
3. The filetype column is the Vim filetype whose syntax file defines the group.
|
|
63
|
+
4. Qualify every selector by language: a language-suffixed scope, or the
|
|
64
|
+
language's root scope plus exactly one other scope. No selector combines two
|
|
65
|
+
non-root scopes, and none uses exclusions.
|
|
66
|
+
5. Don't rely on the order of rows with equal specificity.
|
|
67
|
+
6. Stop when every remaining kind of mismatch is under 1% of characters, or
|
|
68
|
+
would need a rule that depends on context.
|
|
69
|
+
7. Don't fit rows to particular files.
|
|
70
|
+
|
|
71
|
+
## Pull requests
|
|
72
|
+
|
|
73
|
+
- Keep PRs focused on a single change
|
|
74
|
+
- Ensure `uv run ruff check`, `uv run ruff format --check`, `uv run mypy` and
|
|
75
|
+
`uv run pytest` pass (CI runs all four, checks that `uv.lock` is current, and
|
|
76
|
+
runs the tests on macOS and Linux with Python 3.11 through 3.15)
|
|
77
|
+
- Update `CHANGELOG.md` under `[Unreleased]` when making a notable change
|
|
78
|
+
- Use atomic, logically-ordered commits
|
|
79
|
+
- Follow the commit message style of the existing history
|
|
80
|
+
|
|
81
|
+
## Versioning
|
|
82
|
+
|
|
83
|
+
This project follows [Semantic Versioning](https://semver.org/spec/v2.0.0.html):
|
|
84
|
+
|
|
85
|
+
- **MAJOR** for incompatible CLI changes or theme names
|
|
86
|
+
- **MINOR** for backwards-compatible new features
|
|
87
|
+
- **PATCH** for backwards-compatible bug fixes
|
|
88
|
+
|
|
89
|
+
## Releasing
|
|
90
|
+
|
|
91
|
+
1. Run `uv version --bump patch` (or `minor` or `major`). It sets the new
|
|
92
|
+
version in `pyproject.toml` and `uv.lock`, and `vim2bat --version` reads it
|
|
93
|
+
from the installed package.
|
|
94
|
+
2. In `CHANGELOG.md`, move the `[Unreleased]` entries under a new
|
|
95
|
+
`## [X.Y.Z] - YYYY-MM-DD` heading, change the `[Unreleased]` link to compare
|
|
96
|
+
`vX.Y.Z...HEAD`, and add an `[X.Y.Z]` link that compares the previous tag
|
|
97
|
+
with `vX.Y.Z`.
|
|
98
|
+
3. Commit and push, then push a `vX.Y.Z` tag for the new version.
|
|
99
|
+
|
|
100
|
+
The release workflow checks that the tag matches the version in
|
|
101
|
+
`pyproject.toml`, builds the sdist and wheel with `uv build`, and publishes them
|
|
102
|
+
to PyPI through trusted publishing. It then creates the GitHub release with the
|
|
103
|
+
built files attached, and updates the formula in
|
|
104
|
+
[redodson01/homebrew-tap](https://github.com/redodson01/homebrew-tap) using the
|
|
105
|
+
`HOMEBREW_TAP_TOKEN` secret. Each job runs only after the one before it
|
|
106
|
+
succeeds, so a tag that doesn't match the version publishes nothing.
|
|
107
|
+
|
|
108
|
+
### One-time setup
|
|
109
|
+
|
|
110
|
+
Before the first release:
|
|
111
|
+
|
|
112
|
+
1. Create redodson01/vim2bat on GitHub as a public repository and push `main`.
|
|
113
|
+
The tap update downloads the tag's source tarball without credentials, and
|
|
114
|
+
Dependabot's pre-commit updates work only in public repositories.
|
|
115
|
+
2. On PyPI, add a pending trusted publisher on the GitHub tab of your account's
|
|
116
|
+
[Publishing](https://pypi.org/manage/account/publishing/) page:
|
|
117
|
+
|
|
118
|
+
| Field | Value |
|
|
119
|
+
|---|---|
|
|
120
|
+
| PyPI Project Name | `vim2bat` |
|
|
121
|
+
| Owner | `redodson01` |
|
|
122
|
+
| Repository name | `vim2bat` |
|
|
123
|
+
| Workflow name | `release.yml` |
|
|
124
|
+
| Environment name | `pypi` |
|
|
125
|
+
|
|
126
|
+
A pending publisher doesn't reserve the name, and it stops working if
|
|
127
|
+
someone else registers vim2bat first. The first upload turns it into a
|
|
128
|
+
normal publisher.
|
|
129
|
+
3. Optionally, create the `pypi` environment on GitHub (Settings, Environments)
|
|
130
|
+
and add yourself as a required reviewer, so that each PyPI upload waits for
|
|
131
|
+
your approval. Do this before the first tag, because a release run otherwise
|
|
132
|
+
creates the environment with no protection rules. On the Free plan, required
|
|
133
|
+
reviewers work only in public repositories.
|
|
134
|
+
4. Add a repository secret named `HOMEBREW_TAP_TOKEN` (Settings, Secrets and
|
|
135
|
+
variables, Actions). It holds a fine-grained personal access token limited
|
|
136
|
+
to redodson01/homebrew-tap, with Contents set to read and write. Without it,
|
|
137
|
+
the release skips the tap update.
|
vim2bat-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Richard E. Dodson
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
vim2bat-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: vim2bat
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Generate bat themes from Vim colorschemes
|
|
5
|
+
Project-URL: Homepage, https://github.com/redodson01/vim2bat
|
|
6
|
+
Project-URL: Repository, https://github.com/redodson01/vim2bat
|
|
7
|
+
Project-URL: Issues, https://github.com/redodson01/vim2bat/issues
|
|
8
|
+
Project-URL: Changelog, https://github.com/redodson01/vim2bat/blob/main/CHANGELOG.md
|
|
9
|
+
Author: Richard E. Dodson
|
|
10
|
+
License-Expression: MIT
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
Classifier: Development Status :: 4 - Beta
|
|
13
|
+
Classifier: Environment :: Console
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: Operating System :: MacOS
|
|
16
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
17
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.15
|
|
23
|
+
Classifier: Topic :: Text Editors
|
|
24
|
+
Classifier: Topic :: Utilities
|
|
25
|
+
Requires-Python: >=3.11
|
|
26
|
+
Description-Content-Type: text/markdown
|
|
27
|
+
|
|
28
|
+
# vim2bat
|
|
29
|
+
|
|
30
|
+
[](https://github.com/redodson01/vim2bat/actions/workflows/ci.yml)
|
|
31
|
+
[](https://github.com/redodson01/vim2bat/releases/latest)
|
|
32
|
+
[](https://github.com/redodson01/vim2bat/releases/latest)
|
|
33
|
+
[](https://github.com/redodson01/vim2bat/blob/main/LICENSE)
|
|
34
|
+
|
|
35
|
+
Builds [bat](https://github.com/sharkdp/bat) themes from Vim colorschemes, so
|
|
36
|
+
that bat, and tools that use it such as fzf.vim's previews and delta, color code
|
|
37
|
+
the way Vim does.
|
|
38
|
+
|
|
39
|
+
## The problem
|
|
40
|
+
|
|
41
|
+
bat ships its own themes, and most of them use 24-bit colors. If you use a Vim
|
|
42
|
+
colorscheme, especially one built on your terminal's palette like solarized8
|
|
43
|
+
with `g:solarized_use16`, the previews and diffs that bat colors look different
|
|
44
|
+
from the code you edit in Vim. A matching bat theme means mapping Vim's
|
|
45
|
+
highlight groups to TextMate scopes by hand, for each scheme and background.
|
|
46
|
+
|
|
47
|
+
vim2bat asks Vim which colors a colorscheme gives each highlight group, with
|
|
48
|
+
your vimrc, and writes bat themes that use the same palette slots, or the same
|
|
49
|
+
24-bit colors.
|
|
50
|
+
|
|
51
|
+
## Install
|
|
52
|
+
|
|
53
|
+
### Homebrew (macOS and Linux)
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
brew install redodson01/tap/vim2bat
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
### PyPI
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
uv tool install vim2bat # or: pipx install vim2bat
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
### From source
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
git clone https://github.com/redodson01/vim2bat.git
|
|
69
|
+
cd vim2bat
|
|
70
|
+
uv tool install . # or: uv tool install --editable . to follow edits to the checkout
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
The PyPI and source installs put the `vim2bat` command in `~/.local/bin` by
|
|
74
|
+
default. Make sure that folder is on your `$PATH` (`uv tool update-shell` or
|
|
75
|
+
`pipx ensurepath` adds it).
|
|
76
|
+
|
|
77
|
+
## Runtime requirements
|
|
78
|
+
|
|
79
|
+
- Vim 9.1 or newer, with the colorschemes you want to convert
|
|
80
|
+
- bat (0.25 or newer for the `--theme-dark` and `--theme-light` settings below)
|
|
81
|
+
- Python 3.11 or newer
|
|
82
|
+
|
|
83
|
+
Debian and Ubuntu install bat as `batcat`. vim2bat runs `bat`, so link it:
|
|
84
|
+
`ln -s /usr/bin/batcat ~/.local/bin/bat`.
|
|
85
|
+
|
|
86
|
+
## Usage
|
|
87
|
+
|
|
88
|
+
```bash
|
|
89
|
+
vim2bat retrobox # builds vim-retrobox-dark and vim-retrobox-light
|
|
90
|
+
vim2bat --all # builds every colorscheme Vim lists
|
|
91
|
+
bat --theme=vim-retrobox-dark file.rb
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
| Option | Effect |
|
|
95
|
+
|---|---|
|
|
96
|
+
| `-a`, `--all` | Builds every colorscheme Vim lists, several at a time |
|
|
97
|
+
| `-c`, `--clean` | First deletes vim2bat's cache and the whole bat themes folder |
|
|
98
|
+
| `-s`, `--strict` | Maps only Vim's standard highlight groups, such as `Comment` and `String` |
|
|
99
|
+
| `-t`, `--truecolor` | Turns on `termguicolors`, so the themes use the scheme's 24-bit colors |
|
|
100
|
+
| `-p`, `--palette 16\|256` | Overrides your vimrc's `t_Co` |
|
|
101
|
+
|
|
102
|
+
vim2bat rebuilds bat's cache when it finishes, so the themes are available right
|
|
103
|
+
away.
|
|
104
|
+
|
|
105
|
+
### Theme names
|
|
106
|
+
|
|
107
|
+
A scheme that supports both backgrounds gets `vim-SCHEME-dark` and
|
|
108
|
+
`vim-SCHEME-light`. A scheme that supports a single background, by setting
|
|
109
|
+
`background` itself, gets `vim-SCHEME`.
|
|
110
|
+
|
|
111
|
+
### What decides the colors
|
|
112
|
+
|
|
113
|
+
Vim runs with your vimrc in a 256-color terminal, so your vimrc decides what the
|
|
114
|
+
themes look like: a scheme's own options (such as `g:solarized_use16`), `t_Co`
|
|
115
|
+
and `termguicolors` all apply. `-p` and `-t` override `t_Co` and
|
|
116
|
+
`termguicolors` for one run. Each theme records the options it was built with in
|
|
117
|
+
its `comment` entry. `-p` has no effect while `termguicolors` is on, whether
|
|
118
|
+
from `-t` or your vimrc.
|
|
119
|
+
|
|
120
|
+
With `-t`, bat prints the exact colors only when `COLORTERM` is `truecolor` or
|
|
121
|
+
`24bit`. Otherwise it rounds them to the nearest of 256.
|
|
122
|
+
|
|
123
|
+
## Using the themes
|
|
124
|
+
|
|
125
|
+
### bat
|
|
126
|
+
|
|
127
|
+
Add these lines to bat's config file, whose path `bat --config-file` prints:
|
|
128
|
+
|
|
129
|
+
```
|
|
130
|
+
--theme-dark="vim-retrobox-dark"
|
|
131
|
+
--theme-light="vim-retrobox-light"
|
|
132
|
+
--italic-text=always
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
bat's default, `--theme=auto`, picks between them by asking the terminal for its
|
|
136
|
+
background. It doesn't ask when its output goes to a pipe, as in fzf.vim's
|
|
137
|
+
previews, and then uses its own default theme. On macOS, `--theme="auto:system"`
|
|
138
|
+
follows the system appearance instead, and works in pipes too.
|
|
139
|
+
|
|
140
|
+
bat leaves out italics unless `--italic-text` is `always`.
|
|
141
|
+
|
|
142
|
+
### delta
|
|
143
|
+
|
|
144
|
+
delta takes a single syntax theme:
|
|
145
|
+
|
|
146
|
+
```ini
|
|
147
|
+
[delta]
|
|
148
|
+
syntax-theme = vim-retrobox-dark
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
On macOS, git's pager command can pick the theme from the system appearance:
|
|
152
|
+
|
|
153
|
+
```ini
|
|
154
|
+
[core]
|
|
155
|
+
pager = delta --syntax-theme=vim-retrobox-$(defaults read -g AppleInterfaceStyle 2>/dev/null | grep -qx Dark && echo dark || echo light)
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
## Measuring a theme
|
|
159
|
+
|
|
160
|
+
`vim2bat compare THEME FILE...` reports how often the theme gives each
|
|
161
|
+
character the color Vim does, per file and per language, then the most common
|
|
162
|
+
mismatches:
|
|
163
|
+
|
|
164
|
+
```bash
|
|
165
|
+
vim2bat compare vim-retrobox-dark app/models/*.rb
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
Expect 85 to 90 percent on real code in the languages Table 3 covers (see
|
|
169
|
+
below): bat's syntax definitions don't split code exactly the way Vim's do.
|
|
170
|
+
Other languages get only Table 2 and score lower.
|
|
171
|
+
|
|
172
|
+
## How it works
|
|
173
|
+
|
|
174
|
+
1. For each background, vim2bat runs Vim with your vimrc on a pseudo-terminal,
|
|
175
|
+
loads the scheme, and records each highlight group's colors and attributes
|
|
176
|
+
(Table 1, cached in `$XDG_CACHE_HOME/vim2bat/tables`, or
|
|
177
|
+
`~/.cache/vim2bat/tables`). Vim gets a terminal because
|
|
178
|
+
without one it numbers named colors such as `DarkBlue` differently.
|
|
179
|
+
2. `src/vim2bat/share/strict.tsv` (Table 2) maps Vim's standard groups, such
|
|
180
|
+
as `Comment` and `String`, to the TextMate scopes with the same meaning.
|
|
181
|
+
3. `src/vim2bat/share/loose.tsv` (Table 3) maps language-specific scopes to the
|
|
182
|
+
Vim syntax groups that Vim gives the same tokens, for Ruby, ERB, HTML, CSS
|
|
183
|
+
and SCSS, TypeScript and TSX, JavaScript and JSX, YAML, Vim script, git
|
|
184
|
+
commit messages and diffs. The languages and tokens follow what
|
|
185
|
+
vim-solarized8 colors.
|
|
186
|
+
4. Palette colors use bat's palette notation, where `#0E000000` means slot 14,
|
|
187
|
+
and the terminal's default color is `#00000001`.
|
|
188
|
+
|
|
189
|
+
## Known limits
|
|
190
|
+
|
|
191
|
+
- bat doesn't paint a scheme's background color, so a scheme with its own
|
|
192
|
+
background, such as habamax, sits on your terminal's.
|
|
193
|
+
- bat themes support only bold, italic and underline, so reverse and undercurl
|
|
194
|
+
are dropped.
|
|
195
|
+
- `-c` deletes the whole bat themes folder, including themes vim2bat didn't
|
|
196
|
+
build.
|
|
197
|
+
- A single-background scheme whose own name ends in `-dark` or `-light` gets a
|
|
198
|
+
name that looks like another scheme's background variant.
|
|
199
|
+
- Colorschemes in a subfolder of `colors/`, whose names contain `/`, aren't
|
|
200
|
+
supported. vim2bat rejects those names.
|
|
201
|
+
|
|
202
|
+
## Uninstall
|
|
203
|
+
|
|
204
|
+
```bash
|
|
205
|
+
brew uninstall vim2bat # or: uv tool uninstall vim2bat, or pipx uninstall vim2bat
|
|
206
|
+
rm "$(bat --config-dir)"/themes/vim-*.tmTheme && (cd / && bat cache --build)
|
|
207
|
+
rm -rf "${XDG_CACHE_HOME:-$HOME/.cache}/vim2bat"
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
## Development
|
|
211
|
+
|
|
212
|
+
Development uses [uv](https://docs.astral.sh/uv/) (`brew install uv`).
|
|
213
|
+
|
|
214
|
+
```bash
|
|
215
|
+
git clone https://github.com/redodson01/vim2bat.git
|
|
216
|
+
cd vim2bat
|
|
217
|
+
uv sync # creates .venv with vim2bat and the dev tools
|
|
218
|
+
uv run pre-commit install # runs ruff and file checks before each commit
|
|
219
|
+
uv run pytest # unit tests, plus integration tests when vim and bat are installed
|
|
220
|
+
uv run mypy # type checks src and tests
|
|
221
|
+
uv run ruff check # lints
|
|
222
|
+
uv run ruff format # formats
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
[CONTRIBUTING.md](https://github.com/redodson01/vim2bat/blob/main/CONTRIBUTING.md)
|
|
226
|
+
covers the golden files, measuring a change, the rules for the tables, and
|
|
227
|
+
releasing.
|
|
228
|
+
|
|
229
|
+
## License
|
|
230
|
+
|
|
231
|
+
[MIT](https://github.com/redodson01/vim2bat/blob/main/LICENSE)
|