My nvim configuration
| 1 | ---@brief |
| 2 | --- |
| 3 | --- https://github.com/hashicorp/terraform-ls |
| 4 | --- |
| 5 | --- Terraform language server |
| 6 | --- Download a released binary from https://github.com/hashicorp/terraform-ls/releases. |
| 7 | --- |
| 8 | --- From https://github.com/hashicorp/terraform-ls#terraform-ls-vs-terraform-lsp: |
| 9 | --- |
| 10 | --- Both HashiCorp and the maintainer of terraform-lsp expressed interest in |
| 11 | --- collaborating on a language server and are working towards a _long-term_ |
| 12 | --- goal of a single stable and feature-complete implementation. |
| 13 | --- |
| 14 | --- For the time being both projects continue to exist, giving users the |
| 15 | --- choice: |
| 16 | --- |
| 17 | --- - `terraform-ls` providing |
| 18 | --- - overall stability (by relying only on public APIs) |
| 19 | --- - compatibility with any provider and any Terraform >=0.12.0 currently |
| 20 | --- less features |
| 21 | --- - due to project being younger and relying on public APIs which may |
| 22 | --- not offer the same functionality yet |
| 23 | --- |
| 24 | --- - `terraform-lsp` providing |
| 25 | --- - currently more features |
| 26 | --- - compatibility with a single particular Terraform (0.12.20 at time of writing) |
| 27 | --- - configs designed for other 0.12 versions may work, but interpretation may be inaccurate |
| 28 | --- - less stability (due to reliance on Terraform's own internal packages) |
| 29 | --- |
| 30 | --- Note, that the `settings` configuration option uses the `workspace/didChangeConfiguration` event, |
| 31 | --- [which is not supported by terraform-ls](https://github.com/hashicorp/terraform-ls/blob/main/docs/features.md). |
| 32 | --- Instead you should use `init_options` which passes the settings as part of the LSP initialize call |
| 33 | --- [as is required by terraform-ls](https://github.com/hashicorp/terraform-ls/blob/main/docs/SETTINGS.md#how-to-pass-settings). |
| 34 | |
| 35 | ---@type vim.lsp.Config |
| 36 | return { |
| 37 | cmd = { 'terraform-ls', 'serve' }, |
| 38 | filetypes = { 'terraform', 'terraform-vars', 'tf' }, |
| 39 | root_markers = { '.terraform', '.git' }, |
| 40 | } |