load user config from user config directory

load user config and plugins from $HOME/.config/lite overriding the default
configuration, before there was no way of changing configuration per-user
master
Alessandro Mauri 4 years ago
parent 9a367d6ed9
commit efd2f19f86
  1. 3
      TODO
  2. 12
      data/core/docview.lua
  3. 19
      data/core/init.lua
  4. 28
      data/user/colors/fall.lua
  5. 28
      data/user/colors/gruvbox_dark.lua
  6. 28
      data/user/colors/summer.lua
  7. 14
      data/user/init.lua
  8. 1
      makefile
  9. 4
      src/main.c

@ -13,7 +13,8 @@
[ ] that command can be what is selected
[ ] add a cross to close tab
[ ] prevent overscrolling on treeview
[ ] user config file and/or init.lua
[x] user config file and/or init.lua
[ ] change tmp directory to somewhere in /tmp
[ ] save session and restore on reopening
[ ] optimize dir tree taking too long to load on big folders
[ ] go in background when launching from terminal

@ -305,10 +305,6 @@ end
function DocView:draw_line_body(idx, x, y)
local line, col = self.doc:get_selection()
local sw = self:get_font():get_width(" ")
local w = math.ceil(1 * SCALE)
local lh = self:get_line_height()
local color = style.guide or style.selection
-- draw selection if it overlaps this line
local line1, col1, line2, col2 = self.doc:get_selection(true)
@ -329,7 +325,13 @@ function DocView:draw_line_body(idx, x, y)
end
-- draw ruler
renderer.draw_rect(x + config.line_limit * sw, y, sw, lh, color)
if config.line_limit > 0 then
local sw = self:get_font():get_width(" ")
local w = math.ceil(1 * SCALE)
local lh = self:get_line_height()
local color = style.guide or style.selection
renderer.draw_rect(x + config.line_limit * sw, y, sw, lh, color)
end
-- draw line's text
self:draw_line_text(idx, x, y)

@ -113,14 +113,14 @@ function core.init()
core.add_thread(project_scan_thread)
command.add_defaults()
local got_plugin_error = not core.load_plugins()
local got_user_error = not core.try(require, "user")
core.try(require, "user")
local got_project_error = not core.load_project_module()
for _, filename in ipairs(files) do
core.root_view:open_doc(core.open_doc(filename))
end
if got_plugin_error or got_user_error or got_project_error then
if got_plugin_error or got_project_error then
command.perform("core:open-log")
end
end
@ -174,6 +174,7 @@ end
function core.load_plugins()
local no_errors = true
-- Load global plugins first
local files = system.list_dir(EXEDIR .. "/data/plugins")
for _, filename in ipairs(files) do
local modname = "plugins." .. filename:gsub(".lua$", "")
@ -184,6 +185,20 @@ function core.load_plugins()
no_errors = false
end
end
-- Load user plugins
local files = system.list_dir(USERDIR .. "/plugins")
if not files then
return no_errors
end
for _, filename in ipairs(files) do
local modname = "plugins." .. filename:gsub(".lua$", "")
local ok = core.try(require, modname)
if ok then
core.log_quiet("Loaded plugin %q", modname)
else
no_errors = false
end
end
return no_errors
end

@ -1,28 +0,0 @@
local style = require "core.style"
local common = require "core.common"
style.background = { common.color "#343233" }
style.background2 = { common.color "#2c2a2b" }
style.background3 = { common.color "#2c2a2b" }
style.text = { common.color "#c4b398" }
style.caret = { common.color "#61efce" }
style.accent = { common.color "#ffd152" }
style.dim = { common.color "#615d5f" }
style.divider = { common.color "#242223" }
style.selection = { common.color "#454244" }
style.line_number = { common.color "#454244" }
style.line_number2 = { common.color "#615d5f" }
style.line_highlight = { common.color "#383637" }
style.scrollbar = { common.color "#454344" }
style.scrollbar2 = { common.color "#524F50" }
style.syntax["normal"] = { common.color "#efdab9" }
style.syntax["symbol"] = { common.color "#efdab9" }
style.syntax["comment"] = { common.color "#615d5f" }
style.syntax["keyword"] = { common.color "#d36e2d" }
style.syntax["keyword2"] = { common.color "#ef6179" }
style.syntax["number"] = { common.color "#ffd152" }
style.syntax["literal"] = { common.color "#ffd152" }
style.syntax["string"] = { common.color "#ffd152" }
style.syntax["operator"] = { common.color "#efdab9" }
style.syntax["function"] = { common.color "#61efce" }

