Skip to content

Add underscore as a completion trigger character - #153

Merged
diofeher merged 1 commit into
mainfrom
underscore
Mar 7, 2026
Merged

Add underscore as a completion trigger character#153
diofeher merged 1 commit into
mainfrom
underscore

Conversation

@Yantrio

@Yantrio Yantrio commented Feb 11, 2026

Copy link
Copy Markdown
Member

This allows editors to request completions easier when a end-user inputs "_" inside a resource type label for example, (e.g resource "aws_)

This improves the completion experience along with opentofu/hcl-lang#2 to allow users to get improved completion when writing resources

Resolves https://www.reddit.com/r/Terraform/comments/1r14jlr/help_with_terraformls_trigger_characters_andor/

Checklist

  • I have read the contribution guide.
  • I have not used an AI coding assistant to create this PR.
  • I have written all code in this PR myself OR I have marked all code I have not written myself (including modified code, e.g. copied from other places and then modified) with a comment indicating where it came from.
  • I (and other contributors to this PR) have not looked at the Terraform source code while implementing this PR.
  • If I'm releasing, I have read the releasing guide.

Go checklist

  • I have run golangci-lint on my change and receive no errors relevant to my code.
  • I have run existing tests to ensure my code doesn't break anything.
  • I have added tests for all relevant use cases of my code, and those tests are passing.
  • I have only exported functions, variables and structs that should be used from other packages.
  • I have added meaningful comments to all exported functions, variables, and structs.

This allows editors to request completions easier when a end-user
inputs "_" inside a resource type label for example,
(e.g `resource "aws_`)

This improves the completion experience along with
opentofu/hcl-lang#2 to allow users to get
improved completion when writing resources

Signed-off-by: James Humphries <james@james-humphries.co.uk>
@Yantrio
Yantrio requested a review from a team as a code owner February 11, 2026 13:29

@apparentlymart apparentlymart left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With the caveat that I'm not particularly familiar with how this part of the protocol works, the reason for this makes sense to me and I can imagine the implementation working as long as the code which handles the completion requests is able to notice that it's already partway through an identifier.

(And I assume that must be true because it's always possible for the user to explicitly request completion at any point in the input, and so from the perspective of the completion code this should be just like explicitly requesting completion immediately after you type _, right?)

@apparentlymart

Copy link
Copy Markdown

Oh heh somehow between starting to read this and actually leaving my review I forgot that you mentioned opentofu/hcl-lang#2, which deals with the question I asked in the second part of my approval. Sorry... early morning brain. 🤦‍♂️

@diofeher
diofeher merged commit 18e8cd3 into main Mar 7, 2026
21 checks passed
@diofeher
diofeher deleted the underscore branch March 7, 2026 13:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants