From 9e9a73232d3dc6254a89483639137676caa80dd8 Mon Sep 17 00:00:00 2001 From: tiyn Date: Thu, 10 Aug 2023 03:48:56 +0200 Subject: [PATCH] nvim: swapped async tex previewer --- .config/nvim/lua/autocmd.lua | 4 ++-- .config/nvim/lua/keymap.lua | 9 +++++++-- .config/nvim/lua/loadplugins.lua | 25 ++++++++++++++++--------- .local/bin/tools/nvim/opout | 14 -------------- .local/bin/tools/nvim/texclear | 3 +-- 5 files changed, 26 insertions(+), 29 deletions(-) delete mode 100755 .local/bin/tools/nvim/opout diff --git a/.config/nvim/lua/autocmd.lua b/.config/nvim/lua/autocmd.lua index 28c5322..fb5069f 100644 --- a/.config/nvim/lua/autocmd.lua +++ b/.config/nvim/lua/autocmd.lua @@ -19,7 +19,7 @@ vim.filetype.add({ vim.api.nvim_create_autocmd({ 'VimLeave' }, { - pattern = { 'c' }, + pattern = { '*.c' }, command = '!cclear' }) @@ -105,7 +105,7 @@ vim.api.nvim_create_autocmd({ 'BufEnter', 'FileType' }, vim.api.nvim_create_autocmd({ 'VimLeave' }, { - pattern = { 'tex' }, + pattern = { '*.tex' }, command = '!texclear %' }) diff --git a/.config/nvim/lua/keymap.lua b/.config/nvim/lua/keymap.lua index c659517..a1b34e7 100644 --- a/.config/nvim/lua/keymap.lua +++ b/.config/nvim/lua/keymap.lua @@ -42,8 +42,13 @@ vim.api.nvim_set_keymap('n', 'ss', ':%s//gI', { norema vim.api.nvim_set_keymap('n', 'is', ':.w >> indd', { noremap = true }) --- open corresponding file (pdf/html/...,md) -vim.api.nvim_set_keymap('n', 'p', ':!opout %', { noremap = true }) +-- frabjous/knap +vim.api.nvim_create_autocmd('FileType', { + pattern = 'tex', + callback = function() + vim.api.nvim_set_keymap('n', 'p', ':lua require("knap").toggle_autopreviewing()', { noremap = true }) + end, +}) -- iamcco/markdown-preview.nvim vim.api.nvim_create_autocmd('FileType', { diff --git a/.config/nvim/lua/loadplugins.lua b/.config/nvim/lua/loadplugins.lua index 6918e5a..d41d186 100644 --- a/.config/nvim/lua/loadplugins.lua +++ b/.config/nvim/lua/loadplugins.lua @@ -67,15 +67,6 @@ return require("lazy").setup({ build = "cd app && yarn install" }, - -- latex asynchronous pdf rendering - { - 'donRaphaco/neotex', - ft = { 'tex' }, - config = function() - vim.g.neotex_enabled = 2 - end - }, - -- nim language support { 'zah/nim.vim', @@ -420,6 +411,21 @@ return require("lazy").setup({ config = {} }, + -- latex asynchronous pdf rendering + { + 'frabjous/knap', + ft = { 'tex' }, + config = function() + vim.g.knap_settings = { + texoutputext = "pdf", + textopdf = "pdflatex -synctex=1 -halt-on-error -interaction=batchmode %docroot%", + textopdfviewerlaunch = "zathura --synctex-editor-command 'nvim --headless -es --cmd \"lua require('\"'\"'knaphelper'\"'\"').relayjump('\"'\"'%servername%'\"'\"','\"'\"'%{input}'\"'\"',%{line},0)\"' %outputfile%", + textopdfviewerrefresh = "none", + textopdfforwardjump = "zathura --synctex-forward=%line%:%column%:%srcfile% %outputfile%" + } + end + }, + -- colorscheme { 'tiyn/vim-tccs', @@ -427,6 +433,7 @@ return require("lazy").setup({ vim.cmd('colorscheme tccs') end }, + }, -- lazy.nvim configuration diff --git a/.local/bin/tools/nvim/opout b/.local/bin/tools/nvim/opout deleted file mode 100755 index bc0a8f9..0000000 --- a/.local/bin/tools/nvim/opout +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/sh - -# opout: "open output": A general handler for opening a file's intended output, -# usually the pdf of a compiled document. I find this useful especially -# running from vim. -# by lukesmithxyz, checkout github.com/lukesmithxyz/voidrice - -basename="$(echo "$1" | sed 's/\.[^\/.]*$//')" - -case "$1" in - *.tex|*.m[dse]|*.[rR]md|*.mom|*.[0-9]) setsid xdg-open "$basename".pdf >/dev/null 2>&1 & ;; - *.html) setsid "$BROWSER" "$basename".html >/dev/null 2>&1 & ;; - *.sent) setsid sent "$1" >/dev/null 2>&1 & ;; -esac diff --git a/.local/bin/tools/nvim/texclear b/.local/bin/tools/nvim/texclear index d7395b2..aead279 100755 --- a/.local/bin/tools/nvim/texclear +++ b/.local/bin/tools/nvim/texclear @@ -10,8 +10,7 @@ case "$1" in dir=$(dirname "$file") base="${file%.*}" if [ -f "$dir/indent.log" ]; then rm "$dir/indent.log"; fi - find "$dir" -maxdepth 1 -type f -regextype gnu-awk -regex "^$base\\.(4tc|xref|tmp|pyc|pyo|fls|vrb|fdb_latexmk|bak|swp|log|synctex\\(busy\\)|lof|lot|maf|idx|mtc|mtc0|nav|out|snm|toc|bcf|run\\.xml|synctex\\.gz|blg|bbl|glg|glo|gls|glsdefs|ilg|ist|acn|acr|alg|toc)" -delete ; + find "$dir" -maxdepth 1 -type f -regextype gnu-awk -regex "^$base\\.(4tc|xref|tmp|pyc|pyo|fls|vrb|fdb_latexmk|bak|swp|log|synctex\\(busy\\)|lof|lot|maf|idx|mtc|mtc0|nav|out|snm|toc|loa|bcf|run\\.xml|synctex\\.gz|blg|bbl|glg|glo|gls|glsdefs|ilg|ist|acn|acr|alg|toc)" -delete ; find "$dir" -maxdepth 1 -type f -regextype gnu-awk -regex ".*\\.aux" -delete ;; *) printf "Give .tex file as argument.\\n" ;; esac -