project.lua |
|
---|---|
The common.project module tries to figure out the project root directory for a given file. If you have a directory structure like
the function root returns project1 for |
local M = {}
|
Fields |
|
This
The default value contains Textadept's directory and the user's modules directory. |
M.DIRS = { _HOME, _USERHOME..'/modules' }
|
Commands |
|
Match a file's path with project root directories and try to return the project root. If the project root is not found the file's directory is returned. |
function M.root()
local filename = buffer.filename
local project_root
if filename then
for i=1, #M.DIRS do
project_root = filename:match('('..M.DIRS[i]..'[/\\][^/\\]+)[/\\].+')
if project_root then
break
end
end
end
return project_root or buffer.filename:match('(.+)[/\\]')
end
return M
|