aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrancesco Abbate <francesco.bbt@gmail.com>2022-01-04 00:25:14 +0100
committerFrancesco Abbate <francesco.bbt@gmail.com>2022-01-09 23:26:11 +0100
commit5032e7352e0570644a35f805df1df9d203836677 (patch)
tree0afbd135528156f51c9f49947b6555affb10c6f9
parenta703840068c59758bfbde2e207d19d5c10600b2e (diff)
downloadlite-xl-5032e7352e0570644a35f805df1df9d203836677.tar.gz
lite-xl-5032e7352e0570644a35f805df1df9d203836677.zip
Write an initial project module if not present
-rw-r--r--data/core/commands/core.lua3
-rw-r--r--data/core/init.lua40
2 files changed, 43 insertions, 0 deletions
diff --git a/data/core/commands/core.lua b/data/core/commands/core.lua
index 971b95f1..2ea34b2d 100644
--- a/data/core/commands/core.lua
+++ b/data/core/commands/core.lua
@@ -142,6 +142,9 @@ command.add(nil, {
end,
["core:open-project-module"] = function()
+ if not system.get_file_info(".lite_project.lua") then
+ core.try(core.write_init_project_module, ".lite_project.lua")
+ end
local doc = core.open_doc(".lite_project.lua")
core.root_view:open_doc(doc)
doc:save()
diff --git a/data/core/init.lua b/data/core/init.lua
index fcd66734..67efe11e 100644
--- a/data/core/init.lua
+++ b/data/core/init.lua
@@ -715,6 +715,46 @@ local style = require "core.style"
end
+function core.write_init_project_module(init_filename)
+ local init_file = io.open(init_filename, "w")
+ if not init_file then error("cannot create file: \"" .. init_filename .. "\"") end
+ init_file:write([[
+-- Put project's module settings here.
+-- This module will be loaded when opening a project, after the user module
+-- configuration.
+-- It will be automatically reloaded when saved.
+
+local config = require "core.config"
+
+-- you can add some patterns to ignore files within the project
+-- config.ignore_files = {"^%.", <some-patterns>}
+
+-- Patterns are normally applied to the file's or directory's name, without
+-- its path. See below about how to include the path.
+--
+-- Here some examples:
+--
+-- "^%." match any file of directory whose basename begins with a dot.
+--
+-- When there is an '/' at the end the pattern will only match directories. The final
+-- '/' is removed from the pattern to match the file's or directory's name.
+--
+-- "^%.git$/" match any directory named ".git" anywhere in the project.
+--
+-- If a "/" appears anywhere in the pattern (except at the end) then the pattern
+-- will be applied to the full path of the file or directory. An initial "/" will
+-- be prepended to the file's or directory's path to indicate the project's root.
+--
+-- "^/node_modules$/" match a directory named "node_modules" at the project's root.
+-- "^/build/" match any top level directory whose name _begins_ with "build"
+-- "^/subprojects/.+/" match any directory inside a top-level folder named "subprojects".
+
+-- You may activate some plugins on a pre-project base to override the user's settings.
+-- config.plugins.trimwitespace = true
+]])
+ init_file:close()
+end
+
function core.load_user_directory()
return core.try(function()