Sorry for ghosting this thread, I thought I would get a notification but for some reason it just stopped. I’ve done some work, and I’ve come up with a minimal-ish config to get nvim-lint working and fortls.
Looks ugly but customization should be easy to slot in. One thing is that the default lazy bootstrap will load the colorscheme habamax when installing new plugins but not when opening nvim without a new plugin, which I didn’t bother to remove. The config directory structure is based on how lazy.nvim docs suggests doing it, so it loads every plugin in the plugins folder. I’ve set this up on a new Arch install (wsl) and the only thing it requires is python3 and gfortran.

init.lua
require "config.lazy"
vim.api.nvim_create_autocmd({"BufEnter", "InsertLeave", "BufWritePost"}, {
callback = function()
local lint_status, lint = pcall(require, "lint")
if lint_status then
lint.try_lint()
end
end
})
lua/config/lazy.lua
-- Bootstrap lazy.nvim
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not (vim.uv or vim.loop).fs_stat(lazypath) then
local lazyrepo = "https://github.com/folke/lazy.nvim.git"
local out = vim.fn.system({ "git", "clone", "--filter=blob:none", "--branch=stable", lazyrepo, lazypath })
if vim.v.shell_error ~= 0 then
vim.api.nvim_echo({
{ "Failed to clone lazy.nvim:\n", "ErrorMsg" },
{ out, "WarningMsg" },
{ "\nPress any key to exit..." },
}, true, {})
vim.fn.getchar()
os.exit(1)
end
end
vim.opt.rtp:prepend(lazypath)
-- Make sure to setup `mapleader` and `maplocalleader` before
-- loading lazy.nvim so that mappings are correct.
-- This is also a good place to setup other settings (vim.opt)
vim.g.mapleader = " "
vim.g.maplocalleader = "\\"
-- Setup lazy.nvim
require("lazy").setup({
spec = {
-- import your plugins
{ import = "plugins" },
},
-- Configure any other settings here. See the documentation for more details.
-- colorscheme that will be used when installing plugins.
install = { colorscheme = { "habamax" } },
-- automatically check for plugin updates
checker = { enabled = true },
})
plugins/lint.lua
return {
"mfussenegger/nvim-lint",
event = { "BufWritePost", "InsertLeave" },
config = function()
local lint = require "lint"
local gfortran_diagnostic_args = { "-Wall", "-Wextra", "-fmax-errors=5" }
lint.linters_by_ft = {
fortran = {
"gfortran",
},
}
local pattern = "^([^:]+):(%d+):(%d+):%s+([^:]+):%s+(.*)$"
local groups = { "file", "lnum", "col", "severity", "message" }
local severity_map = {
["Error"] = vim.diagnostic.severity.ERROR,
["Warning"] = vim.diagnostic.severity.WARN,
}
local defaults = { ["source"] = "gfortran" }
local required_args = { "-fsyntax-only", "-fdiagnostics-plain-output" }
local args = vim.list_extend(required_args, gfortran_diagnostic_args)
lint.linters.gfortran = {
cmd = "gfortran",
stdin = false,
append_fname = true,
stream = "stderr",
env = nil,
args = args,
ignore_exitcode = true,
parser = require("lint.parser").from_pattern(pattern, groups, severity_map, defaults),
}
end,
}
plugins/lsp.lua
return {
{
"williamboman/mason.nvim",
config = function()
require("mason").setup{}
end,
},
{
"williamboman/mason-lspconfig.nvim",
config = function()
require("mason-lspconfig").setup({
ensure_installed = { "fortls" }
})
end,
},
{
"neovim/nvim-lspconfig",
config = function()
local lspconfig = require("lspconfig")
lspconfig.fortls.setup({})
end,
}
}