From 6a146f4542b3c297639331b31e62aeebea68a43f Mon Sep 17 00:00:00 2001 From: venus Date: Thu, 10 Sep 2026 16:26:03 -0500 Subject: [PATCH] added vimtex and changed some plugins for rendering faster --- init.lua | 4 +-- lua/keybinds.lua | 3 +- lua/plugins/vimtex.lua | 76 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 80 insertions(+), 3 deletions(-) create mode 100644 lua/plugins/vimtex.lua diff --git a/init.lua b/init.lua index 63da9b3..7d5f8bb 100644 --- a/init.lua +++ b/init.lua @@ -38,14 +38,14 @@ require("lazy").setup({ { "m4xshen/hardtime.nvim", lazy = false, dependencies = { "MunifTanjim/nui.nvim" }}, --annoying { "nvzone/typr", dependencies = "nvzone/volt", cmd = { "Typr", "TyprStats" }, }, --typing practice { 'norcalli/nvim-colorizer.lua', config = function() require('colorizer').setup{"*"} end,}, -- preview colors - { 'edluffy/hologram.nvim', auto_display = true,}, --image viewer + -- { 'edluffy/hologram.nvim', auto_display = true,}, -- image viewer (replaced by 3rd/image.nvim) { "denialofsandwich/sudo.nvim", dependencies = { "MunifTanjim/nui.nvim", },config = true, }, --write restricted files without restart { 'akinsho/toggleterm.nvim', version = "*", config = true}, -- terminal toggling and commands { 'nvim-java/nvim-java', config = function() require('java').setup() vim.lsp.enable('jdtls') end, }, --java QOL -- disable matugen if not using noctalia shell { 'RRethy/base16-nvim', config = function() require('matugen').setup() end,}, --colorshceme for noctalia integration - { "lervag/vimtex", lazy = false, init = function() vim.g.vimtex_view_method = "zathura" end }, -- for latex editing + -- { "lervag/vimtex", lazy = false, init = function() vim.g.vimtex_view_method = "zathura" end }, -- for latex editing { 'windwp/nvim-autopairs', event = "InsertEnter", config = true }, { "folke/ts-comments.nvim", event = "VeryLazy", }, -- qol for commenting { "marcinjahn/gemini-cli.nvim", cmd = "Gemini", dependencies = { "folke/snacks.nvim", }, config = true, }, diff --git a/lua/keybinds.lua b/lua/keybinds.lua index 2495037..1b12c42 100644 --- a/lua/keybinds.lua +++ b/lua/keybinds.lua @@ -31,7 +31,8 @@ vim.keymap.set('n','' ,'nohlsearch') vim.keymap.set('t','' ,'' ,{ desc = 'Exit terminal mode' }) vim.keymap.set('t','' ,'' ,{ desc = 'Move focus to the left window' }) -- vim.keymap.set('n','r' ,'TermExec cmd="clear && make"' ,{ desc = '[r]un make in terminal' }) -vim.keymap.set('n','l' ,function() utils.RunCommand("l") end ,{ desc = 'run [l]ast command in terminal' }) +vim.keymap.set('n','L' ,function() utils.RunCommand("l") end ,{ desc = 'run [l]ast command in terminal' }) +vim.keymap.set('n','' ,function() utils.RunCommand("l") end ,{ desc = 'run [l]ast command in terminal' }) vim.keymap.set('n','ss' ,function() utils.saveSnapshot() end ,{ desc = '[S]ave a [S]napshot of the current windows' }) vim.keymap.set('n','sr' ,function() utils.returnSnapshot() end ,{ desc = '[R]eturn to saved [S]napshot' }) vim.keymap.set('n','n' ,'ToggleTerm direction=vertical name=compile size=70', { desc = 'open a [n]ew terminal' }) diff --git a/lua/plugins/vimtex.lua b/lua/plugins/vimtex.lua new file mode 100644 index 0000000..1b650ad --- /dev/null +++ b/lua/plugins/vimtex.lua @@ -0,0 +1,76 @@ +-- Mostly Generated with Antigravity CLI Gemini 3.7 Flash +return { + "lervag/vimtex", + lazy = false, + init = function() + vim.g.vimtex_compiler_method = "tectonic" + vim.g.vimtex_quickfix_mode = 0 + vim.g.vimtex_view_enabled = 0 -- Disable external GUI popup + end, + config = function() + local function open_pdf_split() + local pdf_path = vim.fn.expand("%:p:r") .. ".pdf" + if vim.fn.filereadable(pdf_path) == 1 then + vim.cmd("vsplit " .. vim.fn.fnameescape(pdf_path)) + else + vim.notify("PDF not found: " .. pdf_path .. "\nCompile first with ll", vim.log.levels.WARN) + end + end + + -- Provide user command :VimtexPreviewBuffer + vim.api.nvim_create_user_command("VimtexPreviewBuffer", open_pdf_split, { desc = "VimTeX: Open PDF in vertical split" }) + + -- Buffer-local keymaps for TeX files + vim.api.nvim_create_autocmd("FileType", { + pattern = { "tex", "latex" }, + callback = function(ev) + local opts = { buffer = ev.buf, desc = "VimTeX: View PDF in Neovim split" } + vim.keymap.set("n", "lv", open_pdf_split, opts) + vim.keymap.set("n", "lv", open_pdf_split, opts) + end, + }) + + -- Helper function to refresh and re-render all open PDF splits with image.nvim + local function reload_pdf_buffers() + local ok, image_api = pcall(require, "image") + for _, win in ipairs(vim.api.nvim_list_wins()) do + local buf = vim.api.nvim_win_get_buf(win) + local buf_name = vim.api.nvim_buf_get_name(buf) + if buf_name:match("%.pdf$") then + vim.api.nvim_win_call(win, function() + vim.cmd("edit!") + end) + if ok and image_api then + local imgs = image_api.get_images({ window = win, buffer = buf }) + if #imgs > 0 then + for _, img in ipairs(imgs) do + img:clear() + img:render() + end + else + image_api.hijack_buffer(buf_name, win, buf) + end + end + end + end + end + + -- Automatically trigger compilation on save (:w) + vim.api.nvim_create_autocmd("BufWritePost", { + pattern = "*.tex", + callback = function() + if vim.b.vimtex and vim.fn.exists(":VimtexCompileSS") == 2 then + vim.cmd("VimtexCompileSS") + end + end, + }) + + -- Automatically reload and re-render PDF splits when compilation finishes + vim.api.nvim_create_autocmd("User", { + pattern = { "VimtexEventCompileSuccess", "VimtexEventCompileStopped" }, + callback = function() + reload_pdf_buffers() + end, + }) + end, +}