helm-ls icon indicating copy to clipboard operation
helm-ls copied to clipboard

yamlls and helm_ls

Open thegrumpylion opened this issue 1 year ago • 20 comments

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?

thegrumpylion avatar Aug 30 '23 07:08 thegrumpylion

Hi, i have the same problem here : https://github.com/mrjosh/helm-ls/issues/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

goof03 avatar Sep 21 '23 08:09 goof03

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 https://github.com/mrjosh/helm-ls/pull/32.

qvalentin avatar Sep 21 '23 17:09 qvalentin

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.

qvalentin avatar Sep 21 '23 17:09 qvalentin

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?

thegrumpylion avatar Sep 21 '23 17:09 thegrumpylion

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.

qvalentin avatar Sep 21 '23 19:09 qvalentin

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

goof03 avatar Oct 03 '23 07:10 goof03

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.

https://github.com/rgruyters/nvim/commit/dd7fb86fb6d69a84642ae0869c9ade47eb678735

rgruyters avatar Oct 04 '23 07:10 rgruyters

@rgruyters thanks no more red yamlls errors :-D

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

goof03 avatar Oct 04 '23 21:10 goof03

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

alex-w-k avatar Dec 21 '23 19:12 alex-w-k

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 avatar Dec 22 '23 12:12 qvalentin

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

Mo0rBy avatar Jan 19 '24 10:01 Mo0rBy

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.

qvalentin avatar Jan 19 '24 11:01 qvalentin

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.

Mo0rBy avatar Jan 19 '24 12:01 Mo0rBy

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 avatar Jan 19 '24 12:01 qvalentin

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.

qvalentin avatar Feb 01 '24 20:02 qvalentin

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!

Mo0rBy avatar Feb 04 '24 16:02 Mo0rBy

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.

qvalentin avatar Feb 04 '24 17:02 qvalentin

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?

keoren3 avatar Feb 12 '24 20:02 keoren3

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.

MartinEmrich avatar Mar 11 '24 08:03 MartinEmrich

This config block helped me figure out what's going on: https://github.com/mrjosh/helm-ls/blob/master/examples/nvim/init.lua#L29-L38

In my config I was doing this:

Not Working:

        settings = { [Not committed yet]
            yamlls = {
                enabled = false, -- not yet working, see: https://github.com/mrjosh/helm-ls/issues/44
                enabledForFilesGlob = "*.{yaml.yml}",
                path = "yaml-language-server",
                config = {
                    keyOrdering = false,
                },
            },
        },

Working:

        settings = {
            ['helm-ls'] = {
                yamlls = {
                    enabled = false, -- not yet working, see: https://github.com/mrjosh/helm-ls/issues/44
                    enabledForFilesGlob = "*.{yaml.yml}",
                    path = "yaml-language-server",
                    config = {
                        keyOrdering = false,
                    },
                },
            }, [Not committed yet]
        },

Notice there is 1 additional layer of key indirection: settings.helm-ls.yamlls even though the settings are already for helm_ls in the lsp.

hjkatz avatar Sep 13 '24 19:09 hjkatz