From 507912ab3fbef0bb18d309b27beab4f98bbc559f Mon Sep 17 00:00:00 2001 From: Fernando Schauenburg Date: Thu, 13 Oct 2022 12:57:55 +0200 Subject: [PATCH] vim: prevent crash on init if telescope file_browser is not installed --- config/nvim/after/plugin/telescope.lua | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/config/nvim/after/plugin/telescope.lua b/config/nvim/after/plugin/telescope.lua index bd7d7c9..26a026a 100644 --- a/config/nvim/after/plugin/telescope.lua +++ b/config/nvim/after/plugin/telescope.lua @@ -1,5 +1,5 @@ -local ok, telescope = pcall(require, 'telescope') -if not ok then return end +local has_telescope, telescope = pcall(require, 'telescope') +if not has_telescope then return end local actions = require 'telescope.actions' @@ -51,8 +51,12 @@ telescope.setup { }, } -telescope.load_extension 'file_browser' -vim.keymap.set('n', 'br', 'Telescope file_browser') +local loaded_file_browser, _ = pcall(telescope.load_extension, 'file_browser') +if loaded_file_browser then + vim.keymap.set('n', 'br', 'Telescope file_browser') +else + print('Telescope file_browser not installed!') +end local builtin = require 'telescope.builtin'