lsp-mode
lsp-mode copied to clipboard
Fix(lsp-terraform): Adapt keywords to use underscores for lsp-mode core compatibility
This PR fixes compilation errors in clients/lsp-terraform.el when used with recent versions of lsp-mode 20250531.742`
Fixes #4805
Problem:
The lsp-terraform.el file (which has not been updated in the main repository for approximately a year) started failing to compile. The errors consistently followed the pattern:
Error: Unknown key: :some-key-with-hyphen. Available keys: (... :some_key_with_underscore ...)
This occurred for several multi-word keywords within lsp-defun destructuring forms, such as :docs-link (expected :docs_link) and :provider-requirements (expected :provider_requirements).
This suggests a change in lsp-mode core's keyword handling or its internal type definitions for data related to terraform-ls, now favoring/expecting underscores for these specific multi-word keys.
Solution:
This PR updates the affected keywords in lsp-terraform.el within lsp-defun parameter destructuring (for types like &terraform-ls:Module, &terraform-ls:Providers, etc.) to use the underscore convention, matching the "Available keys" provided in the compilation error messages. Corresponding local variable names have also been updated to use underscores.
These changes allow lsp-terraform.el to compile successfully with the current lsp-mode core.
It looks like there is a compile error: 🤔
Unknown key: :docs_link. Available keys: (:name :docs-link :version :source-type :dependent-modules)
It looks like there is a compile error: 🤔
Unknown key: :docs_link. Available keys: (:name :docs-link :version :source-type :dependent-modules)
It is interesting that when I reproduce it in a clean emacs environment (with emacs version 30.1 and lsp-mode-20250601.129), it shows lsp-terraform.el:305:34: Error: Unknown key: :docs-link. Available keys: (:name :docs_link :version :source_type :dependent_modules).
These initial changes was originally done by me when implementing the terraform lsp client. IIRC, having it like docs_link didn't work correctly when interacting with the terraform language server. @StepaniaH Can you confirm that you are able to see module information on the terraform code with these changes ?
These initial changes was originally done by me when implementing the terraform lsp client. IIRC, having it like
docs_linkdidn't work correctly when interacting with the terraform language server. @StepaniaH Can you confirm that you are able to see module information on the terraform code with these changes ?
Actually, I rarely write Terraform-related codes. I modified it only because this compilation error in it caused issues with the overall LSP configuration when I reset my Emacs.
At least for now, the modified code runs well in my environment. And I will try to re-verify and reproduce the issue at a later time in the near future. If there is any further information, I will promptly sync it with you.