#ifndef EXTENTION_COMPLETION_H #define EXTENTION_COMPLETION_H #include "editor/decl.h" #include "io/sysio.h" #include "pch.h" #include "utils/utils.h" #include "windows/decl.h" struct CompletionItem { std::string label; uint8_t kind; std::optional detail; std::optional documentation; bool is_markup = false; bool deprecated = false; bool asis = true; std::string sort; std::string filter; bool snippet = false; std::vector edits; json original; std::vector end_chars; }; struct CompletionBox : Popup { struct CompletionSession *session; CompletionBox() { this->hidden = true; } void render(std::vector &buffer, Coord size, Coord pos) override; void handle_click(KeyEvent, Coord) override { this->hidden = true; } ~CompletionBox() {} }; struct CompletionSession { struct Editor *editor; std::shared_mutex mtx; bool active = false; Coord hook; uint32_t select = 0; uint32_t scroll = 0; std::vector items; std::vector visible; bool complete = true; std::optional trigger_char; uint8_t trigger = 0; CompletionBox *box = nullptr; uint32_t doc = UINT32_MAX; std::atomic hover_dirty = false; int version; CompletionSession(Editor *editor) : editor(editor) {} void resolve_doc(); void accept(); void next(); void prev(); void choose(uint8_t index); void handle(KeyEvent event); }; CompletionBox *init_completion_box(CompletionSession *session); void completion_request(Editor *editor); void completion_filter(Editor *editor); #endif