mirror of
https://github.com/LunarVim/LunarVim.git
synced 2025-08-30 14:49:43 +02:00
[Refactor] Clean-up redundant module-load checks (#1011)
This commit is contained in:
parent
f36fd1907f
commit
6eb75c5678
8 changed files with 15 additions and 57 deletions
|
@ -4,8 +4,7 @@ repos:
|
||||||
- id: shfmt
|
- id: shfmt
|
||||||
name: shfmt
|
name: shfmt
|
||||||
minimum_pre_commit_version: 2.4.0
|
minimum_pre_commit_version: 2.4.0
|
||||||
language: golang
|
language: system
|
||||||
additional_dependencies: [mvdan.cc/sh/v3/cmd/shfmt@v3.2.2]
|
|
||||||
entry: shfmt
|
entry: shfmt
|
||||||
args: [-i=2, -ci, -w]
|
args: [-i=2, -ci, -w]
|
||||||
types: [shell]
|
types: [shell]
|
||||||
|
@ -21,7 +20,7 @@ repos:
|
||||||
language: rust
|
language: rust
|
||||||
entry: stylua
|
entry: stylua
|
||||||
types: [lua]
|
types: [lua]
|
||||||
args: [.]
|
args: ['-']
|
||||||
- id: luacheck
|
- id: luacheck
|
||||||
name: luacheck
|
name: luacheck
|
||||||
language: system
|
language: system
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
local M = {}
|
local M = {}
|
||||||
local Log = require "core.log"
|
|
||||||
M.config = function()
|
M.config = function()
|
||||||
lvim.builtin.compe = {
|
lvim.builtin.compe = {
|
||||||
enabled = true,
|
enabled = true,
|
||||||
|
@ -61,11 +60,7 @@ end
|
||||||
M.setup = function()
|
M.setup = function()
|
||||||
vim.g.vsnip_snippet_dir = lvim.vsnip_dir
|
vim.g.vsnip_snippet_dir = lvim.vsnip_dir
|
||||||
|
|
||||||
local status_ok, compe = pcall(require, "compe")
|
local compe = require "compe"
|
||||||
if not status_ok then
|
|
||||||
Log:get_default().error "Failed to load compe"
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
compe.setup(lvim.builtin.compe)
|
compe.setup(lvim.builtin.compe)
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
local M = {}
|
local M = {}
|
||||||
local Log = require "core.log"
|
|
||||||
M.config = function()
|
M.config = function()
|
||||||
lvim.builtin.dap = {
|
lvim.builtin.dap = {
|
||||||
active = false,
|
active = false,
|
||||||
|
@ -13,11 +12,7 @@ M.config = function()
|
||||||
end
|
end
|
||||||
|
|
||||||
M.setup = function()
|
M.setup = function()
|
||||||
local status_ok, dap = pcall(require, "dap")
|
local dap = require "dap"
|
||||||
if not status_ok then
|
|
||||||
Log:get_default().error "Failed to load dap"
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
vim.fn.sign_define("DapBreakpoint", lvim.builtin.dap.breakpoint)
|
vim.fn.sign_define("DapBreakpoint", lvim.builtin.dap.breakpoint)
|
||||||
dap.defaults.fallback.terminal_win_cmd = "50vsplit new"
|
dap.defaults.fallback.terminal_win_cmd = "50vsplit new"
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
local M = {}
|
local M = {}
|
||||||
local Log = require "core.log"
|
|
||||||
M.config = function()
|
M.config = function()
|
||||||
lvim.builtin.gitsigns = {
|
lvim.builtin.gitsigns = {
|
||||||
signs = {
|
signs = {
|
||||||
|
@ -49,12 +48,7 @@ M.config = function()
|
||||||
end
|
end
|
||||||
|
|
||||||
M.setup = function()
|
M.setup = function()
|
||||||
local status_ok, gitsigns = pcall(require, "gitsigns")
|
require("gitsigns").setup(lvim.builtin.gitsigns)
|
||||||
if not status_ok then
|
|
||||||
Log:get_default().error "Failed to load gitsigns"
|
|
||||||
return
|
|
||||||
end
|
|
||||||
gitsigns.setup(lvim.builtin.gitsigns)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
return M
|
return M
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
local M = {}
|
local M = {}
|
||||||
local Log = require "core.log"
|
|
||||||
function M.config()
|
function M.config()
|
||||||
local status_ok, actions = pcall(require, "telescope.actions")
|
local status_ok, actions = pcall(require, "telescope.actions")
|
||||||
if not status_ok then
|
if not status_ok then
|
||||||
|
@ -114,6 +113,7 @@ end
|
||||||
function M.setup()
|
function M.setup()
|
||||||
local status_ok, telescope = pcall(require, "telescope")
|
local status_ok, telescope = pcall(require, "telescope")
|
||||||
if not status_ok then
|
if not status_ok then
|
||||||
|
local Log = require "core.log"
|
||||||
Log:get_default().error "Failed to load telescope"
|
Log:get_default().error "Failed to load telescope"
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
local M = {}
|
local M = {}
|
||||||
local Log = require "core.log"
|
|
||||||
local utils = require "utils"
|
local utils = require "utils"
|
||||||
|
|
||||||
M.config = function()
|
M.config = function()
|
||||||
|
@ -46,22 +45,13 @@ M.config = function()
|
||||||
end
|
end
|
||||||
|
|
||||||
M.setup = function()
|
M.setup = function()
|
||||||
local status_ok, terminal = pcall(require, "toggleterm")
|
local terminal = require "toggleterm"
|
||||||
if not status_ok then
|
|
||||||
Log:get_default().error "Failed to load toggleterm"
|
|
||||||
print(terminal)
|
|
||||||
return
|
|
||||||
end
|
|
||||||
for _, exec in pairs(lvim.builtin.terminal.execs) do
|
for _, exec in pairs(lvim.builtin.terminal.execs) do
|
||||||
require("core.terminal").add_exec(exec[1], exec[2], exec[3])
|
require("core.terminal").add_exec(exec[1], exec[2], exec[3])
|
||||||
end
|
end
|
||||||
terminal.setup(lvim.builtin.terminal)
|
terminal.setup(lvim.builtin.terminal)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function is_installed(exe)
|
|
||||||
return vim.fn.executable(exe) == 1
|
|
||||||
end
|
|
||||||
|
|
||||||
M.add_exec = function(exec, keymap, name)
|
M.add_exec = function(exec, keymap, name)
|
||||||
vim.api.nvim_set_keymap(
|
vim.api.nvim_set_keymap(
|
||||||
"n",
|
"n",
|
||||||
|
@ -85,8 +75,9 @@ end
|
||||||
|
|
||||||
M._exec_toggle = function(exec)
|
M._exec_toggle = function(exec)
|
||||||
local binary = M._split(exec)[1]
|
local binary = M._split(exec)[1]
|
||||||
if is_installed(binary) ~= true then
|
if vim.fn.executable(binary) ~= 1 then
|
||||||
print("Please install executable " .. binary .. ". Check documentation for more information")
|
local Log = require "core.log"
|
||||||
|
Log:get_default().error("Unable to run executable " .. binary .. ". Please make sure it is installed properly.")
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
local Terminal = require("toggleterm.terminal").Terminal
|
local Terminal = require("toggleterm.terminal").Terminal
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
local M = {}
|
local M = {}
|
||||||
local Log = require "core.log"
|
|
||||||
M.config = function()
|
M.config = function()
|
||||||
lvim.builtin.which_key = {
|
lvim.builtin.which_key = {
|
||||||
active = false,
|
active = false,
|
||||||
|
@ -230,14 +229,7 @@ M.config = function()
|
||||||
end
|
end
|
||||||
|
|
||||||
M.setup = function()
|
M.setup = function()
|
||||||
-- if not package.loaded['which-key'] then
|
local which_key = require "which-key"
|
||||||
-- return
|
|
||||||
-- end
|
|
||||||
local status_ok, which_key = pcall(require, "which-key")
|
|
||||||
if not status_ok then
|
|
||||||
Log:get_default "Failed to load whichkey"
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
which_key.setup(lvim.builtin.which_key.setup)
|
which_key.setup(lvim.builtin.which_key.setup)
|
||||||
|
|
||||||
|
@ -247,10 +239,8 @@ M.setup = function()
|
||||||
local mappings = lvim.builtin.which_key.mappings
|
local mappings = lvim.builtin.which_key.mappings
|
||||||
local vmappings = lvim.builtin.which_key.vmappings
|
local vmappings = lvim.builtin.which_key.vmappings
|
||||||
|
|
||||||
local wk = require "which-key"
|
which_key.register(mappings, opts)
|
||||||
|
which_key.register(vmappings, vopts)
|
||||||
wk.register(mappings, opts)
|
|
||||||
wk.register(vmappings, vopts)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
return M
|
return M
|
||||||
|
|
|
@ -131,15 +131,9 @@ return {
|
||||||
"terrortylor/nvim-comment",
|
"terrortylor/nvim-comment",
|
||||||
event = "BufRead",
|
event = "BufRead",
|
||||||
config = function()
|
config = function()
|
||||||
local status_ok, nvim_comment = pcall(require, "nvim_comment")
|
require("nvim_comment").setup()
|
||||||
if not status_ok then
|
|
||||||
local Log = require "core.log"
|
|
||||||
Log:get_default().error "Failed to load nvim-comment"
|
|
||||||
return
|
|
||||||
end
|
|
||||||
nvim_comment.setup()
|
|
||||||
if lvim.builtin.comment.on_config_done then
|
if lvim.builtin.comment.on_config_done then
|
||||||
lvim.builtin.comment.on_config_done(nvim_comment)
|
lvim.builtin.comment.on_config_done(require "nvim_comment")
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue