Skip to content

Commit 425bdc5

Browse files
committed
refactor: Use the abort attribute for functions in autoload
1 parent b507cbd commit 425bdc5

File tree

2 files changed

+23
-23
lines changed

2 files changed

+23
-23
lines changed

autoload/color_helper.vim

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
" Example: color_helper#dec_to_hex(255, 5)
1111
" Returns: '000FF'
1212
"
13-
function! color_helper#dec_to_hex(arg, padding)
13+
function! color_helper#dec_to_hex(arg, padding) abort
1414
return toupper(printf('%0' . a:padding . 'x', a:arg + 0))
1515
endfunction
1616

@@ -26,7 +26,7 @@ endfunction
2626
" Example: color_helper#hex_to_dec('00')
2727
" Returns: 0
2828
"
29-
function! color_helper#hex_to_dec(arg)
29+
function! color_helper#hex_to_dec(arg) abort
3030
return (a:arg =~? '^0x') ? a:arg + 0 : ('0x'.a:arg) + 0
3131
endfunction
3232

@@ -36,7 +36,7 @@ endfunction
3636
" Example: color_helper#hex_color_to_rgb('#0088FF')
3737
" Returns: [0, 136, 255]
3838
"
39-
function! color_helper#hex_color_to_rgb(hex_color)
39+
function! color_helper#hex_color_to_rgb(hex_color) abort
4040
let l:rgb = []
4141

4242
if a:hex_color =~ g:indent_guides_color_hex_pattern
@@ -55,7 +55,7 @@ endfunction
5555
" Example: color_helper#rgb_color_to_hex([0, 136, 255])
5656
" Returns: '#0088FF'
5757
"
58-
function! color_helper#rgb_color_to_hex(rgb_color)
58+
function! color_helper#rgb_color_to_hex(rgb_color) abort
5959
let l:hex_color = '#'
6060
let l:hex_color .= color_helper#dec_to_hex(a:rgb_color[0], 2) " red
6161
let l:hex_color .= color_helper#dec_to_hex(a:rgb_color[1], 2) " green
@@ -71,7 +71,7 @@ endfunction
7171
" Example: color_helper#hex_color_lighten('#000000', 0.10)
7272
" Returns: '#191919'
7373
"
74-
function! color_helper#hex_color_lighten(color, percent)
74+
function! color_helper#hex_color_lighten(color, percent) abort
7575
let l:rgb = color_helper#hex_color_to_rgb(a:color)
7676
let l:rgb_lightened = []
7777

@@ -89,7 +89,7 @@ endfunction
8989
" Example: color_helper#hex_color_darken('#FFFFFF', 0.10)
9090
" Returns: '#E5E5E5'
9191
"
92-
function! color_helper#hex_color_darken(color, percent)
92+
function! color_helper#hex_color_darken(color, percent) abort
9393
let l:rgb = color_helper#hex_color_to_rgb(a:color)
9494
let l:rgb_darkened = []
9595

@@ -106,7 +106,7 @@ endfunction
106106
" Example: color_helper#color_name_to_hex('darkslategray')
107107
" Returns: '#2F4F4F'
108108
"
109-
function! color_helper#color_name_to_hex(color_name)
109+
function! color_helper#color_name_to_hex(color_name) abort
110110
let l:hex_code = ''
111111
let l:color_name = tolower(a:color_name)
112112

autoload/indent_guides.vim

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"
55
" Toggles the indent guides on and off.
66
"
7-
function! indent_guides#toggle()
7+
function! indent_guides#toggle() abort
88
call indent_guides#init_matches()
99

1010
if empty(w:indent_guides_matches)
@@ -18,7 +18,7 @@ endfunction
1818
" Called from autocmds, keeps indent guides enabled or disabled when entering
1919
" other buffers and windows.
2020
"
21-
function! indent_guides#process_autocmds()
21+
function! indent_guides#process_autocmds() abort
2222
if g:indent_guides_autocmds_enabled
2323
call indent_guides#enable()
2424
else
@@ -30,7 +30,7 @@ endfunction
3030
" Enables the indent guides for the current buffer and any other buffer upon
3131
" entering it.
3232
"
33-
function! indent_guides#enable()
33+
function! indent_guides#enable() abort
3434
let g:indent_guides_autocmds_enabled = 1
3535

3636
if &diff || indent_guides#exclude_filetype()
@@ -64,15 +64,15 @@ endfunction
6464
" Disables the indent guides for the current buffer and any other buffer upon
6565
" entering it.
6666
"
67-
function! indent_guides#disable()
67+
function! indent_guides#disable() abort
6868
let g:indent_guides_autocmds_enabled = 0
6969
call indent_guides#clear_matches()
7070
endfunction
7171

