From cfb3bccc73a959ecf34661b2a1b00f0315f707cb Mon Sep 17 00:00:00 2001 From: Robert Günzler Date: Wed, 18 May 2022 16:25:29 +0200 Subject: vim: gracefully handle non-existant 'fortune' binary --- .vim/lua/plugins.lua | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to '.vim') diff --git a/.vim/lua/plugins.lua b/.vim/lua/plugins.lua index 86ae9f5..c29d2c2 100644 --- a/.vim/lua/plugins.lua +++ b/.vim/lua/plugins.lua @@ -1012,12 +1012,15 @@ require('packer').startup({function() return { type = 'text', val = function() - local j = require('plenary.job'):new({ + local Job = require('plenary.job') + local ok, j = pcall(Job.new, Job, { command = 'fortune', args = {vim.env.HOME..'/devel/projects/zig/fortune/fortunes'}, enable_recording = true, }) - local lines = j:sync() + if not ok then return {} end + local lines, exit_code = j:sync() + if not exit_code == 0 then return {} end local new = {} for i = 1, #lines do if not (vim.trim(lines[i]) == '') then -- cgit 1.4.1