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

feat(pack): Adding helm pack #496

Merged
merged 1 commit into from
Aug 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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",
},
}