feat(sioyek/nvim): synctex

This commit is contained in:
Barrett Ruth 2026-03-05 21:58:19 -05:00
parent 26492351d5
commit f969cacdff
Signed by: barrett
GPG key ID: A6C96C9349D2FC81
3 changed files with 30 additions and 24 deletions

View file

@ -300,6 +300,7 @@ return {
vim.filetype.add({
extension = { puml = 'plantuml', pu = 'plantuml' },
})
vim.fn.serverstart('/tmp/nvim-preview.sock')
vim.api.nvim_create_autocmd('User', {
pattern = 'PreviewCompileSuccess',
callback = function(args)
@ -312,10 +313,7 @@ return {
plantuml = true,
mermaid = true,
latex = {
open = {
'sioyek',
'--instance-name', 'preview',
},
open = { 'sioyek', '--instance-name', 'preview' },
output = function(ctx)
return vim.fn.fnamemodify(ctx.file, ':h')
.. '/build/'
@ -337,22 +335,24 @@ return {
end,
keys = {
{ '<leader>p', '<cmd>Preview toggle<cr>' },
{
'<leader>s',
function()
local bufnr = vim.api.nvim_get_current_buf()
local pdf = synctex_pdf[bufnr]
if pdf then
vim.fn.jobstart({
'sioyek',
'--instance-name', 'preview',
'--forward-search-file', vim.fn.expand('%:p'),
'--forward-search-line', tostring(vim.fn.line('.')),
pdf,
})
end
end,
},
},
after = function()
local function forward_search()
local pdf = synctex_pdf[vim.api.nvim_get_current_buf()]
if pdf then
vim.fn.jobstart({
'sioyek',
'--instance-name', 'preview',
'--forward-search-file', vim.fn.expand('%:p'),
'--forward-search-line', tostring(vim.fn.line('.')),
pdf,
})
end
end
vim.api.nvim_create_autocmd('CursorHold', {
pattern = '*.tex',
callback = forward_search,
})
end,
},
}

View file

@ -32,6 +32,10 @@
"rev": "9f3c6dd7868bcc116e9c1c1929ce063b978fa519",
"src": "https://github.com/lewis6991/gitsigns.nvim"
},
"gruvbox-material": {
"rev": "790afe9dd085aa04eccd1da3626c5fa05c620e53",
"src": "https://github.com/sainnhe/gruvbox-material"
},
"guard-collection": {
"rev": "edf6c86c06badc972964dadb7fd469022690cbf0",
"src": "https://github.com/nvimdev/guard-collection"

View file

@ -94,7 +94,9 @@ let
nativeBuildInputs = [ pkgs.makeWrapper ];
postBuild = ''
wrapProgram $out/bin/sioyek \
--set QT_QPA_PLATFORM xcb
--set QT_QPA_PLATFORM xcb \
--add-flags "--execute-command toggle_statusbar" \
--add-flags "--execute-command toggle_synctex"
'';
};
in
@ -145,14 +147,14 @@ in
toggle_statusbar b
close_window q
synctex_under_cursor i
'';
};
xdg.configFile."sioyek/prefs_user.config" = lib.mkIf sioyek {
text = ''
wheel_zoom_on_cursor 1
startup_commands show_statusbar 0;toggle_synctex
page_separator_width 10
should_launch_new_window 1
@ -161,7 +163,7 @@ in
font_size 18
status_bar_font_size 18
inverse_search_command sh -c 'nvim --server "$NVIM" --remote-send ":e +%2 %1<CR>"'
inverse_search_command nvim --server /tmp/nvim-preview.sock --remote-expr "execute('b +%2 %1')"
'';
};