Metadata-Version: 2.4
Name: textual-nvim-themes
Version: 0.1.0
Summary: Neovim colorschemes for Textual apps, including TextArea syntax highlighting
Keywords: textual,tui,neovim,themes,colorscheme,terminal
Author: Fosox
License-Expression: MIT
License-File: LICENSE
License-File: LICENSES/Lumis-MIT
Classifier: Development Status :: 3 - Alpha
Classifier: Environment :: Console
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.14
Classifier: Operating System :: OS Independent
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Topic :: Terminals
Requires-Dist: rich>=15.0.0
Requires-Dist: textual>=8.2.7
Requires-Dist: textual[syntax]>=8.2.7 ; extra == 'syntax'
Requires-Python: >=3.14
Project-URL: Homepage, https://github.com/Fosox/textual-nvim-themes
Project-URL: Repository, https://github.com/Fosox/textual-nvim-themes
Project-URL: Issues, https://github.com/Fosox/textual-nvim-themes/issues
Provides-Extra: syntax
Description-Content-Type: text/markdown

# textual-nvim-themes

Use Neovim colorschemes in your [Textual](https://github.com/Textualize/textual) apps, including full syntax highlighting in `TextArea` widgets.

Themes are sourced from the Neovim community via [Lumis](https://github.com/leandrocp/lumis).

---

## Installation

```bash
pip install textual-nvim-themes
```

```bash
uv add textual-nvim-themes
```

> Doesn't have syntax highlighting support for `TextArea` by default as you might not need it and only want this for `App` themes.
> See bellow how to add it.

### Syntax highlighting support:
```bash
pip install "textual-nvim-themes[syntax]"
```

```bash
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](https://github.com/kreuzberg-dev/tree-sitter-language-pack):

```python
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:

```bash
python -m demo
```

Use the arrow keys or your mouse to cycle through themes

---

## Bundled themes

List all bundled theme names:

```bash
python -c "from textual_nvim_themes import available_themes; print('\n'.join(available_themes()))"
```

Or you can check [themes](textual_nvim_themes/themes)

---

## Quick start

Inherit from `ThemedApp` to get default theme switching and the command palette integration:

```python
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:

```python
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_theme` load a theme from its name, return a `NvimTheme`
- `make_app_theme` convert a `NvimTheme` into a textual app `Theme`
- `make_textarea_theme` convert a `NvimTheme` into a textual app `TextAreaTheme`

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):

```python
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](API.md)

---

## License

MIT. See [LICENSE](LICENSE)

Theme data belongs to the original Neovim colorscheme authors.

---

## Acknowledgements

This project incorporates code adapted from [Lumis](https://github.com/leandrocp/lumis)
(notably all the Neovim extraction part) by Leandro Pereira, licensed under the [MIT License](LICENSES/Lumis-MIT).

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](CONTRIBUTING.md)