Code Monkey home page Code Monkey logo

vscode-saltstack's Introduction

SaltStack extension for Visual Studio Code

This extension adds language colorization support for the SaltStack template language to VS Code. The language is a yaml with Jinja2 templating.

IDE

Using the extension

First, you will need to install Visual Studio Code 1.19.0 or higher. In the command palette (cmd-shift-p) select Install Extension and choose SaltStack.

Autocompletion

Salt states

When writing Salt states, pressing ctrl+space will offer to autocomplete state functions and some stanzas.

Example:

some_id:
  test.<ctrl+space>

Results in:

some_id:
  test.+-----------------------+
       |check_pillar           |
       |configurable_test_state|
       |fail_with_changes      |
       |fail_without_changes   |
       |nop                    |
       |show_notification      |
       |succeed_with_changes   |
       |succeed_without_changes|
       +-----------------------+

Full state modules can also be completed:

some_other_id:
  test.configurable_test_state:<ctrl+space>

Results in:

some_other_id:
  test.conffigurable_test_state:
    - name: _unique_string_
    - changes: True
    - result: True
    - comment: ''

Saltcheck

Saltcheck tests (.tst files) can also be autocompleted with the keyword sctest<ctrl+space>

Example:

_testid_:
  module_and_function: _test.echo_
  args:
    - should return
  assertion: _assertTrue_
  expected_return: _should return_

Contributing

If you are interested in making this extension better, I will gladly take pull requests that expand it to add intellisense, hovers and validators. If you're not familiar with working on Visual Studio Code extensions, check out the VS Code extenders documentation at https://code.visualstudio.com/docs.

To get started on the extension...

  1. Go to the Debug viewlet and select Launch Extension then hit run (F5). This will launch a second instance of Code with the extension from the first window loaded.

  2. As you make changes, you can also reload (Ctrl+R or Cmd+R on Mac) the second Code window to load any changes.

If you have a previous release of the extension installed and you perform these steps, Code will temporarily override the locally installed version instead for the one you're working on for the second window. The first (main) window will remain to have the locally installed, prior version installed and enabled until an update is available.

Publishing

  1. Bump version number in package.json

  2. After git push, a build starts automatically. Publishing to marketplace requires manual approval in Jenkins

Credits

Created by Marek Obuchowicz from KoreKontrol.

Many thanks to William Holroyd, Ross Neufeld and Christian McHugh.

License

MIT

vscode-saltstack's People

Contributors

marek-obuchowicz avatar mchugh19 avatar roaldnefs avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

vscode-saltstack's Issues

Installation issue v0.0.8

Hi,

I'm running into an installation issue with v0.0.8 on the following vscode setup

Version: 1.54.3
Electron: 11.3.0
Chrome: 87.0.4280.141
Node.js: 12.18.3
V8: 8.7.220.31-electron.0
OS: Linux x64 5.8.0-48-generic snap
Ubuntu 20.04 LTS 64-bit

The extension doesn't get loaded after installation, even after window reload and vscode restart. The issue manifests through the lack of color/syntax highlighting and no salt related auto completion suggestions when pressing ctrl+space (just the default vscode text suggestions). I first thought this might be due to conflict with Better Jinja and salt-lint extensions but still had the same issue after uninstalling them.

The workaround for now has been

  1. Install extension
  2. Install a lower version which enables the "Reload required" button
  3. Press the "Reload required" button
  4. Update to the latest version
  5. Press the "Reload required" button again

This seems to load the extension properly. Perhaps there is a way to reload the extension directly through the command palette?

Either way, minor issue but thought I'd mention it.

Best regards

Jinja variable detection reports false positive

This expression
{% do network2host[interfacedetails['network']].update({current_host:{'ip':interfacedetails['ip'],'mac':interfacedetails['mac']}}) %}
is wrongly recognized as a variable. Therefore the problem message:
Jinja variables should have spaces before and after: '{{ var_name }}' salt-lint(206) does not apply and should not be displayed.

network2host and current_host are dicts

Feature request: module autocompletion

I don't think it would be too hard to add autocompletion, such that, when I type, say, file., I get a dropdown that contains exists, managed, symlink, etc. This could also be implemented as snippets instead.

Compatible with 1.18

Hi is it possible to make it compatible with VS code 1.18 instead of 1.19? Or are there breaking changes?

Autocomplete gives extra closing bracket.

When typing {% the auto completion seems to give me a completion of {%%}} (placing my cursor in the centre of the %'s)

Unfortunately, this is not syntactically valid Jinja2

some JINJA wrongly highlighted

Thanks for the great extension! I noticed a couple instances where the JINJA highlighting is wrong:

  1. Commented JINJA after YAML value is not properly highlighted as comments
    {% set Stuff = "/tmp/baz.json" %}
    example:
      file.managed:
        - name: /tmp/foo.json {# {{ Stuff }} #}
  2. JINJA text highlighting for this case should NOT be commented, as JINJA will render and replace the YAML '#'
    # {% set Stuff = "/tmp/baz.json" %}
    example:
      file.managed:
        - name: {{ Stuff }}

Integrate with the Salt LSP server?

Hi, @cbosdo and myself have hacked an experimental Language Server for SaltStack SLS during this year's hackweek at @SUSE. The project is still in a very early state (see: https://github.com/dcermak/salt-lsp) but we were wondering whether you'd be interested in collaborating in the future?

I think that it could be definitely beneficial for us to join our efforts here, resulting in less duplicated efforts. What do you all think?

Proritize Jinja highlighting over Salt string highlighting.

Since Jinja is rendered by Salt first, I think it should be highlighted above all else even if it is inside of a string. It can be quite annoying to lose your highlighting just because your Jinja is inside a string even though the renderer does not treat it as a string.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.