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

nvim-lint with gcc #262

Open
ghost opened this issue Oct 17, 2022 · 1 comment
Open

nvim-lint with gcc #262

ghost opened this issue Oct 17, 2022 · 1 comment
Labels
needs: contribution Contributions are welcome

Comments

@ghost
Copy link

ghost commented Oct 17, 2022

Has somebody successfully used this with gcc for linting? I've experimenting with the settings for adding a new linter using the cppcheck as e template together with some of the info on gccdiag at null-ls.nvim and ALE, but with no success. Here's what I've tried:

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,
}

require('lint').linters.gcc = {
  cmd = 'cc',
  stdin = false, -- or false if it doesn't support content input via stdin. In that case the filename is automatically added to the arguments.
  append_fname = false, -- Automatically append the file name to `args` if `stdin = false` (default: true)
  args = {'-std=c89', '-Wall'}, -- list of arguments. Can contain functions with zero arguments that will be evaluated once the linter is used.
  stream = both, -- ('stdout' | 'stderr' | 'both') configure the stream to which the linter outputs the linting result.
  ignore_exitcode = false, -- set this to true if the linter exits with a code != 0 and that's considered normal.
  env = nil, -- custom environment table to use with the external process. Note that this replaces the *entire* environment, it is not additive.
  parser = require('lint.parser').from_pattern(pattern, groups, severity_map, { ['source'] = 'gcc' }),
}

Problem is, that I don't really know lua and don't know what I'm doing really. I just want to be able to use gcc together with the other linters to lint my code, just as i did with ALE. "cc" exists with code 1 according to neovim, but I don't know where I can get any more information? nvim-lint doesn't have any logs on what commands it runs (as LSP does?).

@mfussenegger mfussenegger added the needs: contribution Contributions are welcome label Jun 22, 2023
@kapkanov
Copy link

Try this: #492 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs: contribution Contributions are welcome
Projects
None yet
Development

No branches or pull requests

2 participants