diff --git a/config/after/ftplugin/typst.lua b/config/after/ftplugin/typst.lua index e4480d4..62d8cb3 100644 --- a/config/after/ftplugin/typst.lua +++ b/config/after/ftplugin/typst.lua @@ -1,6 +1,18 @@ -vim.api.nvim_create_user_command("OpenPdf", function() - local filepath = vim.fn.bufname() - if filepath:match("%.typ$") then - vim.ui.open(vim.fn.shellescape(filepath:gsub("%.typ$", ".pdf")), {}) +-- options ==================================================================== + +vim.bo.textwidth = 80 +vim.bo.iskeyword = vim.bo.iskeyword .. ",_,*" + +-- commands =================================================================== + +vim.api.nvim_create_user_command("OpenPdf", function(opts) + local filepath = opts.nargs > 0 and opts.fargs[1] or vim.fn.bufname() + filepath = vim.fs.abspath(filepath) + if not filepath:match("%.typ$") then + vim.notify(("Not a typst file: %s"):format(filepath), vim.log.levels.ERROR) + return end -end, {}) + vim.ui.open(filepath:gsub("%.typ$", ".pdf"), {}) +end, { + nargs = 1, +})