Skip to content

Commit

Permalink
Merge pull request #1071 from preservim/vint
Browse files Browse the repository at this point in the history
Lint vimscript, fix errors and warnings, add CI job to review PRs
  • Loading branch information
PhilRunninger authored Jan 2, 2020
2 parents f64c006 + 3fb31b2 commit 97fb849
Show file tree
Hide file tree
Showing 24 changed files with 694 additions and 671 deletions.
15 changes: 15 additions & 0 deletions .github/workflows/vint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: Vint
on: [push, pull_request]
jobs:
vint:
strategy:
fail-fast: false
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@master
- name: Run vint with reviewdog
uses: reviewdog/[email protected]
with:
github_token: ${{ secrets.github_token }}
reporter: github-pr-review
5 changes: 5 additions & 0 deletions .vintrc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
cmdargs:
severity: style_problem
color: true
env:
neovim: false
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
- **.PATCH**: Pull Request Title (PR Author) [PR Number](Link to PR)
-->
#### 6.4
- **.2**: Lint vimscript, fix errors and warnings, add CI job to review PRs (Caleb Maclennan) [#1071](https://github.com/preservim/nerdtree/pull/1071)
- **.1**: Ensure backward compatibility. v:t_func is not available before Vim 8.0 (Phil Runninger)
- **.0**: Allow use of function references as callbacks (HiPhish) [#1067](https://github.com/scrooloose/nerdtree/pull/1067)
#### 6.3
Expand Down
2 changes: 1 addition & 1 deletion README.markdown
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
The NERDTree
The NERDTree [![Vint](https://github.com/preservim/nerdtree/workflows/Vint/badge.svg)](https://github.com/preservim/nerdtree/actions?workflow=Vint)
=============

Introduction
Expand Down
76 changes: 38 additions & 38 deletions autoload/nerdtree.vim
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
if exists("g:loaded_nerdtree_autoload")
if exists('g:loaded_nerdtree_autoload')
finish
endif
let g:loaded_nerdtree_autoload = 1

let s:rootNERDTreePath = resolve(expand("<sfile>:p:h:h"))
let s:rootNERDTreePath = resolve(expand('<sfile>:p:h:h'))

"FUNCTION: nerdtree#version(...) {{{1
" If any value is given as an argument, the entire line of text from the
" change log is shown for the current version; otherwise, only the version
" number is shown.
function! nerdtree#version(...)
function! nerdtree#version(...) abort
let l:text = 'Unknown'
try
let l:changelog = readfile(join([s:rootNERDTreePath, "CHANGELOG.md"], nerdtree#slash()))
let l:changelog = readfile(join([s:rootNERDTreePath, 'CHANGELOG.md'], nerdtree#slash()))
let l:line = 0
while l:line <= len(l:changelog)
if l:changelog[l:line] =~ '\d\+\.\d\+'
if l:changelog[l:line] =~# '\d\+\.\d\+'
let l:text = substitute(l:changelog[l:line], '.*\(\d\+.\d\+\).*', '\1', '')
let l:text .= substitute(l:changelog[l:line+1], '^.\{-}\(\.\d\+\).\{-}:\(.*\)', a:0>0 ? '\1:\2' : '\1', '')
break
Expand All @@ -31,7 +31,7 @@ endfunction
"============================================================

"FUNCTION: nerdtree#slash() {{{2
function! nerdtree#slash()
function! nerdtree#slash() abort

if nerdtree#runningWindows()
if exists('+shellslash') && &shellslash
Expand All @@ -46,8 +46,8 @@ endfunction

"FUNCTION: nerdtree#and(x,y) {{{2
" Implements and() function for Vim <= 7.2
function! nerdtree#and(x,y)
if exists("*and")
function! nerdtree#and(x,y) abort
if exists('*and')
return and(a:x, a:y)
else
let l:x = a:x
Expand All @@ -68,7 +68,7 @@ endfunction

"FUNCTION: nerdtree#checkForBrowse(dir) {{{2
"inits a window tree in the current buffer if appropriate
function! nerdtree#checkForBrowse(dir)
function! nerdtree#checkForBrowse(dir) abort
if !isdirectory(a:dir)
return
endif
Expand All @@ -83,18 +83,18 @@ endfunction
"FUNCTION: s:reuseWin(dir) {{{2
"finds a NERDTree buffer with root of dir, and opens it.
function! s:reuseWin(dir) abort
let path = g:NERDTreePath.New(fnamemodify(a:dir, ":p"))
let path = g:NERDTreePath.New(fnamemodify(a:dir, ':p'))

for i in range(1, bufnr("$"))
for i in range(1, bufnr('$'))
unlet! nt
let nt = getbufvar(i, "NERDTree")
let nt = getbufvar(i, 'NERDTree')
if empty(nt)
continue
endif

if nt.isWinTree() && nt.root.path.equals(path)
call nt.setPreviousBuf(bufnr("#"))
exec "buffer " . i
call nt.setPreviousBuf(bufnr('#'))
exec 'buffer ' . i
return 1
endif
endfor
Expand All @@ -104,33 +104,33 @@ endfunction

" FUNCTION: nerdtree#completeBookmarks(A,L,P) {{{2
" completion function for the bookmark commands
function! nerdtree#completeBookmarks(A,L,P)
function! nerdtree#completeBookmarks(A,L,P) abort
return filter(g:NERDTreeBookmark.BookmarkNames(), 'v:val =~# "^' . a:A . '"')
endfunction

"FUNCTION: nerdtree#compareNodes(dir) {{{2
function! nerdtree#compareNodes(n1, n2)
function! nerdtree#compareNodes(n1, n2) abort
return a:n1.path.compareTo(a:n2.path)
endfunction

"FUNCTION: nerdtree#compareNodesBySortKey(n1, n2) {{{2
function! nerdtree#compareNodesBySortKey(n1, n2)
function! nerdtree#compareNodesBySortKey(n1, n2) abort
let sortKey1 = a:n1.path.getSortKey()
let sortKey2 = a:n2.path.getSortKey()
let i = 0
while i < min([len(sortKey1), len(sortKey2)])
" Compare chunks upto common length.
" If chunks have different type, the one which has
" integer type is the lesser.
if type(sortKey1[i]) == type(sortKey2[i])
if type(sortKey1[i]) ==# type(sortKey2[i])
if sortKey1[i] <# sortKey2[i]
return - 1
elseif sortKey1[i] ># sortKey2[i]
return 1
endif
elseif type(sortKey1[i]) == v:t_number
elseif type(sortKey1[i]) ==# v:t_number
return -1
elseif type(sortKey2[i]) == v:t_number
elseif type(sortKey2[i]) ==# v:t_number
return 1
endif
let i = i + 1
Expand All @@ -150,7 +150,7 @@ endfunction
" FUNCTION: nerdtree#deprecated(func, [msg]) {{{2
" Issue a deprecation warning for a:func. If a second arg is given, use this
" as the deprecation message
function! nerdtree#deprecated(func, ...)
function! nerdtree#deprecated(func, ...) abort
let msg = a:0 ? a:func . ' ' . a:1 : a:func . ' is deprecated'

if !exists('s:deprecationWarnings')
Expand All @@ -164,22 +164,22 @@ endfunction

" FUNCTION: nerdtree#exec(cmd, ignoreAll) {{{2
" Same as :exec cmd but, if ignoreAll is TRUE, set eventignore=all for the duration
function! nerdtree#exec(cmd, ignoreAll)
let old_ei = &ei
function! nerdtree#exec(cmd, ignoreAll) abort
let old_ei = &eventignore
if a:ignoreAll
set ei=all
set eventignore=all
endif
exec a:cmd
let &ei = old_ei
let &eventignore = old_ei
endfunction

" FUNCTION: nerdtree#has_opt(options, name) {{{2
function! nerdtree#has_opt(options, name)
return has_key(a:options, a:name) && a:options[a:name] == 1
function! nerdtree#has_opt(options, name) abort
return has_key(a:options, a:name) && a:options[a:name] ==# 1
endfunction

" FUNCTION: nerdtree#loadClassFiles() {{{2
function! nerdtree#loadClassFiles()
function! nerdtree#loadClassFiles() abort
runtime lib/nerdtree/path.vim
runtime lib/nerdtree/menu_controller.vim
runtime lib/nerdtree/menu_item.vim
Expand All @@ -197,7 +197,7 @@ function! nerdtree#loadClassFiles()
endfunction

" FUNCTION: nerdtree#postSourceActions() {{{2
function! nerdtree#postSourceActions()
function! nerdtree#postSourceActions() abort
call g:NERDTreeBookmark.CacheBookmarks(1)
call nerdtree#ui_glue#createDefaultBindings()

Expand All @@ -206,13 +206,13 @@ function! nerdtree#postSourceActions()
endfunction

"FUNCTION: nerdtree#runningWindows(dir) {{{2
function! nerdtree#runningWindows()
return has("win16") || has("win32") || has("win64")
function! nerdtree#runningWindows() abort
return has('win16') || has('win32') || has('win64')
endfunction

"FUNCTION: nerdtree#runningCygwin(dir) {{{2
function! nerdtree#runningCygwin()
return has("win32unix")
function! nerdtree#runningCygwin() abort
return has('win32unix')
endfunction

" SECTION: View Functions {{{1
Expand All @@ -223,16 +223,16 @@ endfunction
"
"Args:
"msg: the message to echo
function! nerdtree#echo(msg)
function! nerdtree#echo(msg) abort
redraw
echomsg empty(a:msg) ? "" : ("NERDTree: " . a:msg)
echomsg empty(a:msg) ? '' : ('NERDTree: ' . a:msg)
endfunction

"FUNCTION: nerdtree#echoError {{{2
"Wrapper for nerdtree#echo, sets the message type to errormsg for this message
"Args:
"msg: the message to echo
function! nerdtree#echoError(msg)
function! nerdtree#echoError(msg) abort
echohl errormsg
call nerdtree#echo(a:msg)
echohl normal
Expand All @@ -242,14 +242,14 @@ endfunction
"Wrapper for nerdtree#echo, sets the message type to warningmsg for this message
"Args:
"msg: the message to echo
function! nerdtree#echoWarning(msg)
function! nerdtree#echoWarning(msg) abort
echohl warningmsg
call nerdtree#echo(a:msg)
echohl normal
endfunction

"FUNCTION: nerdtree#renderView {{{2
function! nerdtree#renderView()
function! nerdtree#renderView() abort
call b:NERDTree.render()
endfunction

Expand Down
Loading

0 comments on commit 97fb849

Please sign in to comment.