Skip to content

Fix(lsp-terraform): Adapt keywords to use underscores for lsp-mode core compatibility #4806

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions CHANGELOG.org
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
* Improve the lsp-ocaml client (see [[https://github.com/emacs-lsp/lsp-mode/issues/4731][#4731]] for the follow-up issue. MRs: [[https://github.com/emacs-lsp/lsp-mode/pull/4741][#4741]], [[https://github.com/emacs-lsp/lsp-mode/pull/4732][#4732]])
* Add support for ~source.removeUnusedImports~ for lsp-javascript
* Add Python(ty) support
* Adapt keywords (e.g., `:docs_link`, `:provider_requirements`) to use underscores for compatibility with recent lsp-mode core, resolving compilation errors. (Fixes #4805)

** 9.0.0
* Add language server config for QML (Qt Modeling Language) using qmlls.
Expand Down
54 changes: 27 additions & 27 deletions clients/lsp-terraform.el
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
;;; lsp-terraform.el --- Terraform Client settings -*- lexical-binding: t; -*-
;;; lsp-terraform.el --- Terraform Client settings -*- lexical-binding: t; -*-

;; Copyright (C) 2019 Ross Donaldson, Sibi Prabakaran

Expand Down Expand Up @@ -134,12 +134,12 @@ Defaults to side following treemacs default."
(lsp-defun lsp-terraform-ls--show-references ((&Command :arguments?))
"Show references for command with ARGS."
(lsp-show-xrefs
(lsp--locations-to-xref-items
(lsp-request "textDocument/references"
(lsp--make-reference-params
(lsp--text-document-position-params nil (elt arguments? 0)))))
t
t))
(lsp--locations-to-xref-items
(lsp-request "textDocument/references"
(lsp--make-reference-params
(lsp--text-document-position-params nil (elt arguments? 0)))))
t
t))

(defun lsp-terraform-ls--custom-capabilities ()
"Construct custom capabilities for the language server."
Expand Down Expand Up @@ -252,11 +252,11 @@ Defaults to side following treemacs default."
This is a synchronous action."
(interactive)
(lsp-request
"workspace/executeCommand"
(list :command "terraform-ls.terraform.init"
:arguments (vector (format "uri=%s" (lsp--path-to-uri (lsp-workspace-root)))))
:no-wait nil
:no-merge t))
"workspace/executeCommand"
(list :command "terraform-ls.terraform.init"
:arguments (vector (format "uri=%s" (lsp--path-to-uri (lsp-workspace-root)))))
:no-wait nil
:no-merge t))

(defun lsp-terraform-ls-version ()
"Get information about the terraform binary version for the current module."
Expand Down Expand Up @@ -302,25 +302,25 @@ This is a synchronous action."
:installed-version installed-version
:version-constraint (lsp-get provider :version_constraint)))

(lsp-defun construct-tf-module ((&terraform-ls:Module :name :docs-link :version :source-type :dependent-modules))
(lsp-defun construct-tf-module ((&terraform-ls:Module :name :docs_link :version :source_type :dependent_modules))
"Construct `TF-MODULE' using MODULE."
(make-tf-module :name name
:doc-link docs-link
:doc-link docs_link
:version version
:source-type source-type
:dependent-modules dependent-modules))
:source-type source_type
:dependent-modules dependent_modules))

(lsp-defun lsp-terraform-ls--providers-to-tf-package ((&terraform-ls:Providers :provider-requirements :installed-providers))
(lsp-defun lsp-terraform-ls--providers-to-tf-package ((&terraform-ls:Providers :provider_requirements :installed_providers))
"Convert PROVIDERS-TREE-DATA to list of `tf-package'."
(let* ((provider-requirements-keys (hash-table-keys provider-requirements))
(installed-versions (mapcar (lambda (x) (lsp-get installed-providers (make-symbol (format ":%s" x)))) provider-requirements-keys))
(providers (mapcar (lambda (x) (lsp-get provider-requirements (make-symbol (format ":%s" x)))) provider-requirements-keys))
(tf-packages (-zip-with (lambda (x y) (construct-tf-package x y)) providers installed-versions)))
(let* ((provider_requirements-keys (hash-table-keys provider_requirements))
(installed_versions (mapcar (lambda (x) (lsp-get installed_providers (make-symbol (format ":%s" x)))) provider_requirements-keys))
(providers (mapcar (lambda (x) (lsp-get provider_requirements (make-symbol (format ":%s" x)))) provider_requirements-keys))
(tf-packages (-zip-with (lambda (x y) (construct-tf-package x y)) providers installed_versions)))
tf-packages))

(lsp-defun lsp-terraform-ls--modules-to-tf-module ((&terraform-ls:ModuleCalls :module-calls))
(lsp-defun lsp-terraform-ls--modules-to-tf-module ((&terraform-ls:ModuleCalls :module_calls))
"Convert MODULES-TREE-DATA to list of `TF-MODULE'."
(let* ((modules (-map (lambda (x) (construct-tf-module x)) module-calls)))
(let* ((modules (-map (lambda (x) (construct-tf-module x)) module_calls)))
modules))

(defun lsp-terraform-ls--fetch-modules-data (project-root)
Expand Down Expand Up @@ -358,10 +358,10 @@ This is a synchronous action."
(defun lsp-terraform-ls--tf-modules-to-treemacs (tf-modules)
"Convert list of `TF-MODULES' to treemacs compatible data."
(mapcar (lambda (module) (list :label (format "%s %s" (tf-module-name module) (tf-module-version module))
:icon 'package
:key (tf-module-name module)
:ret-action (lambda (&rest _) (browse-url (tf-module-doc-link module)))
)) tf-modules))
:icon 'package
:key (tf-module-name module)
:ret-action (lambda (&rest _) (browse-url (tf-module-doc-link module)))
)) tf-modules))

(defun lsp-terraform-ls--show-providers (ignore-focus?)
"Show terraform providers and focus on it if IGNORE-FOCUS? is nil."
Expand Down
Loading