diff options
| author | Francesco Abbate <francesco.bbt@gmail.com> | 2022-01-04 00:25:14 +0100 |
|---|---|---|
| committer | Francesco Abbate <francesco.bbt@gmail.com> | 2022-01-04 00:25:14 +0100 |
| commit | d4dba77dc03d309112a625ec6e0d2568adadfe96 (patch) | |
| tree | 8320e7bbcacaad5184e15c80d009b31ab1c5f38d | |
| parent | 1e312a97bc8ab808a4c6b94417ab2982bad97e20 (diff) | |
| download | lite-xl-path-ignore-files.tar.gz lite-xl-path-ignore-files.zip | |
Write an initial project module if not presentpath-ignore-files
| -rw-r--r-- | data/core/commands/core.lua | 3 | ||||
| -rw-r--r-- | data/core/init.lua | 40 |
2 files changed, 43 insertions, 0 deletions
diff --git a/data/core/commands/core.lua b/data/core/commands/core.lua index 3242e2ef..fa79cbdd 100644 --- a/data/core/commands/core.lua +++ b/data/core/commands/core.lua @@ -141,6 +141,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 9b06b09d..79da057b 100644 --- a/data/core/init.lua +++ b/data/core/init.lua @@ -700,6 +700,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() |