7272
"
7373
" Clear all highlight matches for the current window.
7474
"
75-
function! indent_guides#clear_matches()
75+
function! indent_guides#clear_matches() abort
7676
call indent_guides#init_matches()
7777
if !empty(w:indent_guides_matches)
7878
let l:index = 0
@@ -91,7 +91,7 @@ endfunction
9191
"
9292
" Automagically calculates and defines the indent highlight colors.
9393
"
94-
function! indent_guides#highlight_colors()
94+
function! indent_guides#highlight_colors() abort
9595
if s:auto_colors
9696
if has('gui_running') || has('nvim')
9797
call indent_guides#gui_highlight_colors()
@@ -105,7 +105,7 @@ endfunction
105105
" Defines some basic indent highlight colors that work for Terminal Vim and
106106
" gVim when colors can't be automatically calculated.
107107
"
108-
function! indent_guides#basic_highlight_colors()
108+
function! indent_guides#basic_highlight_colors() abort
109109
let l:cterm_colors = (&g:background == 'dark') ? ['darkgrey', 'black'] : ['lightgrey', 'white']
110110
let l:gui_colors = (&g:background == 'dark') ? ['grey15', 'grey30'] : ['grey70', 'grey85']
111111

@@ -117,7 +117,7 @@ endfunction
117117
" Automagically calculates and defines the indent highlight colors for gui
118118
" vim.
119119
"
120-
function! indent_guides#gui_highlight_colors()
120+
function! indent_guides#gui_highlight_colors() abort
121121
let l:hi_normal_guibg = ''
122122

123123
" capture the backgroud color from the normal highlight
@@ -150,7 +150,7 @@ endfunction
150150
" Takes a color and darkens or lightens it depending on whether a dark or light
151151
" colorscheme is being used.
152152
"
153-
function! indent_guides#lighten_or_darken_color(color)
153+
function! indent_guides#lighten_or_darken_color(color) abort
154154
let l:new_color = ''
155155

156156
if (&g:background == 'dark')
@@ -165,23 +165,23 @@ endfunction
165165
"
166166
" Define default highlights.
167167
"
168-
function! indent_guides#define_default_highlights()
168+
function! indent_guides#define_default_highlights() abort
169169
hi default clear IndentGuidesOdd
170170
hi default clear IndentGuidesEven
171171
endfunction
172172

173173
"
174174
" Init the w:indent_guides_matches variable.
175175
"
176-
function! indent_guides#init_matches()
176+
function! indent_guides#init_matches() abort
177177
let w:indent_guides_matches = exists('w:indent_guides_matches') ? w:indent_guides_matches : []
178178
endfunction
179179

180180
"
181181
" We need to initialize these vars every time a buffer is entered while the
182182
" plugin is enabled.
183183
"
184-
function! indent_guides#init_script_vars()
184+
function! indent_guides#init_script_vars() abort
185185
if &l:shiftwidth > 0 && &l:expandtab
186186
let s:indent_size = &l:shiftwidth
187187
else
@@ -229,7 +229,7 @@ endfunction
229229
"
230230
" NOTE: Currently, this only works when soft-tabs are being used.
231231
"
232-
function! indent_guides#calculate_guide_size()
232+
function! indent_guides#calculate_guide_size() abort
233233
let l:guide_size = g:indent_guides_guide_size
234234

235235
if l:guide_size == 0 || l:guide_size > s:indent_size
@@ -245,7 +245,7 @@ endfunction
245245
" Example: indent_guides#capture_highlight('normal')
246246
" Returns: 'Normal xxx guifg=#323232 guibg=#ffffff'
247247
"
248-
function! indent_guides#capture_highlight(group_name)
248+
function! indent_guides#capture_highlight(group_name) abort
249249
redir => l:output
250250
exe "silent hi " . a:group_name
251251
redir END
@@ -266,7 +266,7 @@ endfunction
266266
" Example: indent_guides#indent_highlight_pattern('\t', 9, 2)
267267
" Returns: /^\t*\%9v\zs\t*\%11v\ze/
268268
"
269-
function! indent_guides#indent_highlight_pattern(indent_pattern, column_start, indent_size)
269+
function! indent_guides#indent_highlight_pattern(indent_pattern, column_start, indent_size) abort
270270
let l:pattern = '^' . a:indent_pattern . '*\%' . a:column_start . 'v\zs'
271271
let l:pattern .= a:indent_pattern . '*\%' . (a:column_start + a:indent_size) . 'v'
272272
let l:pattern .= '\ze'
@@ -276,7 +276,7 @@ endfunction
276276
"
277277
" Detect if any of the buffer filetypes should be excluded.
278278
"
279-
function! indent_guides#exclude_filetype()
279+
function! indent_guides#exclude_filetype() abort
280280
for ft in split(&ft, '\.')
281281
if index(g:indent_guides_exclude_filetypes, ft) > -1
282282
return 1

0 commit comments

Comments
 (0)