Fix terraform browse documentation command
This commit is contained in:
parent
da98498fd4
commit
e72ae38079
@ -44,6 +44,24 @@
|
||||
(defun terraform-setup-eldoc ()
|
||||
(add-hook 'eldoc-documentation-functions #'terraform-devdocs-eldoc-function nil t))
|
||||
|
||||
(add-hook 'terraform-mode-hook #'terraform-setup-eldoc))
|
||||
(add-hook 'terraform-mode-hook #'terraform-setup-eldoc)
|
||||
|
||||
(defun find-terraform-root ()
|
||||
"Returns the highest-level parent directory containing a .tf file."
|
||||
(let ((current-dir default-directory)
|
||||
(root nil))
|
||||
(while (and (not (string-match locate-dominating-stop-dir-regexp current-dir))
|
||||
(f-glob "*.tf" current-dir))
|
||||
(setq root current-dir)
|
||||
(setq current-dir (f-parent current-dir)))
|
||||
(when root (file-name-as-directory root))))
|
||||
|
||||
;; Use root terraform module to resolve providers
|
||||
(defun terraform-provider-ns-advice (oldfn &rest args)
|
||||
(let ((dir (or (find-terraform-root) default-directory)))
|
||||
(let ((default-directory dir))
|
||||
(apply oldfn args))))
|
||||
|
||||
(advice-add 'terraform--get-resource-provider-namespace :around #'terraform-provider-ns-advice))
|
||||
|
||||
(provide 'init-terraform)
|
||||
|
Loading…
Reference in New Issue
Block a user