diff options
author | pommicket <pommicket@gmail.com> | 2022-12-24 00:28:50 -0500 |
---|---|---|
committer | pommicket <pommicket@gmail.com> | 2022-12-24 00:28:50 -0500 |
commit | 1c346f2aba30fcb581f20f2b67bd5e6adcb4a7e6 (patch) | |
tree | 863b8ebbd37c67cb4dd0015d5c72a436dd89bc7e /ted.c | |
parent | 8d96a4b0f0ebb059a63cc4c3193e0169ccf4f5b5 (diff) |
find build directory in a much better way
this will be useful for LSPs
Diffstat (limited to 'ted.c')
-rw-r--r-- | ted.c | 12 |
1 files changed, 12 insertions, 0 deletions
@@ -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); |