Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request company-mode completion #17

Open
ghost opened this issue Nov 9, 2017 · 8 comments
Open

Feature Request company-mode completion #17

ghost opened this issue Nov 9, 2017 · 8 comments

Comments

@ghost
Copy link

@ghost ghost commented Nov 9, 2017

I really like where this is headed.. I would like to have the completion using company-mode in spacemacs. I will dive in and help if I can.. I'm new to lisp elisp.. I'm going to dig into getting this working.. If you have any tips or pointers that would help, it would be appreciated ..

Marty

@glynnforrest
Copy link
Owner

@glynnforrest glynnforrest commented Nov 10, 2017

I agree @MBuchaus, company-mode completion would be a great addition. I've been hoping to get started with this for a while but haven't had the time. Please, go ahead if you feel so inclined!

See this wiki page for some tips on writing a company-mode backend. Alternatively, you may want to consider creating a completion-at-point function instead and using company's built-in CAPF backend too.

It would be awesome if you could add some tests for the backend. Don't worry if you're not sure, I can help you 👍

Let me know if you have any questions or need any help.

@ghost
Copy link
Author

@ghost ghost commented Nov 10, 2017

I will do what I can.. I want to learn this, thanks for the feedback.

@max-arnold
Copy link
Contributor

@max-arnold max-arnold commented Oct 8, 2018

With a little bit of python intronspection (for ideas see https://github.com/gtmanfred/salint) this could be very useful

@glynnforrest
Copy link
Owner

@glynnforrest glynnforrest commented Oct 8, 2018

@max-arnold what's the first thing you'd like to have completion for?

I think adding something small will be more achievable to begin with.

@max-arnold
Copy link
Contributor

@max-arnold max-arnold commented Oct 10, 2018

I see four broad categories for possible autocompletion helpers:

  1. Salt state modules (module/function names, arguments)
  2. User state trees (state path/id autocompletion for include, extend, require, watch, onchanges etc)
  3. Yaml keywords which have special meaning in salt (name, include, extend, require, watch, onchanges, onfail, prereq, use, listen and their *_in and *_any counterparts, runas, runas_password, fire_event, reload_*, unless, onlyif, check_cmd, retry, order). Basically, everything defined in salt.state.STATE_INTERNAL_KEYWORDS.
  4. Basic Jinja syntax, plus maybe the helpers defined in salt.utils.jinja.py

So far the (3) seems to be easiest to start with, and (1) looks most useful.

As a side note, the Salt plugin for Sublime partially covers (1) and (4): https://github.com/saltstack/sublime-text/tree/master/Snippets

@max-arnold
Copy link
Contributor

@max-arnold max-arnold commented May 29, 2020

The new baredoc module in the upcoming Salt 3001 Sodium release can dump all the state/execution module functions. VSCode SaltStack plugin already uses it to provide the most comprehensive state autocompletion feature:

korekontrol/vscode-saltstack#6
korekontrol/vscode-saltstack#8

@glynnforrest
Copy link
Owner

@glynnforrest glynnforrest commented May 29, 2020

Interesting, thanks @max-arnold!

Do you have an opinion on the VSCode approach (generating and storing json files) vs the salt-mode approach (calling a python script and loading the definitions into memory)?

@max-arnold
Copy link
Contributor

@max-arnold max-arnold commented May 29, 2020

VSCode approach pros:

  • Easier to setup (just install the plugin, no need to fiddle with salt)
  • Works with any Salt version (not just the upcoming 3001)
  • Probably faster

Cons:

  • JSON files need to be updated when a new Salt version is released
  • Can't work with custom modules that are not bundled with Salt
  • Potential version mismatch (json files vs a particular Salt version)

I guess it is easier to keep the existing approach in salt-mode and call the baredoc module directly (it can parse any salt module even if it doesn't have all the necessary dependencies installed).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants