nvim-lint
nvim-lint copied to clipboard
Feature needed : How to add a linter for fortran?
I would like to add a linter for Fortran by using gfortran
compiler.
However, I am not sure how to do it. The linter setting used in vscode is given here: https://github.com/fortran-lang/vscode-fortran-support/blob/main/src/lint/compilers.ts
I need help in parsing.
My settings in neovim is given below:
{
"mfussenegger/nvim-lint",
config = function()
vim.notify("Loading fortran linting", 3, { title = "LazyVim" })
local lint = require("lint")
local pattern = [[^([^:]+):(%d+):(%d+):%s+([^:]+):%s+(.*)$]]
local groups = { "file", "lnum", "col", "code", "severity", "message" }
local severity_map = {
["error"] = vim.diagnostic.severity.ERROR,
["warning"] = vim.diagnostic.severity.WARN,
["performance"] = vim.diagnostic.severity.WARN,
["style"] = vim.diagnostic.severity.INFO,
["information"] = vim.diagnostic.severity.INFO,
}
local defaults = { ["source"] = "fortran" }
lint.linters.gfortran = {
name = "gfortran",
cmd = "gfortran",
args = {
"-c",
"-Wunused-variable",
"-Wunused-dummy-argument",
"-Wall",
"-I",
os.getenv("HOME") .. "/.easifem/install/easifem/extpkgs/include/",
os.getenv("HOME") .. "/.easifem/install/easifem/extpkgs/include/toml-f/modules/",
os.getenv("HOME") .. "/.easifem/install/easifem/base/include/",
os.getenv("HOME") .. "/.easifem/install/easifem/classes/include/",
os.getenv("HOME") .. "/.easifem/ide/include/",
"-J",
os.getenv("HOME") .. "/.easifem/ide/include/",
}, -- args to pass to the linter
ignore_exitcode = false, -- set this to true if you don't want to show error messages
stream = "both", -- set this to "stdout" if the output is not an error, for example with luac
parser = require("lint.parser").from_pattern(pattern, groups, severity_map, defaults),
}
lint.linters_by_ft = { fortran = { "gfortran" } }
end,
},
Did you manage to make it work? I'm also interested in enabling a linter for Fortran as well.
change ignore_exitcode = false
to ignore_exitcode = true
add args:
-fsyntax-only -cpp -fdiagnostics-plain-output
and change
local groups = { "file", "lnum", "col", "code", "severity", "message" }
to
local groups = { "file", "lnum", "col", "severity", "message" }
I modified it base on my gcc config, and i have not tested it