fix: sioyek and neomutt integration to neovim

This commit is contained in:
Ray Andrew 2025-12-12 13:22:35 -06:00
parent 26386b2ea7
commit 937ab7e510
Signed by: rayandrew
SSH key fingerprint: SHA256:XYrYrxF0Z3A72n8P/p6mqPRNQZT22F88XcLsG+kX4xw
5 changed files with 51 additions and 20 deletions

11
bin/neomutt-open-message Executable file
View file

@ -0,0 +1,11 @@
#!/bin/bash
# Open a specific message in neomutt by message ID
# Usage: neomutt-open-message <message-id>
message_id="$1"
if [[ -z $message_id ]]; then
echo "Usage: neomutt-open-message <message-id>" >&2
exit 1
fi
exec neomutt -e "push \"<vfolder-from-query>id:${message_id}<enter><display-message>\""

View file

@ -26,30 +26,18 @@ notmuch_url="notmuch://?query=id:${message_id}"
if $open_in_current; then if $open_in_current; then
exec neomutt -f "$notmuch_url" exec neomutt -f "$notmuch_url"
else else
# Create a temp script with PATH setup embedded
tmpscript=$(mktemp /tmp/open-mail-XXXXXX.sh)
cat >"$tmpscript" <<EOF
#!/bin/bash
export PATH="/etc/profiles/per-user/\$USER/bin:/run/current-system/sw/bin:\$PATH"
export NOTMUCH_CONFIG="\$HOME/.config/notmuch/config"
rm -f "$tmpscript"
exec neomutt -f '$notmuch_url'
EOF
chmod +x "$tmpscript"
if [[ "$(uname)" == "Darwin" ]]; then if [[ "$(uname)" == "Darwin" ]]; then
aerospace workspace 8 aerospace workspace 8
open -na Ghostty --args --title="Mail" -e "$tmpscript" open -na Ghostty --args -e "$SCRIPT_DIR/path-shim" "$SCRIPT_DIR/neomutt-open-message" "$message_id"
else else
# Linux (i3/sway) # Linux (i3/sway)
if command -v swaymsg &>/dev/null; then if command -v swaymsg &>/dev/null; then
swaymsg workspace 8 swaymsg workspace 8
ghostty --title="Mail" -e "$tmpscript" & ghostty -e neomutt -e "push \"<vfolder-from-query>id:${message_id}<enter><display-message>\"" &
elif command -v i3-msg &>/dev/null; then elif command -v i3-msg &>/dev/null; then
i3-msg workspace 8 i3-msg workspace 8
ghostty --title="Mail" -e "$tmpscript" & ghostty -e neomutt -e "push \"<vfolder-from-query>id:${message_id}<enter><display-message>\"" &
else else
rm -f "$tmpscript"
exec neomutt -f "$notmuch_url" exec neomutt -f "$notmuch_url"
fi fi
fi fi

View file

