Skip to content

Refactor color scheme handling and key bindings initialization #33

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ Add the following to the bottom of your config:
local wezterm = require("wezterm")
local modal = wezterm.plugin.require("https://github.com/MLFlexer/modal.wezterm")
modal.apply_to_config(config)
modal.set_default_keys(config)
```
This will add the keybindings to enter and exit modes:
* `ALT-u` to enter UI mode from normal mode
Expand Down
48 changes: 27 additions & 21 deletions plugin/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -186,8 +186,12 @@ local function apply_to_config(config)
mod_seperator = "-",
}

if config.colors == nil then
config.colors = wezterm.color.get_default_colors()
if not config.colors then
if config.color_scheme then
config.colors = wezterm.color.get_builtin_schemes()[config.color_scheme]
else
config.colors = wezterm.color.get_default_colors()
end
end

local colors = {
Expand Down Expand Up @@ -221,26 +225,27 @@ local function apply_to_config(config)
add_mode("Visual", {}, status_text)

config.key_tables = key_tables
end

if config.keys == nil then
config.keys = {}
end

table.insert(config.keys, {
key = "n",
mods = "ALT",
action = activate_mode("Scroll"),
})
table.insert(config.keys, {
key = "u",
mods = "ALT",
action = activate_mode("UI"),
})
table.insert(config.keys, {
key = "c",
mods = "ALT",
action = activate_mode("copy_mode"),
})
local function set_default_keys(config)
if config.keys == nil then
config.keys = {}
end
table.insert(config.keys, {
key = "n",
mods = "ALT",
action = activate_mode("Scroll"),
})
table.insert(config.keys, {
key = "u",
mods = "ALT",
action = activate_mode("UI"),
})
table.insert(config.keys, {
key = "c",
mods = "ALT",
action = activate_mode("copy_mode"),
})
end

return {
Expand All @@ -254,6 +259,7 @@ return {
key_tables = key_tables,
enable_defaults = enable_defaults,
apply_to_config = apply_to_config,
set_default_keys = set_default_keys,
activate_mode = activate_mode,
exit_mode = exit_mode,
exit_all_modes = exit_all_modes,
Expand Down