Skip to content

Commit ebbc5b3

Browse files
authored
Add some VimScript lint tools (#1558)
* Add some VimScript lint tools https://github.com/syngan/vim-vimlint https://github.com/Kuniwak/vint * Remove trailing newlines * Add augroup to all autocmds * Fix undefined variables `l:tmpname` is never defined. * Explicitly define global variables with g: * Disable some vint errors * Change has() syntax to what vimlint wants * Disable warning for unused variables Too much effort to fix and vimlint can't deal with closures... * Install vint in Dockerfile * Add 2>&1
1 parent a81c1bd commit ebbc5b3

File tree

19 files changed

+103
-41
lines changed

19 files changed

+103
-41
lines changed

.travis.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
language: go
2+
notifications:
3+
email: false
24
matrix:
35
include:
46
- env: SCRIPT=test VIM_VERSION=vim-7.4
@@ -7,5 +9,6 @@ matrix:
79
- env: SCRIPT=lint VIM_VERSION=vim-8.0
810
install:
911
- ./scripts/install-vim $VIM_VERSION
12+
- pip install --user vim-vint
1013
script:
1114
- ./scripts/$SCRIPT $VIM_VERSION

.vintrc.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
policies:
2+
ProhibitUnnecessaryDoubleQuote:
3+
enabled: false
4+
ProhibitEqualTildeOperator:
5+
enabled: false
6+
ProhibitNoAbortFunction:
7+
enabled: false

Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
FROM golang:1.9.1
22

33
RUN apt-get update -y && \
4-
apt-get install -y build-essential curl git libncurses5-dev && \
4+
apt-get install -y build-essential curl git libncurses5-dev python3-pip && \
55
apt-get clean && \
66
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
77

@@ -14,5 +14,6 @@ WORKDIR /vim-go
1414
RUN scripts/install-vim vim-7.4
1515
RUN scripts/install-vim vim-8.0
1616
RUN scripts/install-vim nvim
17+
RUN pip3 install vim-vint
1718

1819
ENTRYPOINT ["make"]

autoload/ctrlp/decls.vim

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,6 @@ function! ctrlp#decls#enter() abort
9393
return
9494
endif
9595

96-
if exists("l:tmpname")
97-
call delete(l:tmpname)
98-
endif
99-
10096
let result = eval(out)
10197
if type(result) != 4 || !has_key(result, 'decls')
10298
return

autoload/fzf/decls.vim

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,10 +90,6 @@ function! s:source(mode,...) abort
9090
return
9191
endif
9292

93-
if exists("l:tmpname")
94-
call delete(l:tmpname)
95-
endif
96-
9793
let result = eval(out)
9894
if type(result) != 4 || !has_key(result, 'decls')
9995
return ret_decls

autoload/go/cmd.vim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ function! go#cmd#Build(bang, ...) abort
1414
" placeholder with the current folder (indicated with '.'). We also pass -i
1515
" that tries to install the dependencies, this has the side effect that it
1616
" caches the build results, so every other build is faster.
17-
let args =
17+
let args =
1818
\ ["build"] +
1919
\ map(copy(a:000), "expand(v:val)") +
2020
\ ["-i", ".", "errors"]

autoload/go/coverage.vim

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,9 @@ function! go#coverage#Clear() abort
9595
if exists("s:toggle") | let s:toggle = 0 | endif
9696

9797
" remove the autocmd we defined
98-
if exists("#BufWinLeave#<buffer>")
99-
autocmd! BufWinLeave <buffer>
100-
endif
98+
augroup vim-go-coverage
99+
autocmd!
100+
augroup end
101101
endfunction
102102

103103
" Browser creates a new cover profile with 'go test -coverprofile' and opens
@@ -258,7 +258,10 @@ function! go#coverage#overlay(file) abort
258258
endfor
259259

260260
" clear the matches if we leave the buffer
261-
autocmd BufWinLeave <buffer> call go#coverage#Clear()
261+
augroup vim-go-coverage
262+
autocmd!
263+
autocmd BufWinLeave <buffer> call go#coverage#Clear()
264+
augroup end
262265

263266
for m in matches
264267
call matchaddpos(m.group, m.pos)

autoload/go/fmt.vim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ function! go#fmt#update_file(source, target)
131131

132132
" the title information was introduced with 7.4-2200
133133
" https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
134-
if has('patch-7.4-2200')
134+
if has('patch-7.4.2200')
135135
" clean up previous list
136136
if l:listtype == "quickfix"
137137
let l:list_title = getqflist({'title': 1})

autoload/go/guru.vim

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,10 @@ function! s:same_ids_highlight(exit_val, output) abort
529529
if get(g:, "go_auto_sameids", 0)
530530
" re-apply SameIds at the current cursor position at the time the buffer
531531
" is redisplayed: e.g. :edit, :GoRename, etc.
532-
autocmd BufWinEnter <buffer> nested call go#guru#SameIds()
532+
augroup vim-go-sameids
533+
autocmd!
534+
autocmd BufWinEnter <buffer> nested call go#guru#SameIds()
535+
augroup end
533536
endif
534537
endfunction
535538

@@ -551,9 +554,9 @@ function! go#guru#ClearSameIds() abort
551554
endif
552555

553556
" remove the autocmds we defined
554-
if exists("#BufWinEnter#<buffer>")
555-
autocmd! BufWinEnter <buffer>
556-
endif
557+
augroup vim-go-sameids
558+
autocmd!
559+
augroup end
557560

558561
return 0
559562
endfunction

autoload/go/list.vim

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ if !exists("g:go_list_type_commands")
77
endif
88

99
" Window opens the list with the given height up to 10 lines maximum.
10-
" Otherwise g:go_loclist_height is used.
10+
" Otherwise g:go_loclist_height is used.
1111
"
12-
" If no or zero height is given it closes the window by default.
12+
" If no or zero height is given it closes the window by default.
1313
" To prevent this, set g:go_list_autoclose = 0
1414
function! go#list#Window(listtype, ...) abort
1515
" we don't use lwindow to close the location list as we need also the

0 commit comments

Comments
 (0)