From a23a3f8a506fe9414204c25783ada7b28a216c48 Mon Sep 17 00:00:00 2001 From: Ray Andrew Date: Thu, 11 Dec 2025 19:25:01 -0600 Subject: [PATCH] feat: add sioyek config --- bin/nvim-vimtex-callback | 43 +++++++++++++++++ config/nvim/init.lua | 5 ++ config/nvim/lua/vimtex.lua | 85 +++++++++++++++++++++++++++++++++ config/sioyek/.gitignore | 3 ++ config/sioyek/keys_user.config | 65 +++++++++++++++++++++++++ config/sioyek/prefs_user.config | 52 ++++++++++++++++++++ config/zathura/zathurarc | 45 +++++++++++++++++ home/gui.nix | 2 + home/neovim.nix | 1 + home/sioyek.nix | 34 +++++++++++++ home/zathura.nix | 22 +++++++++ hosts/dango/default.nix | 2 + 12 files changed, 359 insertions(+) create mode 100755 bin/nvim-vimtex-callback create mode 100644 config/nvim/lua/vimtex.lua create mode 100644 config/sioyek/.gitignore create mode 100644 config/sioyek/keys_user.config create mode 100644 config/sioyek/prefs_user.config create mode 100644 config/zathura/zathurarc create mode 100644 home/sioyek.nix create mode 100644 home/zathura.nix diff --git a/bin/nvim-vimtex-callback b/bin/nvim-vimtex-callback new file mode 100755 index 0000000..61d0e35 --- /dev/null +++ b/bin/nvim-vimtex-callback @@ -0,0 +1,43 @@ +#!/bin/bash +# VimTeX inverse search callback wrapper +# This script is called by sioyek for inverse search +# It uses nvr to connect to the running Neovim instance + +SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" +SERVERNAME_FILE="/tmp/vimtex-servername" + +# VimTeX calls: nvim --headless -c "VimtexInverseSearch LINE 'FILE'" +# Parse the VimtexInverseSearch command to extract LINE and FILE +# Then use nvr --remote +LINE FILE which is more reliable + +CMD="" +while [[ $# -gt 0 ]]; do + case $1 in + --headless) + shift + ;; + -c) + shift + CMD="$1" + shift + ;; + *) + shift + ;; + esac +done + +if [[ -n $CMD ]]; then + # Extract line number and file from: VimtexInverseSearch LINE 'FILE' + if [[ $CMD =~ VimtexInverseSearch\ ([0-9]+)\ \'(.+)\' ]]; then + LINE="${BASH_REMATCH[1]}" + FILE="${BASH_REMATCH[2]}" + + if [[ -f $SERVERNAME_FILE ]]; then + SERVERNAME=$(cat "$SERVERNAME_FILE") + exec "$SCRIPT_DIR/path-shim" nvr --servername "$SERVERNAME" --remote-silent +"$LINE" "$FILE" + else + exec "$SCRIPT_DIR/path-shim" nvr --remote-silent +"$LINE" "$FILE" + fi + fi +fi diff --git a/config/nvim/init.lua b/config/nvim/init.lua index d45e5d5..087e786 100644 --- a/config/nvim/init.lua +++ b/config/nvim/init.lua @@ -61,10 +61,13 @@ add { source = 'R-nvim/R.nvim', depends = { 'nvim-treesitter/nvim-treesitter' } add 'nvim-treesitter/nvim-treesitter' add 'nvim-treesitter/nvim-treesitter-textobjects' add { source = 'nvim-pack/nvim-spectre', depends = { 'nvim-lua/plenary.nvim' } } +add 'lervag/vimtex' -- color themes add 'EdenEast/nightfox.nvim' +now(function() require('vimtex').setup() end) + now(function() require('mail-count').setup { accounts = { @@ -311,6 +314,8 @@ later(function() 'diff', 'git_rebase', 'gitcommit', + 'latex', + 'bibtex', }, auto_install = true, highlight = { enable = true }, diff --git a/config/nvim/lua/vimtex.lua b/config/nvim/lua/vimtex.lua new file mode 100644 index 0000000..e56d666 --- /dev/null +++ b/config/nvim/lua/vimtex.lua @@ -0,0 +1,85 @@ +-- VimTeX configuration with Sioyek as PDF viewer +local M = {} + +function M.setup() + -- Use Sioyek as the PDF viewer + vim.g.vimtex_view_method = 'sioyek' + + -- Sioyek executable (use 'sioyek' if in PATH) + vim.g.vimtex_view_sioyek_exe = 'sioyek' + + -- Enable synctex for forward/inverse search + vim.g.vimtex_view_sioyek_sync = 1 + + -- Use custom wrapper script for inverse search (uses nvr instead of --headless) + vim.g.vimtex_callback_progpath = vim.fn.expand '~/dotfiles/bin/nvim-vimtex-callback' + + -- Compiler settings + vim.g.vimtex_compiler_method = 'latexmk' + vim.g.vimtex_compiler_latexmk = { + build_dir = '', + callback = 1, + continuous = 1, + executable = 'latexmk', + options = { + '-verbose', + '-file-line-error', + '-synctex=1', + '-interaction=nonstopmode', + }, + } + + -- Quickfix settings + vim.g.vimtex_quickfix_mode = 0 -- Don't open quickfix automatically + + -- Disable default mappings, we'll set our own + vim.g.vimtex_mappings_enabled = 1 + + -- TOC settings + vim.g.vimtex_toc_config = { + split_pos = 'vert leftabove', + split_width = 40, + show_help = 0, + } + + -- Fold settings + vim.g.vimtex_fold_enabled = 0 + + -- Set up filetype-specific keymaps + vim.api.nvim_create_autocmd('FileType', { + pattern = { 'tex', 'latex' }, + callback = function() + local opts = { buffer = true, silent = true } + + -- Compilation + vim.keymap.set('n', 'll', 'VimtexCompile', vim.tbl_extend('force', opts, { desc = 'Compile LaTeX' })) + vim.keymap.set('n', 'lk', 'VimtexStop', vim.tbl_extend('force', opts, { desc = 'Stop compilation' })) + vim.keymap.set('n', 'lc', 'VimtexClean', vim.tbl_extend('force', opts, { desc = 'Clean aux files' })) + vim.keymap.set('n', 'lC', 'VimtexClean!', vim.tbl_extend('force', opts, { desc = 'Clean all files' })) + + -- View PDF (forward search) - save servername first for inverse search + vim.keymap.set('n', 'lv', function() + -- Save servername to file for inverse search callback + local servername = vim.v.servername + local f = io.open('/tmp/vimtex-servername', 'w') + if f then + f:write(servername) + f:close() + end + vim.cmd 'VimtexView' + end, vim.tbl_extend('force', opts, { desc = 'View PDF (forward search)' })) + + -- TOC + vim.keymap.set('n', 'lt', 'VimtexTocToggle', vim.tbl_extend('force', opts, { desc = 'Toggle TOC' })) + + -- Errors + vim.keymap.set('n', 'le', 'VimtexErrors', vim.tbl_extend('force', opts, { desc = 'Show errors' })) + + -- Info + vim.keymap.set('n', 'li', 'VimtexInfo', vim.tbl_extend('force', opts, { desc = 'VimTeX info' })) + vim.keymap.set('n', 'ls', 'VimtexStatus', vim.tbl_extend('force', opts, { desc = 'Compilation status' })) + end, + }) +end + +return M diff --git a/config/sioyek/.gitignore b/config/sioyek/.gitignore new file mode 100644 index 0000000..89e247e --- /dev/null +++ b/config/sioyek/.gitignore @@ -0,0 +1,3 @@ +*.db +auto.config +*.txt diff --git a/config/sioyek/keys_user.config b/config/sioyek/keys_user.config new file mode 100644 index 0000000..8a3dcf3 --- /dev/null +++ b/config/sioyek/keys_user.config @@ -0,0 +1,65 @@ +# Sioyek user keybindings +# Vim-like keybindings + +# Navigation - use visual mark commands (works as scroll when no mark exists) +move_visual_mark_down j +move_visual_mark_up k +move_left h +move_right l + +# Page navigation +next_page J +previous_page K +screen_down +screen_up +goto_page_with_page_number g + +# Scroll +screen_down +screen_up + +# Search +search / +next_item n +prev_item N + +# Zoom +zoom_in + +zoom_in = +zoom_out - +fit_to_page_width w +fit_to_page_width_smart e + +# Bookmarks +add_bookmark m +goto_bookmark ' + +# Highlights - mouse select text, then h + letter for color +add_highlight H +goto_next_highlight ]h +goto_prev_highlight [h +delete_highlight dh + +# Table of contents +goto_toc t + +# Visual mark - right-click or v to create, then j/k to move +visual_mark_under_cursor v +toggle_visual_scroll + +# Synctex (for LaTeX integration) +synctex_under_cursor + +# Color mode toggle +toggle_dark_mode +toggle_custom_color + +# Open/close +quit q +open_document o + +# Portal (linked view) +portal p + +# Overview (thumbnail view) +overview diff --git a/config/sioyek/prefs_user.config b/config/sioyek/prefs_user.config new file mode 100644 index 0000000..da2e717 --- /dev/null +++ b/config/sioyek/prefs_user.config @@ -0,0 +1,52 @@ +# Sioyek user preferences +# Noctis Azureus Ghostty theme + +# Precise hex to RGB (0.0-1.0) conversions: +# #051b29 -> 5/255=0.0196, 27/255=0.1059, 41/255=0.1608 +# #041520 -> 4/255=0.0157, 21/255=0.0824, 32/255=0.1255 +# #becfda -> 190/255=0.7451, 207/255=0.8118, 218/255=0.8549 +# #49e9a6 -> 73/255=0.2863, 233/255=0.9137, 166/255=0.6510 +# #e4b781 -> 228/255=0.8941, 183/255=0.7176, 129/255=0.5059 +# #49ace9 -> 73/255=0.2863, 172/255=0.6745, 233/255=0.9137 + +# Background - deep blue #051b29 +background_color 0.0196 0.1059 0.1608 +dark_mode_background_color 0.0196 0.1059 0.1608 +dark_mode_contrast 1.0 + +# Custom color mode (toggle with Ctrl+r) +custom_background_color 0.0196 0.1059 0.1608 +custom_text_color 0.7451 0.8118 0.8549 + +# Search highlight (green #49e9a6) +search_highlight_color 0.2863 0.9137 0.6510 + +# Link color (blue #49ace9) +link_highlight_color 0.2863 0.6745 0.9137 + +# Text selection/highlight (yellow #e4b781) +text_highlight_color 0.8941 0.7176 0.5059 + +# Page separator +page_separator_width 2 +page_separator_color 0.1569 0.2078 0.2431 + +# Status bar - darker blue #041520 +ui_background_color 0.0157 0.0824 0.1255 +ui_text_color 0.7451 0.8118 0.8549 + +# Startup - use custom color mode by default +should_launch_new_window 0 +startup_commands toggle_custom_color + +# Smooth scrolling +smooth_scroll_speed 3.0 +smooth_scroll_drag 2500 + +# Zoom +default_zoom_level 1.0 +zoom_inc_factor 1.2 + +# Inverse search - click PDF to jump to Neovim source +# VimTeX passes --inverse-search with servername, this is fallback +inverse_search_command nvr --remote-silent +%2 %1 diff --git a/config/zathura/zathurarc b/config/zathura/zathurarc new file mode 100644 index 0000000..12314f1 --- /dev/null +++ b/config/zathura/zathurarc @@ -0,0 +1,45 @@ +# Noctis Azureus Ghostty theme for Zathura + +set default-bg "#051b29" +set default-fg "#becfda" + +set statusbar-bg "#041520" +set statusbar-fg "#becfda" + +set inputbar-bg "#051b29" +set inputbar-fg "#becfda" + +set notification-bg "#051b29" +set notification-fg "#49e9a6" +set notification-error-bg "#051b29" +set notification-error-fg "#e66533" +set notification-warning-bg "#051b29" +set notification-warning-fg "#e4b781" + +set highlight-color "#e4b781" +set highlight-active-color "#49e9a6" + +set completion-bg "#041520" +set completion-fg "#becfda" +set completion-highlight-bg "#0c3f5f" +set completion-highlight-fg "#becfda" + +set index-bg "#051b29" +set index-fg "#becfda" +set index-active-bg "#0c3f5f" +set index-active-fg "#becfda" + +set render-loading-bg "#051b29" +set render-loading-fg "#becfda" + +# Recolor settings (inverts PDF colors to match theme) +set recolor "true" +# set recolor-reverse-video "true" +set recolor-keephue "true" +set recolor-lightcolor "#051b29" +set recolor-darkcolor "#becfda" +# set recolor-keephue "false" + +# Selection settings +set selection-clipboard clipboard +set selection-notification true diff --git a/home/gui.nix b/home/gui.nix index 6934768..f94cf13 100644 --- a/home/gui.nix +++ b/home/gui.nix @@ -12,6 +12,8 @@ ./hammerspoon.nix ./kitty.nix ./ghostty.nix + ./zathura.nix + ./sioyek.nix ]; options.custom.gui = with lib; { diff --git a/home/neovim.nix b/home/neovim.nix index 8731119..9faa5df 100644 --- a/home/neovim.nix +++ b/home/neovim.nix @@ -16,6 +16,7 @@ home.packages = with pkgs; [ (neovim.override { withNodeJs = true; }) tree-sitter + neovim-remote ]; xdg.configFile."nvim".source = config.lib.file.mkOutOfStoreSymlink "${dots}/config/nvim"; diff --git a/home/sioyek.nix b/home/sioyek.nix new file mode 100644 index 0000000..ffdacfb --- /dev/null +++ b/home/sioyek.nix @@ -0,0 +1,34 @@ +{ + config, + pkgs, + lib, + dots, + ... +}: + +{ + options.custom.gui = with lib; { + sioyek = { + enable = mkEnableOption "Enable sioyek"; + }; + }; + + config = lib.mkIf config.custom.gui.sioyek.enable ( + lib.mkMerge [ + { + home.packages = with pkgs; [ + sioyek + ]; + } + # Linux uses ~/.config/sioyek + (lib.mkIf pkgs.stdenv.isLinux { + xdg.configFile."sioyek".source = config.lib.file.mkOutOfStoreSymlink "${dots}/config/sioyek"; + }) + # macOS uses ~/Library/Application Support/sioyek + (lib.mkIf pkgs.stdenv.isDarwin { + home.file."Library/Application Support/sioyek".source = + config.lib.file.mkOutOfStoreSymlink "${dots}/config/sioyek"; + }) + ] + ); +} diff --git a/home/zathura.nix b/home/zathura.nix new file mode 100644 index 0000000..54e1440 --- /dev/null +++ b/home/zathura.nix @@ -0,0 +1,22 @@ +{ + config, + pkgs, + lib, + dots, + ... +}: + +{ + options.custom.gui = with lib; { + zathura = { + enable = mkEnableOption "Enable zathura"; + }; + }; + + config = lib.mkIf config.custom.gui.zathura.enable { + home.packages = with pkgs; [ + zathura + ]; + xdg.configFile."zathura".source = config.lib.file.mkOutOfStoreSymlink "${dots}/config/zathura"; + }; +} diff --git a/hosts/dango/default.nix b/hosts/dango/default.nix index 6998db1..a22fae5 100644 --- a/hosts/dango/default.nix +++ b/hosts/dango/default.nix @@ -99,6 +99,8 @@ ghostty.enable = true; hammerspoon.enable = true; kitty.enable = true; + zathura.enable = true; + sioyek.enable = true; }; email = { enable = true;