summaryrefslogtreecommitdiff
path: root/lua/lvim/core/builtins/init.lua
blob: e918b033f8b366daa3e918b693eda2b0bac5ef33 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
local M = {}

---@class LvimBuiltin
---@field active boolean is builtin enabled
---@field setup table options passed to setup()
---@field on_config function function called to configure the builtin
---@field on_config_done function function called to configure the builtin

local builtins = {
  "which_key",
  "gitsigns",
  "cmp",
  "dap",
  "terminal",
  "telescope",
  "treesitter",
  "nvimtree",
  "lir",
  "illuminate",
  "indentlines",
  "breadcrumbs",
  "project",
  "bufferline",
  "autopairs",
  "comment",
  "lualine",
  "alpha",
  "mason",
}

function M.init()
  for _, name in ipairs(builtins) do
    lvim.builtin[name] = { active = true }
  end

  reload("lvim.core.theme").config()

  lvim.builtin.cmp.cmdline = { enable = false }

  lvim.builtin.luasnip = {
    sources = {
      friendly_snippets = true,
    },
  }

  lvim.builtin.bigfile = {
    active = true,
    config = {},
  }
end

function M.setup(builtin_mod_name)
  local builtin_name = builtin_mod_name:gsub("-", "_")
  local mod = require("lvim.core." .. builtin_mod_name)

  -- initialize config table
  mod.config()
  local builtin = lvim.builtin[builtin_name]

  if type(builtin.on_config) == "function" then
    builtin.on_config()

    local deprecated = require "lvim.config._deprecated"
    local deprecation_handler = deprecated.post_builtin[builtin_name]
    if deprecation_handler then
      deprecation_handler()
    end
  end

  mod.setup()

  if type(builtin.on_config_done) == "function" then
    builtin.on_config_done()
  end
end

return M