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

yamlls and helm_ls #44

Open
thegrumpylion opened this issue Aug 30, 2023 · 19 comments
Open

yamlls and helm_ls #44

thegrumpylion opened this issue Aug 30, 2023 · 19 comments
Labels
documentation Improvements or additions to documentation enhancement New feature or request nvim

Comments

@thegrumpylion
Copy link

hi, thank you for this language server!

should yamlls be enabled for ft=helm? for example if a file begins with {{- if .Values...}} yamlls diagnostics are useless.

what's the recommended way to use this LS with yamlls?

@goof03
Copy link

goof03 commented Sep 21, 2023

Hi,
i have the same problem here :
#29

My issue is close because i was too busy to respond in time … Sorry my bad

But problem is still there … I use lazyvim setup and i get errors on every lines even if deployment is ok in k8s ...

oh! and i have add { "towolf/vim-helm", lazy = false } even if it seems to be no more maintained

@qvalentin
Copy link
Collaborator

hi, thank you for this language server!

should yamlls be enabled for ft=helm? for example if a file begins with {{- if .Values...}} yamlls diagnostics are useless.

what's the recommended way to use this LS with yamlls?

To answer the original issue: yamlls should be disabled for helm files.
There is some effort to support this in #32.

@qvalentin
Copy link
Collaborator

Hi, i have the same problem here : #29

My issue is close because i was too busy to respond in time … Sorry my bad

But problem is still there … I use lazyvim setup and i get errors on every lines even if deployment is ok in k8s ...

oh! and i have add { "towolf/vim-helm", lazy = false } even if it seems to be no more maintained

If you run set ft? in vim, what does it return? How did you configure yamlls, you should use https://github.com/neovim/nvim-lspconfig for this.

@thegrumpylion
Copy link
Author

To answer the original issue: yamlls should be disabled for helm files. There is some effort to support this in #32.

thank you. if there is any way i can assist with development (testing,coding,etc.) please let me know. i'd be more than happy.

perhaps a note/caveat section in the readme on how to use this LS with yamlls will be helpful, no?

@qvalentin
Copy link
Collaborator

To answer the original issue: yamlls should be disabled for helm files. There is some effort to support this in #32.

thank you. if there is any way i can assist with development (testing,coding,etc.) please let me know. i'd be more than happy.

perhaps a note/caveat section in the readme on how to use this LS with yamlls will be helpful, no?

Feel free to take a look at the code for reviewing or look for more bugs. I just stated a list with todos and bugs in the first merge request comment.

@goof03
Copy link

goof03 commented Oct 3, 2023

@qvalentin Yes lazyvim use lspconfig LspInfo return yamlls and helm_ls on a deployment.yaml

set ft return filetype=conf

feel free to ask me other debug comment no problem …

@rgruyters
Copy link

I had the same issue, but found a solution for it. I exclude yaml support when filetype helm is active.
Below you can find how i have solved it.

rgruyters/nvim@dd7fb86

@goof03
Copy link

goof03 commented Oct 4, 2023

@rgruyters thanks no more red yamlls errors :-D

now is there a way to have auto-format or just auto-indent on save ?

@qvalentin qvalentin added documentation Improvements or additions to documentation enhancement New feature or request labels Oct 14, 2023
@alex-w-k
Copy link

how do you exclude yamlls when setting up yamlls through lspconfig i can't really figure that out at the moment

@qvalentin
Copy link
Collaborator

qvalentin commented Dec 22, 2023

This is really a little bit complicated, because there is a lot of filetype detection magic going on:

I found two solutions to fix it:

  1. (recommended) Use lazy to install towolf/vim-helm and set ft=helm:
require("lazy").setup({
  -- towolf/vim-helm provides basic syntax highlighting and filetype detection
  -- ft = 'helm' is important to not start yamlls
  { 'towolf/vim-helm',       ft = 'helm' },

  { "neovim/nvim-lspconfig", event = { "BufReadPre", "BufNewFile", "BufEnter" } }
})

Check out the minimal config example: https://github.com/mrjosh/helm-ls/blob/master/examples/nvim/init.lua

  1. Install vim-polyglot instead of towolf/vim-helm.

@qvalentin qvalentin mentioned this issue Jan 19, 2024
@Mo0rBy
Copy link

Mo0rBy commented Jan 19, 2024

