Skip to content

Commit 06e2550

Browse files
Merge pull request #16 from venkatarenduchintala/feat/sre-go-terraform
feat(sre): add Go and Terraform language support with CI validation
2 parents 7813c35 + f919002 commit 06e2550

14 files changed

Lines changed: 304 additions & 32 deletions

File tree

.github/workflows/validate.yml

Lines changed: 4 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -38,36 +38,12 @@ jobs:
3838
- name: Check Neovim version
3939
run: docker run --rm nvim-config:ci nvim --version
4040

41-
- name: Prepare plugin data directory
42-
run: |
43-
mkdir -p $HOME/.local/share/nvim-ci
44-
chmod 777 $HOME/.local/share/nvim-ci
45-
46-
- name: Cache lazy.nvim plugins
47-
uses: actions/cache@v4
48-
with:
49-
path: ~/.local/share/nvim-ci
50-
key: nvim-plugins-${{ hashFiles('lua/plugins/**/*.lua') }}
51-
restore-keys: nvim-plugins-
52-
53-
- name: Install plugins via lazy.nvim
54-
run: |
55-
docker run --rm \
56-
-e CI=true \
57-
-v "${{ github.workspace }}:/home/dev/.config/nvim:ro" \
58-
-v "$HOME/.local/share/nvim-ci:/home/dev/.local/share/nvim" \
59-
nvim-config:ci \
60-
nvim --headless \
61-
-c "lua require('lazy').sync({wait=true, show=false})" \
62-
-c "qall"
63-
timeout-minutes: 15
64-
65-
- name: Validate Neovim loads with all plugins
41+
- name: Run all Neovim validations
6642
run: |
6743
docker run --rm \
44+
--network=host \
6845
-e CI=true \
6946
-v "${{ github.workspace }}:/home/dev/.config/nvim:ro" \
70-
-v "$HOME/.local/share/nvim-ci:/home/dev/.local/share/nvim" \
7147
nvim-config:ci \
72-
nvim --headless -c "qall"
73-
timeout-minutes: 2
48+
bash /home/dev/.config/nvim/test/ci_validate.sh
49+
timeout-minutes: 30

lua/autocmds.lua

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,14 @@ vim.api.nvim_create_autocmd("FileType", {
4545
end,
4646
})
4747

48+
-- Disable cmp autocompletion for YAML — we want linting/diagnostics only
49+
vim.api.nvim_create_autocmd("FileType", {
50+
pattern = "yaml",
51+
callback = function()
52+
require("cmp").setup.buffer({ enabled = false })
53+
end,
54+
})
55+
4856
-- Disable automatic line breaks
4957
vim.api.nvim_create_autocmd("FileType", {
5058
pattern = "*",

lua/lsp/configs/go.lua

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
return {
2+
"leoluz/nvim-dap-go",
3+
ft = "go",
4+
dependencies = {
5+
"mfussenegger/nvim-dap",
6+
},
7+
config = function()
8+
require("dap-go").setup({
9+
dap_configurations = {
10+
{
11+
type = "go",
12+
name = "Attach remote",
13+
mode = "remote",
14+
request = "attach",
15+
},
16+
},
17+
delve = {
18+
path = "dlv",
19+
initialize_timeout_sec = 20,
20+
port = "${port}",
21+
args = {},
22+
build_flags = "",
23+
detached = vim.fn.has("win32") == 0,
24+
},
25+
})
26+
27+
local wk = require("which-key")
28+
wk.add({
29+
{ "<leader>dt", "<cmd>lua require('dap-go').debug_test()<cr>", desc = "[GO] Debug test under cursor" },
30+
{ "<leader>dT", "<cmd>lua require('dap-go').debug_last_test()<cr>", desc = "[GO] Debug last test" },
31+
})
32+
end,
33+
}

lua/lsp/init.lua

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,10 +114,32 @@ if lspconfig then
114114
capabilities = capabilities,
115115
})
116116

117-
-- YAMLs
117+
-- YAMLs — diagnostics only, no completion
118118
lspconfig("yamlls", {
119+
autostart = true,
119120
capabilities = capabilities,
120-
autostart = false,
121+
settings = {
122+
yaml = {
123+
validate = true,
124+
hover = true,
125+
completion = false,
126+
schemaStore = {
127+
enable = true,
128+
url = "https://www.schemastore.org/api/json/catalog.json",
129+
},
130+
schemas = {
131+
-- Kubernetes manifests in common SRE directory layouts
132+
kubernetes = {
133+
"manifests/**/*.yaml",
134+
"k8s/**/*.yaml",
135+
"kubernetes/**/*.yaml",
136+
"deploy/**/*.yaml",
137+
"templates/**/*.yaml",
138+
"chart/templates/**/*.yaml",
139+
},
140+
},
141+
},
142+
},
121143
})
122144

123145
-- CMake Language Server
@@ -140,8 +162,18 @@ if lspconfig then
140162

