Skip to content

Commit 41b620b

Browse files
authored
Initial support for Sioyek viewer (#1634)
1 parent fc0a8ee commit 41b620b

File tree

3 files changed

+69
-1
lines changed

3 files changed

+69
-1
lines changed

LaTeXTools.sublime-settings

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,9 @@
246246

247247
"osx": {
248248
// Path used when invoking tex & friends; MUST include $PATH
249-
"texpath" : "/Library/TeX/texbin:/usr/texbin:/usr/local/bin:/opt/local/bin:$PATH"
249+
"texpath": "/Library/TeX/texbin:/usr/texbin:/usr/local/bin:/opt/local/bin:$PATH",
250+
// Command to invoke Sioyek. If blank, "sioyek.exe" is used (it has to be on your PATH)
251+
"sioyek": ""
250252
},
251253

252254
"windows": {
@@ -256,6 +258,8 @@
256258
"texpath" : "",
257259
// TeX distro: "miktex" or "texlive"
258260
"distro" : "miktex",
261+
// Command to invoke Sioyek. If blank, "sioyek.exe" is used (it has to be on your PATH)
262+
"sioyek": "",
259263
// Command to invoke Sumatra. If blank, "SumatraPDF.exe" is used (it has to be on your PATH)
260264
"sumatra": "",
261265
// Command to invoke Sublime Text. Used if the keep_focus toggle is true.
@@ -275,6 +279,8 @@
275279
// Both Python2 and Python3 are supported, but must have the DBus bindings
276280
// installed.
277281
"python": "",
282+
// Command to invoke Sioyek. If blank, "sioyek.exe" is used (it has to be on your PATH)
283+
"sioyek": "",
278284
// How long to wait after evince or okular has launched before sending a sync message
279285
// in seconds, floating point; choose 2.0 or 3.0 on a slower machine, 0.5 on a fast one
280286
// Note: only tweak this if sync after launching the PDF viewer does not seem to work,
@@ -523,6 +529,8 @@
523529
//
524530
// "preview" uses Preview.app to open the pdf
525531
//
532+
// "sioyek" uses Sioyek to open the pdf
533+
//
526534
// "skim" uses Skim to open the pdf; this is the
527535
// default on OSX
528536
//

plugins/viewer/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from .evince_viewer import EvinceViewer
33
from .okular_viewer import OkularViewer
44
from .preview_viewer import PreviewViewer
5+
from .sioyek_viewer import SioyekViewer
56
from .skim_viewer import SkimViewer
67
from .sumatra_viewer import SumatraViewer
78
from .zathura_viewer import ZathuraViewer

plugins/viewer/sioyek_viewer.py

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
import sublime
2+
3+
from ...latextools.utils.external_command import external_command
4+
from ...latextools.utils.settings import get_setting
5+
6+
from .base_viewer import BaseViewer
7+
8+
__all__ = ["SioyekViewer"]
9+
10+
11+
class SioyekViewer(BaseViewer):
12+
13+
def _run_sioyek(self, *args, **kwargs):
14+
platform = sublime.platform()
15+
sioyek_binary = (
16+
# prefer `viewer_settings`
17+
get_setting("viewer_settings", {}).get("sioyek")
18+
# fallback to platform specific settings
19+
or get_setting(platform, {}).get("sioyek")
20+
# static binary expected to be found on $PATH
21+
or "sioyek.exe"
22+
if platform == "windows"
23+
else "sioyek"
24+
)
25+
26+
command = [sioyek_binary]
27+
28+
keep_focus = kwargs.pop("keep_focus", True)
29+
if keep_focus:
30+
command.append("--nofocus")
31+
32+
command += args
33+
external_command(command, use_texpath=False, show_window=True)
34+
35+
def forward_sync(self, pdf_file, tex_file, line, col, **kwargs):
36+
sublime_text = get_setting(sublime.platform(), {}).get("sublime_executable") or "subl"
37+
self._run_sioyek(
38+
"--execute-command",
39+
"turn_on_synctex",
40+
"--forward-search-file",
41+
tex_file,
42+
"--forward-search-line",
43+
f"{line}",
44+
"--forward-search-column",
45+
f"{col}",
46+
"--inverse-search",
47+
f"{sublime_text} %1:%2",
48+
pdf_file,
49+
**kwargs
50+
)
51+
52+
def view_file(self, pdf_file, **kwargs):
53+
self._run_sioyek("--new-window", pdf_file, **kwargs)
54+
55+
def supports_keep_focus(self):
56+
return True
57+
58+
def supports_platform(self, platform):
59+
return True

0 commit comments

Comments
 (0)