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

make --exclude-use-default configurable #2501

Closed
jschwinger233 opened this issue Sep 19, 2019 · 4 comments
Closed

make --exclude-use-default configurable #2501

jschwinger233 opened this issue Sep 19, 2019 · 4 comments

Comments

@jschwinger233
Copy link

What did you do? (required: The issue will be closed when not provided)

composed a golangci-lint config file under the project root dir but failed to make it work

# .golangci.yml
linters:
  # inverted configuration with `enable-all` and `disable` is not scalable during updates of golangci-lint
  disable-all: true
  enable:
    - golint

issues:
  exclude-use-default: true

What did you expect to happen?

it's expected that exported method should have comment or be unexported is hidden because I specified exclude-use-default: true in config file.

What happened instead?

error exported method should have comment or be unexported still raised

Configuration (MUST fill this out):

vim-go version:

silent! let g:plugs['vim-go'].commit = '1946131'

vimrc you used to reproduce (use a minimal vimrc with other plugins disabled; do not link to a 2,000 line vimrc):

vimrc
let g:go_metalinter_command='golangci-lint'
let g:go_metalinter_autosave = 1
let g:go_fmt_command = "goimports"
let g:go_def_mapping_enabled = 0

Vim version (first three lines from :version):

VIM - Vi IMproved 8.1 (2018 May 18, compiled Jul 21 2019 22:54:00)
macOS version
Included patches: 1-1722

Go version (go version):

go version go1.12.6 darwin/amd64

Go environment

go env Output:

@jschwinger233
Copy link
Author

I believe the issue is caused by

let cmd += ["--exclude-use-default=false"]
, could we add a variable to toggle this flag?

@bhcleek
Copy link
Collaborator

bhcleek commented Sep 19, 2019

I'm reluctant to add specific support for this for reasons that are outlined in golangci/golangci-lint#456.

However, vim-go does support specifying your own metalinter command to run by setting g:go_metalinter_command to the value you want. 🤔

@bhcleek
Copy link
Collaborator

bhcleek commented Sep 19, 2019

I'll give this some more thought; it may be possible to provide a feature to do this easily in a way that gives you more control generically and will be extensible in the future. 🤔

@jschwinger233
Copy link
Author

jschwinger233 commented Sep 20, 2019

never mind, I made it by implementing a crude compiler:

  1. compose a compiler file:
# cat > ~/.vim/plugged/vim-go/compiler/golangci-lint.vim <<'!'
let g:current_compiler = "golangci-lint"
CompilerSet makeprg=golangci-lint\ run
CompilerSet errorformat =%f:%l:%c:\ %m
!
  1. configure project lint:
# cat > $PROJECT/.golangci.yaml <<'!'
issues:
  exclude-use-default: false
!
  1. add some shortcuts for auto lint once :w
# cat >> ~/.vimrc <<'!'
autocmd FileType go nnoremap <C-n> :copen<cr>:cn<cr>
autocmd FileType go nnoremap <C-p> :copen<cr>:cp<cr>
autocmd FileType go compiler golangci-lint
autocmd BufWritePost *.go :make %
!
  1. then simply type :w and voilà, use ctrl-n / ctrl-p to jump.

Thanks all the same.

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