141163
-- Go Language Server
142164
lspconfig("gopls", {
143-
autostart = false,
165+
autostart = true,
144166
capabilities = capabilities,
167+
settings = {
168+
gopls = {
169+
analyses = {
170+
unusedparams = true,
171+
shadow = true,
172+
},
173+
staticcheck = true,
174+
gofumpt = true,
175+
},
176+
},
145177
})
146178

147179
-- Gradle Language Server

lua/plugins/configs/mason.lua

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ return {
2020
automatic_enable = false,
2121
-- skip heavy binary downloads in CI; lazy.nvim plugin code is still validated
2222
ensure_installed = vim.env.CI and {} or {
23+
"gopls",
24+
"terraform-ls",
2325
"ansiblels",
2426
"awk_ls",
2527
"bashls",
@@ -56,6 +58,7 @@ return {
5658
automatic_installation = not vim.env.CI,
5759
quiet_mode = false,
5860
ensure_installed = vim.env.CI and {} or {
61+
"tflint",
5962
"actionlint",
6063
"ansible-lint",
6164
"api-linter",
@@ -81,6 +84,18 @@ return {
8184
},
8285
ignore_install = {},
8386
})
87+
88+
-- Wire up nvim-lint: which linters run per filetype and when
89+
local lint = require("lint")
90+
lint.linters_by_ft = {
91+
yaml = { "yamllint" },
92+
}
93+
vim.api.nvim_create_autocmd({ "BufWritePost", "BufEnter" }, {
94+
pattern = { "*.yaml", "*.yml" },
95+
callback = function()
96+
lint.try_lint()
97+
end,
98+
})
8499
end,
85100
},
86101
{
@@ -93,6 +108,7 @@ return {
93108
config = function()
94109
require("mason-nvim-dap").setup({
95110
ensure_installed = vim.env.CI and {} or {
111+
"delve",
96112
"codelldb",
97113
"javatest",
98114
"javadbg",

lua/plugins/configs/treesitter.lua

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,11 @@ return {
3636
"javascript",
3737
"typescript",
3838
"vue",
39-
"toml"
39+
"toml",
40+
-- SRE
41+
"go",
42+
"terraform",
43+
"hcl",
4044
},
4145
refactor = {
4246
highlight_definitions = {

lua/plugins/init.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ local plugins = {
8686
require("plugins.configs.mason"),
8787
"neovim/nvim-lspconfig",
8888
require("lsp.configs.dap"),
89+
require("lsp.configs.go"),
8990
require("lsp.configs.java"),
9091
require("lsp.configs.rust"),
9192
require("lsp.configs.python"),

test/ci_install_plugins.lua

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
-- Headless lazy.nvim plugin installer for CI.
2+
-- Exits 1 loudly if lazy.nvim is not loadable or sync fails.
3+
local ok, lazy = pcall(require, 'lazy')
4+
if not ok then
5+
io.stderr:write('FATAL: lazy.nvim not loadable: ' .. tostring(lazy) .. '\n')
6+
vim.cmd('cquit 1')
7+
end
8+
9+
print('lazy.nvim loaded, starting sync...')
10+
lazy.sync({ wait = true, show = false })
11+
print('lazy.nvim sync complete')

test/ci_validate.sh

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/bin/bash
2+
set -e
3+
4+
echo "=== Bootstrapping lazy.nvim ==="
5+
git clone --filter=blob:none \
6+
https://github.com/folke/lazy.nvim.git \
7+
--branch=stable \
8+
"$HOME/.local/share/nvim/lazy/lazy.nvim"
9+
10+
echo "=== Installing plugins via lazy.nvim ==="
11+
nvim --headless \
12+
-c "luafile /home/dev/.config/nvim/test/ci_install_plugins.lua" \
13+
-c "qall"
14+
15+
echo "=== Validating Neovim startup with all plugins ==="
16+
nvim --headless -c "qall"
17+
18+
echo "=== Installing treesitter parsers (Go, Terraform, HCL) ==="
19+
nvim --headless \
20+
-c "luafile /home/dev/.config/nvim/test/install_parsers.lua" \
21+
-c "qall"
22+
23+
echo "=== Testing Go and Terraform treesitter parsers ==="
24+
nvim --headless \
25+
-c "luafile /home/dev/.config/nvim/test/validate_treesitter.lua" \
26+
-c "qall"
27+
28+
echo "=== All validations passed! ==="

test/fixtures/deployment.yaml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: hello-app
5+
namespace: default
6+
labels:
7+
app: hello-app
8+
spec:
9+
replicas: 2
10+
selector:
11+
matchLabels:
12+
app: hello-app
13+
template:
14+
metadata:
15+
labels:
16+
app: hello-app
17+
spec:
18+
containers:
19+
- name: hello-app
20+
image: nginx:1.25
21+
ports:
22+
- containerPort: 80
23+
resources:
24+
requests:
25+
cpu: "100m"
26+
memory: "128Mi"
27+
limits:
28+
cpu: "250m"
29+
memory: "256Mi"

0 commit comments

Comments
 (0)