Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ Plugin | Description
[`gofmt`](plugins/gofmt.lua?raw=1) | Auto-formats the current go file, adds the missing imports and the missing return cases
[`hidelinenumbers`](plugins/hidelinenumbers.lua?raw=1) | Hides the line numbers on the left of documents *([screenshot](https://user-images.githubusercontent.com/3920290/81692043-b8b19c00-9455-11ea-8d74-ad99be4b9c5f.png))*
[`hidestatus`](plugins/hidestatus.lua?raw=1) | Hides the status bar at the bottom of the window
[`homeuserdata`](plugins/homeuserdata.lua?raw=1) | Loads init.lua from ~/.config/lite or ~/.lite, allowing you to save plugins or color themes on these directories and adds the 'Open Home User Module' command.
[`inanimate`](plugins/inanimate.lua?raw=1) | Disables all transition animations
[`indentguide`](plugins/indentguide.lua?raw=1) | Adds indent guides *([screenshot](https://user-images.githubusercontent.com/3920290/79640716-f9860000-818a-11ea-9c3b-26d10dd0e0c0.png))*
[`language_angelscript`](plugins/language_angelscript.lua?raw=1) | Syntax for the [Angelscript](https://www.angelcode.com/angelscript/) programming language
Expand Down
74 changes: 74 additions & 0 deletions plugins/homeuserdata.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
local core = require "core"
local command = require "core.command"
local CommandView = require "core.commandview"

-- don't execute plugin on windows
if package.cpath:match("%p[\\|/]?%p(%a+)") == "dll" then
return
end

-- check if home directory is set
local home_dir = os.getenv("HOME")

if not home_dir then
return
end

-- user configurations path in order of preference
local configs = {
home_dir .. "/.config/lite",
home_dir .. "/.lite"
}

-- load user settings
for i,dir in ipairs(configs) do
if system.get_file_info(dir) then
package.path = package.path .. ";" .. dir .. "/?/init.lua"
package.path = package.path .. ";" .. dir .. "/?.lua"

if system.get_file_info(dir .. "/init.lua") then
local init = loadfile(dir .. "/init.lua")
init()
end

break
end
end

command.add(nil, {
["core:open-home-user-module"] = function()
local directory = nil
for i,dir in ipairs(configs) do
if system.get_file_info(dir) then
directory = dir
end
end
if not directory then
directory = home_dir .. "/.config/lite"
os.execute("mkdir -p " .. directory)
end

local filename = directory .. "/init.lua"

if system.get_file_info(filename) then
core.root_view:open_doc(core.open_doc(filename))
else
local doc = core.open_doc()
core.root_view:open_doc(doc)

local content = "-- put user settings here\n\n"
.. "local keymap = require \"core.keymap\"\n"
.. "local config = require \"core.config\"\n"
.. "local style = require \"core.style\"\n\n"
.. "-- load plugins from " .. directory .. "/plugins:\n"
.. "-- require \"plugins.myplugin\"\n\n"
.. "-- load themes from " .. directory .. "/colors:\n"
.. "-- require \"colors.mytheme\"\n\n"
.. "-- key binding:\n"
.. "-- keymap.add { [\"ctrl+escape\"] = \"core:quit\" }\n"

doc:insert(1, 1, content)
doc:save(filename)
end
end,
})