Skip to content

Commit

Permalink
refactor: vendor LSP code, and reduce dependencies, fixes #1050 (#1054)
Browse files Browse the repository at this point in the history
  • Loading branch information
a-h authored Jan 27, 2025
1 parent 8501201 commit 0474dd9
Show file tree
Hide file tree
Showing 78 changed files with 34,530 additions and 304 deletions.
2 changes: 1 addition & 1 deletion .version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.3.828
0.3.832
2 changes: 1 addition & 1 deletion cmd/templ/generatecmd/fatalerror.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ func (e FatalError) Is(target error) bool {
return ok
}

func (e FatalError) As(target interface{}) bool {
func (e FatalError) As(target any) bool {
_, ok := target.(*FatalError)
return ok
}
12 changes: 6 additions & 6 deletions cmd/templ/lspcmd/httpdebug/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@ package httpdebug
import (
"encoding/json"
"io"
"log/slog"
"net/http"
"net/url"

"github.com/a-h/templ"
"github.com/a-h/templ/cmd/templ/lspcmd/proxy"
"github.com/a-h/templ/cmd/templ/visualize"
"go.uber.org/zap"
)

var log *zap.Logger
var log *slog.Logger

func NewHandler(l *zap.Logger, s *proxy.Server) http.Handler {
func NewHandler(l *slog.Logger, s *proxy.Server) http.Handler {
m := http.NewServeMux()
log = l
m.HandleFunc("/templ", func(w http.ResponseWriter, r *http.Request) {
Expand Down Expand Up @@ -112,19 +112,19 @@ func JSON(w http.ResponseWriter, v any) {
enc := json.NewEncoder(w)
enc.SetIndent("", " ")
if err := enc.Encode(v); err != nil {
log.Error("failed to write JSON response", zap.Error(err))
log.Error("failed to write JSON response", slog.Any("error", err))
}
}

func String(w http.ResponseWriter, s string) {
if _, err := io.WriteString(w, s); err != nil {
log.Error("failed to write string response", zap.Error(err))
log.Error("failed to write string response", slog.Any("error", err))
}
}

func Error(w http.ResponseWriter, msg string, status int) {
w.WriteHeader(status)
if _, err := io.WriteString(w, msg); err != nil {
log.Error("failed to write error response", zap.Error(err))
log.Error("failed to write error response", slog.Any("error", err))
}
}
Loading

0 comments on commit 0474dd9

Please sign in to comment.