From b106fe19b55e9fe3348b3a5c9992c21dac27b02c Mon Sep 17 00:00:00 2001 From: Zuhaitz Méndez Fernández de Aránguiz Date: Tue, 20 Jan 2026 12:51:23 +0000 Subject: Working a bit on the LSP + fixed some bugs --- src/lsp/lsp_project.h | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 src/lsp/lsp_project.h (limited to 'src/lsp/lsp_project.h') diff --git a/src/lsp/lsp_project.h b/src/lsp/lsp_project.h new file mode 100644 index 0000000..9b4fe42 --- /dev/null +++ b/src/lsp/lsp_project.h @@ -0,0 +1,59 @@ +#ifndef LSP_PROJECT_H +#define LSP_PROJECT_H + +#include "parser.h" +#include "lsp_index.h" + +typedef struct ProjectFile +{ + char *path; // Absolute path + char *uri; // file:// URI + char *source; // Cached source content + LSPIndex *index; // File-specific index (local vars, refs) + struct ProjectFile *next; +} ProjectFile; + +typedef struct +{ + // Global symbol table (Structs, Functions, Globals) + // We reuse ParserContext for this, as it already supports registries. + ParserContext *ctx; + + // List of tracked files + ProjectFile *files; + + // Root directory + char *root_path; +} LSPProject; + +// Global project instance +extern LSPProject *g_project; + +// Initialize the project with a root directory +void lsp_project_init(const char *root_path); + +// Find a file in the project +ProjectFile *lsp_project_get_file(const char *uri); + +// Update a file (re-parse and re-index) +void lsp_project_update_file(const char *uri, const char *src); + +// Find definition globally +typedef struct +{ + char *uri; + LSPRange *range; +} DefinitionResult; + +DefinitionResult lsp_project_find_definition(const char *name); + +typedef struct ReferenceResult +{ + char *uri; + LSPRange *range; + struct ReferenceResult *next; +} ReferenceResult; + +ReferenceResult *lsp_project_find_references(const char *name); + +#endif -- cgit v1.2.3