1
0
Fork 0

nvim: Only use wezterm integration if binary exists

This commit is contained in:
Daniel Kempkens 2023-07-15 00:48:28 +02:00
parent 1b5e7e71dd
commit 33f9deda29
Signed by: daniel
SSH key fingerprint: SHA256:Ks/MyhQYcPRQiwMKLAKquWCdCPe3JXlb1WttgnAoSeM

View file

@ -1,14 +1,16 @@
(let [wezterm (require :wezterm)
wezterm-exists (vim.fn.executable :wezterm)
augroup (vim.api.nvim_create_augroup :NifocWezterm {:clear true})
aucmd vim.api.nvim_create_autocmd]
(wezterm.setup {:create_commands false})
(aucmd :BufEnter {:callback (fn [args]
(let [path (vim.api.nvim_buf_get_name args.buf)
name (vim.fs.basename path)
title (if (and name (> (length name) 0))
(.. "nvim " name)
"")]
(wezterm.set_tab_title title)))
:group augroup})
(aucmd :VimLeavePre {:callback #(wezterm.set_tab_title "") :group augroup}))
(when (= wezterm-exists 1)
(wezterm.setup {:create_commands false})
(aucmd :BufEnter {:callback (fn [args]
(let [path (vim.api.nvim_buf_get_name args.buf)
name (vim.fs.basename path)
title (if (and name (> (length name) 0))
(.. "nvim " name)
"")]
(wezterm.set_tab_title title)))
:group augroup})
(aucmd :VimLeavePre {:callback #(wezterm.set_tab_title "") :group augroup})))