Skip to main content

Emacs Pulumi LSP

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.

Popular posts from this blog

npm run build base-href

Using NPM to specify base-href When building an Angular application, people usually use "ng" and pass arguments to that invocation. Typically, when wanting to hard code "base-href" in "index.html", one will issue: ng build --base-href='https://ngx.rktmb.org/foo' I used to build my angular apps through Bamboo or Jenkins and they have a "npm" plugin. I got the habit to build the application with "npm run build" before deploying it. But the development team once asked me to set the "--base-href='https://ngx.rktmb.org/foo'" parameter. npm run build --base-href='https://ngx.rktmb.org/foo did not set the base href in indext.html After looking for a while, I found https://github.com/angular/angular-cli/issues/13560 where it says: You need to use −− to pass arguments to npm scripts. This did the job! The command to issue is then: npm run build -- --base-href='https://ngx.rktmb.org/foo&

emacs29 intelephense

Emacs 29 and PHP Intelephense I use to use Emacs and PHP Intelephense for PHP development. I recently upgraded to Emacs 29 and PHP Intelephense stopped working. I found a solution on Reddit Based on that, I rewrote my .emacs file to use eglot instead of lsp-mode, and this is the result. (use-package eglot :ensure t) (add-hook 'php-mode-hook 'eglot-ensure) (use-package php-mode :ensure t :mode ("\\.php\\'" . php-mode)) (add-to-list 'auto-mode-alist '("\\.php$" . php-mode)) (provide 'lang-php) (use-package company :ensure t :config (setq company-idle-delay 0.3) (global-company-mode 1) (global-set-key (kbd "M- ") 'company-complete)) (require 'eglot) (add-to-list 'eglot-server-programs '((php-mode :language-id "php") . ("intelephense" "--stdio" :initializationOptions (:licenseKey "98989898989898989898"

Jenkins invalid privatekey

Publish over SSH, Message "invalid privatekey:" With quite recent (June-July 2020) installations of Jenkins and OpenSSH, I have the following error message when using the "Deploy overs SSH" Jenkins plug-in and publishing artifacts to the target overs SSH: jenkins.plugins.publish_over.BapPublisherException: Failed to add SSH key. Message [invalid privatekey: [B@d8d395a] This problem seems to be referenced here: https://issues.jenkins-ci.org/browse/JENKINS-57495 Just regenerate a key with the right parameters To solve it: ssh-keygen -t rsa -b 4096 Or ssh-keygen -t rsa -b 4096 -m PEM