Skip to content

Commit

Permalink
Feat: Keymaps and Keys App (#580)
Browse files Browse the repository at this point in the history
* feat: load keymap plug-ins; create harlequin_vscode plug-in

* feat: add more widget bindings

* feat: add tests for editor and results bindings

* feat: load keymaps from config files

* feat: add keymap_name config to config wizard

* refactor: create ConfigFile class to abstract pyproject details

* fix: fix bad config test

* feat: serialize keymaps to dict

* fix: unwrap toml doc when consumed by Harlequin

* refactor: split theme loading into AppBase

* wip: keymap app

* fix: wire up new key input flow

* feat: finish keys app

* feat: add tests

* fix: add tests, update changelog

* fix: update help screen; further tweaks

* feat: add more actions for focusing different widgets

* fix: update snapshot tests

* fix: update snapshots for py3.12/sqlite

* fix: add extra wait in keys app test

* fix: more waits in keys app test

* fix: try different waits

* fix: update snapshot after better waiting
  • Loading branch information
tconbeer authored Jun 27, 2024
1 parent e8cf428 commit d004a4b
Show file tree
Hide file tree
Showing 54 changed files with 8,430 additions and 5,141 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,16 @@ All notable changes to this project will be documented in this file.

## [Unreleased]

### Features

- Harlequin now loads key bindings from keymap plug-ins, and accepts a `--keymap_name` CLI option to specify a keymap to be loaded. This option can be repeated to load (and merge) multiple keymaps.
- Harlequin now also loads key bindings from keymaps configured in Harlequin config files or `pyproject.toml` files. To merge user-defined keymaps with keymap plug-ins, repeat the `--keymap-name` option. For example: `--keymap-name vscode --keymap-name my_custom_keymap`. For more information on user-defined keymaps, see Harlequin's [docs](https://harlequin.sh/docs/bindings).
- Harlequin ships with a new app for creating keymaps to customize keybindings. You can run it with `harlequin --keys`. The new app will load any existing keymap config and allow you to edit individual bindings. On quitting the app, it will write the new keymap to a file, so you can use it the next time you start Harlequin.

### Changed

- The default key bindings have been refactored to a plug-in in a separate package (`harlequin_vscode`) that is distributed with Harlequin.

## [1.21.0] - 2024-06-17

- The Cassandra adapter is now installable as an extra; use `pip install harlequin[cassandra]`.
Expand Down
6 changes: 5 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,16 @@ lint:

.PHONY: serve
serve:
textual run --dev -c harlequin -P None -f .
textual run --dev -c harlequin -P dev -f .

.PHONY: sqlite
sqlite:
textual run --dev -c harlequin -P sqlite

.PHONY: keys
keys:
textual run --dev -c harlequin --keys

marketing: $(wildcard static/themes/*.svg) static/harlequin.gif

static/themes/%.svg: pyproject.toml src/scripts/export_screenshots.py
Expand Down
4 changes: 2 additions & 2 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file removed prql
Binary file not shown.
Empty file removed prql.wal
Empty file.
7 changes: 5 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ packages = [
{ include = "harlequin", from = "src" },
{ include = "harlequin_duckdb", from = "src" },
{ include = "harlequin_sqlite", from = "src" },
{ include = "harlequin_vscode", from = "src" },
]

[build-system]
Expand All @@ -34,7 +35,6 @@ duckdb = ">=0.8.0"
shandy-sqlfmt = ">=0.19.0"
platformdirs = ">=3.10,<5.0"
importlib_metadata = { version = ">=4.6.0", python = "<3.10.0" }
tomli = { version = "^2.0.1", python = "<3.11.0" }
tomlkit = "^0.12.3"
questionary = "^2.0.1"

Expand Down Expand Up @@ -103,6 +103,9 @@ nebulagraph = ["harlequin-nebulagraph"]
duckdb = "harlequin_duckdb:DuckDbAdapter"
sqlite = "harlequin_sqlite:HarlequinSqliteAdapter"

[tool.poetry.plugins."harlequin.keymap"]
vscode = "harlequin_vscode:VSCODE"

[tool.poetry.plugins."pygments.styles"]
harlequin = "harlequin.colors:HarlequinPygmentsStyle"

Expand All @@ -118,7 +121,7 @@ files = [
"src/**/*.py",
"tests/**/*.py",
]
mypy_path = "src:stubs"
mypy_path = "stubs"

show_column_numbers = true

Expand Down
5 changes: 5 additions & 0 deletions src/harlequin/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
from harlequin.adapter import HarlequinAdapter, HarlequinConnection, HarlequinCursor
from harlequin.app import Harlequin
from harlequin.autocomplete import HarlequinCompletion
from harlequin.keymap import HarlequinKeyBinding, HarlequinKeyMap
from harlequin.keys_app import HarlequinKeys
from harlequin.options import HarlequinAdapterOption, HarlequinCopyFormat
from harlequin.transaction_mode import HarlequinTransactionMode

Expand All @@ -13,4 +15,7 @@
"HarlequinCopyFormat",
"HarlequinCursor",
"HarlequinTransactionMode",
"HarlequinKeys",
"HarlequinKeyMap",
"HarlequinKeyBinding",
]
Loading

0 comments on commit d004a4b

Please sign in to comment.