Adding custom go-metalinter script
Only runs on files which have been modified.
This commit is contained in:
parent
46d5175dea
commit
679e3acbc1
5
.vimrc
5
.vimrc
@ -114,9 +114,8 @@ au FileType go nmap <Leader>gl <Plug>(go-metalinter)
|
||||
let g:go_auto_type_info = 0
|
||||
let g:go_fmt_command = "goimports"
|
||||
let g:go_metalinter_autosave = 1
|
||||
let g:go_metalinter_autosave_enabled = ['vet', 'golint', 'errcheck', 'varcheck']
|
||||
let g:go_metalinter_enabled = ['vet', 'golint', 'errcheck', 'varcheck', 'aligncheck', 'ineffassign', 'gosimple', 'staticcheck']
|
||||
let g:go_metalinter_deadline = '10s'
|
||||
let g:go_metalinter_command = "git metalinter"
|
||||
|
||||
|
||||
" Python Support {{{1
|
||||
Plug 'klen/python-mode'
|
||||
|
30
bin/git-metalint
Executable file
30
bin/git-metalint
Executable file
@ -0,0 +1,30 @@
|
||||
#!/usr/bin/python
|
||||
|
||||
import subprocess
|
||||
import sys
|
||||
import os
|
||||
from os import path
|
||||
|
||||
# Find the git root directory
|
||||
cwd = os.getcwd()
|
||||
while (".git" not in os.listdir(cwd)) and cwd != "/":
|
||||
cwd = path.dirname(cwd)
|
||||
|
||||
if cwd == "/":
|
||||
print("Could not find the git repository root")
|
||||
sys.exit(1)
|
||||
|
||||
# Run the metalinter commands from the root directory
|
||||
os.chdir(cwd)
|
||||
|
||||
files = subprocess.check_output(["git", "diff", "--name-only"])
|
||||
files_list = files.splitlines()
|
||||
|
||||
if len(files_list) == 0:
|
||||
sys.exit(0)
|
||||
|
||||
dirs_list = map(path.dirname, files_list)
|
||||
dirs_list = set(dirs_list)
|
||||
|
||||
for dir in dirs_list:
|
||||
subprocess.call(["gometalinter", dir])
|
Loading…
Reference in New Issue
Block a user