summaryrefslogtreecommitdiff
path: root/ted.c
diff options
context:
space:
mode:
authorpommicket <pommicket@gmail.com>2022-12-24 00:28:50 -0500
committerpommicket <pommicket@gmail.com>2022-12-24 00:28:50 -0500
commit1c346f2aba30fcb581f20f2b67bd5e6adcb4a7e6 (patch)
tree863b8ebbd37c67cb4dd0015d5c72a436dd89bc7e /ted.c
parent8d96a4b0f0ebb059a63cc4c3193e0169ccf4f5b5 (diff)
find build directory in a much better way
this will be useful for LSPs
Diffstat (limited to 'ted.c')
-rw-r--r--ted.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/ted.c b/ted.c
index 8bc4f18..9000676 100644
--- a/ted.c
+++ b/ted.c
@@ -48,6 +48,18 @@ static void *ted_realloc(Ted *ted, void *p, size_t new_size) {
return ret;
}
+// get the project root directory (based on the active buffer or ted->cwd if there's no active buffer).
+// the return value should be freed
+char *ted_get_root_dir(Ted *ted) {
+ Settings *settings = ted_active_settings(ted);
+ TextBuffer *buffer = ted->active_buffer;
+ if (buffer) {
+ return settings_get_root_dir(settings, buffer->filename);
+ } else {
+ return settings_get_root_dir(settings, ted->cwd);
+ }
+}
+
Settings *ted_active_settings(Ted *ted) {
if (ted->active_buffer)
return buffer_settings(ted->active_buffer);