summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris <[email protected]>2021-07-06 20:42:29 -0400
committerChris <[email protected]>2021-07-06 20:42:29 -0400
commit716f127e95b71bdc1f1ebb960b381ba50b10c1fe (patch)
tree0683b852e4f54cfeaf98c206f9049e4ee130ddbb
parent0e2ad0c1fec50a24177129c89b3edb9007776caf (diff)
wrap requires in pcall
-rw-r--r--lua/lv-autopairs/init.lua4
-rw-r--r--lua/lv-colorizer/init.lua6
-rw-r--r--lua/lv-compe/init.lua8
-rw-r--r--lua/lv-galaxyline/init.lua6
-rw-r--r--lua/lv-gitsigns/init.lua6
-rw-r--r--lua/lv-lspinstall/init.lua4
-rw-r--r--lua/lv-nvimtree/init.lua6
-rw-r--r--lua/lv-telescope/init.lua6
-rw-r--r--lua/lv-treesitter/init.lua6
-rw-r--r--lua/lv-which-key/init.lua6
-rw-r--r--lua/lv-zen/init.lua6
-rw-r--r--lua/plugins.lua10
12 files changed, 58 insertions, 16 deletions
diff --git a/lua/lv-autopairs/init.lua b/lua/lv-autopairs/init.lua
index 6a9e4286..b8dad5f3 100644
--- a/lua/lv-autopairs/init.lua
+++ b/lua/lv-autopairs/init.lua
@@ -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"
diff --git a/lua/lv-colorizer/init.lua b/lua/lv-colorizer/init.lua
index ac5f1356..abe2f728 100644
--- a/lua/lv-colorizer/init.lua
+++ b/lua/lv-colorizer/init.lua
@@ -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
diff --git a/lua/lv-compe/init.lua b/lua/lv-compe/init.lua
index 5b86f27e..36c99ad3 100644
--- a/lua/lv-compe/init.lua
+++ b/lua/lv-compe/init.lua
@@ -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)
diff --git a/lua/lv-galaxyline/init.lua b/lua/lv-galaxyline/init.lua
index 2189eab3..69404b48 100644
--- a/lua/lv-galaxyline/init.lua
+++ b/lua/lv-galaxyline/init.lua
@@ -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 = {
diff --git a/lua/lv-gitsigns/init.lua b/lua/lv-gitsigns/init.lua
index 7f1fbff4..d98e6281 100644
--- a/lua/lv-gitsigns/init.lua
+++ b/lua/lv-gitsigns/init.lua
@@ -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 = {
diff --git a/lua/lv-lspinstall/init.lua b/lua/lv-lspinstall/init.lua
index 68fcfa2b..f6796fe3 100644
--- a/lua/lv-lspinstall/init.lua
+++ b/lua/lv-lspinstall/init.lua
@@ -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
diff --git a/lua/lv-nvimtree/init.lua b/lua/lv-nvimtree/init.lua
index 37a931ef..8f616730 100644
--- a/lua/lv-nvimtree/init.lua
+++ b/lua/lv-nvimtree/init.lua
@@ -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" },
diff --git a/lua/lv-telescope/init.lua b/lua/lv-telescope/init.lua
index 6bbce291..8175a7ed 100644
--- a/lua/lv-telescope/init.lua
+++ b/lua/lv-telescope/init.lua
@@ -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",
diff --git a/lua/lv-treesitter/init.lua b/lua/lv-treesitter/init.lua
index 27877f03..8ec9b08a 100644
--- a/lua/lv-treesitter/init.lua
+++ b/lua/lv-treesitter/init.lua
@@ -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 = {
diff --git a/lua/lv-which-key/init.lua b/lua/lv-which-key/init.lua
index 8edb244b..42547916 100644
--- a/lua/lv-which-key/init.lua
+++ b/lua/lv-which-key/init.lua
@@ -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
diff --git a/lua/lv-zen/init.lua b/lua/lv-zen/init.lua
index 0d6bfca0..d4a3da5c 100644
--- a/lua/lv-zen/init.lua
+++ b/lua/lv-zen/init.lua
@@ -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
diff --git a/lua/plugins.lua b/lua/plugins.lua
index 33efdf05..22132956 100644
--- a/lua/plugins.lua
+++ b/lua/plugins.lua
@@ -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,
}