vim syntax for helm templates (yaml + gotmpl + sprig + custom)
Install via vundle:
Plugin 'towolf/vim-helm'
vim syntax for helm templates (yaml + gotmpl + sprig + custom)
License: Other
Helm files are handled as YAML and produces much LSP errors.
I've got this in my on_attach function:
local on_attach = function(client, bufnr)
-- Short-circuit for Helm template files
if vim.bo[bufnr].buftype ~= '' or vim.bo[bufnr].filetype == 'helm' then
vim.diagnostic.disable(bufnr)
vim.defer_fn(function()
vim.diagnostic.reset(nil, bufnr)
end, 1000)
return
end
...
It's not perfect (defer_fn), the statusline still reports error summary sometimes, but it's the best I came up with.
Anybody has better workarounds?
Hello @towolf @luisdavim
After the latest update 69a5117
Every *.yaml
file within the folder containing Chart.yaml
is detected as helm
.
Even Chart.yaml
itself is detected as helm
E.g. in such structure, all three yaml
files are detected as helm
, and that's wrong.
Only ones located in templates
folder should be considered as helm
.
├── Chart.yaml
├── src
│ └── model
│ └── test.yaml
└── templates
└── deployment.yaml
Hello
Currently, default Vim's commentstring
is used, it's usually C-style comment /* ... */
.
The plugin should set it to {{/* ... */}}
- this will be a proper comment both for Go template and Yaml within Helm template or similar files.
Currently there could be collisions with regular yaml files and Ansible yamls, etc.
Also, there's no support for yml
, only yaml
.
This can be improved by detecting Chart.yaml in parent directory for example.
Here's an example from an Ansible plugin: https://github.com/pearofducks/ansible-vim/blob/master/ftdetect/ansible.vim
Oil is an alternative file explorer for Neovim that lets you edit the filesystem inside a normal buffer. The buffer has the type oil
and is named oil:///<file path>
(or, I believe, oil-ssh:///<file path>
, since Oil also has ssh support)
The issue is that since the Oil opens directories in simple buffers, vim-helm
calls this function on them (also, I'm not sure why, but findfile("Chart.yaml", expand('%:p:h').';')
is always returning something, regardless of the current directory being emtpy. i.e. if I'm on an empty /foo
directory and I call findfile("Chart.yaml", expand('%:p:h').';')
on it, it will return /foo/Chart.yaml
)
Considering a neovim installation with both Oil.nvim
and vim-helm
, and an empty directory /Users/foo
, when I open that directory with nvim /Users/foo
and execute:
:echo findfile("Chart.yaml", expand('%:p:h').';')
I see:
(notice the filetype set to helm
and the output of the findfile command)
Currently helmfile templated values and auxilarily helmfile files are not detected anymore,
i.e. files like my.yaml.gotmpl
or helmfile-common.yaml
.
They were working before the latest changes.
There are my merged PRs
It would be great if this could be loaded as a vim plugin, i.e. with a plugin manager. A great guide for creating syntax plugins is here: https://robots.thoughtbot.com/writing-vim-syntax-plugins.
Thanks for the fantastic syntax file.
Hello,
I wanted to do a small PR to add a little precision in the README file, for the new user. (but it seems you are not accepting PR?)
changed proposed
" set the .tpl file type to yaml to get basic syntax and indentation
autocmd BufNewFile,BufRead *.tpl set filetype=yaml
" set the file type to helm to augment the syntax
autocmd BufRead,BufNewFile */templates/*.yaml,*/templates/*.tpl set ft=helm
this way it would colorize the Helm .tpl
files
thank you for your work
This would improve the syntax highlight of those files as well as the use of the helm language server, see: mrjosh/helm-ls#82
I think this should be builtin into vim, would you like to upstream it?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.