Quellcode durchsuchen

Add Vimtex for Latex support (#512)

* Add vimtex plugin

Vimtex provides a full integration for latex files, see: https://github.com/lervag/vimtex.
Zathura is used as default pdf viewer as it allows live reloading.

* Provide the <leader>L shortcut for Latex operations.

* Move vimtex into the extra plugins section

Add a short comment above extra plugins to introduce their functionality

* Only define whcihKey mapping for Vimtex if O.extras is true

Co-authored-by: Christian Chiarulli <chris.machine@pm.me>
Luc Sinet vor 4 Jahren
Ursprung
Commit
15d194ce09
4 geänderte Dateien mit 45 neuen und 2 gelöschten Zeilen
  1. 1 0
      init.lua
  2. 15 0
      lua/lv-vimtex/init.lua
  3. 11 0
      lua/lv-which-key/init.lua
  4. 18 2
      lua/plugins.lua

+ 1 - 0
init.lua

@@ -31,6 +31,7 @@ if O.extras then
     require('lv-colorizer')
     require('lv-spectre')
     require('lv-symbols-outline')
+    require('lv-vimtex')
 end
 
 

+ 15 - 0
lua/lv-vimtex/init.lua

@@ -0,0 +1,15 @@
+vim.g.vimtex_compiler_method='latexmk'
+vim.g.vimtex_view_method='zathura'
+vim.g.vimtex_fold_enabled=0
+
+-- Compile on initialization, cleanup on quit
+vim.api.nvim_exec(
+    [[
+        augroup vimtex_event_1
+            au!
+            au User VimtexEventQuit     call vimtex#compiler#clean(0)
+            au User VimtexEventInitPost call vimtex#compiler#compile()
+        augroup END
+    ]], false
+)
+

+ 11 - 0
lua/lv-which-key/init.lua

@@ -184,6 +184,17 @@ local mappings = {
     }
 }
 
+if O.extras then
+    mappings["L"] = {
+        name = "+Latex",
+        c = {"<cmd>VimtexCompile<cr>", "Toggle Compilation Mode"},
+        f = {"<cmd>call vimtex#fzf#run()<cr>", "Fzf Find"},
+        i = {"<cmd>VimtexInfo<cr>", "Project Information"},
+        s = {"<cmd>VimtexStop<cr>", "Stop Project Compilation"},
+        t = {"<cmd>VimtexTocToggle<cr>", "Toggle Table Of Content"},
+        v = {"<cmd>VimtexView<cr>", "View PDF"}
+    }
+end
 -- TODO come back and fix visual mappings
 -- local visualOpts = {
 --     mode = "v", -- Visual mode

+ 18 - 2
lua/plugins.lua

@@ -89,8 +89,10 @@ return require("packer").startup(function(use)
     -- Zen Mode
     use {"Pocco81/TrueZen.nvim", opt = true}
 
-		-- Sane gx for netrw_gx bug
-    -- use {"felipec/vim-sanegx"}
+
+	-- Sane gx for netrw_gx bug
+    use {"felipec/vim-sanegx"}
+
 
     require_plugin("nvim-lspconfig")
     require_plugin("lspsaga.nvim")
@@ -125,28 +127,42 @@ return require("packer").startup(function(use)
 
     -- Extras
     if O.extras then
+        -- Interactive scratchpad
         use {'metakirby5/codi.vim', opt = true}
         require_plugin('codi.vim')
+        -- Markdown preview
         use {'iamcco/markdown-preview.nvim', run = 'cd app && npm install', opt = true}
         require_plugin('markdown-preview.nvim')
+        -- Floating terminal
         use {'numToStr/FTerm.nvim', opt = true}
         require_plugin('FTerm.nvim')
+        -- Enhanced increment/decrement
         use {'monaqa/dial.nvim', opt = true}
         require_plugin('dial.nvim')
+        -- Peek lines
         use {'nacro90/numb.nvim', opt = true}
         require_plugin('numb.nvim')
+        -- HTML preview
         use {'turbio/bracey.vim', run = 'npm install --prefix server', opt = true}
         require_plugin('bracey.vim')
+        -- Better motions
         use {'phaazon/hop.nvim', opt = true}
         require_plugin('hop.nvim')
+        -- Colorizer
         use {'norcalli/nvim-colorizer.lua', opt = true}
         require_plugin('nvim-colorizer.lua')
+        -- Search & Replace
         use {'windwp/nvim-spectre', opt = true}
         require_plugin('nvim-spectre')
         use {'simrat39/symbols-outline.nvim', opt = true}
         require_plugin('symbols-outline.nvim')
+        -- Treesitter playground
         use {'nvim-treesitter/playground', opt = true}
         require_plugin('playground')
+        -- Latex
+        use {"lervag/vimtex", opt = true}
+        require_plugin("vimtex")
+
         -- folke/todo-comments.nvim
         -- gennaro-tedesco/nvim-jqx
         -- TimUntersberger/neogit