Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature needed : How to add a linter for fortran? #568

Open
vickysharma0812 opened this issue Apr 13, 2024 · 1 comment
Open

Feature needed : How to add a linter for fortran? #568

vickysharma0812 opened this issue Apr 13, 2024 · 1 comment

Comments

@vickysharma0812
Copy link

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,
  },
@HeathenHeart
Copy link

Did you manage to make it work? I'm also interested in enabling a linter for Fortran as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants