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

Request: ansible-vim integration #312

Open
serpro69 opened this issue Jun 10, 2024 · 16 comments
Open

Request: ansible-vim integration #312

serpro69 opened this issue Jun 10, 2024 · 16 comments

Comments

@serpro69
Copy link

Hi,
I'd like to ask if it's possible to support ansible-vim plugin's syntax highlighting.
There's no treesitter specifically for ansible that I could find, but the aforementioned plugin exists which adds syntax highlighting for both ansible playbook file and jinja.
However, this doesn't seem to be supported with nvchad.

This is how it looks like on my end with 'onenord' theme, so it seems that whatever ansible-vim plugin is trying to do is clearly not working with nvchad?

image

@siduck
Copy link
Member

siduck commented Jun 10, 2024

{
   "pearofducks/ansible-vim",
    ft={"ansible"}
  }

You should know that all plugins in nvchad are lazyloaded by default i.e have that lazy=true in lazy.nvim config so the plugin will load only if its module is called, thats why either lazyload properly by cmd, keys, events etc or lazy=false or event='VeryLazy'

@siduck siduck closed this as completed Jun 10, 2024
@serpro69
Copy link
Author

Hi @siduck ,

I already had that in the config:

  {
    "pearofducks/ansible-vim",
    ft = "yaml.ansible",
  },

And in fact the plugin is reported as loaded in ansible files, so I don't think that's the issue here.

image

@siduck
Copy link
Member

siduck commented Jun 10, 2024

@serpro69 what happens if you load it after nvim-treesitter plugin? i.e add a dependency

@serpro69
Copy link
Author

serpro69 commented Jun 10, 2024

@siduck ,

Actually I haven't had treesitter for yaml enabled at all. Now tried both with and without yaml treesitter - almost no difference. In fact, ansible-vim doesn't seem to be compatible with nvim-treesitter

Using :map <F10> :echo "hi<" . synIDattr(synID(line("."),col("."),1),"name") . '> trans<' . synIDattr(synID...,col("."),0),"name") . "> lo<" . synIDattr(synIDtrans(synID(line("."),col("."),1)),"name") . ">"<CR> I could inspect the groups that are being highlighted by the ansible-vim plugin, but with yaml language installed with treesitter, these return empty strings.

W/o yaml treesitter installed:

image

With yaml treesitter:

image

I also tried adding treesitter as a dependency for ansible-vim as you suggested - that doesn't change anything.

@siduck
Copy link
Member

siduck commented Jun 10, 2024

@serpro69 so this ansible thing just has yml files , looks fine here , how do u want it to look?

image

@serpro69
Copy link
Author

serpro69 commented Jun 10, 2024

@siduck , well, yeah, ansible is essentially yaml, but it has a lot of it's own syntax (grammar?)

If you look at ansible-vim examples with solarized theme, various parts of the code are highlighted differently, depending on the syntax.
So a module , like win_get_url would have one color, the parameters like url and dest would have another color, some keywords would have their own colors, etc.

@siduck
Copy link
Member

siduck commented Jun 10, 2024

you're right @serpro69 , i no nothing about this ansible thing so cant be of any help.

@siduck
Copy link
Member

siduck commented Jun 10, 2024

ask in our discord server @serpro69

@siduck siduck reopened this Jun 10, 2024
@serpro69
Copy link
Author

Yeah, I did ask there first.
So far the only thing I could come up with was for me to add custom highlight groups, like

hl_add = {
    ansble_fqcn_keywords = {
      fg = "blue",
    },
    ansble_normal_keywords = {
      fg = "blue",
    },
}

But I'm not sure how well that would work. I think the ansible-vim plugin does a bunch of "magic":

sources the original formats and simply modifies the highlights as appropriate

Which is why I then decided to ask here if official support can be added :)

But thanks for your replies anyways :) I do get that this might not be easy, especially if you're unfamiliar with the tooling behind the syntax.

@siduck
Copy link
Member

siduck commented Jun 10, 2024

if you make this ansible thing work without nvchad ( in minimal init.lua ) then i can look into it, try tinyvim or make minimal init.lua

@serpro69
Copy link
Author

I'll try :) Will post here if it works.
Thanks

@serpro69
Copy link
Author

Nop, I give up 😀 It could be it's not supported with nvim 0.10.0 or I'm doing smth weird, but this plugin is a PIA to get to work properly with nvim, even outside of nvchad.
I did learn some tricks in the process to enable jinja support via treesitter, which is neat. For plain yaml, I'll just use it as is with yaml treesitter and not bother with plugins that highlight syntax...

@siduck siduck reopened this Jun 11, 2024
@siduck
Copy link
Member

siduck commented Jun 11, 2024

@serpro69 once make it work in astrovim if it doesnt work then ask its creator i.e in its discord server, he's pretty knowledgeable as he has been using vim since 2 decades

@serpro69
Copy link
Author

@siduck thanks for the tip, I'll take a look at that :)

I\m not sure, but I think this neovim/neovim#26378 could potentially have something to do with me not being able to make it work on nvim 0.10.0. I might try an older version, just to confirm this theory, but at this point I'm not sure I want to use an external plugin that modifies syntax highlighting in the first place, as it sounds like it might break too often, especially if the plugin author does not provide official nvim support. So not sure it's worth the effort, even if I do make it work eventually.

@siduck
Copy link
Member

siduck commented Jun 11, 2024

@serpro69 we dont use the default colorscheme btw , nor we use the colorscheme command! so i doubt if this affects us

@serpro69
Copy link
Author

serpro69 commented Jun 11, 2024

@serpro69 we dont use the default colorscheme btw , nor we use the colorscheme command! so i doubt if this affects us

No, not in nvchad
But I also tried yesterday with plan nvim, and that didn't work very well when I tried to just install ansible-vim and the solarized scheme that the plugin author has as example in their readme. I did get some variety in the syntax highlights in the yaml file, but it still looked quite weird, which I think was because of the above issue I mentioned.

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

No branches or pull requests

2 participants