Updated vimtex and snippets
This commit is contained in:
parent
84a6b218fe
commit
10bf23a6ec
44 changed files with 4209 additions and 69 deletions
1
personal/inverse-search/README.md
Normal file
1
personal/inverse-search/README.md
Normal file
|
|
@ -0,0 +1 @@
|
|||
Scripts for implementing inverse search between PDF files (generally LaTeX or `lilypond-book` output) and the corresponding text source files in the Neovim text editor.
|
||||
53
personal/inverse-search/inverse-search.sh
Normal file
53
personal/inverse-search/inverse-search.sh
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
#!/bin/sh
|
||||
# A script to manage inverse search from both LyTeX and LaTeX files
|
||||
# Arguments:
|
||||
# 1: line number to display
|
||||
# e.g. "42"
|
||||
# 2: path to LaTeX source file
|
||||
# e.g. "$HOME/test/tex/test.tex"
|
||||
# 3: operating system name as returned by uname
|
||||
# i.e. "Darwin" on macOS and "Linux" on Linux
|
||||
|
||||
# echo "${1}\n${2}" > "${HOME}/log.txt"
|
||||
|
||||
function inverse_search() {
|
||||
# Arguments:
|
||||
# 1: path to Neovim server socket
|
||||
# e.g. "/tmp/texsocket" or "/tmp/lytexsocket"
|
||||
# 2: line number to display
|
||||
# e.g. "42"
|
||||
# 3: path to the file to display
|
||||
# e.g. /Users/ejmastnak/test/tex/test.tex
|
||||
# 4: operating system name as returned by uname
|
||||
# i.e. "Darwin" on macOS and "Linux" on Linux
|
||||
if [ ${4} = "Darwin" ] # macOS
|
||||
then
|
||||
nvr --servername="${1}" +"${2}" "${3}" && open -a Alacritty
|
||||
else # Linux/other
|
||||
nvr --servername="${1}" +"${2}" "${3}"
|
||||
fi
|
||||
}
|
||||
|
||||
# read first line of /tmp/inverse-search-target.txt into the variable target
|
||||
read -r target < /tmp/inverse-search-target.txt
|
||||
|
||||
if [ ${target} = "TEX" ] # standard TEX inverse search
|
||||
then
|
||||
inverse_search "/tmp/texsocket" "${1}" "${2}" "${3}"
|
||||
elif [ ${target} = "LYTEX" ] # LilyPond LYTEX inverse search
|
||||
then
|
||||
|
||||
# change extension from ".tex" to ".lytex" using "${2%"tex"}lytex"
|
||||
# replace "lilybook-out/" with "" sed using 's/lilybook-out\///'
|
||||
lytex_file=$(echo "${2%"tex"}lytex" | sed 's/lilybook-out\///')
|
||||
|
||||
# get line in LYTEX file corresponding to line in TEX file
|
||||
lytex_to_tex_script="$HOME/.config/nvim/personal/lilypond-scripts/lytex-to-tex.sh"
|
||||
lytex_line=$(sh "${lytex_to_tex_script}" ${1} "${2}" "${lytex_file}")
|
||||
inverse_search "/tmp/lytexsocket" "${lytex_line}" "${lytex_file}" "${3}"
|
||||
|
||||
# echo "TEX line: ${1}"
|
||||
# echo "LYTEX line: ${lytex_line}"
|
||||
else
|
||||
exit
|
||||
fi
|
||||
20
personal/inverse-search/latex-linux.sh
Normal file
20
personal/inverse-search/latex-linux.sh
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
#!/bin/sh
|
||||
# Used for inverse search from a PDF in Zathura
|
||||
# to the corresponding *.tex in Neovim on Linux.
|
||||
# xdotool is used to return focus to the Vim window.
|
||||
#
|
||||
# SYNOPSIS
|
||||
# inverse <tex_file> <line_num> <window_id>
|
||||
# ARGUMENT
|
||||
# <tex_file>
|
||||
# Path to the LaTeX file to open in Neovim
|
||||
#
|
||||
# <line_num>
|
||||
# Line number to move the cursor to in the opened LaTeX file
|
||||
#
|
||||
# <window_id>
|
||||
# Numerical ID of the window in which Vim is running
|
||||
# as returned by `xdotool getactivewindow`.
|
||||
# E.g. 10485762
|
||||
nvr --remote-silent --servername=/tmp/texsocket +"${2}" "${1}"
|
||||
xdotool windowfocus ${3}
|
||||
Loading…
Add table
Add a link
Reference in a new issue