diff --git a/README.md b/README.md index f7bcfea..455b144 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/plugin/init.lua b/plugin/init.lua index 017aa90..8d32db3 100644 --- a/plugin/init.lua +++ b/plugin/init.lua @@ -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 = { @@ -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 { @@ -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,