Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit

Permalink
Merge pull request #22 from MLFlexer/21-a-single-function-setup
Browse files Browse the repository at this point in the history
21 a single function setup
  • Loading branch information
MLFlexer authored Apr 18, 2024
2 parents 5568822 + 40111f0 commit bdc47fa
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 0 deletions.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,16 @@ This only provides an option to add hints or mode indicator to Wezterms buildin
![image](https://github.com/MLFlexer/modal.wezterm/assets/75012728/477089b8-ae80-4f3b-821c-bb29c545408c)

## Setup
It is recommended to do the setup with some [Customization](###Customization). However if you just want to try it out you can follow the [Preset](###Preset)
### Preset
Add the following to the bottom of your config:
```lua
local wezterm = require("wezterm")
local modal = wezterm.plugin.require("https://github.com/MLFlexer/modal.wezterm")
modal.apply_to_config(config)
```

### Customization
1. Require the plugin:
```lua
local wezterm = require("wezterm")
Expand Down
64 changes: 64 additions & 0 deletions plugin/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,69 @@ local function set_right_status(window)
end
end

local function apply_to_config(config)
enable_defaults("https://github.com/MLFlexer/modal.wezterm")
local icons = {
left_seperator = wezterm.nerdfonts.ple_left_half_circle_thick,
key_hint_seperator = "",
mod_seperator = "-",
}
local colors = {
key_hint_seperator = config.colors.tab_bar.active_tab.fg_color,
key = config.colors.tab_bar.active_tab.fg_color,
hint = config.colors.tab_bar.active_tab.fg_color,
bg = config.colors.tab_bar.active_tab.bg_color,
left_bg = config.colors.tab_bar.background,
}

local status_text = require("ui_mode").get_hint_status_text(
icons,
colors,
{ bg = config.colors.ansi[2], fg = config.colors.tab_bar.active_tab.bg_color }
)

add_mode("UI", require("ui_mode").key_table, status_text)

status_text = require("scroll_mode").get_hint_status_text(
icons,
colors,
{ bg = config.colors.ansi[7], fg = config.colors.tab_bar.active_tab.bg_color }
)
add_mode("Scroll", require("scroll_mode").key_table, status_text)

status_text = require("copy_mode").get_hint_status_text(
icons,
colors,
{ bg = config.colors.ansi[4], fg = config.colors.tab_bar.active_tab.bg_color }
)
add_mode("copy_mode", {}, status_text)

status_text = require("search_mode").get_hint_status_text(
icons,
colors,
{ bg = config.colors.ansi[6], fg = config.colors.tab_bar.active_tab.bg_color }
)
add_mode("search_mode", {}, status_text)

config.key_tables = key_tables
table.insert(config.keys, {
key = "n",
mods = "ALT",
action = wezterm.action.ActivateKeyTable({
name = "Scroll",
one_shot = false,
}),
})
table.insert(config.keys, {
key = "u",
mods = "ALT",
action = wezterm.action.ActivateKeyTable({
name = "UI",
one_shot = false,
}),
})
end

return {
set_right_status = set_right_status,
add_mode = add_mode,
Expand All @@ -93,4 +156,5 @@ return {
modes = modes,
key_tables = key_tables,
enable_defaults = enable_defaults,
apply_to_config = apply_to_config,
}

0 comments on commit bdc47fa

Please sign in to comment.