tomaciazek / vscode-ansible

Ansible VS Code Extension
MIT License
28 stars 3 forks source link

YAML files that are not related to Ansible are being taken over/interpreted by the extension #10

Closed briantist closed 3 years ago

briantist commented 3 years ago

Summary

For example, the YAML files in my .github directory uses to have proper code completion for GitHub Actions, and my other Ansible extensions did not interfere, but now I can't as this extension has taken over those files as being "Ansible" files.

If there's a way to ignore certain paths, that might be good? I can change the dropdown back to YAML for these, but I'd like to not have to mess with file associations in vscode to do this reliably. However the other extensions worked, they were smart enough not to mess with these, so I'd really like that functionality back.

Extension version

1.0.2

VS Code version

1.57.1

Ansible Version

ansible [core 2.12.0.dev0] (devel 4d78b58540) last updated 2021/07/22 20:09:47 (GMT -400)
  config file = None
  configured module search path = ['/home/briantist/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/briantist/code/ansible/ansible.core/lib/ansible
  ansible collection location = /home/briantist/.ansible/collections:/usr/share/ansible/collections
  executable location = /home/briantist/.a211/bin/ansible
  python version = 3.6.9 (default, Jan 26 2021, 15:33:00) [GCC 8.4.0]
  jinja version = 3.0.1
  libyaml = True

OS / Environment

Ubuntu 18.04 (WSL2)

Relevant log output

[Info  - 2:58:55 PM] [ansible-lint] WARNING  Overriding detected file kind 'yaml' with 'playbook' for given positional argument: /home/briantist/code/ansible/ansible_collections/community/hashi_vault/.github/workflows/ansible-test.yml
tomaciazek commented 3 years ago

The extension is configured to recognize all .yml and .yaml files as Ansible, because Ansible's directory layout and naming conventions (particularly in case of playbook files) isn't any more restrictive than that.

But you can always override that behavior using the files.associations setting. Using that setting, you could for instance create a glob pattern and map it to ansible - this will effectively override the configuration that comes with this plugin, so that .yml/.yaml files that do not match the glob would no longer be mistaken for Ansible files.

The log output is from the ansible-lint execution and it does not affect selection of the language for the file.

briantist commented 3 years ago

I definitely understand that Ansible doesn't have restrictive directory layouts that make it easy to know for sure. I feel like a sensible default for your plugin would be to exclude directories with a leading dot . by default, and instead having those be opt-in, via files.associations.

You can't easily blanket exclude any .directory via that setting, so you have to list each type with an affirmative association (so knowing what they all are in advance). At least that's my understanding of it.

@tomaciazek I think .directories are rare to use in an Ansible layout; would you consider excluding those?

tomaciazek commented 3 years ago

That's not possible in the extension manifest. Essentially, I have the same toolset to work with as you. You can also try to associate all .*/**/*.yml to yaml language ID.