NvChad / base46

NvChad's base46 theme plugin with caching ( Total re-write )
Other
169 stars 184 forks source link

Request: ansible-vim integration #312

Open serpro69 opened 2 weeks ago

serpro69 commented 2 weeks ago

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 commented 2 weeks ago
{
   "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'

serpro69 commented 2 weeks ago

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 commented 2 weeks ago

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

serpro69 commented 2 weeks ago

@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 commented 2 weeks ago

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

image

serpro69 commented 2 weeks ago

@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 commented 2 weeks ago

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

siduck commented 2 weeks ago

ask in our discord server @serpro69

serpro69 commented 2 weeks ago

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 commented 2 weeks ago

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 commented 2 weeks ago

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

serpro69 commented 2 weeks ago

Nop, I give up :grinning: 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 commented 2 weeks ago

@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 commented 2 weeks ago

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

I\m not sure, but I think this https://github.com/neovim/neovim/issues/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 commented 2 weeks ago

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

serpro69 commented 2 weeks ago

@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.