From 3a09e91ad6393c50c33ec628c2b4b410914664b8 Mon Sep 17 00:00:00 2001 From: Jeremie Fraeys Date: Thu, 22 Aug 2024 19:40:03 -0400 Subject: [PATCH] moved tex mapping to ftplugin and added surround for tex --- ftplugin/tex.lua | 21 +++++++++++++++++++++ lua/config/mappings.lua | 22 +--------------------- lua/custom/plugins/surround.lua | 1 + 3 files changed, 23 insertions(+), 21 deletions(-) create mode 100644 ftplugin/tex.lua diff --git a/ftplugin/tex.lua b/ftplugin/tex.lua new file mode 100644 index 00000000..bcdde064 --- /dev/null +++ b/ftplugin/tex.lua @@ -0,0 +1,21 @@ +-- Keybinding to compile LaTeX to PDF using xelatex with latexmk and output to the "output" directory +vim.keymap.set('n', 'll', ':!mkdir -p output && latexmk -pdf -xelatex -output-directory=output -synctex=1 %', + { + desc = 'Compile LaTeX to PDF using xelatex with SyncTeX in the output directory', + noremap = true, + silent = true + }) + +-- Keybinding to view the compiled PDF in Zathura from the output directory +vim.keymap.set('n', 'lv', function() + local pdf_path = vim.fn.expand('%:p:h') .. '/output/' .. vim.fn.expand('%:t:r') .. '.pdf' + vim.cmd(':silent !nohup zathura ' .. pdf_path .. ' >/dev/null 2>&1 &') +end, { + desc = 'View PDF in Zathura from the output directory', + noremap = true, + silent = true +}) + +-- Custom surroundings for LaTeX +vim.g.surround_110 = "\\begin{\r}\n\\end{\r}" -- map `yssn` for \begin{} \end{} + diff --git a/lua/config/mappings.lua b/lua/config/mappings.lua index a6d3be5a..349f8837 100755 --- a/lua/config/mappings.lua +++ b/lua/config/mappings.lua @@ -117,27 +117,7 @@ vim.keymap.set('n', ']d', vim.diagnostic.goto_next, { desc = 'Go to next diagnos -- runner.run_all(true) -- end, { desc = "run all cells of all languages", silent = true }) --- Latex-specific Keymaps --- Keybinding to compile LaTeX to PDF using xelatex with latexmk and output to the "output" directory -vim.keymap.set('n', 'll', ':!mkdir -p output && latexmk -pdf -xelatex -output-directory=output -synctex=1 %', - { - desc = 'Compile LaTeX to PDF using xelatex with SyncTeX in the output directory', - noremap = true, - silent = true - }) - - --- Keybinding to view the compiled PDF in Zathura from the output directory -vim.keymap.set('n', 'lv', function() - local pdf_path = vim.fn.expand('%:p:h') .. '/output/' .. vim.fn.expand('%:t:r') .. '.pdf' - vim.cmd(':silent !nohup zathura ' .. pdf_path .. ' >/dev/null 2>&1 &') -end, { - desc = 'View PDF in Zathura from the output directory', - noremap = true, - silent = true -}) - --- -- Refactoring Keymaps +-- Refactoring Keymaps -- vim.keymap.set({ "x" }, "re", [[lua require('refactoring').refactor('Extract Function')]], -- { noremap = true, silent = true, expr = false, desc = "Extract Function" }) -- vim.keymap.set({ "x" }, "rf", [[lua require('refactoring').refactor('Extract Function To File')]], diff --git a/lua/custom/plugins/surround.lua b/lua/custom/plugins/surround.lua index b21edb8c..247f29c1 100755 --- a/lua/custom/plugins/surround.lua +++ b/lua/custom/plugins/surround.lua @@ -1,5 +1,6 @@ return { 'tpope/vim-surround', + event = 'BufRead', config = function() -- You may configure any additional settings here if needed end,