Skip to main content

Cfn Lsp Extra

Project description

Cfn Lsp Extra

Python Version PyPI codecov

An experimental cloudformation lsp server (with support for SAM templates) built on top of cfn-lint aiming to provide hovering, completion, etc. YAML and JSON are supported, though YAML has more features currently implemented (for example snippets) and will give a better experience. Trust me.

https://user-images.githubusercontent.com/17688577/176939586-df1d9ed8-5ec6-46d5-9f26-7222644047bd.mp4

Features

Method Status
textDocument/hover Done for resources, resource properties, subproperties and !Refs. TODO !GetAtts, intrinsic functions.
textDocument/completion Done for resources, resource properties, subproperties, refs and intrinsic functions. TODO !GetAtt.
textDocument/definition Done for !Refs. TODO mappings.
textDocument/publishDiagnostics Done through cfnlint.

Installation

First install the executable, pipx is recommended, but you can use pip instead if you like to live dangerously:

pipx install cfn-lsp-extra

Or get the bleeding edge from source:

pipx install git+https://github.com/laurencewarne/cfn-lsp-extra.git@$(git ls-remote git@github.com:laurencewarne/cfn-lsp-extra.git | head -1 | cut -f1)

Updating:

pipx upgrade cfn-lsp-extra

Emacs

Install the lsp-cfn.el package.

Patches detailing integration steps for other editors are very welcome 🙏

Alternatives

vscode-cfn-lint

cfn-lint

Note this is used by cfn-lsp-extra under the hood to generate diagnostics. One difference with cfn-lsp-extra is that diagnostics will be refreshed every time you make a change to the document, in other words you don't need to save the file.

yamlls

You can use yamlls in conjunction with the Cloudformation schema at https://www.schemastore.org/json/ as an alternative. For Emacs, lsp-mode can install yamlls for you, from there you could do something like:

(defun my-yamlls-cloudformation-setup ()
  ;; There's also one for serverless
  (lsp-yaml-set-buffer-schema "https://raw.githubusercontent.com/awslabs/goformation/master/schema/cloudformation.schema.json")
  (setq-local
   lsp-yaml-custom-tags
   ["!And"
    "!Base64"
    "!Cidr"
    "!Equals"
    "!FindInMap sequence"
    "!GetAZs"
    "!GetAtt"
    "!If"
    "!ImportValue"
    "!Join sequence"
    "!Not"
    "!Or"
    "!Ref Scalar"
    "!Ref"
    "!Select"
    "!Split"
    "!Sub"
    "!fn"]))

;; Using the mode defined by https://www.emacswiki.org/emacs/CfnLint
(add-hook 'cfn-yaml-mode-hook #'my-yamlls-cloudformation-setup)
(add-hook 'cfn-yaml-mode-hook #'lsp-deferred)

This will give you completions (and some support for value completions?), though no hover documentation.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cfn-lsp-extra-0.4.1.tar.gz (1.3 MB view hashes)

Uploaded Source

Built Distribution

cfn_lsp_extra-0.4.1-py3-none-any.whl (1.3 MB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page