Coder Social home page Coder Social logo

Comments (10)

lervag avatar lervag commented on June 12, 2024 1

As I said I do not use vim.cmd 'filetype plugin indent on' and vim.cmd 'syntax enable' as I read the comment. :)

Ok, cool. You included it in your original post, which is why I mentioned that.

When adding the following as suggested:

  init = function()
    vim.api.nvim_create_autocmd(
        "VimtexEventQuit",
        { command = "VimtexClean" }
    )
  end

Sorry, that's my mistake. It should be:

  init = function()
    vim.api.nvim_create_autocmd("User", {
        pattern = "VimtexEventQuit",
        group = vim.api.nvim_create_augroup("init_vimtex", {}),
        command = "VimtexClean"
    })
  end

I did read from the help page:

Note: Commands such as |:VimtexClean| cannot be used in this autocommand
because when quitting vim the current buffer does not necessarily have filetype "tex".

I think that comment may be wrong; I'm not 100% sure. Please test my updated version.

But I may use e.g. VimtexEventCompileSuccess

Yes, this is also an option, but you should only do it if you do not use continuous compilation.

Notice that for larger documents, LaTeX compilation times are sometimes nontrivial. Thus, cleaning after every compile implies that you need to fully recompile everything everytime. Thus, I think it is better to instead do a clean when you are finished working with your document.

Thank you for your precious help!

Glad to help!

from vimtex.

lervag avatar lervag commented on June 12, 2024 1

I believe the last update should be good - the text is better now.

from vimtex.

lervag avatar lervag commented on June 12, 2024

I have tried to use the compilation argument "-c" to automatically clean up the output files instead of running :VimtexClean every time.

That's not really possibly. :VimtexCompile starts latexmk in the background as a continuous process that compiles your document when you save it.

IMHO, there is really no reason to worry about the generated files. Just ignore them.

Also, please remove the vim.cmd 'filetype plugin indent on' and vim.cmd 'syntax enable' from your config. Those are not necessary when you use a plugin manager (as is mentioned in the very comments you've copied into your config!). Thus, you may simplify your config to this:

return {
    'lervag/vimtex',
    init = function()
        -- you could remove the init block if you are not setting any options
    end,
}

Also; if you really do want to add an option to latexmk, you should append to the default list. Thus:

return {
    'lervag/vimtex',
    init = function()
        vim.g.vimtex_compiler_latexmk = {
            options = {
                '-verbose',
                '-file-line-error',
                '-synctex=1',
                '-interaction=nonstopmode',
                '-c',
            },
        }
    end,
}

However, I still think it does not make sense to add -c when latexmk is run in continuous mode.

from vimtex.

0xN1C04ND3 avatar 0xN1C04ND3 commented on June 12, 2024

Also, please remove the vim.cmd 'filetype plugin indent on' and vim.cmd 'syntax enable' from your config. Those are not necessary when you use a plugin manager (as is mentioned in the very comments you've copied into your config!).

Regarding the config I just simply copied the example but I don't have it in otherwise.

The thing is, I have different tex files in the same directory so generating 7 files instead of 3 for every tex files adds up.

I have tried to run with and without continuous mode. But the compiler simply don't compile with the -c flag.
Does this clean option work at all then ?

from vimtex.

lervag avatar lervag commented on June 12, 2024

Also, please remove the vim.cmd 'filetype plugin indent on' and vim.cmd 'syntax enable' from your config. Those are not necessary when you use a plugin manager (as is mentioned in the very comments you've copied into your config!).

Regarding the config I just simply copied the example but I don't have it in otherwise.

Then take this advice: 1) read the comments in example code that you copy, and 2) strive to properly understand code that you are copying. The latter is sometimes takes time you feel that you don't have, but I believe in many cases you can actually reduce time waste by investing this time up front.

The thing is, I have different tex files in the same directory so generating 7 files instead of 3 for every tex files adds up.

So, how about creating separate directories for your projects?

I have tried to run with and without continuous mode. But the compiler simply don't compile with the -c flag. Does this clean option work at all then ?

That's the expected behaviour. As far as I know, latexmk was never designed for doing compile then clean in the same invocation.

One thing you can try: Use an event to trigger clean when you exit neovim with something like this:

  init = function()
    vim.api.nvim_create_autocmd(
        "VimtexEventQuit",
        { command = "VimtexClean" }
    )
  end

You may also be interested in reading my related response here: #2820 (comment).

from vimtex.

0xN1C04ND3 avatar 0xN1C04ND3 commented on June 12, 2024

Also, please remove the vim.cmd 'filetype plugin indent on' and vim.cmd 'syntax enable' from your config. Those are not necessary when you use a plugin manager (as is mentioned in the very comments you've copied into your config!).

Regarding the config I just simply copied the example but I don't have it in otherwise.

Then take this advice: 1) read the comments in example code that you copy, and 2) strive to properly understand code that you are copying. The latter is sometimes takes time you feel that you don't have, but I believe in many cases you can actually reduce time waste by investing this time up front.

As I said I do not use vim.cmd 'filetype plugin indent on' and vim.cmd 'syntax enable' as I read the comment. :)

The thing is, I have different tex files in the same directory so generating 7 files instead of 3 for every tex files adds up.

So, how about creating separate directories for your projects?

I would have liked to, but I'm told to do so.

When adding the following as suggested:

  init = function()
    vim.api.nvim_create_autocmd(
        "VimtexEventQuit",
        { command = "VimtexClean" }
    )
  end

Even though I don't lazy load Vimtex I get:

Failed to run `init` for **vimtex**
.../.config/nvim-24/lua/ftplugin/tex.lua:43: Invalid 'event': 'VimtexEventQuit'

I did read from the help page:

Note: Commands such as |:VimtexClean| cannot be used in this autocommand
because when quitting vim the current buffer does not necessarily have filetype "tex".

But I may use e.g. VimtexEventCompileSuccess

You are correct, I did see now that latexmk cannot compile and then clean.
Was using it wrong.
(And I know it defeats its purpose to clean after every compilation.)

Thank you for your precious help!

from vimtex.

0xN1C04ND3 avatar 0xN1C04ND3 commented on June 12, 2024

Sorry, that's my mistake. It should be:

 init = function()
   vim.api.nvim_create_autocmd("User", {
       pattern = "VimtexEventQuit",
       group = vim.api.nvim_create_augroup("init_vimtex", {}),
       command = "VimtexClean"
   })
 end

This works like a charm!
(Tried quitting from another buffer and the documentation seem to be correct)

Big thanks! Couldn't hope for a better solution.

from vimtex.

lervag avatar lervag commented on June 12, 2024

Great, I'm glad to hear it!

It seems I should update the docs, though, as they are indicating that this specific thing does not work. Thanks for pointing that out!

from vimtex.

0xN1C04ND3 avatar 0xN1C04ND3 commented on June 12, 2024

It wasn't maybe not that clear in my phrase. Sorry. I mean the docs are correct in the current state.
When quitting from a buffer that is not of tex filetype, the command is not executed. :)

from vimtex.

lervag avatar lervag commented on June 12, 2024

Ah, ok, sorry. Then I'll revert the docs :)

from vimtex.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.