Hey all, I am having some trouble getting yamlls to play nice with Helm chart files.

I had vim-helm installed and I think I have setup yamlls and helm_ls correctly, but I get millions of yamlls errors on Helm charts and templates. I've looked through some of the examples in this thread but don't really understand them so I feel a little uncomfortable using them.

I have now uninstalled vim-helm and installed vim-polyglot instead and I get a few less errors in my Helm chart files from yamlls, but still too many than I would like that aren't relevant.

Here is my config for LSP's: https://github.com/Mo0rBy/nvim_config/blob/fix-helmls-lsp/lua/moorby/plugins/lsp/lspconfig.lua

And here is part of a Helm chart file that is still getting a few too many LSP errors for my liking:
Screenshot 2024-01-19 at 10 51 31

First of all, I want to check if what I'm doing is correct, and if not what am I doing wrong?

If I'm not doing anything wrong, can someone help me out in getting yamlls and helm_ls to work together properly.

Also, is there currently any work/idea to make this installation process easier and more user friendly. I'd be interested in helping to test this as a minimum contribution, but if I have time and energy I could even try and contribute code to this project as it seems to be the only one around that is trying to get Helm implementation done properly in neovim (and I really don't want to go back to VSCode).


I was also wondering, would it be possible to configure helmls or yamlls to warn/error for your own formatting, for example in my team, we like to have indents on array values, e.g.

someKeyForArray:
  - arrayItem1
  - arrayItem2

Rather than having it inline with the key value:

someKeyForArray:
- arrayItem1
- arrayItem2

@qvalentin
Copy link
Collaborator

Hi @Mo0rBy, thanks for the detailed description.

There a two type of problems currently known:

  1. Getting diagnostics from yamlls because it was wrongly started for helm files. This is what this thread was about up to now.
  2. Getting wrong diagnostics that helm-ls got from yamlls. These always start with "Yamlls" and are your problem as shown in the screenshot.

Those diagnostics are caused by the yamlls integration of helm-ls which can be disabled via the config.
This should fix the problem for you, but you will be missing some features.

The wrong diagnostics seem to be a bug, please send me all helm template files that caused wrong diagnostics starting with "Yamlls" so I can try to fix the bugs.

@Mo0rBy
Copy link

Mo0rBy commented Jan 19, 2024

Thanks for the quick response @qvalentin , I've set the configuration to disable yamlls and now I get no errors (nice!), but I think without yamlls enabled, there are A LOT of features missing. With this initial look, it seems all I can get is documentation for go template stuff, for example:

ne
Screenshot 2024-01-19 at 12 21 26

default
Screenshot 2024-01-19 at 12 21 35

quote
Screenshot 2024-01-19 at 12 21 45

toYaml
Screenshot 2024-01-19 at 12 21 52

I'll revert this change so I can get you the info on the LSP bugs that you describe, but I will need some time to modify the charts slightly as I can't share them as they are right now. Give me some time to do this (probably this weekend) and then I'll get them to you. Do you just want them posted here? I have a lot of examples, so it will be a big post.

@qvalentin
Copy link
Collaborator

qvalentin commented Jan 19, 2024

Thanks for the quick response @qvalentin , I've set the configuration to disable yamlls and now I get no errors (nice!), but I think without yamlls enabled, there are A LOT of features missing. With this initial look, it seems all I can get is documentation for go template stuff, for example:

ne Screenshot 2024-01-19 at 12 21 26

default Screenshot 2024-01-19 at 12 21 35

quote Screenshot 2024-01-19 at 12 21 45

toYaml Screenshot 2024-01-19 at 12 21 52

I'll revert this change so I can get you the info on the LSP bugs that you describe, but I will need some time to modify the charts slightly as I can't share them as they are right now. Give me some time to do this (probably this weekend) and then I'll get them to you. Do you just want them posted here? I have a lot of examples, so it will be a big post.

Sounds good, maybe open a seperate issue and post the files as gists/pastebins or a new git repo.

@qvalentin
Copy link
Collaborator

Thanks for the quick response @qvalentin , I've set the configuration to disable yamlls and now I get no errors (nice!), but I think without yamlls enabled, there are A LOT of features missing. With this initial look, it seems all I can get is documentation for go template stuff, for example:

ne Screenshot 2024-01-19 at 12 21 26

