1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
local config_files = {
"vsg_config.yaml",
"vsg_config.yml",
"vsg_config.json",
"vsg.yaml",
"vsg.yml",
"vsg.json",
".vsg_config.yaml",
".vsg_config.yml",
".vsg_config.json",
".vsg.yaml",
".vsg.yml",
".vsg.json",
}
local function find_config(dirname)
local paths = {
dirname,
(os.getenv("XDG_CONFIG_HOME") or os.getenv("HOME") .. "/.config") .. "/vsg",
}
for _, path in ipairs(paths) do
local config = vim.fs.find(config_files, {
path = path,
upward = path == dirname,
})[1]
if config then
return config
end
end
end
---@type conform.FileFormatterConfig
return {
meta = {
url = "https://github.com/jeremiah-c-leary/vhdl-style-guide",
description = "Style guide enforcement for VHDL.",
},
command = "vsg",
stdin = false,
args = function(_, ctx)
local args = { "-of", "syntastic", "--fix", "-f", "$FILENAME" }
local config_file = find_config(ctx.dirname)
if config_file then
table.insert(args, "-c")
table.insert(args, config_file)
end
return args
end,
}
|