wrap requires in pcall

This commit is contained in:
Chris 2021-07-06 20:42:29 -04:00
parent 0e2ad0c1fe
commit 716f127e95
12 changed files with 58 additions and 16 deletions

View file

@ -1,6 +1,10 @@
-- if not package.loaded['nvim-autopairs'] then
-- return
-- end
local status_ok, autopairs = pcall(require, "nvim-autopairs")
if not status_ok then
return
end
local npairs = require "nvim-autopairs"
local Rule = require "nvim-autopairs.rule"

View file

@ -1,4 +1,8 @@
require("colorizer").setup({ "*" }, {
local status_ok, colorizer = pcall(require, "colorizer")
if not status_ok then
return
end
colorizer.setup({ "*" }, {
RGB = true, -- #RGB hex codes
RRGGBB = true, -- #RRGGBB hex codes
RRGGBBAA = true, -- #RRGGBBAA hex codes

View file

@ -7,7 +7,7 @@ local M = {}
vim.g.vsnip_snippet_dir = O.vnsip_dir
M.config = function()
opt = {
local opt = {
enabled = O.auto_complete,
autocomplete = true,
debug = false,
@ -39,8 +39,12 @@ M.config = function()
-- for emoji press : (idk if that in compe tho)
},
}
local status_ok, compe = pcall(require, "compe")
if not status_ok then
return
end
require("compe").setup(opt)
compe.setup(opt)
local t = function(str)
return vim.api.nvim_replace_termcodes(str, true, true, true)

View file

@ -1,8 +1,10 @@
-- if not package.loaded['galaxyline'] then
-- return
-- end
local gl = require "galaxyline"
local status_ok, gl = pcall(require, "galaxyline")
if not status_ok then
return
end
-- get my theme in galaxyline repo
-- local colors = require('galaxyline.theme').default
local colors = {

View file

@ -1,7 +1,11 @@
local M = {}
M.config = function()
require("gitsigns").setup {
local status_ok, gitsigns = pcall(require, "gitsigns ")
if not status_ok then
return
end
gitsigns.setup {
signs = {
-- TODO add hl to colorscheme
add = {

View file

@ -1,7 +1,7 @@
-- 1. get the config for this server from nvim-lspconfig and adjust the cmd path.
-- relative paths are allowed, lspinstall automatically adjusts the cmd and cmd_cwd for us!
local config = require("lspconfig").jdtls.document_config
require("lspconfig/configs").jdtls = nil -- important, unset the loaded config again
-- local config = require("lspconfig").jdtls.document_config
-- require("lspconfig/configs").jdtls = nil -- important, unset the loaded config again
-- config.default_config.cmd[1] = "./node_modules/.bin/bash-language-server"
-- 2. extend the config with an install_script and (optionally) uninstall_script

View file

@ -3,6 +3,10 @@
--end
local M = {}
local status_ok, nvim_tree_config = pcall(require, "nvim-tree.config")
if not status_ok then
return
end
M.config = function()
local g = vim.g
@ -52,7 +56,7 @@ M.config = function()
symlink = "",
},
}
local tree_cb = require("nvim-tree.config").nvim_tree_callback
local tree_cb = nvim_tree_config.nvim_tree_callback
vim.g.nvim_tree_bindings = {
{ key = { "l", "<CR>", "o" }, cb = tree_cb "edit" },

View file

@ -1,3 +1,7 @@
local status_ok, telescope = pcall(require, "telescope")
if not status_ok then
return
end
local actions = require "telescope.actions"
-- if O.plugin.trouble.active then
-- local trouble = require("trouble.providers.telescope")
@ -5,7 +9,7 @@ local actions = require "telescope.actions"
-- Global remapping
------------------------------
-- '--color=never',
require("telescope").setup {
telescope.setup {
defaults = {
find_command = {
"rg",

View file

@ -80,8 +80,12 @@ if status then
wk.register(textobj_move_keymaps["goto_previous_start"], normal)
wk.register(textobj_move_keymaps["goto_previous_end"], normal)
end
local status_ok, treesitter_configs = pcall(require, "nvim-treesitter.configs")
if not status_ok then
return
end
require("nvim-treesitter.configs").setup {
treesitter_configs.setup {
ensure_installed = O.treesitter.ensure_installed, -- one of "all", "maintained" (parsers with maintainers), or a list of languages
ignore_install = O.treesitter.ignore_install,
matchup = {

View file

@ -1,8 +1,12 @@
-- if not package.loaded['which-key'] then
-- return
-- end
local status_ok, which_key = pcall(require, "which-key")
if not status_ok then
return
end
require("which-key").setup {
which_key.setup {
plugins = {
marks = true, -- shows a list of your marks on ' and `
registers = true, -- shows your registers on " in NORMAL or <C-r> in INSERT mode

View file

@ -1,7 +1,11 @@
local M = {}
local status_ok, zen_mode = pcall(require, "zen-mode")
if not status_ok then
return
end
M.config = function()
require("zen-mode").setup {
zen_mode.setup {
window = {
backdrop = 1,
height = 0.85, -- height of the Zen window

View file

@ -94,7 +94,11 @@ return require("packer").startup(function(use)
"terrortylor/nvim-comment",
cmd = "CommentToggle",
config = function()
require("nvim_comment").setup()
local status_ok, nvim_comment = pcall(require, "nvim_comment")
if not status_ok then
return
end
nvim_comment.setup()
end,
}
@ -145,8 +149,8 @@ return require("packer").startup(function(use)
"norcalli/nvim-colorizer.lua",
event = "BufRead",
config = function()
require("colorizer").setup()
vim.cmd "ColorizerReloadAllBuffers"
require "lv-colorizer"
-- vim.cmd "ColorizerReloadAllBuffers"
end,
disable = not O.plugin.colorizer.active,
}