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

Undefined global vim

Defining vim as global outside of Neovim When developing plugins for Neovim, particularly in Lua, developers often encounter the "Undefined global vim" warning. This warning can be a nuisance and disrupt the development workflow. However, there is a straightforward solution to this problem by configuring the Lua Language Server Protocol (LSP) to recognize 'vim' as a global variable. Getting "Undefined global vim" warning when developing Neovim plugin While developing Neovim plugins using Lua, the Lua language server might not recognize the 'vim' namespace by default. This leads to warnings about 'vim' being an undefined global variable. These warnings are not just annoying but can also clutter the development environment with unnecessary alerts, potentially hiding other important warnings or errors. Defining vim as global in Lua LSP configuration to get rid of the warning To resolve the "Undefined global vi...

LazyGit AI Commit Message

Having AI‑generated commit messages directly integrated into LazyGit If you use LazyGit every day, you already know how it turns Git from a chore into something you can actually enjoy. But there is one part of the workflow that still tends to feel a bit tedious: writing good commit messages. In this post, I show how to plug OpenAI models directly into LazyGit using a tiny one‑file BASH script, so you can get AI‑generated commit messages based on your actual diffs, without waiting for external tools to catch up with the new OpenAI Responses API . The result is a minimal, focused tool you can drop into your setup today: lgaicm . It behaves like a mini aichat that does exactly one thing: generate commit messages from Git diffs, optimized for LazyGit. Why AI‑generated commit messages in LazyGit? Commit messages matter. They are the stor...

CopilotChat GlobFile Configuration

CopilotChat GlobFile Configuration Want to feed multiple files into GitHub Copilot Chat from Neovim without listing each one manually? Let's add a tiny feature that does exactly that: a file glob that includes full file contents . In this post, we'll walk through what CopilotChat.nvim offers out of the box, why the missing piece matters, and how to implement a custom #file_glob:<pattern> function to include the contents of all files matching a glob. Using Copilot Chat with Neovim CopilotChat.nvim brings GitHub Copilot's chat right into your editing flow. No context switching, no browser hopping — just type your prompt in a Neovim buffer and let the AI help you refactor code, write tests, or explain tricky functions. You can open the chat (for example) with a command like :CopilotChat , then provide extra context using built-in functions. That “extra context” is where the magic really happens. Built-in functio...