Ansible deserves proper language server

I’ve restarted creating ansible yaml content and realized that some quality of life tooling is missing for ansible yaml content developers. That is why I’ve decided to create ansible language protocol server (LSP) with all the features that are missing in the official one (from my point of view).

Here is a link to public repo:

https://github.com/kksat/zals

There are also VS Code (and Open VSX) plugins:

https://marketplace.visualstudio.com/items?itemName=kksat.zals

Open VSX Registry (VS Code forks, e.g. Cursor)

This extension is a drop-in replacement for official Red Hat ansible VS Code extension, but also can be used alogn side it:

https://marketplace.visualstudio.com/items?itemName=redhat.ansible

All the ansible yaml language features available in both extensions (mine and official):

  • Syntax highlighting
  • Integration with ansible-lint
  • Smart autocompletion
  • Documentation reference (in official extension this feature is only for modules, see below for zals)
  • Jump to module code

What is not supported in my extension:

  • all that is not related to ansible yaml content
  • lightspeed (certainly not)
  • mcp server (certainly not)
  • ansible execution environments (unlikely in the future)
  • content creation tools (not yet)
  • nothing related to ansible-dev-tools package (no idea)

What does this extension bring? Why would anyone use it? Because of its features. All screenshots and screen recordins are from VS Code. I am preparing neovim plugin as well.

Variables:

  1. Variable hover

  2. Find all references of variable:

find all reference of a variable

  1. Find all references of variable key:

    find all references of a variable key
    Here only variables ansible_facts['distribution'] are shown, this will also work with ansible_facts.distribution(both ways)

  2. Add and remove debug statements for variables

    add debug statement for variable

    remove debug statement for variable

    Roles:

  3. Role hover - opens role readme file when you hover over role name in import_role or include_role

  4. Role parameter hover - get extract from argument_specs file when you hover over role parameters (both for import_role and include_role)

  5. Go to role definition. Here role definition is argument_spec file:

    go to role definition

  6. Go to role implementation. Here role implementation is role tasks/main file:

    go to role implementation

  7. Go to definition for role parameters - again this is argument_specs file:

    go to role parameter definition

  8. Go to implementaton for role parameters - open defaults/main or vars/main role file where parameter value is set:

    Workspace features:

  9. Find symbols in the workspace - fuzzy search across all playbooks, roles, tasks in your workspace:

    find symbols in workspace

More to follow!

If you have an idea in mind - please let me know. The current roadmap: variable rename, extracting tasks to roles, memory usage optimization.

More information about implementation.
This is native binary (win, mac, linux) written in zig. Size is about 5 Mb. Does not depend on anything with exception of ansible-core and ansible-lint. When it starts it needs < 10 seconds to read and parse collection with 1000 files. After that it does not reread from disk.
Memory footprint for this extension is 40 MB current / 155 MB peak on my mac for the project
that contains roughly 5,542 YAML files and 11,104 total files (excluding Git, virtualenvs, and common caches).
Almost all operations (with few exceptions) are performed in around 10 ms, this was one of the reasons I’ve used zig (compiled language). I wanted nice UX and not break user flow.

If you find this extension and lsp useful, I would highly appreciate it if you write a quick review and submit your rating using these links:

https://marketplace.visualstudio.com/items?itemName=kksat.zals&ssr=false#review-details

https://open-vsx.org/extension/kksat/zals/reviews

You can always contact me directly

Thank you for you attention.

2 Likes

I was fortunate to get some time with @kks (than you again for sharing), where the plugin was demonstrated on my own open source content and i was very impressed.
The speed of response once, the variable hover is amazing and can really help with some of those more complex setups that i’ve seen (and created).
The insert debug and creating a separate task files (all with the ability to undo & redo ) are brilliant.
Excited to get some time to look at this, some of the functions currently there and already being thought about for the next stage are brilliant.

I know that anyone testing feedback will be appreciated.

Thank you again

1 Like