Skip to content

Commit 80205b1

Browse files
authored
Fix lints from vim-vint (#102)
Fixes violations of the Google vimscipt style guide. - Use string matching operators that don't depend on user settings. - Always put autocmd in an augroup. - Use single quotes. - Always prefix variables with their scope.
1 parent c16efc1 commit 80205b1

File tree

5 files changed

+21
-19
lines changed

5 files changed

+21
-19
lines changed

autoload/dart.vim

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ endfunction
8484
" If the path cannot be resolved, or is not a package: uri, returns the
8585
" original.
8686
function! dart#resolveUri(uri) abort
87-
if a:uri !~ 'package:'
87+
if a:uri !~# 'package:'
8888
return a:uri
8989
endif
9090
let package_name = substitute(a:uri, 'package:\(\w\+\)\/.*', '\1', '')
@@ -116,20 +116,20 @@ function! s:PackageMap() abort
116116
let lines = readfile(dot_packages)
117117
let map = {}
118118
for line in lines
119-
if line =~ '\s*#'
119+
if line =~# '\s*#'
120120
continue
121121
endif
122122
let package = substitute(line, ':.*$', '', '')
123123
let lib_dir = substitute(line, '^[^:]*:', '', '')
124-
if lib_dir =~ 'file:/'
124+
if lib_dir =~# 'file:/'
125125
let lib_dir = substitute(lib_dir, 'file://', '', '')
126-
if lib_dir =~ '/[A-Z]:/'
126+
if lib_dir =~# '/[A-Z]:/'
127127
let lib_dir = lib_dir[1:]
128128
endif
129129
else
130130
let lib_dir = resolve(dot_packages_dir.'/'.lib_dir)
131131
endif
132-
if lib_dir =~ '/$'
132+
if lib_dir =~# '/$'
133133
let lib_dir = lib_dir[:len(lib_dir) - 2]
134134
endif
135135
let map[package] = lib_dir
@@ -139,7 +139,7 @@ endfunction
139139

140140
" Toggle whether dartfmt is run on save or not.
141141
function! dart#ToggleFormatOnSave() abort
142-
if get(g:, "dart_format_on_save", 0)
142+
if get(g:, 'dart_format_on_save', 0)
143143
let g:dart_format_on_save = 0
144144
return
145145
endif

ftdetect/dart.vim

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1-
autocmd BufRead,BufNewFile *.dart set filetype=dart
1+
augroup dart-vim-plugin-ftdetec
2+
autocmd!
3+
autocmd BufRead,BufNewFile *.dart set filetype=dart
4+
autocmd BufRead * call s:DetectShebang()
5+
augroup END
26

37
function! s:DetectShebang()
48
if did_filetype() | return | endif
5-
if getline(1) == '#!/usr/bin/env dart'
9+
if getline(1) ==# '#!/usr/bin/env dart'
610
setlocal filetype=dart
711
endif
812
endfunction
9-
10-
autocmd BufRead * call s:DetectShebang()

indent/dart.vim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ setlocal indentexpr=DartIndent()
1010

1111
let b:undo_indent = 'setl cin< cino<'
1212

13-
if exists("*DartIndent")
13+
if exists('*DartIndent')
1414
finish
1515
endif
1616

plugin/dart.vim

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ set cpo&vim
99

1010
function! s:FormatOnSave()
1111
" Dart code formatting on save
12-
if get(g:, "dart_format_on_save", 0)
13-
call dart#fmt("")
12+
if get(g:, 'dart_format_on_save', 0)
13+
call dart#fmt('')
1414
endif
1515
endfunction
1616

syntax/dart.vim

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33
" for details. All rights reserved. Use of this source code is governed by a
44
" BSD-style license that can be found in the LICENSE file.
55

6-
if !exists("g:main_syntax")
7-
if version < 600
6+
if !exists('g:main_syntax')
7+
if v:version < 600
88
syntax clear
9-
elseif exists("b:current_syntax")
9+
elseif exists('b:current_syntax')
1010
finish
1111
endif
1212
let g:main_syntax = 'dart'
13-
syntax region dartFold start="{" end="}" transparent fold
13+
syntax region dartFold start='{' end='}' transparent fold
1414
endif
1515

1616
" Ensure long multiline strings are highlighted.
@@ -134,8 +134,8 @@ highlight default link dartUserType dartType
134134
highlight default link dartType Type
135135
highlight default link dartFunction Function
136136

137-
let b:current_syntax = "dart"
138-
let b:spell_options = "contained"
137+
let b:current_syntax = 'dart'
138+
let b:spell_options = 'contained'
139139

140140
if g:main_syntax is# 'dart'
141141
unlet g:main_syntax

0 commit comments

Comments
 (0)