default Screenshot 2024-01-19 at 12 21 35

quote Screenshot 2024-01-19 at 12 21 45

toYaml Screenshot 2024-01-19 at 12 21 52

I'll revert this change so I can get you the info on the LSP bugs that you describe, but I will need some time to modify the charts slightly as I can't share them as they are right now. Give me some time to do this (probably this weekend) and then I'll get them to you. Do you just want them posted here? I have a lot of examples, so it will be a big post.

One short edit: You can also set the configuration option yamlls.diagnosticsLimit to a small number, to remove the wrong diagnostics, but not remove all yamlls features.

@Mo0rBy
Copy link

Mo0rBy commented Feb 4, 2024

I've decided not to post my own Helm charts as I'm a little worried my company would come after me!

Instead, can I suggest looking at the Bitnami Helm charts repo? There are looooooads of examples available on there that can be worked with.

1 question I have to see if this would even be possible. So with Helm Library charts, they can be stored and referenced within the local machines filesystem and I imagine that with this method, it would be possible to get the LSP to find definitions for Helm templates, however, would this be possible for library charts hosted in online repositories? For example, Bitnami have a common library which contains a bunch of useful utility templates that are heavily used in their own Helm charts and can easily be used in your own custom Helm charts. Furthermore, would it be possible to setup the LSP to get template definitions from private repositories? (my initial guess would be no without setting up some authentication stuff which I think would be kind of advanced for any LSP to do).

I would love to contribute to this so if you could point me to something that needs doing, let me know!

@qvalentin
Copy link
Collaborator

I've decided not to post my own Helm charts as I'm a little worried my company would come after me!

Instead, can I suggest looking at the Bitnami Helm charts repo? There are looooooads of examples available on there that can be worked with.

1 question I have to see if this would even be possible. So with Helm Library charts, they can be stored and referenced within the local machines filesystem and I imagine that with this method, it would be possible to get the LSP to find definitions for Helm templates, however, would this be possible for library charts hosted in online repositories? For example, Bitnami have a common library which contains a bunch of useful utility templates that are heavily used in their own Helm charts and can easily be used in your own custom Helm charts. Furthermore, would it be possible to setup the LSP to get template definitions from private repositories? (my initial guess would be no without setting up some authentication stuff which I think would be kind of advanced for any LSP to do).

I would love to contribute to this so if you could point me to something that needs doing, let me know!

I understand that You can't share the whole charts of you company, maybe you could pick a file where helm-ls breaks and try to delete stuff until you find out what causes the problem? Then you can narrow it down an make it easier to remove private information of your company.
I actually used the bitnami charts repo for testing, but probably not tested all files.

@keoren3
Copy link

keoren3 commented Feb 12, 2024

I've disabled the yamlls, using this code in my LSP:

["helm-ls"] = {                                                                                                        
    logLevel = "info",                                                                                                 
    valuesFiles = {                                                                                                    
        mainValuesFile = "values.yaml",                                                                                
        lintOverlayValuesFile = "values.lint.yaml",                                                                    
        additionalValuesFilesGlobPattern = "values*.yaml",                                                             
    },                                                                                                                 
    yamlls = {                                                                                                         
        enabled = false,                                                                                               
        diagnosticsLimit = 50,                                                                                         
        showDiagnosticsDirectly = false,                                                                               
        path = "yaml-language-server",                                                                                 
        filetypes_exclude = { "helm" },                                                                                
        config = {                                                                                                     
            schemas = {                                                                                                
                kubernetes = "templates/**",                                                                           
            },                                                                                                         
            completion = true,                                                                                         
            hover = true,                                                                                              
            -- any other config from https://github.com/redhat-developer/yaml-language-server#language-server-settings 
        },                                                                                                             
    },                                                                                                                 
},                                                                                                                     

And I'm getting this weird behavior that it shows some Yamlls errors, and each time I save the file the errors change until they disapear.

Did anyone else encounter this?

@qvalentin qvalentin added the nvim label Feb 29, 2024
@MartinEmrich
Copy link

Had the issue, too... After staring on my nvim-lspconfig setup for too long, the fault wasn't there all along:

The ft = 'helm' option on "towolf/wim-helm" is the magic sauce, no further Lua magic was necessary after that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation enhancement New feature or request nvim
Projects
None yet
Development

No branches or pull requests

8 participants