Skip to main content

Cfn Lsp Extra

Project description

Cfn Lsp Extra

Python Version Version

An experimental cloudformation lsp server built on top of cfn-lint aiming to provide hovering, completion, etc.

https://user-images.githubusercontent.com/17688577/166110762-71058f8f-4cb6-44ae-960b-9370a166125a.mp4

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

You need to install an lsp client like lsp-mode and register cfn-lsp-extra. yaml-mode is also highly recommended.

;; After lsp-mode and yaml-mode have been loaded
(when-let ((exe (executable-find "cfn-lsp-extra")))

  ;; Copied from https://www.emacswiki.org/emacs/CfnLint
  (define-derived-mode cfn-json-mode js-mode
    "CFN-JSON"
    "Simple mode to edit CloudFormation template in JSON format."
  (setq js-indent-level 2))

  (add-to-list 'magic-mode-alist
               '("\\({\n *\\)? *[\"']AWSTemplateFormatVersion" . cfn-json-mode))
  (add-to-list 'lsp-language-id-configuration
               '(cfn-json-mode . "cloudformation"))
  (add-hook 'cfn-json-mode-hook #'lsp)
  
  (when (featurep 'yaml-mode)
    (define-derived-mode cfn-yaml-mode yaml-mode
      "CFN-YAML"
      "Simple mode to edit CloudFormation template in YAML format.")
    (add-to-list 'magic-mode-alist
                 '("\\(---\n\\)?AWSTemplateFormatVersion:" . cfn-yaml-mode))
    (add-to-list 'lsp-language-id-configuration
                 '(cfn-yaml-mode . "cloudformation"))
    (add-hook 'cfn-yaml-mode-hook #'lsp))
  
  (lsp-register-client
   (make-lsp-client :new-connection (lsp-stdio-connection exe)
                    :activation-fn (lsp-activate-on "cloudformation")
                    :server-id 'cfn-lsp-extra)))

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.

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.2.0.tar.gz (1.3 MB view hashes)

Uploaded Source

Built Distribution

cfn_lsp_extra-0.2.0-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