From 3e74a27e639019f39779a2819ac0ecc88b3f480a Mon Sep 17 00:00:00 2001 From: SerhiiCho Date: Thu, 15 May 2025 16:03:33 +0300 Subject: [PATCH 1/3] docs: update changelod and makefile --- CHANGELOG.md | 15 +++++++++------ Makefile | 4 ++++ 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9f25d6c..31163e5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,16 +1,19 @@ # Release Notes +## v0.1.2 (2025-05-15) +- 🐛 Fixed bug with autocompletion not working properly on vscode editor + ## v0.1.1 (2025-05-12) -- Fixed issue with autocompletion not working properly in some cases +- 🐛 Fixed bug with autocompletion not working properly in some cases ## v0.1.0 (2025-05-03) -- Added `build.yml` file for GitHub actions to build releases with all LSP binaries +- ✨ Added `build.yml` file for GitHub actions to build releases with all LSP binaries ## v0.0.2 (2025-04-25) -- Improved logger -- Add generating `build-version` file to `bin` directory +- ✨ Improved logger +- ✨ Added generating `build-version` file to `bin` directory ## v0.0.1 (2025-04-16) -- Added completions for directives -- Added showing hover information for directives +- ✨ Added completions for directives +- ✨ Added showing hover information for directives diff --git a/Makefile b/Makefile index ddb4467..f6ff08c 100644 --- a/Makefile +++ b/Makefile @@ -11,4 +11,8 @@ push: git push @echo "✅ Pushed to GitHub!" +.PHONE: build +build: + go build main.go + .DEFAULT_GOAL := test From bdc3bdd8fe3d1054f9ab70190d177eb051b659b8 Mon Sep 17 00:00:00 2001 From: SerhiiCho Date: Thu, 15 May 2025 16:04:24 +0300 Subject: [PATCH 2/3] fix: add FilterText field to completion items vscode requires it for proper display --- analysis/completion.go | 1 + lsp/textdocument_completion.go | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/analysis/completion.go b/analysis/completion.go index f4d0a6c..9765414 100644 --- a/analysis/completion.go +++ b/analysis/completion.go @@ -47,6 +47,7 @@ func (s *State) Completion(id int, uri string, pos lsp.Position) (lsp.Completion items = append(items, lsp.CompletionItem{ Label: dir.Label, + FilterText: dir.Insert, InsertText: dir.Insert, Documentation: dir.Documentation, LabelDetails: &lsp.CompletionItemLabelDetails{ diff --git a/lsp/textdocument_completion.go b/lsp/textdocument_completion.go index a660fed..25630a5 100644 --- a/lsp/textdocument_completion.go +++ b/lsp/textdocument_completion.go @@ -73,6 +73,11 @@ type CompletionItem struct { // be an unqualified name of the completion item. Label string `json:"label"` + // A string that should be used when filtering a set of + // completion items. When omitted the label is used as the + // filter text for this item. + FilterText string `json:"filterText,omitempty"` + // LabelDetails is additional details for the label. LabelDetails *CompletionItemLabelDetails `json:"labelDetails,omitempty"` From dfd46ee6ecc7b3bc0bd834acfd3fa1eadbe3ef63 Mon Sep 17 00:00:00 2001 From: SerhiiCho Date: Thu, 15 May 2025 18:05:20 +0300 Subject: [PATCH 3/3] refactor: remove filtering of completion result editors do filter themselves, we don't need to filter on the server --- analysis/completion.go | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/analysis/completion.go b/analysis/completion.go index 9765414..0e729ee 100644 --- a/analysis/completion.go +++ b/analysis/completion.go @@ -1,7 +1,6 @@ package analysis import ( - "regexp" "strings" "github.com/textwire/lsp/lsp" @@ -20,19 +19,6 @@ func (s *State) Completion(id int, uri string, pos lsp.Position) (lsp.Completion return s.completionResponse(id, nil), nil } - line := lines[pos.Line] - cursorPos := int(pos.Character) - textBeforeCursor := line[:cursorPos] - - directiveRegex := regexp.MustCompile(`(^|[^\\])@(\w*)$`) - directiveMatch := directiveRegex.FindStringSubmatch(textBeforeCursor) - - if directiveMatch == nil { - return s.completionResponse(id, []lsp.CompletionItem{}), nil - } - - directiveName := directiveMatch[2] - directives, err := completions.GetDirectives("en") if err != nil { return lsp.CompletionResponse{}, err @@ -41,10 +27,6 @@ func (s *State) Completion(id int, uri string, pos lsp.Position) (lsp.Completion items := make([]lsp.CompletionItem, 0, len(directives)) for _, dir := range directives { - if !strings.HasPrefix(dir.Insert, directiveName) { - continue - } - items = append(items, lsp.CompletionItem{ Label: dir.Label, FilterText: dir.Insert,