diff options
| author | Albert Cervin <albert@acervin.com> | 2025-11-21 23:38:54 +0100 |
|---|---|---|
| committer | Albert Cervin <albert@acervin.com> | 2025-11-21 23:38:54 +0100 |
| commit | 5019b312d999f4f9c6a6acee1f047b9587c06f79 (patch) | |
| tree | caa5bac2ffda56978dc097aab7887622d439af5a /src/main/lsp.c | |
| parent | 715165b53f055b785e005984038bcae8d88142db (diff) | |
| download | dged-5019b312d999f4f9c6a6acee1f047b9587c06f79.tar.gz dged-5019b312d999f4f9c6a6acee1f047b9587c06f79.tar.xz dged-5019b312d999f4f9c6a6acee1f047b9587c06f79.zip | |
Add support for documentChanges in LSP
These should ideally be paired with setting the capability on
initialize, but for now, the parsing support is there at least for
LSP servers that ignore it (like pylsp).
Diffstat (limited to 'src/main/lsp.c')
| -rw-r--r-- | src/main/lsp.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/main/lsp.c b/src/main/lsp.c index a8e806b..6c5999c 100644 --- a/src/main/lsp.c +++ b/src/main/lsp.c @@ -12,6 +12,7 @@ #include "dged/minibuffer.h" #include "dged/reactor.h" #include "dged/settings.h" +#include "dged/vec.h" #include "dged/window.h" #include "lsp/references.h" @@ -790,6 +791,25 @@ bool apply_edits(struct lsp_server *server, buffer_push_undo_boundary(b); } + VEC_FOR_EACH(&ws_edit->document_changes, struct text_document_edit * edit) { + if (VEC_EMPTY(&edit->edits)) { + continue; + } + + const char *p = s8tocstr(edit->text_document.uri); + struct buffer *b = buffers_find_by_filename(g_lsp_data.buffers, &p[7]); + + if (b == NULL) { + struct buffer new_buf = buffer_from_file(&p[7]); + b = buffers_add(g_lsp_data.buffers, new_buf); + } + + free((void *)p); + buffer_push_undo_boundary(b); + apply_edits_buffer(server, b, edit->edits, NULL); + buffer_push_undo_boundary(b); + } + resume_completion(); return true; } |
