Use a different saner syntax for pcall

takes less lines, looks much better

remove neoscroll.lua, missed in 2952f4d5c7
This commit is contained in:
Akianonymus 2021-07-17 16:44:52 +05:30
parent 1d7602e3e4
commit 9c1a3ad2a2
17 changed files with 56 additions and 158 deletions

View File

@ -1,11 +1,6 @@
local packer local present, packer = pcall(require, "packer")
if
not pcall( if not present then
function()
packer = require "packer"
end
)
then
local packer_path = vim.fn.stdpath("data") .. "/site/pack/packer/start/packer.nvim" local packer_path = vim.fn.stdpath("data") .. "/site/pack/packer/start/packer.nvim"
print("Cloning packer..") print("Cloning packer..")
@ -21,12 +16,10 @@ if
packer_path packer_path
} }
) )
if pcall(
function() present, packer = pcall(require, "packer")
packer = require "packer"
end if present then
)
then
print("Packer cloned successfully.") print("Packer cloned successfully.")
else else
error("Couldn't clone packer !\nPacker path: " .. packer_path) error("Couldn't clone packer !\nPacker path: " .. packer_path)

View File

@ -1,11 +1,6 @@
local packer local present, _ = pcall(require, "packerInit")
if
pcall( if present then
function()
require "packerInit"
end
)
then
packer = require "packer" packer = require "packer"
else else
return false return false

View File

@ -1,12 +1,7 @@
local autopairs, autopairs_completion local present1, autopairs = pcall(require, "nvim-autopairs")
if local present2, autopairs_completion = pcall(require, "nvim-autopairs.completion.compe")
not pcall(
function() if not (present1 or present2) then
autopairs = require "nvim-autopairs"
autopairs_completion = require "nvim-autopairs.completion.compe"
end
)
then
return return
end end

View File

@ -1,12 +1,6 @@
-- autosave.nvim plugin disabled by default -- autosave.nvim plugin disabled by default
local autosave local present, autosave = pcall(require, "autosave")
if if not present then
not pcall(
function()
autosave = require "autosave"
end
)
then
return return
end end

View File

@ -1,14 +1,8 @@
local global_theme = "themes/" .. vim.g.nvchad_theme local global_theme = "themes/" .. vim.g.nvchad_theme
local colors = require(global_theme) local colors = require(global_theme)
local bufferline local present, bufferline = pcall(require, "bufferline")
if if not present then
not pcall(
function()
bufferline = require "bufferline"
end
)
then
return return
end end

View File

@ -1,11 +1,5 @@
local compe local present, compe = pcall(require, "compe")
if if not present then
not pcall(
function()
compe = require "compe"
end
)
then
return return
end end

View File

@ -1,11 +1,5 @@
local gitsigns local present, gitsigns = pcall(require, "gitsigns")
if if not present then
not pcall(
function()
gitsigns = require "gitsigns"
end
)
then
return return
end end

View File

@ -1,11 +1,5 @@
local icons local present, icons = pcall(require, "nvim-web-devicons")
if if not present then
not pcall(
function()
icons = require "nvim-web-devicons"
end
)
then
return return
end end

View File

@ -1,12 +1,6 @@
local lspconfig, lspinstall local present1, lspconfig = pcall(require, "lspconfig")
if local present2, lspinstall = pcall(require, "lspinstall")
not pcall( if not (present1 or present2) then
function()
lspconfig = require "lspconfig"
lspinstall = require "lspinstall"
end
)
then
return return
end end

View File

@ -1,5 +0,0 @@
pcall(
function()
require("neoscroll").setup()
end
)

View File

@ -1,14 +1,9 @@
local tree_cb local present, tree_c = pcall(require, "nvim-tree.config")
if if not present then
not pcall(
function()
tree_cb = require "nvim-tree.config".nvim_tree_callback
end
)
then
return return
end end
local tree_cb = tree_c.nvim_tree_callback
local g = vim.g local g = vim.g
vim.o.termguicolors = true vim.o.termguicolors = true

View File

@ -1,35 +1,25 @@
local M = {} local M = {}
M.colorizer = function() M.colorizer = function()
local colorizer local present, colorizer = pcall(require, "colorizer")
if if present then
not pcall( colorizer.setup()
function() vim.cmd("ColorizerReloadAllBuffers")
colorizer = require("colorizer")
end
)
then
return
end end
colorizer.setup()
vim.cmd("ColorizerReloadAllBuffers")
end end
M.comment = function() M.comment = function()
pcall( local present, nvim_comment = pcall(require, "nvim_comment")
function() if present then
require("nvim_comment").setup() nvim_comment.setup()
end end
)
end end
M.lspkind = function() M.lspkind = function()
pcall( local present, lspkind = pcall(require, "lspkind")
function() if present then
require("lspkind").init() lspkind.init()
end end
)
end end
M.neoscroll = function() M.neoscroll = function()

View File

@ -1,12 +1,6 @@
local gl, condition local present1, gl = pcall(require, "galaxyline")
if local present2, condition = pcall(require, "galaxyline.condition")
not pcall( if not (present1 or present2) then
function()
gl = require "galaxyline"
condition = require "galaxyline.condition"
end
)
then
return return
end end

View File

@ -1,11 +1,5 @@
local telescope local present, telescope = pcall(require, "telescope")
if if not present then
not pcall(
function()
telescope = require("telescope")
end
)
then
return return
end end

View File

@ -1,11 +1,5 @@
local ts_config local present, ts_config = pcall(require, "nvim-treesitter.configs")
if if not present then
not pcall(
function()
ts_config = require "nvim-treesitter.configs"
end
)
then
return return
end end

View File

@ -1,11 +1,5 @@
local true_zen local present, true_zen = pcall(require, "true-zen")
if if not present then
not pcall(
function()
true_zen = require "true-zen"
end
)
then
return return
end end

View File

@ -1,15 +1,10 @@
vim.g.nvchad_theme = "onedark" vim.g.nvchad_theme = "onedark"
local base16 local present, base16 = pcall(require, "base16")
if
not pcall( if present then
function()
base16 = require "base16"
end
)
then
return false
else
base16(base16.themes["onedark"], true) base16(base16.themes["onedark"], true)
return true return true
else
return false
end end