Merge branch 'master' of git.tfld.de:Schwarztee/alkaa

This commit is contained in:
Max Hohlfeld 2023-07-26 23:16:08 +02:00
commit b02c0fbf06
2 changed files with 24 additions and 5 deletions

View File

@ -352,8 +352,8 @@ require('lir').setup {
['h'] = actions.up, ['h'] = actions.up,
['q'] = actions.quit, ['q'] = actions.quit,
['K'] = actions.mkdir, ['nd'] = actions.mkdir,
['N'] = actions.newfile, ['nf'] = actions.newfile,
['R'] = actions.rename, ['R'] = actions.rename,
['@'] = actions.cd, ['@'] = actions.cd,
['Y'] = actions.yank_path, ['Y'] = actions.yank_path,

View File

@ -3,14 +3,22 @@ local M = {}
local pdf_viewer_pid = 0 local pdf_viewer_pid = 0
local compile = function(file) local compile = function(file)
vim.fn.jobstart({ "compiledoc", file }, { return vim.fn.jobstart({ "compiledoc", file }, {
on_exit = function() print("Finished compiling.") end on_exit = function(_, exit_code) if exit_code == 0 then print("Finished compiling.") end end,
on_stderr = function(_, err, _) print(table.concat(err, "\n")) end,
stderr_buffered = true
}) })
end end
local file_exists = function(name)
local f=io.open(name,"r")
if f~=nil then io.close(f) return true else return false end
end
M.open_document_preview = function() M.open_document_preview = function()
local filename = vim.api.nvim_buf_get_name(0) local filename = vim.api.nvim_buf_get_name(0)
compile(filename) local compile_job = compile(filename)
vim.api.nvim_create_augroup("compileDoc", {}) vim.api.nvim_create_augroup("compileDoc", {})
@ -21,6 +29,17 @@ M.open_document_preview = function()
}) })
local pdf_filename = string.gsub(filename, "%..+$", ".pdf") local pdf_filename = string.gsub(filename, "%..+$", ".pdf")
vim.fn.jobwait({compile_job})
if not file_exists(pdf_filename) then
local scan = require'plenary.scandir'
local build_dir = scan.scan_dir({ '.', '..' }, { depth = 1, add_dirs = true, search_pattern = 'build' })
local result = scan.scan_dir(build_dir[1], { depth = 3, search_pattern = ".*%.pdf" })
pdf_filename = result[1]
end
pdf_viewer_pid = vim.fn.jobstart({ "zathura", pdf_filename }) pdf_viewer_pid = vim.fn.jobstart({ "zathura", pdf_filename })
end end