summaryrefslogtreecommitdiff
path: root/lua/core
diff options
context:
space:
mode:
authorLuc Sinet <[email protected]>2021-08-25 07:47:48 +0200
committerGitHub <[email protected]>2021-08-25 07:47:48 +0200
commit00b895d9e9577f084cf577a07f9d6d6e1f7a4cac (patch)
tree1139617d5b3acd56f221f24ce301f51535267bdc /lua/core
parentf6c706ac0c346491cc79bdea46a52ee7a8694e0d (diff)
[Feature] Encapsulate config logic (#1338)
* Define core/builtins, streamline status_color interface * Encapsulate configuration in its own module * Add fallback to lv-config.lua * Rectify settings loading order to allow overriding vim options * Move default-config into config/ module * replace uv.fs_stat with utils.is_file
Diffstat (limited to 'lua/core')
-rw-r--r--lua/core/autocmds.lua3
-rw-r--r--lua/core/builtins/init.lua29
-rw-r--r--lua/core/dashboard.lua4
-rw-r--r--lua/core/info.lua6
4 files changed, 37 insertions, 5 deletions
diff --git a/lua/core/autocmds.lua b/lua/core/autocmds.lua
index 91278544..91ec70b5 100644
--- a/lua/core/autocmds.lua
+++ b/lua/core/autocmds.lua
@@ -1,4 +1,5 @@
local autocommands = {}
+local config = require "config"
lvim.autocommands = {
_general_settings = {
@@ -32,7 +33,7 @@ lvim.autocommands = {
"*",
"setlocal formatoptions-=c formatoptions-=r formatoptions-=o",
},
- { "BufWritePost", USER_CONFIG_PATH, "lua require('utils').reload_lv_config()" },
+ { "BufWritePost", config.path, "lua require('utils').reload_lv_config()" },
{
"FileType",
"qf",
diff --git a/lua/core/builtins/init.lua b/lua/core/builtins/init.lua
new file mode 100644
index 00000000..32f96af5
--- /dev/null
+++ b/lua/core/builtins/init.lua
@@ -0,0 +1,29 @@
+local M = {}
+
+local builtins = {
+ "keymappings",
+ "core.which-key",
+ "core.gitsigns",
+ "core.compe",
+ "core.dashboard",
+ "core.dap",
+ "core.terminal",
+ "core.telescope",
+ "core.treesitter",
+ "core.nvimtree",
+ "core.project",
+ "core.bufferline",
+ "core.autopairs",
+ "core.comment",
+ "core.lspinstall",
+ "core.lualine",
+}
+
+function M.config(config)
+ for _, builtin_path in ipairs(builtins) do
+ local builtin = require(builtin_path)
+ builtin.config(config)
+ end
+end
+
+return M
diff --git a/lua/core/dashboard.lua b/lua/core/dashboard.lua
index c76d55c9..ac6ee013 100644
--- a/lua/core/dashboard.lua
+++ b/lua/core/dashboard.lua
@@ -1,6 +1,6 @@
local M = {}
-M.config = function()
+M.config = function(config)
lvim.builtin.dashboard = {
active = false,
on_config_done = nil,
@@ -47,7 +47,7 @@ M.config = function()
},
e = {
description = { " Configuration " },
- command = ":e " .. USER_CONFIG_PATH,
+ command = ":e " .. config.path,
},
},
diff --git a/lua/core/info.lua b/lua/core/info.lua
index d9b348b5..67e45d1c 100644
--- a/lua/core/info.lua
+++ b/lua/core/info.lua
@@ -16,6 +16,7 @@ local function str_list(list)
end
local function get_formatter_suggestion_msg(ft)
+ local config = require "config"
local null_formatters = require "lsp.null-ls.formatters"
local supported_formatters = null_formatters.list_available(ft)
local section = {
@@ -27,7 +28,7 @@ local function get_formatter_suggestion_msg(ft)
if not vim.tbl_isempty(supported_formatters) then
vim.list_extend(section, {
"* Configured formatter needs to be installed and executable.",
- fmt("* Enable installed formatter(s) with following config in %s", USER_CONFIG_PATH),
+ fmt("* Enable installed formatter(s) with following config in %s", config.path),
"",
fmt(" lvim.lang.%s.formatters = { { exe = '%s' } }", ft, table.concat(supported_formatters, "│")),
})
@@ -37,6 +38,7 @@ local function get_formatter_suggestion_msg(ft)
end
local function get_linter_suggestion_msg(ft)
+ local config = require "config"
local null_linters = require "lsp.null-ls.linters"
local supported_linters = null_linters.list_available(ft)
local section = {
@@ -48,7 +50,7 @@ local function get_linter_suggestion_msg(ft)
if not vim.tbl_isempty(supported_linters) then
vim.list_extend(section, {
"* Configured linter needs to be installed and executable.",
- fmt("* Enable installed linter(s) with following config in %s", USER_CONFIG_PATH),
+ fmt("* Enable installed linter(s) with following config in %s", config.path),
"",
fmt(" lvim.lang.%s.linters = { { exe = '%s' } }", ft, table.concat(supported_linters, "│")),
})