Skip to content

Automatically detect vimtex_compiler_method (for arara) #2721

@mizhozan

Description

@mizhozan

I would like to suggest a feature enhancement for the vimtex plugin. By default, I prefer using latexmk as the compiler method. However, for certain larger projects, I find it more suitable to use arara, as it is specified in top of the main .tex file.

Ideally, I would like the vimtex_compiler_method to remain as latexmk by default, but automatically switch to arara when the main .tex file indicates its use.

As an alternative solution, I believe it may be possible to achieve this behavior using a small Vim function or script that runs on .tex files and detects the presence of arara. However, the challenge lies in accurately detecting the main .tex file, a task which vimtex already handles effectively. If this doesn't worth a feature-request, I would appreciate guidance on utilizing Vimtex's built-in functions for a possible script.

Something like this:

function! SetCompilerMethod()
    let mainFile = vimtex#main#find()

    if mainFile !=# '' && filereadable(mainFile)
        let firstFiveLines = getline(1, 5)

        for line in firstFiveLines
            if line =~# '^%!\s*arara'
                let g:vimtex_compiler_method = 'arara'
                return
            endif
        endfor
    endif
endfunction

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions