Skip to content

Commit

Permalink
feat(pack): Adding helm pack (#496)
Browse files Browse the repository at this point in the history
  • Loading branch information
Sacro authored Aug 2, 2023
1 parent 7d7f82a commit f8fbe84
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lua/astrocommunity/pack/helm/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Helm Language Pack

This plugin pack does the following:

- Adds `go-template` Treesitter parsers
- Adds `helm-ls` language server
- Adds [vim-helm](https://github.com/towolf/vim-helm) for language specific tools
67 changes: 67 additions & 0 deletions lua/astrocommunity/pack/helm/init.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
local utils = require "astronvim.utils"
return {
-- Helm support
{
"nvim-treesitter/nvim-treesitter",
optional = true,
dependencies = {
{
"ngalaiko/tree-sitter-go-template",
config = function()
require("nvim-treesitter.parsers").get_parser_configs().gotmpl = {
install_info = {
url = vim.fn.stdpath "data" .. "/lazy/tree-sitter-go-template",
files = "src/parser.c",
},
filetype = "helm",
}
end,
},
},
},
{
"williamboman/mason-lspconfig.nvim",
opts = function(_, opts)
opts.ensure_installed = utils.list_insert_unique(opts.ensure_installed, "helm_ls")

local configs = require "lspconfig.configs"
local lspconfig = require "lspconfig"
local util = require "lspconfig.util"

if not configs.helm_ls then
configs.helm_ls = {
default_config = {
cmd = { "helm_ls", "serve" },
filetypes = { "helm" },
root_dir = function(fname) return util.root_pattern "Chart.yaml"(fname) end,
},
}
end

lspconfig.helm_ls.setup {
filetypes = { "helm" },
cmd = { "helm_ls", "serve" },
}
end,
},
{
"towolf/vim-helm",
init = function()
local function helm_ft(path, _)
-- check if file is in templates folder or is helmfile
local path_regex = vim.regex "/templates/*\\.(tpl|yaml)$|*.gotmpl|helmfile*.yaml"
if path_regex and path_regex:match_str(path) then return "helm" end

-- return yaml if nothing else
return "yaml"
end

vim.filetype.add {
extension = {
yaml = helm_ft,
},
}
end,
ft = "helm",
},
}

0 comments on commit f8fbe84

Please sign in to comment.