Skip to content
This repository has been archived by the owner on Aug 12, 2023. It is now read-only.

feat: add diagnostic support for vhdl with vcom and ghdl #1207

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
32 changes: 32 additions & 0 deletions lua/null-ls/builtins/diagnostics/ghdl.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
local h = require("null-ls.helpers")
local methods = require("null-ls.methods")

local DIAGNOSTICS = methods.internal.DIAGNOSTICS

return h.make_builtin({
name = "ghdl",
meta = {
url = "https://github.com/ghdl/ghdl",
description = "Adds support for `ghdl` VHDL compiler/checker",
},
method = DIAGNOSTICS,
filetypes = { "vhdl" },
generator_opts = {
command = "ghdl",
to_stdin = false,
to_temp_file = true,
from_stderr = true,
args = { "-a", "--std=08", "--workdir=/tmp", "$FILENAME" },

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know nothing about this language or CLI tool, but judging from the documentation, it looks like there are multiple standards. Is this something we want to always set, or should we leave it up to users to configure?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, just so I understand: is the --workdir flag necessary because the program will otherwise compile and leave files in the current directory? If this is necessary then we may want to mention that the source will not work as expected on platforms that don't use /tmp.

format = "line",
on_output = h.diagnostics.from_pattern(
[[([^:]+):(%d+):(%d+):%s+(.+)]],
{ 'filename', 'row', 'col', 'message'},
{
severities = {
E = h.diagnostics.severities["error"],
},
}
),
},
factory = h.generator_factory,
})
34 changes: 34 additions & 0 deletions lua/null-ls/builtins/diagnostics/vcom.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
local h = require("null-ls.helpers")
local methods = require("null-ls.methods")

local DIAGNOSTICS = methods.internal.DIAGNOSTICS

return h.make_builtin({
name = "vcom",
meta = {
url = "https://eda.sw.siemens.com/en-US/ic/modelsim/",
description = "Adds support for Mentor Graphics Questa/ModelSim `vcom` VHDL compiler/checker",
notes = "If you want the work directory to be in the current working directory, remove '-work' and '/tmp/vcom_work' from the args list",
},
method = DIAGNOSTICS,
filetypes = { "vhdl" },
generator_opts = {
command = "vcom",
args = { "-2008", "-quiet", "-lint", "-work", "/tmp/vcom_work", "$FILENAME" },

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comments for above apply here.

to_stdin = false,
to_temp_file = true,
from_stderr = true,
format = "line",
on_output = h.diagnostics.from_pattern(
[[^**%s(%w+):[%a%d%s%.-_/]+%((%d+)%):%s+(.+)]],
{"severity", "row", "message" },
{
severities = {
E = h.diagnostics.severities["Error"],
W = h.diagnostics.severities["Warning"],
},
}
),
},
factory = h.generator_factory,
})