Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions function-hcl-ls/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
vendor/
cover.out
spec.md
.claude/
8 changes: 8 additions & 0 deletions function-hcl-ls/.golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
version: "2"
linters:
exclusions:
rules:
# exclude unused checks from protocol generated code.
- path: internal/langserver/protocol/
linters:
- unused
19 changes: 19 additions & 0 deletions function-hcl-ls/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@

.PHONY: default
default: build test lint

.PHONY: build
build:
go install ./...

.PHONY: test
test:
go test ./...

.PHONY: fmt
fmt:
gofumpt -w .

.PHONY: lint
lint:
golangci-lint run
35 changes: 35 additions & 0 deletions function-hcl-ls/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
function-hcl-ls
---

A language server implementation for function-hcl.

Provides the following features:

* Completion
* Hover descriptions
* Goto Declaration/ Find references
* Semantic tokens
* Validations and inline errors
* Code folding

Completion requires provider CRDs to be set up such that the language server can find type definitions.

The exact mechanics of how to set this up along with IDE integration will be documented under
[the docs page](https://crossplane-contrib.github.io/function-hcl/) when the client code is added to the repo.

## Standing on the shoulders of giants

This repo owes a lot to the [HCL language library](https://github.com/hashicorp/hcl-lang) and
the [Terraform language server](https://github.com/hashicorp/terraform-ls) implementation.

This repo contains code copied from the above repos and modified for use. Since function-hcl is different
enough from Terraform, the borrowed code did not work well for it but gave the authors a great starting
point. A lot of refactoring has been done on both these copied codebases to make the language server
work for function-hcl.

In addition, the `go.mod` replaces the [HCL dependency](https://github.com/hashicorp/hcl)
with a [fork](https://github.com/gotwarlost/hcl) because of a [critical fix](https://github.com/hashicorp/hcl/pull/785)
for a [known issue](https://github.com/hashicorp/hcl/issues/597) that is needed.

You cannot build this repo using `go install github.com/...` because of this. For source builds, you will need to clone
the repo and build it locally.
107 changes: 107 additions & 0 deletions function-hcl-ls/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
module github.com/crossplane-contrib/function-hcl/function-hcl-ls

go 1.25

require (
github.com/apparentlymart/go-textseg v1.0.0
github.com/bmatcuk/doublestar/v4 v4.9.1
github.com/creachadair/jrpc2 v1.3.2
github.com/crossplane-contrib/function-hcl v0.1.4-0.20260213150247-c08e518c903a
github.com/crossplane/crossplane-runtime/v2 v2.1.0
github.com/crossplane/crossplane/v2 v2.1.3
github.com/ghodss/yaml v1.0.0
github.com/google/go-cmp v0.7.0
github.com/google/go-containerregistry v0.20.6
github.com/hashicorp/go-uuid v1.0.3
github.com/hashicorp/go-version v1.7.0
github.com/hashicorp/hcl/v2 v2.24.0
github.com/pkg/errors v0.9.1
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2
github.com/spf13/cobra v1.9.1
github.com/stretchr/testify v1.11.1
github.com/zclconf/go-cty v1.17.0
github.com/zclconf/go-cty-debug v0.0.0-20240509010212-0d6042c53940
k8s.io/api v0.34.2
k8s.io/apiextensions-apiserver v0.34.2
k8s.io/apimachinery v0.34.2
)

replace github.com/hashicorp/hcl/v2 => github.com/gotwarlost/hcl/v2 v2.0.0-20260210011329-0927384ef641

require (
dario.cat/mergo v1.0.2 // indirect
github.com/agext/levenshtein v1.2.3 // indirect
github.com/apparentlymart/go-cidr v1.1.0 // indirect
github.com/apparentlymart/go-textseg/v15 v15.0.0 // indirect
github.com/containerd/stargz-snapshotter/estargz v0.16.3 // indirect
github.com/creachadair/mds v0.25.1 // indirect
github.com/crossplane/crossplane-runtime v1.20.0 // indirect
github.com/crossplane/function-sdk-go v0.4.0 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/docker/cli v28.2.2+incompatible // indirect
github.com/docker/distribution v2.8.3+incompatible // indirect
github.com/docker/docker-credential-helpers v0.9.3 // indirect
github.com/emicklei/go-restful/v3 v3.12.2 // indirect
github.com/evanphx/json-patch/v5 v5.9.11 // indirect
github.com/fxamacker/cbor/v2 v2.9.0 // indirect
github.com/go-logr/logr v1.4.3 // indirect
github.com/go-logr/zapr v1.3.0 // indirect
github.com/go-openapi/jsonpointer v0.21.0 // indirect
github.com/go-openapi/jsonreference v0.21.0 // indirect
github.com/go-openapi/swag v0.23.0 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/google/gnostic-models v0.7.0 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/klauspost/compress v1.18.0 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/mattn/go-colorable v0.1.14 // indirect
github.com/mitchellh/go-homedir v1.1.0 // indirect
github.com/mitchellh/go-wordwrap v1.0.1 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.3-0.20250322232337-35a7c28c31ee // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/onsi/ginkgo/v2 v2.23.3 // indirect
github.com/onsi/gomega v1.37.0 // indirect
github.com/opencontainers/go-digest v1.0.0 // indirect
github.com/opencontainers/image-spec v1.1.1 // indirect
github.com/sirupsen/logrus v1.9.3 // indirect
github.com/spf13/afero v1.12.0 // indirect
github.com/spf13/pflag v1.0.6 // indirect
github.com/vbatts/tar-split v0.12.1 // indirect
github.com/x448/float16 v0.8.4 // indirect
github.com/zclconf/go-cty-yaml v1.1.0 // indirect
go.opentelemetry.io/otel v1.38.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.27.0 // indirect
go.yaml.in/yaml/v2 v2.4.2 // indirect
go.yaml.in/yaml/v3 v3.0.4 // indirect
golang.org/x/crypto v0.45.0 // indirect
golang.org/x/mod v0.30.0 // indirect
golang.org/x/net v0.47.0 // indirect
golang.org/x/oauth2 v0.30.0 // indirect
golang.org/x/sync v0.18.0 // indirect
golang.org/x/sys v0.38.0 // indirect
golang.org/x/term v0.37.0 // indirect
golang.org/x/text v0.31.0 // indirect
golang.org/x/time v0.11.0 // indirect
golang.org/x/tools v0.39.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20250303144028-a0af3efb3deb // indirect
google.golang.org/grpc v1.72.1 // indirect
google.golang.org/protobuf v1.36.6 // indirect
gopkg.in/evanphx/json-patch.v4 v4.12.0 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
k8s.io/client-go v0.34.2 // indirect
k8s.io/klog/v2 v2.130.1 // indirect
k8s.io/kube-openapi v0.0.0-20250710124328-f3f2b991d03b // indirect
k8s.io/utils v0.0.0-20250604170112-4c0f3b243397 // indirect
sigs.k8s.io/controller-runtime v0.22.2 // indirect
sigs.k8s.io/json v0.0.0-20241014173422-cfa47c3a1cc8 // indirect
sigs.k8s.io/randfill v1.0.0 // indirect
sigs.k8s.io/structured-merge-diff/v6 v6.3.0 // indirect
sigs.k8s.io/yaml v1.6.0 // indirect
)
Loading
Loading