@ -72,16 +72,20 @@ now(function() require('vimtex').setup() end)
now(function() now(function()
local function open_neomutt_link(url) local function open_neomutt_link(url)
local message_id = url:gsub('^neomutt://', '') local message_id = url:gsub('^neomutt://', '')
vim.notify('Opening: ' .. message_id, vim.log.levels.INFO) -- vim.notify('Opening: ' .. message_id, vim.log.levels.INFO)
-- Use vfolder-from-query then display the message (hide sidebar and index, q quits directly) -- Use vfolder-from-query then display the message (hide sidebar and index, q quits directly)
-- Note: nvim terminal doesn't support neomutt's directcolor, so we disable colors for clean display -- Note: nvim terminal doesn't support neomutt's directcolor, so we disable colors for clean display
local search_cmd = string.format( local search_cmd = string.format(
[[neomutt -e "set color_directcolor=no sidebar_visible=no pager_index_lines=0" -e "color normal default default" -e "color hdrdefault default default" -e "color quoted default default" -e "color signature default default" -e "color attachment default default" -e "color header default default '.*'" -e "color body default default '.*'" -e "macro pager q '<exit><quit>'" -e "macro index q '<quit>'" -e "push \"<vfolder-from-query>id:%s<enter><display-message>\""]], [[neomutt -e "set color_directcolor=no sidebar_visible=no pager_index_lines=0" -e "color normal default default" -e "color hdrdefault default default" -e "color quoted default default" -e "color signature default default" -e "color attachment default default" -e "color header default default '.*'" -e "color body default default '.*'" -e "macro pager q '<exit><quit>'" -e "macro index q '<quit>'" -e "push \"<vfolder-from-query>id:%s<enter><display-message>\""]],
message_id message_id
) )
require('snacks').terminal(search_cmd, { require('snacks').terminal(search_cmd, {
win = { position = 'bottom', height = 0.4 }, win = { position = 'bottom', height = 0.4 },
}) })
-- local script = vim.env.HOME .. '/dotfiles/bin/open-message-link'
-- vim.fn.jobstart({ script, url }, { detach = true })
end end
vim.api.nvim_create_user_command( vim.api.nvim_create_user_command(
@ -95,7 +99,7 @@ now(function()
vim.api.nvim_create_autocmd('BufEnter', { vim.api.nvim_create_autocmd('BufEnter', {
pattern = '*.md', pattern = '*.md',
callback = function() callback = function()
vim.keymap.set('n', 'gl', function() vim.keymap.set('n', 'gx', function()
local line = vim.api.nvim_get_current_line() local line = vim.api.nvim_get_current_line()
local url = line:match 'neomutt://[^%)%s>]+' local url = line:match 'neomutt://[^%)%s>]+'
if url then if url then

View file

@ -13,7 +13,7 @@ function M.setup()
-- Compiler settings -- Compiler settings
vim.g.vimtex_compiler_method = 'latexmk' vim.g.vimtex_compiler_method = 'latexmk'
vim.g.vimtex_compiler_latexmk = { vim.g.vimtex_compiler_latexmk = {
build_dir = '', build_dir = 'build',
callback = 1, callback = 1,
continuous = 1, continuous = 1,
executable = 'latexmk', executable = 'latexmk',

View file

@ -12,7 +12,19 @@ next_page J
previous_page K previous_page K
screen_down <C-d> screen_down <C-d>
screen_up <C-u> screen_up <C-u>
goto_page_with_page_number g screen_down <C-f>
screen_up <C-b>
goto_page_with_page_number <C-g>
goto_beginning gg
goto_end G
# Chapter navigation (like vim [[ ]])
next_chapter ]]
prev_chapter [[
# History navigation (like vim jumplist)
prev_state <C-o>
next_state <tab>
# Scroll # Scroll
screen_down <space> screen_down <space>
@ -23,6 +35,12 @@ search /
next_item n next_item n
prev_item N prev_item N
# Copy
copy y
# Command mode
command :
# Zoom # Zoom
zoom_in + zoom_in +
zoom_in = zoom_in =
@ -33,6 +51,7 @@ fit_to_page_width_smart e
# Bookmarks # Bookmarks
add_bookmark m add_bookmark m
goto_bookmark ' goto_bookmark '
delete_bookmark dm
# Highlights - mouse select text, then h + letter for color # Highlights - mouse select text, then h + letter for color
add_highlight H add_highlight H
@ -49,7 +68,9 @@ toggle_visual_scroll <F7>
# Synctex (for LaTeX integration) # Synctex (for LaTeX integration)
# F4 toggles synctex mode, then right-click on text jumps to source # F4 toggles synctex mode, then right-click on text jumps to source
# Use v to start visual mark, then Enter to jump to source in editor
toggle_synctex <F4> toggle_synctex <F4>
synctex_under_ruler <return>
# Color mode toggle # Color mode toggle
toggle_dark_mode <C-i> toggle_dark_mode <C-i>
@ -57,10 +78,17 @@ toggle_custom_color <C-r>
# Open/close # Open/close
quit q quit q
quit ZZ
quit ZQ
open_document o open_document o
# View
rotate_clockwise r
rotate_counterclockwise R
toggle_fullscreen F
# Portal (linked view) # Portal (linked view)
portal p portal p
# Overview (thumbnail view) # Overview (thumbnail view)
overview <tab> overview <S-tab>