2023-08-20 21:30:03 +02:00
|
|
|
;<!
|
|
|
|
; tmpl:setPostProcessor(opt.fennelCompile)
|
|
|
|
; local shell = os.getenv "SHELL"
|
|
|
|
;!>
|
2023-04-16 18:12:38 +02:00
|
|
|
; vim: filetype=fennel
|
2023-02-19 14:44:15 +01:00
|
|
|
|
|
|
|
(local wt (require :wezterm))
|
|
|
|
|
|
|
|
(macro kmap [key mods act args]
|
|
|
|
(if args
|
|
|
|
`{:key ,key :mods ,mods :action ((. wt :action ,act) ,args)}
|
|
|
|
`{:key ,key :mods ,mods :action (. wt :action ,act)}))
|
|
|
|
|
2023-03-06 13:48:29 +01:00
|
|
|
(var keys [;; splitting
|
2023-04-15 00:14:56 +02:00
|
|
|
(kmap :s :LEADER :SplitVertical {})
|
2023-03-06 13:48:29 +01:00
|
|
|
(kmap :v :LEADER :SplitHorizontal {})
|
|
|
|
;; tabs
|
|
|
|
(kmap :t :CTRL|SHIFT :SpawnTab :CurrentPaneDomain)
|
|
|
|
(kmap :t :CTRL :ActivateTabRelative 1)
|
|
|
|
;; font size
|
|
|
|
(kmap "+" :CTRL :IncreaseFontSize)
|
|
|
|
(kmap "-" :CTRL :DecreaseFontSize)
|
|
|
|
;; moving panes
|
|
|
|
(kmap :r :LEADER :RotatePanes :Clockwise)
|
|
|
|
(kmap :m :LEADER :PaneSelect {:mode :SwapWithActive})
|
|
|
|
;; scrolling
|
|
|
|
(kmap :PageUp :ALT :ScrollByPage -1)
|
|
|
|
(kmap :PageDown :ALT :ScrollByPage 1)
|
|
|
|
;; copying
|
|
|
|
(kmap :C :CTRL|SHIFT :CopyTo :ClipboardAndPrimarySelection)
|
2023-04-21 16:43:34 +02:00
|
|
|
(kmap :V :CTRL|SHIFT :PasteFrom :Clipboard)
|
|
|
|
;; copy mode
|
2023-04-27 22:36:08 +02:00
|
|
|
(kmap :y :LEADER :ActivateCopyMode)
|
|
|
|
;; command palette
|
2023-05-26 00:03:32 +02:00
|
|
|
(kmap :p :LEADER :ActivateCommandPalette)
|
|
|
|
;; search mode
|
|
|
|
(kmap :t :LEADER :Search :CurrentSelectionOrEmptyString)])
|
2023-02-19 14:44:15 +01:00
|
|
|
|
|
|
|
(local directions [[:h :Left] [:j :Down] [:k :Up] [:l :Right]])
|
|
|
|
|
|
|
|
(each [_ dir (ipairs directions)]
|
|
|
|
(let [(dir-key dir-name) (table.unpack dir)]
|
|
|
|
;; switching panes
|
|
|
|
(table.insert keys (kmap dir-key :ALT :ActivatePaneDirection dir-name))
|
|
|
|
;; resize double in horizontal directions so the absolute amounts are constant
|
|
|
|
(local resize-amt (if (or (= dir-name :Up) (= dir-name :Down)) 2 4))
|
|
|
|
(table.insert keys (kmap dir-key :ALT|SHIFT :AdjustPaneSize
|
|
|
|
[dir-name resize-amt]))))
|
|
|
|
|
2023-08-13 00:07:37 +02:00
|
|
|
|
|
|
|
(fn on-format-tab-title [tab tabs panes config hover max_width]
|
|
|
|
(let [title (if (and tab.tab_title (> (length tab.tab_title) 0))
|
|
|
|
tab.tab_title tab.active_pane.title)
|
2023-08-15 20:00:08 +02:00
|
|
|
bg (fn [t h] (if t.is_active :#cba6f7 (if h :#45475a :#313244)))
|
2023-08-13 00:07:37 +02:00
|
|
|
fg (fn [t] (if t.is_active :#181825 :#cdd6f4))
|
2023-08-13 09:12:19 +02:00
|
|
|
not-first? (~= tab.tab_index 0)
|
|
|
|
last? (= tab.tab_index (- (length tabs) 1))
|
|
|
|
deco-len (+ 2
|
|
|
|
(if not-first? 1 0)
|
|
|
|
(if last? 2 0))
|
2023-08-13 00:07:37 +02:00
|
|
|
elems []]
|
|
|
|
;; first tab
|
|
|
|
(when (~= tab.tab_index 0)
|
2023-08-15 20:00:08 +02:00
|
|
|
(table.insert elems {:Foreground {:Color (bg (. tabs tab.tab_index) false)}})
|
|
|
|
(table.insert elems {:Background {:Color (bg tab hover)}})
|
2023-08-13 09:12:19 +02:00
|
|
|
(table.insert elems {:Text ""}))
|
2023-08-13 00:07:37 +02:00
|
|
|
|
2023-08-15 20:00:08 +02:00
|
|
|
(table.insert elems {:Background {:Color (bg tab hover)}})
|
2023-08-13 00:07:37 +02:00
|
|
|
(table.insert elems {:Foreground {:Color (fg tab)}})
|
2023-08-13 09:12:19 +02:00
|
|
|
(table.insert elems {:Text (.. " " (string.sub title 1 (math.min (- max_width deco-len) (length title))) " ")})
|
2023-08-13 00:07:37 +02:00
|
|
|
|
|
|
|
;; last tab
|
|
|
|
(when (= tab.tab_index (- (length tabs) 1))
|
2023-08-15 20:00:08 +02:00
|
|
|
(table.insert elems {:Foreground {:Color (bg tab hover)}})
|
2023-08-13 00:07:37 +02:00
|
|
|
(table.insert elems {:Background {:Color :#45475a}}) ;; color of new tab button
|
|
|
|
(table.insert elems {:Text " "}))
|
|
|
|
elems))
|
|
|
|
|
|
|
|
(wt.on :format-tab-title on-format-tab-title)
|
|
|
|
|
2023-08-13 09:25:55 +02:00
|
|
|
(fn new-tab-button [hover]
|
|
|
|
(let [bg (if hover :#89b4fa :#45475a)]
|
|
|
|
(wt.format [{:Background {:Color bg}}
|
|
|
|
{:Foreground {:Color :#cdd6f4}}
|
|
|
|
{:Text " "}
|
|
|
|
{:Foreground {:Color bg}}
|
|
|
|
{:Background {:Color :#11111b}}
|
|
|
|
{:Text ""}])))
|
|
|
|
|
2023-08-20 21:30:03 +02:00
|
|
|
{:default_prog ["<% shell %>"]
|
2023-06-08 23:17:19 +02:00
|
|
|
:color_scheme "Catppuccin Mocha"
|
2023-02-19 14:44:15 +01:00
|
|
|
:font (wt.font "<% opt.term_font %>")
|
2023-03-07 18:25:18 +01:00
|
|
|
:warn_about_missing_glyphs false
|
2023-02-19 14:44:15 +01:00
|
|
|
:window_background_opacity 0.8
|
|
|
|
:disable_default_key_bindings true
|
|
|
|
:leader {:key :a :mods :CTRL :timeout_milliseconds 2000}
|
2023-08-13 00:07:37 +02:00
|
|
|
:adjust_window_size_when_changing_font_size false ;; this breaks on tiling WMs
|
|
|
|
:cursor_blink_ease_in :Constant
|
|
|
|
:cursor_blink_ease_out :Constant
|
|
|
|
:check_for_updates false ;; WTF
|
|
|
|
:use_fancy_tab_bar false
|
2023-08-13 09:25:55 +02:00
|
|
|
:tab_bar_style {:new_tab (new-tab-button false) :new_tab_hover (new-tab-button true)}
|
2023-08-13 06:20:58 +02:00
|
|
|
:tab_max_width 128
|
2023-08-20 21:30:03 +02:00
|
|
|
;; BULLSHIT: WezTerm by default sets $SHELL to the login shell.
|
|
|
|
;; This is justified by the fact that some users are too incompetent to
|
|
|
|
;; relog after chaning their login shell. WezTerm is fixing a very rare (and basic)
|
|
|
|
;; user error while compromising the experience of advanced users.
|
|
|
|
;; See https://github.com/wez/wezterm/issues/4168
|
|
|
|
:set_environment_variables {:SHELL "<% shell %>"}
|
2023-02-19 14:44:15 +01:00
|
|
|
: keys}
|