main
1-- Tekton LSP: attaches tekton-lsp to YAML files containing tekton.dev apiVersion
2-- TODO: remove hardcoded path once tekton-lsp is in $PATH
3local tekton_lsp_bin = vim.fn.expand("~/src/tektoncd/tekton-lsp-go/tekton-lsp")
4
5vim.api.nvim_create_autocmd({ "BufReadPost", "BufNewFile" }, {
6 group = vim.api.nvim_create_augroup("tekton_lsp_attach", { clear = true }),
7 pattern = { "*.yaml", "*.yml" },
8 callback = function(ev)
9 local lines = vim.api.nvim_buf_get_lines(ev.buf, 0, 50, false)
10 for _, line in ipairs(lines) do
11 if line:match("tekton%.dev") or line:match("triggers%.tekton%.dev") then
12 vim.lsp.start({
13 name = "tekton-lsp",
14 cmd = { tekton_lsp_bin },
15 root_dir = vim.fs.root(ev.buf, { ".git" }) or vim.fn.getcwd(),
16 })
17 return
18 end
19 end
20 end,
21})
22
23return {}