Description
See the issue I previously opened on terraform-ls.
I asked about this in #lsp-mode gitter and @yyoncho suggested that I open an issue for tracking purposes. I'm not sure if it's necessarily clear yet whether this should be fixed on the client or the server. Yyoncho suggested that:
server authors would assume [this] to be correct - what vscode does, not what the spec says
Also seems that whatever way VSCode is handling this, Sublime Text seems to handle it in the same way.
Describe the bug
Essentially, (nested) autocompleted nested blocks do not get indented. The block itself has some indent information being returned from the language server, but when autocompleting a nested block, it is placed in the editor as if it were not nested. Example:
resource "aws_appmesh_mesh" "test" {
spec {
egress_filter {
0
}
}
}
The expected behavior would be to indent something like this:
resource "aws_appmesh_mesh" "test" {
spec {
egress_filter {
0
}
}
}
Also, this may be related. I'm just noticing this now that I've fired up VSCode for testing, but there's another discrepancy in the way that lsp-mode handles things. When I start typing resource
in VSCode and autocomplete it, the resource block looks something like this:
resource "" "name" {
}
And the cursor is placed inside the "" for you to type the resource name. In lsp-mode, it's autocompleted like this:
resource "1" "name" {
3
}
I believe the 1
and the 3
are coming from the number of required items in that part of the schema. You can see some of that above in egress_filter
.
To Reproduce
Minimal project that I've been using for testing:
https://github.com/gruntwork-io/intro-to-terraform/tree/master/database
You will need to have terraform binary installed and on your path. You will also need to do a terraform init
inside of the database
folder.
Note: you may need to open the workspace at the level of database
rather than top level intro-to-terraform
(especially in VSCode, I believe in lsp-mode it will prompt you for which workspace to import). This is because currently the language server assumes that the top level of your workspace is the base level of the module. However, intro-to-terraform
includes multiple modules.
Which Language Server did you use
This is in the new terraform-ls server, which hashicorp has started developing rather than Julio Sueiras's terraform-lsp which lsp-mode uses by default.
OS
Arch Linux
Error callstack
Log output from the language server running both in VSCode and lsp-mode.
VSCode log:
https://gist.github.com/amasover/507b165beee1639f3c922492a8dfb6fd
lsp-mode log:
https://gist.github.com/amasover/ed2ba0c211bb84cc612f2acc21c79933