jakewvincent / texmagic.nvim

https://github.com/jakewvincent/texmagic.nvim
GNU General Public License v3.0
56 stars 2 forks source link

```_G.TeXMagicBuildConfig``` is nil #6

Open SivanLaai opened 1 year ago

SivanLaai commented 1 year ago

I use Nvchad as my nvimrc.

I install texlab and texmagic in my nvim, but _G.TeXMagicBuildConfig is nil, which can't be used in TexBuild. TexBuild use the default config to generate files in current directory.

I add texmagic in file custom\plugins.lua

  {
    lazy = false,
    "jakewvincent/texmagic.nvim",
    config = function()
      require("custom.configs.texmagic")
    end,
  },

custom.configs.texmagic

require('texmagic').setup{
    engines = {
        pdflatex = {    -- This has the same name as a default engine but would
                        -- be preferred over the same-name default if defined
            executable = "latexmk",
            args = {
                "-pdflatex",
                "-interaction=nonstopmode",
                "-synctex=1",
                "-outdir=.build",
                "-pv",
                "%f"
            },
            isContinuous = false
        },
        lualatex = {    -- This is *not* one of the defaults, but it can be
                        -- called via magic comment if defined here
            executable = "latexmk",
            args = {
                "-pdflua",
                "-interaction=nonstopmode",
                "-synctex=1",
                "-pv",
                "%f"
            },
            isContinuous = false
        }
    }
}

lspconfig

lspconfig.texlab.setup({
  cmd = { vim.fn.exepath("texlab") },
  filetypes = {"tex", "bib"},
  on_attach = on_attach,
    capabilities = capabilities,
    settings = {
        texlab = {
      rootDirectory = nil,
      --      ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
      build = _G.TeXMagicBuildConfig,
      --      ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑
      --
      ------------------------------- 
            --build = {
            --  executable = "latexmk",
            --  args = { "-pdf", "-interaction=nonstopmode", "-synctex=1", "%f" },
            --  onSave = false,
            --  forwardSearchAfter = true,
            --},
            chktex = {
                onOpenAndSave = true,
            },
            forwardSearch = {
                executable = "SumatraPDF",
                args = { "%p" },
            },
        },
    },
})

relative value

Value Info
TeXMagicConfigFound nil
TeXMagicCommentsFound false
TeXMagicSelectedProgram No program selected
TeXMagicShowComments nil
TeXMagicSetupStatus true
TeXMagicLoaded 1
jakewvincent commented 11 months ago

Hi @SivanLaai, sorry for the slow reply. The fact that TeXMagicConfigFound is returning nil indicates that your TeXMagic config isn't being found or loaded, which leads me to think this isn't a TeXMagic plugin issue. As a troubleshooting step, I would suggest taking your call of the setup function (require('texmagic').setup({...})) and placing it in the config function where you load the plugin:

{
    lazy = false,
    "jakewvincent/texmagic.nvim",
    config = function()
        require("texmagic").setup({
            engines = {
                -- your engines here
            }
        })
    end
}

If TeXMagicConfigFound returns true when the plugin is configured in this way, then there's something going on with how your config file is loaded. Let me know what the result is.