From 213e3961fa637e4dbe4ef1ea5fceadcb372e020e Mon Sep 17 00:00:00 2001 From: chaeing Date: Sat, 31 Jul 2021 11:28:59 -0700 Subject: [Feature] Rename lv-config.lua to config.lua (#1193) * Rename example config files * Update user config path in installer * Update user config path with a variable * Update default user config file to config.lua * Add fallback to lv-config if config.lua not found * Add global variable USER_CONFIG_PATH --- init.lua | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) (limited to 'init.lua') diff --git a/init.lua b/init.lua index 92ec3d4b..a69fde44 100644 --- a/init.lua +++ b/init.lua @@ -11,12 +11,32 @@ vim.cmd [[ set runtimepath^=~/.local/share/lunarvim/lvim/after ]] -- vim.opt.rtp:append() instead of vim.cmd ? + +local function file_exists(name) + local f = io.open(name, "r") + if f ~= nil then + io.close(f) + return true + else + return false + end +end + +local lvim_path = os.getenv "HOME" .. "/.config/lvim/" +USER_CONFIG_PATH = lvim_path .. "config.lua" +local config_exist = file_exists(USER_CONFIG_PATH) +if not config_exist then + USER_CONFIG_PATH = lvim_path .. "lv-config.lua" + print "Rename ~/.config/lvim/lv-config.lua to config.lua" +end + require "default-config" local autocmds = require "core.autocmds" require("settings").load_options() -local status_ok, error = pcall(vim.cmd, "luafile ~/.config/lvim/lv-config.lua") + +local status_ok, error = pcall(vim.cmd, "luafile " .. USER_CONFIG_PATH) if not status_ok then - print "something is wrong with your lv-config" + print("something is wrong with your " .. USER_CONFIG_PATH) print(error) end require("settings").load_commands() -- cgit v1.2.3