@ -1,28 +0,0 @@
local style = require "core.style"
local common = require "core.common"
style.background = { common.color "#282828" }
style.background2 = { common.color "#1d2021" }
style.background3 = { common.color "#1d2021" }
style.text = { common.color "#928374" }
style.caret = { common.color "#fbf1c7" }
style.accent = { common.color "#ebdbb2" }
style.dim = { common.color "#928374" }
style.divider = { common.color "#1d2021" }
style.selection = { common.color "#3c3836" }
style.line_number = { common.color "#928374" }
style.line_number2 = { common.color "#ebdbb2" }
style.line_highlight = { common.color "#32302f" }
style.scrollbar = { common.color "#928374" }
style.scrollbar2 = { common.color "#fbf1c7" }
style.syntax["normal"] = { common.color "#ebdbb2" }
style.syntax["symbol"] = { common.color "#ebdbb2" }
style.syntax["comment"] = { common.color "#928374" }
style.syntax["keyword"] = { common.color "#fb4934" }
style.syntax["keyword2"] = { common.color "#83a598" }
style.syntax["number"] = { common.color "#d3869b" }
style.syntax["literal"] = { common.color "#d3869b" }
style.syntax["string"] = { common.color "#b8bb26" }
style.syntax["operator"] = { common.color "#ebdbb2" }
style.syntax["function"] = { common.color "#8ec07c" }

@ -1,28 +0,0 @@
local style = require "core.style"
local common = require "core.common"
style.background = { common.color "#fbfbfb" }
style.background2 = { common.color "#f2f2f2" }
style.background3 = { common.color "#f2f2f2" }
style.text = { common.color "#404040" }
style.caret = { common.color "#fc1785" }
style.accent = { common.color "#fc1785" }
style.dim = { common.color "#b0b0b0" }
style.divider = { common.color "#e8e8e8" }
style.selection = { common.color "#b7dce8" }
style.line_number = { common.color "#d0d0d0" }
style.line_number2 = { common.color "#808080" }
style.line_highlight = { common.color "#f2f2f2" }
style.scrollbar = { common.color "#e0e0e0" }
style.scrollbar2 = { common.color "#c0c0c0" }
style.syntax["normal"] = { common.color "#181818" }
style.syntax["symbol"] = { common.color "#181818" }
style.syntax["comment"] = { common.color "#22a21f" }
style.syntax["keyword"] = { common.color "#fb6620" }
style.syntax["keyword2"] = { common.color "#fc1785" }
style.syntax["number"] = { common.color "#1586d2" }
style.syntax["literal"] = { common.color "#1586d2" }
style.syntax["string"] = { common.color "#1586d2" }
style.syntax["operator"] = { common.color "#fb6620" }
style.syntax["function"] = { common.color "#fc1785" }

@ -1,14 +0,0 @@
-- put user settings here
-- this module will be loaded after everything else when the application starts
local keymap = require "core.keymap"
local config = require "core.config"
local style = require "core.style"
-- light theme:
-- require "user.colors.summer"
require "user.colors.gruvbox_dark"
-- key binding:
-- keymap.add { ["ctrl+escape"] = "core:quit" }

@ -18,6 +18,7 @@ install: lite
mkdir -p ${DESTDIR}${PREFIX}/share/lite
cp -f lite ${DESTDIR}${PREFIX}/share/lite/lite
chmod 755 ${DESTDIR}${PREFIX}/share/lite/lite
rm -rf ${DESTDIR}${PREFIX}/share/lite/data
cp -rf data/. ${DESTDIR}${PREFIX}/share/lite/data
mkdir -p ${DESTDIR}${PREFIX}/bin
ln -sf ${DESTDIR}${PREFIX}/share/lite/lite ${DESTDIR}${PREFIX}/bin/lite

@ -95,10 +95,14 @@ int main(int argc, char **argv)
"local core\n"
"xpcall(function()\n"
" SCALE = tonumber(os.getenv(\"LITE_SCALE\")) or SCALE\n"
" USERDIR = os.getenv(\"HOME\") .. '/.config/lite'\n"
" PATHSEP = package.config:sub(1, 1)\n"
" EXEDIR = EXEFILE:match(\"^(.+)[/\\\\].*$\")\n"
" package.path = EXEDIR .. '/data/?.lua;' .. package.path\n"
" package.path = EXEDIR .. '/data/?/init.lua;' .. package.path\n"
// load user config file
" package.path = USERDIR .. '/?.lua;' .. package.path\n"
" package.path = USERDIR .. '/?/init.lua;' .. package.path\n"
" core = require('core')\n"
" core.init()\n"
" core.run()\n"

Loading…
Cancel
Save