Cleanup and ui bar

This commit is contained in:
2026-01-03 17:46:04 +00:00
parent 0390a1bc5d
commit ac04754318
18 changed files with 210 additions and 77 deletions

View File

@@ -167,42 +167,44 @@ static const std::unordered_map<uint8_t, LSP> kLsps = {
};
static const std::unordered_map<std::string, Language> kLanguages = {
{"bash", {"bash", LANG(bash), 4}},
{"c", {"c", LANG(cpp), 1}},
{"cpp", {"cpp", LANG(cpp), 1}},
{"h", {"h", LANG(cpp), 1}},
{"css", {"css", LANG(css), 5}},
{"fish", {"fish", LANG(fish), 7}},
{"go", {"go", LANG(go), 8}},
{"gomod", {"gomod", LANG(gomod), 8}},
{"haskell", {"haskell", LANG(haskell), 9}},
{"html", {"html", LANG(html), 10}},
{"javascript", {"javascript", LANG(javascript), 11}},
{"typescript", {"typescript", LANG(tsx), 11}},
{"json", {"json", LANG(json), 6}},
{"jsonc", {"jsonc", LANG(json), 6}},
{"erb", {"erb", LANG(embedded_template), 10}},
{"ruby", {"ruby", LANG(ruby), 3}},
{"lua", {"lua", LANG(lua), 12}},
{"python", {"python", LANG(python), 13}},
{"rust", {"rust", LANG(rust), 14}},
{"php", {"php", LANG(php), 15}},
{"markdown", {"markdown", LANG(markdown), 16}},
{"markdown_inline", {"markdown_inline", LANG(markdown_inline), 16}},
{"nginx", {"nginx", LANG(nginx), 17}},
{"toml", {"toml", LANG(toml), 18}},
{"yaml", {"yaml", LANG(yaml), 19}},
{"sql", {"sql", LANG(sql), 20}}, // Can use `22` for more accuracy but need
// config to connect to database
{"make", {"make", LANG(make), 21}},
{"gdscript", {"gdscript", LANG(gdscript)}}, // TODO: connect to godot
{"man", {"man", LANG(man)}},
{"diff", {"diff", LANG(diff)}},
{"gitattributes", {"gitattributes", LANG(gitattributes)}},
{"gitignore", {"gitignore", LANG(gitignore)}},
{"query", {"query", LANG(query)}},
{"regex", {"regex", LANG(regex)}},
{"ini", {"ini", LANG(ini)}},
{"bash", {"bash", LANG(bash), 4, 0x4d5a5e, ""}},
{"c", {"c", LANG(cpp), 1, 0x555555, ""}},
{"cpp", {"cpp", LANG(cpp), 1, 0x00599C, ""}},
{"h", {"h", LANG(cpp), 1, 0xA8B9CC, ""}},
{"css", {"css", LANG(css), 5, 0x36a3d9, ""}},
{"fish", {"fish", LANG(fish), 7, 0x4d5a5e, ""}},
{"go", {"go", LANG(go), 8, 0x00add8, ""}},
{"gomod", {"gomod", LANG(gomod), 8, 0x00add8, ""}},
{"haskell", {"haskell", LANG(haskell), 9, 0xa074c4, ""}},
{"html", {"html", LANG(html), 10, 0xef8a91, ""}},
{"javascript", {"javascript", LANG(javascript), 11, 0xf0df8a, ""}},
{"typescript", {"typescript", LANG(tsx), 11, 0x36a3d9, ""}},
{"json", {"json", LANG(json), 6, 0xcbcb41, "{}"}},
{"jsonc", {"jsonc", LANG(json), 6, 0xcbcb41, "{}"}},
{"erb", {"erb", LANG(embedded_template), 10, 0x6e1516, ""}},
{"ruby", {"ruby", LANG(ruby), 3, 0xff8087, "󰴭 "}},
{"lua", {"lua", LANG(lua), 12, 0x36a3d9, "󰢱 "}},
{"python", {"python", LANG(python), 13, 0x95e6cb, "󰌠 "}},
{"rust", {"rust", LANG(rust), 14, 0xdea584, "󱘗 "}},
{"php", {"php", LANG(php), 15, 0xa074c4, "󰌟 "}},
{"markdown", {"markdown", LANG(markdown), 16, 0x36a3d9, ""}},
{"markdown_inline",
{"markdown_inline", LANG(markdown_inline), 16, 0x36a3d9, ""}},
{"nginx", {"nginx", LANG(nginx), 17, 0x6d8086, ""}},
{"toml", {"toml", LANG(toml), 18, 0x36a3d9, ""}},
{"yaml", {"yaml", LANG(yaml), 19, 0x6d8086, ""}},
{"sql", {"sql", LANG(sql), 20, 0xdad8d8, ""}},
{"make", {"make", LANG(make), 21, 0x4e5c61, ""}},
{"gdscript", {"gdscript", LANG(gdscript), 0, 0x6d8086, ""}},
{"man", {"man", LANG(man), 0, 0xdad8d8, ""}},
{"diff", {"diff", LANG(diff), 0, 0xDD4C35, ""}},
{"gitattributes",
{"gitattributes", LANG(gitattributes), 0, 0xF05032, ""}},
{"gitignore", {"gitignore", LANG(gitignore), 0, 0xF05032, ""}},
{"query", {"query", LANG(query), 0, 0x7E57C2, ""}},
{"regex", {"regex", LANG(regex), 0, 0x9E9E9E, ".*"}},
{"ini", {"ini", LANG(ini), 0, 0x6d8086, ""}},
};
static const std::unordered_map<std::string, std::string> kExtToLang = {

View File

@@ -1,12 +1,12 @@
#ifndef EDITOR_H
#define EDITOR_H
#include "ui/diagnostics.h"
#include "ui/hover.h"
#include "editor/spans.h"
#include "io/knot.h"
#include "io/sysio.h"
#include "ts/decl.h"
#include "ui/diagnostics.h"
#include "ui/hover.h"
#include "utils/utils.h"
#define CHAR 0
@@ -29,6 +29,7 @@ struct Editor {
Coord position;
Coord size;
Coord scroll;
Language lang;
TSSetMain ts;
Queue<TSInputEdit> edit_queue;
std::vector<Fold> folds;

View File

@@ -10,6 +10,8 @@
#define JUMPER 4
extern std::atomic<bool> running;
extern uint8_t mode;
extern std::atomic<uint8_t> mode;
extern std::vector<struct Editor *> editors;
extern uint8_t current_editor;
#endif

View File

@@ -9,7 +9,9 @@
struct Language {
std::string name;
const TSLanguage *(*fn)();
uint8_t lsp_id = 0;
uint8_t lsp_id;
uint32_t color = 0xFFFFFF;
const char *symbol = "";
};
struct Highlight {

View File

@@ -1,6 +1,19 @@
#ifndef UI_BAR_H
#define UI_BAR_H
#include "editor/editor.h"
#include "io/sysio.h"
#include "utils/utils.h"
struct Bar {
Coord screen;
std::string command = "";
int cursor = 0;
Bar(Coord screen) : screen(screen) {}
void render();
void handle(KeyEvent event);
void log(std::string message);
};
#endif

View File

@@ -79,6 +79,7 @@ void log(const char *fmt, ...);
std::string path_abs(const std::string &path_str);
std::string path_to_file_uri(const std::string &path_str);
std::string filename_from_path(const std::string &path);
std::string get_exe_dir();
char *load_file(const char *path, uint32_t *out_len);
char *detect_file_type(const char *filename);