Johan Rong il y a 2 heures
Parent
commit
f380d4862c

+ 1 - 1
go.mod

@@ -19,7 +19,7 @@ require (
 	github.com/gdamore/encoding v1.0.1 // indirect
 	github.com/lucasb-eyer/go-colorful v1.4.1 // indirect
 	github.com/mattn/go-pointer v0.0.1 // indirect
-	github.com/tetratelabs/wazero v1.8.2 // indirect
+	github.com/tetratelabs/wazero v1.12.0 // indirect
 	github.com/tree-sitter/go-tree-sitter v0.25.0 // indirect
 	golang.design/x/x11 v0.2.0 // indirect
 	golang.org/x/exp/shiny v0.0.0-20260820142414-ca536658362e // indirect

+ 2 - 0
go.sum

@@ -20,6 +20,8 @@ github.com/mattn/go-pointer v0.0.1 h1:n+XhsuGeVO6MEAp7xyEukFINEa+Quek5psIR/ylA6o
 github.com/mattn/go-pointer v0.0.1/go.mod h1:2zXcozF6qYGgmsG+SeTZz3oAbFLdD3OWqnUbNvJZAlc=
 github.com/tetratelabs/wazero v1.8.2 h1:yIgLR/b2bN31bjxwXHD8a3d+BogigR952csSDdLYEv4=
 github.com/tetratelabs/wazero v1.8.2/go.mod h1:yAI0XTsMBhREkM/YDAK/zNou3GoiAce1P6+rp/wQhjs=
+github.com/tetratelabs/wazero v1.12.0 h1:DuWcpNu/FzgEXgGBDp8J1Spc+CWOvvtvVyjKlaZopYU=
+github.com/tetratelabs/wazero v1.12.0/go.mod h1:LvKtzl2RqO4gyF27BiXU+nKAjcV8f38U+kP/q2vgxh0=
 github.com/tree-sitter/go-tree-sitter v0.25.0 h1:sx6kcg8raRFCvc9BnXglke6axya12krCJF5xJ2sftRU=
 github.com/tree-sitter/go-tree-sitter v0.25.0/go.mod h1:r77ig7BikoZhHrrsjAnv8RqGti5rtSyvDHPzgTPsUuU=
 github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=

+ 0 - 64
internal/extension/highlight/highlight.go

@@ -1,64 +0,0 @@
-package highlight
-
-import (
-	"context"
-	"fmt"
-	"os"
-	"path/filepath"
-
-	sitter "github.com/tree-sitter/go-tree-sitter/bindings/go"
-)
-
-type HighlightEngine struct {
-	parser    *sitter.Parser
-	wasmDir   string
-	languages map[string]*sitter.Language
-}
-
-func NewHighlightEngine() (*HighlightEngine, error) {
-	home, err := os.UserHomeDir()
-	if err != nil {
-		return nil, err
-	}
-
-	wasmDir := filepath.Join(home, ".config", "moose", "tree-sitter")
-
-	return &HighlightEngine{
-		parser:    sitter.NewParser(),
-		wasmDir:   wasmDir,
-		languages: make(map[string]*sitter.Language),
-	}, nil
-}
-
-func (h *HighlightEngine) LoadLanguage(ctx context.Context, langName string) (*sitter.Language, error) {
-	if lang, exists := h.languages[langName]; exists {
-		return lang, nil
-	}
-
-	wasmFile := fmt.Sprintf("tree-sitter-%s.wasm", langName)
-	wasmPath := filepath.Join(h.wasmDir, wasmFile)
-
-	wasmBytes, err := os.ReadFile(wasmPath)
-	if err != nil {
-		return nil, fmt.Errorf("failed to read grammar %s: %w", wasmPath, err)
-	}
-
-	lang, err := sitter.NewWasmLanguage(ctx, wasmBytes, fmt.Sprintf("tree_sitter_%s", langName))
-	if err != nil {
-		return nil, fmt.Errorf("failed to load WASM language %s: %w", langName, err)
-	}
-
-	h.languages[langName] = lang
-	return lang, nil
-}
-
-func (h *HighlightEngine) ParseBuffer(ctx context.Context, langName string, content []byte) (*sitter.Tree, error) {
-	lang, err := h.LoadLanguage(ctx, langName)
-	if err != nil {
-		return nil, err
-	}
-
-	h.parser.SetLanguage(lang)
-	tree := h.parser.Parse(content, nil)
-	return tree, nil
-}

+ 21 - 0
internal/extension/highlight/hightlight.go

@@ -0,0 +1,21 @@
+package highlight
+
+import (
+	"context"
+
+	"github.com/tetratelabs/wazero"
+	//"github.com/tetratelabs/wazero/imports/wasi_snapshot_preview1"
+)
+
+type HighlightEngine struct {
+}
+
+func NewHighlightEngine() *HighlightEngine {
+	ctx := context.Background()
+	r := wazero.NewRuntime(ctx)
+	defer r.Close(ctx)
+
+	return &HighlightEngine {
+		
+	}
+}

+ 0 - 5
internal/extension/treesitter.go

@@ -1,5 +0,0 @@
-package extension
-
-import (
-
-)