Hi everyone long time vim/neovim user, currently for my latex I have in ~/.config/nvim/after/ftplugin.lua the following line:

vim.opt_local.makeprg="pdflatex -output-format pdf -output-directory /tmp %"

I am now working in a latex project that has a makefile, is it possible to create something in the lines of:

if ! makefile_exists then
  vim.opt_local.makeprg="pdflatex -output-format pdf -output-directory /tmp %"
end

Ended up with this and it seems to work fine:

~/.config/nvim/after/ftplugin/tex.lua

local makefile_exists = vim.fs.find('makefile', {
  upward = true,
  stop = vim.uv.os_homedir(),
  path = vim.fs.dirname(vim.api.nvim_buf_get_name(0)),
})

if #makefile_exists == 0 then
	vim.opt_local.makeprg = "pdflatex -output-format pdf -output-directory /tmp %"
end
  • CjkOvPDwQWOP
    link
    fedilink
    arrow-up
    1
    ·
    1 year ago

    Thanks for the comment, but I ended up finding a solution. Added tto the main comment