Install Pulumi Emacs Mode
The source code is on https://github.com/pulumi/pulumi-lsp.
At the very bottom of the page are the instructions on how to install.
You Need to have make
installed.
$ make install emacs-client mkdir -p ./bin go build -ldflags "-X github.com/pulumi/pulumi-lsp/sdk/version.Version=v0.2.3-6-gec49054" -o ./bin -p 10 ./cmd/... go: downloading github.com/pulumi/pulumi/sdk/v3 v3.53.1 ... ... ... go install -ldflags "-X github.com/pulumi/pulumi-lsp/sdk/version.Version=v0.2.3-6-gec49054" ./cmd/... mkdir -p editors/emacs/bin cd editors/emacs && emacs -Q --batch --eval "(progn (setq package-user-dir \"$(pwd)/bin\" \ package-archives '((\"melpa\" . \"https://melpa.org/packages/\") \ (\"gnu\" . \"https://elpa.gnu.org/packages/\"))) \ (package-initialize) \ (package-install 'yaml-mode) (package-install 'lsp-mode))" -f batch-byte-compile pulumi-yaml.el Contacting host: melpa.org:443 INFO Scraping files for yaml-mode-autoloads.el...done Checking /home/mihamina/.emacs.d/pulumi-lsp/editors/emacs/bin/yaml-mode-20230329.723... Package ‘yaml-mode’ installed. Setting ‘package-selected-packages’ temporarily since "emacs -q" would overwrite customizations Contacting host: melpa.org:443 INFO Scraping files for lv-autoloads.el...done Checking /home/mihamina/.emacs.d/pulumi-lsp/editors/emacs/bin/lv-20200507.1518... Contacting host: melpa.org:443 INFO Scraping files for markdown-mode-autoloads.el...done Checking /home/mihamina/.emacs.d/pulumi-lsp/editors/emacs/bin/markdown-mode-20230412.126... INFO Scraping files for spinner-autoloads.el...done Checking /home/mihamina/.emacs.d/pulumi-lsp/editors/emacs/bin/spinner-1.7.4... Contacting host: melpa.org:443 Parsing tar file...done Extracting...done INFO Scraping files for dash-autoloads.el...done Checking /home/mihamina/.emacs.d/pulumi-lsp/editors/emacs/bin/dash-20230415.2324... Contacting host: melpa.org:443 INFO Scraping files for ht-autoloads.el... ht:0: Warning: Not registering prefix "ht". INFO Scraping files for ht-autoloads.el...done Checking /home/mihamina/.emacs.d/pulumi-lsp/editors/emacs/bin/ht-20230214.1632... Contacting host: melpa.org:443 INFO Scraping files for s-autoloads.el...done Checking /home/mihamina/.emacs.d/pulumi-lsp/editors/emacs/bin/s-20220902.1511... Contacting host: melpa.org:443 Parsing tar file...done Extracting...done INFO Scraping files for f-autoloads.el...done Checking /home/mihamina/.emacs.d/pulumi-lsp/editors/emacs/bin/f-20230116.1032... Contacting host: melpa.org:443 Parsing tar file...done Extracting...done INFO Scraping files for lsp-mode-autoloads.el...done Checking /home/mihamina/.emacs.d/pulumi-lsp/editors/emacs/bin/lsp-mode-20230418.1027... ... ... ... Package ‘lsp-mode’ installed. In toplevel form: pulumi-yaml.el:105:44: Warning: reference to free variable ‘pulumi-yaml-store-path’ pulumi-yaml.el:113:17: Warning: reference to free variable ‘eglot-server-programs’ pulumi-yaml.el:113:17: Warning: assignment to free variable ‘eglot-server-programs’ mkdir -p ./bin cp editors/emacs/pulumi-yaml.elc bin/
The installation is done. We need to configure Emacs to use it.
In case of upgrade, run make clean
before make emacs-client
Configure Emacs
In order to configure Emacs to use it, we need to instruct Emacs about the path of the mode, and require it.
This configuration section has been updated after some reader comments
(add-to-list 'load-path "/home/mihamina/.emacs.d/pulumi-lsp/bin") (require 'pulumi-yaml) (require 'lsp-mode) (add-to-list 'auto-mode-alist '("Pulumi.*\\.yaml\\'" . pulumi-yaml-mode)) (add-to-list 'auto-mode-alist '("Pulumi.*\\.yml\\'" . pulumi-yaml-mode)) (add-hook 'pulumi-yaml-mode-hook #'lsp-mode)
You have noticed I added the path of the elc file, which has been copied there by the previous compilation.
When you first open a Pulumi YAML file, it will load the Pulumi mode, but without the LSP server enabled.
In order to run the Pulumi LSP, M-x lsp
.
This will prompt about the LSP server to use: the only choice will be pulumi-lsp
, choose it.