moved tex mapping to ftplugin and added surround for tex

This commit is contained in:
Jeremie Fraeys 2024-08-22 19:40:03 -04:00
parent f2eaf7c67a
commit 3a09e91ad6
3 changed files with 23 additions and 21 deletions

21
ftplugin/tex.lua Normal file
View File

@ -0,0 +1,21 @@
-- Keybinding to compile LaTeX to PDF using xelatex with latexmk and output to the "output" directory
vim.keymap.set('n', '<leader>ll', ':!mkdir -p output && latexmk -pdf -xelatex -output-directory=output -synctex=1 %<CR>',
{
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', '<leader>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{}

View File

@ -117,27 +117,7 @@ vim.keymap.set('n', ']d', vim.diagnostic.goto_next, { desc = 'Go to next diagnos
-- runner.run_all(true) -- runner.run_all(true)
-- end, { desc = "run all cells of all languages", silent = true }) -- end, { desc = "run all cells of all languages", silent = true })
-- Latex-specific Keymaps -- Refactoring Keymaps
-- Keybinding to compile LaTeX to PDF using xelatex with latexmk and output to the "output" directory
vim.keymap.set('n', '<leader>ll', ':!mkdir -p output && latexmk -pdf -xelatex -output-directory=output -synctex=1 %<CR>',
{
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', '<leader>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
-- vim.keymap.set({ "x" }, "<leader>re", [[<Esc><Cmd>lua require('refactoring').refactor('Extract Function')<CR>]], -- vim.keymap.set({ "x" }, "<leader>re", [[<Esc><Cmd>lua require('refactoring').refactor('Extract Function')<CR>]],
-- { noremap = true, silent = true, expr = false, desc = "Extract Function" }) -- { noremap = true, silent = true, expr = false, desc = "Extract Function" })
-- vim.keymap.set({ "x" }, "<leader>rf", [[<Esc><Cmd>lua require('refactoring').refactor('Extract Function To File')<CR>]], -- vim.keymap.set({ "x" }, "<leader>rf", [[<Esc><Cmd>lua require('refactoring').refactor('Extract Function To File')<CR>]],

View File

@ -1,5 +1,6 @@
return { return {
'tpope/vim-surround', 'tpope/vim-surround',
event = 'BufRead',
config = function() config = function()
-- You may configure any additional settings here if needed -- You may configure any additional settings here if needed
end, end,