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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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