2 Commits

Author SHA1 Message Date
e37d291e1d Cleanup 2026-01-10 19:29:56 +00:00
78bf2d666d Completions bug fixes and switch to a better html lsp 2026-01-10 19:24:38 +00:00
5 changed files with 15 additions and 9 deletions

View File

@@ -72,7 +72,7 @@ The following lsp's are supported and can be installed anywhere in your `$PATH`<
* [fish-lsp](https://github.com/ndonfris/fish-lsp) * [fish-lsp](https://github.com/ndonfris/fish-lsp)
* [gopls](https://pkg.go.dev/golang.org/x/tools/gopls) * [gopls](https://pkg.go.dev/golang.org/x/tools/gopls)
* [haskell-language-server](https://github.com/haskell/haskell-language-server) * [haskell-language-server](https://github.com/haskell/haskell-language-server)
* [emmet-ls](https://github.com/aca/emmet-ls) *Autocompletion for emmet works but doesn't show popup correctly for now, use ctrl+\\ to run after writing emmet code* * [emmet-language-server](https://github.com/olrtg/emmet-language-server)
* [typescript-language-server](https://github.com/typescript-language-server/typescript-language-server) * [typescript-language-server](https://github.com/typescript-language-server/typescript-language-server)
* [lua-language-server](https://github.com/LuaLS/lua-language-server) * [lua-language-server](https://github.com/LuaLS/lua-language-server)
* [pyright-langserver](https://github.com/microsoft/pyright) * [pyright-langserver](https://github.com/microsoft/pyright)
@@ -292,6 +292,7 @@ Activated by `:` or `;`.
- diagnostics - diagnostics
- autocompletion - autocompletion
- hover docs (with markdown support) - hover docs (with markdown support)
- formatting *(very few lsp's support this - try to configure a few more which can but need configuration and for others need to add support for external formatters)*
- A list of all supported lsp's can be found [here](#lsps). - A list of all supported lsp's can be found [here](#lsps).
**A lot lot more to come** **A lot lot more to come**

View File

@@ -21,6 +21,7 @@ Copyright 2025 Syed Daanish
- [ ] For `"insertTextFormat": 2` in `clangd` and similar use only the last word in the signature when replacing - [ ] For `"insertTextFormat": 2` in `clangd` and similar use only the last word in the signature when replacing
- [ ] Keep a list of words in the current buffer. (for auto completion) (maybe?) - [ ] Keep a list of words in the current buffer. (for auto completion) (maybe?)
- [ ] Add ecma to js and make tsx - [ ] Add ecma to js and make tsx
- [ ] Add formatting for files whose lsp doesnt.
- [ ] Switch to like `RapidJSON` ro something more basic but faster than rn - [ ] Switch to like `RapidJSON` ro something more basic but faster than rn
- also decrease use of `std::string` so much in ui stuff and lsp and warnings etc. - also decrease use of `std::string` so much in ui stuff and lsp and warnings etc.
- [ ] Add lsp jumping support for goto definition, hover etc. - [ ] Add lsp jumping support for goto definition, hover etc.

View File

@@ -75,9 +75,9 @@ static const std::unordered_map<uint8_t, LSP> kLsps = {
nullptr, nullptr,
}}}, }}},
{10, {10,
{"emmet-ls", {"emmet-language-server",
{ {
"emmet-ls", "emmet-language-server",
"--stdio", "--stdio",
nullptr, nullptr,
}}}, }}},

View File

@@ -52,11 +52,11 @@ void completion_filter(Editor *editor) {
void completion_request(Editor *editor) { void completion_request(Editor *editor) {
Coord hook = editor->cursor; Coord hook = editor->cursor;
word_boundaries(editor, editor->cursor, &hook.col, nullptr, nullptr, nullptr); word_boundaries(editor, editor->cursor, &hook.col, nullptr, nullptr, nullptr);
editor->completion.hook = hook;
editor->completion.active = true; editor->completion.active = true;
editor->completion.items.clear(); editor->completion.items.clear();
editor->completion.visible.clear(); editor->completion.visible.clear();
editor->completion.select = 0; editor->completion.select = 0;
editor->completion.hook = hook;
LSPPending *pending = new LSPPending(); LSPPending *pending = new LSPPending();
pending->editor = editor; pending->editor = editor;
pending->method = "textDocument/completion"; pending->method = "textDocument/completion";
@@ -94,6 +94,7 @@ void completion_request(Editor *editor) {
} }
} }
session.items.reserve(items_json.size() + 1); session.items.reserve(items_json.size() + 1);
session.visible.reserve(items_json.size() + 1);
for (auto &item_json : items_json) { for (auto &item_json : items_json) {
CompletionItem item; CompletionItem item;
item.original = item_json; item.original = item_json;
@@ -190,8 +191,8 @@ void completion_request(Editor *editor) {
if (c.is_string() && c.get<std::string>().size() == 1) if (c.is_string() && c.get<std::string>().size() == 1)
item.end_chars.push_back(c.get<std::string>()[0]); item.end_chars.push_back(c.get<std::string>()[0]);
session.items.push_back(std::move(item)); session.items.push_back(std::move(item));
session.visible.push_back(session.items.size() - 1);
} }
completion_filter(editor);
session.box.hidden = false; session.box.hidden = false;
session.box.render_update(); session.box.render_update();
}; };
@@ -268,7 +269,7 @@ void handle_completion(Editor *editor, KeyEvent event) {
completion_request(editor); completion_request(editor);
} }
} else if (ch == CTRL('\\')) { } else if (ch == CTRL('\\')) {
if (editor->completion.active) { if (editor->completion.active && editor->completion.visible.size()) {
complete_accept(editor); complete_accept(editor);
} else { } else {
editor->completion.trigger = 1; editor->completion.trigger = 1;
@@ -280,7 +281,7 @@ void handle_completion(Editor *editor, KeyEvent event) {
} else if (ch == CTRL('o')) { } else if (ch == CTRL('o')) {
if (editor->completion.active) if (editor->completion.active)
complete_prev(editor); complete_prev(editor);
} else if (ch == 0x7F || ch == 0x08) { } else if (ch == 0x7F || ch == 0x08 || ch == CTRL('W')) {
if (editor->completion.active) { if (editor->completion.active) {
if (editor->completion.complete) { if (editor->completion.complete) {
if (editor->cursor <= editor->completion.hook) if (editor->cursor <= editor->completion.hook)
@@ -288,7 +289,10 @@ void handle_completion(Editor *editor, KeyEvent event) {
else else
completion_filter(editor); completion_filter(editor);
} else { } else {
completion_request(editor); if (editor->cursor <= editor->completion.hook)
editor->completion.active = false;
else
completion_request(editor);
} }
} }
} else { } else {