refactor: use more flexible paths (#1381)

This commit is contained in:
kylo252 2021-09-13 11:28:15 +02:00 committed by GitHub
parent 38b0c3d860
commit 8eed75d67f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 216 additions and 153 deletions

View file

@ -1,21 +1,14 @@
local home_dir = vim.loop.os_homedir()
local M = {
path = string.format("%s/.config/lvim/config.lua", home_dir),
}
local M = {}
--- Initialize lvim default configuration
-- Define lvim global variable
function M:init()
function M:init(opts)
opts = opts or {}
self.path = opts.path
local utils = require "utils"
require "config.defaults"
local builtins = require "core.builtins"
builtins.config(self)
local settings = require "config.settings"
settings.load_options()
-- Fallback config.lua to lv-config.lua
if not utils.is_file(self.path) then
local lv_config = self.path:gsub("config.lua$", "lv-config.lua")
@ -23,6 +16,12 @@ function M:init()
self.path = lv_config
end
local builtins = require "core.builtins"
builtins.config(self)
local settings = require "config.settings"
settings.load_options()
end
--- Override the configuration with a user provided one