Neovim colorschemes for Textual apps, including TextArea syntax highlighting
Project description
textual-nvim-themes
Use Neovim colorschemes in your Textual apps, including full syntax highlighting in TextArea widgets.
Themes are sourced from the Neovim community via Lumis.
Installation
pip install textual-nvim-themes
uv add textual-nvim-themes
Doesn't have syntax highlighting support for
TextAreaby default as you might not need it and only want this forAppthemes. See bellow how to add it.
Syntax highlighting support:
pip install "textual-nvim-themes[syntax]"
uv add textual-nvim-themes --extra syntax
You can also add support for it by using textual[syntax] or manually by using TextArea.register_language(name, language, highlight_query)
with another source for tree-sitter like tree_sitter_language_pack:
from tree_sitter_language_pack import get_language, get_highlights_query
from textual.widgets import TextArea
LANGUAGES = ["kotlin", "yaml", "ini", "c"]
class MyTextArea(TextArea):
def on_mount(self):
for name in LANGUAGES:
language = get_language(name)
query = get_highlights_query(name)
if language and query:
self.register_language(name, language, query)
Demo
Run the bundled demo to browse all available themes live:
python -m demo
Use the arrow keys or your mouse to cycle through themes
Bundled themes
List all bundled theme names:
python -c "from textual_nvim_themes import available_themes; print('\n'.join(available_themes()))"
Or you can check themes
Quick start
Inherit from ThemedApp to get default theme switching and the command palette integration:
from textual.app import ComposeResult
from textual.widgets import TextArea
from textual_nvim_themes import ThemedApp
class MyApp(ThemedApp):
THEMES = ["tokyonight_night", "nord", "dracula"] # restrict the themes inside the command palette
DEFAULT_THEME = "tokyonight_night"
def compose(self) -> ComposeResult:
yield TextArea("print('hello')", language="python")
if __name__ == "__main__":
MyApp().run()
Manual setup
If you don't want to inherit ThemedApp e.g. you already have a custom App base class, you can wire things up yourself:
from textual.app import App, ComposeResult
from textual.widgets import TextArea
from textual_nvim_themes import apply_theme, ThemePalette
class MyApp(App):
def compose(self) -> ComposeResult:
yield TextArea("print('hello')", language="python")
def on_mount(self) -> None:
apply_theme(self, "tokyonight_night")
# Override so the command palette's "Change theme" command uses our themes
def search_themes(self) -> None:
themes = None # themes is the equivalent of ThemedApp.THEMES
self.push_screen(ThemePalette(themes, "Search themes…"))
if __name__ == "__main__":
MyApp().run()
Advanced use
You can directly access the textual themes if you want to modify or manually register them:
load_nvim_themeload a theme from its name, return aNvimThememake_app_themeconvert aNvimThemeinto a textual appThememake_textarea_themeconvert aNvimThemeinto a textual appTextAreaTheme
If you choose to register and change themes yourself without using apply_theme then you can use apply_textarea_theme
in your app watch_theme method to sync your textarea to your app theme (it also register theme into the textarea just in case):
from textual.app import App, ComposeResult
from textual.widgets import TextArea
from textual_nvim_themes import load_nvim_theme, make_app_theme, make_textarea_theme, apply_textarea_theme, ThemePalette
class MyApp(App):
def compose(self) -> ComposeResult:
yield TextArea("print('hello')", language="python")
def on_mount(self) -> None:
theme = load_nvim_theme("dracula")
self.register_theme(make_app_theme(theme))
self.query_one(TextArea).register_theme(make_textarea_theme(theme))
self.theme = "dracula"
# Override so the command palette's "Change theme" command uses our themes
def search_themes(self) -> None:
themes = None # themes is the equivalent of ThemedApp.THEMES
self.push_screen(ThemePalette(themes, "Search themes…"))
# Keep TextArea syntax highlighting in sync when the theme changes
def watch_theme(self, theme: str) -> None:
apply_textarea_theme(self, theme)
if __name__ == "__main__":
MyApp().run()
API
See API
License
MIT. See LICENSE
Theme data belongs to the original Neovim colorscheme authors.
Acknowledgements
This project incorporates code adapted from Lumis (notably all the Neovim extraction part) by Leandro Pereira, licensed under the MIT License.
Many thanks for making the project open source.
Also, big thanks to the Neovim community for all the themes !
Contributions
Contributions are welcomed. See CONTRIBUTING
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file textual_nvim_themes-0.1.0.tar.gz.
File metadata
- Download URL: textual_nvim_themes-0.1.0.tar.gz
- Upload date:
- Size: 133.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c088839b1d73a6085bbf0ef0559582dab13674bd8934ec3b28eeb69f2ee387bc
|
|
| MD5 |
2597ff338223df2f9518db1c98a49650
|
|
| BLAKE2b-256 |
196e6fc0121fd5fe669f1c70bfdf961f127709ad97f540142f8cb48bc8d8248c
|
Provenance
The following attestation bundles were made for textual_nvim_themes-0.1.0.tar.gz:
Publisher:
publish.yml on Fosox/textual-nvim-themes
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
textual_nvim_themes-0.1.0.tar.gz -
Subject digest:
c088839b1d73a6085bbf0ef0559582dab13674bd8934ec3b28eeb69f2ee387bc - Sigstore transparency entry: 2001368987
- Sigstore integration time:
-
Permalink:
Fosox/textual-nvim-themes@5cc0892126fbb8715aaa26ee0d1ba79152fe7828 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/Fosox
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@5cc0892126fbb8715aaa26ee0d1ba79152fe7828 -
Trigger Event:
release
-
Statement type:
File details
Details for the file textual_nvim_themes-0.1.0-py3-none-any.whl.
File metadata
- Download URL: textual_nvim_themes-0.1.0-py3-none-any.whl
- Upload date:
- Size: 301.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
50d1e061a4d0aa6d875b2c3484273dc60b1726c5d28baf837350b9b42be9c03e
|
|
| MD5 |
51947b03cd86c30f2e72c88c396de2af
|
|
| BLAKE2b-256 |
9e2fd8361bf6f344673126e5007682af2709c5262084baa12f5d81e90eca6c2b
|
Provenance
The following attestation bundles were made for textual_nvim_themes-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on Fosox/textual-nvim-themes
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
textual_nvim_themes-0.1.0-py3-none-any.whl -
Subject digest:
50d1e061a4d0aa6d875b2c3484273dc60b1726c5d28baf837350b9b42be9c03e - Sigstore transparency entry: 2001369087
- Sigstore integration time:
-
Permalink:
Fosox/textual-nvim-themes@5cc0892126fbb8715aaa26ee0d1ba79152fe7828 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/Fosox
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@5cc0892126fbb8715aaa26ee0d1ba79152fe7828 -
Trigger Event:
release
-
Statement type: