1
0
mirror of https://github.com/amix/vimrc synced 2025-06-30 11:54:59 +08:00

Updated plugins

This commit is contained in:
Amir
2023-04-01 22:48:04 +02:00
parent 2b653aa950
commit b318c1d0e5
96 changed files with 2382 additions and 625 deletions

View File

@ -1,5 +1,5 @@
" Author: Nate Kane <nathanaelkane AT gmail DOT com>
" Homepage: http://github.com/nathanaelkane/vim-indent-guides
" Homepage: http://github.com/preservim/vim-indent-guides
"
" Return hex string equivalent to given decimal string or number.
@ -10,7 +10,7 @@
" Example: color_helper#dec_to_hex(255, 5)
" Returns: '000FF'
"
function! color_helper#dec_to_hex(arg, padding)
function! color_helper#dec_to_hex(arg, padding) abort
return toupper(printf('%0' . a:padding . 'x', a:arg + 0))
endfunction
@ -26,7 +26,7 @@ endfunction
" Example: color_helper#hex_to_dec('00')
" Returns: 0
"
function! color_helper#hex_to_dec(arg)
function! color_helper#hex_to_dec(arg) abort
return (a:arg =~? '^0x') ? a:arg + 0 : ('0x'.a:arg) + 0
endfunction
@ -36,7 +36,7 @@ endfunction
" Example: color_helper#hex_color_to_rgb('#0088FF')
" Returns: [0, 136, 255]
"
function! color_helper#hex_color_to_rgb(hex_color)
function! color_helper#hex_color_to_rgb(hex_color) abort
let l:rgb = []
if a:hex_color =~ g:indent_guides_color_hex_pattern
@ -55,7 +55,7 @@ endfunction
" Example: color_helper#rgb_color_to_hex([0, 136, 255])
" Returns: '#0088FF'
"
function! color_helper#rgb_color_to_hex(rgb_color)
function! color_helper#rgb_color_to_hex(rgb_color) abort
let l:hex_color = '#'
let l:hex_color .= color_helper#dec_to_hex(a:rgb_color[0], 2) " red
let l:hex_color .= color_helper#dec_to_hex(a:rgb_color[1], 2) " green
@ -71,7 +71,7 @@ endfunction
" Example: color_helper#hex_color_lighten('#000000', 0.10)
" Returns: '#191919'
"
function! color_helper#hex_color_lighten(color, percent)
function! color_helper#hex_color_lighten(color, percent) abort
let l:rgb = color_helper#hex_color_to_rgb(a:color)
let l:rgb_lightened = []
@ -89,7 +89,7 @@ endfunction
" Example: color_helper#hex_color_darken('#FFFFFF', 0.10)
" Returns: '#E5E5E5'
"
function! color_helper#hex_color_darken(color, percent)
function! color_helper#hex_color_darken(color, percent) abort
let l:rgb = color_helper#hex_color_to_rgb(a:color)
let l:rgb_darkened = []
@ -106,7 +106,7 @@ endfunction
" Example: color_helper#color_name_to_hex('darkslategray')
" Returns: '#2F4F4F'
"
function! color_helper#color_name_to_hex(color_name)
function! color_helper#color_name_to_hex(color_name) abort
let l:hex_code = ''
let l:color_name = tolower(a:color_name)

View File

@ -1,10 +1,10 @@
" Author: Nate Kane <nathanaelkane AT gmail DOT com>
" Homepage: http://github.com/nathanaelkane/vim-indent-guides
" Homepage: http://github.com/preservim/vim-indent-guides
"
" Toggles the indent guides on and off.
"
function! indent_guides#toggle()
function! indent_guides#toggle() abort
call indent_guides#init_matches()
if empty(w:indent_guides_matches)
@ -18,7 +18,7 @@ endfunction
" Called from autocmds, keeps indent guides enabled or disabled when entering
" other buffers and windows.
"
function! indent_guides#process_autocmds()
function! indent_guides#process_autocmds() abort
if g:indent_guides_autocmds_enabled
call indent_guides#enable()
else
@ -30,7 +30,7 @@ endfunction
" Enables the indent guides for the current buffer and any other buffer upon
" entering it.
"
function! indent_guides#enable()
function! indent_guides#enable() abort
let g:indent_guides_autocmds_enabled = 1
if &diff || indent_guides#exclude_filetype()
@ -64,7 +64,7 @@ endfunction
" Disables the indent guides for the current buffer and any other buffer upon
" entering it.
"
function! indent_guides#disable()
function! indent_guides#disable() abort
let g:indent_guides_autocmds_enabled = 0
call indent_guides#clear_matches()
endfunction
@ -72,7 +72,7 @@ endfunction
"
" Clear all highlight matches for the current window.
"
function! indent_guides#clear_matches()
function! indent_guides#clear_matches() abort
call indent_guides#init_matches()
if !empty(w:indent_guides_matches)
let l:index = 0
@ -86,14 +86,21 @@ function! indent_guides#clear_matches()
let l:index += l:index
endfor
endif
" Make sure to clear indent guide if remembered match id has gone somehow.
for l:match in getmatches()
if l:match.group =~# '^IndentGuides\v(Even|Odd)$'
call matchdelete(l:match.id)
endif
endfor
endfunction
"
" Automagically calculates and defines the indent highlight colors.
"
function! indent_guides#highlight_colors()
function! indent_guides#highlight_colors() abort
if s:auto_colors
if has('gui_running') || has('nvim')
if has('gui_running') || has('nvim') || (has('termguicolors') && &termguicolors)
call indent_guides#gui_highlight_colors()
else
call indent_guides#basic_highlight_colors()
@ -105,9 +112,9 @@ endfunction
" Defines some basic indent highlight colors that work for Terminal Vim and
" gVim when colors can't be automatically calculated.
"
function! indent_guides#basic_highlight_colors()
let l:cterm_colors = (&g:background == 'dark') ? ['darkgrey', 'black'] : ['lightgrey', 'white']
let l:gui_colors = (&g:background == 'dark') ? ['grey15', 'grey30'] : ['grey70', 'grey85']
function! indent_guides#basic_highlight_colors() abort
let l:cterm_colors = (&g:background ==# 'dark') ? ['darkgrey', 'black'] : ['lightgrey', 'white']
let l:gui_colors = (&g:background ==# 'dark') ? ['grey15', 'grey30'] : ['grey70', 'grey85']
exe 'hi IndentGuidesEven guibg=' . l:gui_colors[0] . ' guifg=' . l:gui_colors[1] . ' ctermbg=' . l:cterm_colors[0] . ' ctermfg=' . l:cterm_colors[1]
exe 'hi IndentGuidesOdd guibg=' . l:gui_colors[1] . ' guifg=' . l:gui_colors[0] . ' ctermbg=' . l:cterm_colors[1] . ' ctermfg=' . l:cterm_colors[0]
@ -117,7 +124,7 @@ endfunction
" Automagically calculates and defines the indent highlight colors for gui
" vim.
"
function! indent_guides#gui_highlight_colors()
function! indent_guides#gui_highlight_colors() abort
let l:hi_normal_guibg = ''
" capture the backgroud color from the normal highlight
@ -150,10 +157,10 @@ endfunction
" Takes a color and darkens or lightens it depending on whether a dark or light
" colorscheme is being used.
"
function! indent_guides#lighten_or_darken_color(color)
function! indent_guides#lighten_or_darken_color(color) abort
let l:new_color = ''
if (&g:background == 'dark')
if (&g:background ==# 'dark')
let l:new_color = color_helper#hex_color_lighten(a:color, s:change_percent)
else
let l:new_color = color_helper#hex_color_darken (a:color, s:change_percent)
@ -165,7 +172,7 @@ endfunction
"
" Define default highlights.
"
function! indent_guides#define_default_highlights()
function! indent_guides#define_default_highlights() abort
hi default clear IndentGuidesOdd
hi default clear IndentGuidesEven
endfunction
@ -173,7 +180,7 @@ endfunction
"
" Init the w:indent_guides_matches variable.
"
function! indent_guides#init_matches()
function! indent_guides#init_matches() abort
let w:indent_guides_matches = exists('w:indent_guides_matches') ? w:indent_guides_matches : []
endfunction
@ -181,7 +188,7 @@ endfunction
" We need to initialize these vars every time a buffer is entered while the
" plugin is enabled.
"
function! indent_guides#init_script_vars()
function! indent_guides#init_script_vars() abort
if &l:shiftwidth > 0 && &l:expandtab
let s:indent_size = &l:shiftwidth
else
@ -191,7 +198,7 @@ function! indent_guides#init_script_vars()
let s:hi_normal = indent_guides#capture_highlight('Normal')
" remove 'font=<value>' from the s:hi_normal string (only seems to happen on Vim startup in Windows)
let s:hi_normal = substitute(s:hi_normal, ' font=[A-Za-z0-9:]\+', "", "")
let s:hi_normal = substitute(s:hi_normal, ' font=[A-Za-z0-9:]\+', '', '')
" shortcuts to the global variables - this makes the code easier to read
let s:debug = g:indent_guides_debug
@ -229,7 +236,7 @@ endfunction
"
" NOTE: Currently, this only works when soft-tabs are being used.
"
function! indent_guides#calculate_guide_size()
function! indent_guides#calculate_guide_size() abort
let l:guide_size = g:indent_guides_guide_size
if l:guide_size == 0 || l:guide_size > s:indent_size
@ -245,12 +252,9 @@ endfunction
" Example: indent_guides#capture_highlight('normal')
" Returns: 'Normal xxx guifg=#323232 guibg=#ffffff'
"
function! indent_guides#capture_highlight(group_name)
redir => l:output
exe "silent hi " . a:group_name
redir END
let l:output = substitute(l:output, "\n", "", "")
function! indent_guides#capture_highlight(group_name) abort
let l:output = execute('hi ' . a:group_name, 'silent')
let l:output = substitute(l:output, '\n', '', '')
return l:output
endfunction
@ -266,7 +270,7 @@ endfunction
" Example: indent_guides#indent_highlight_pattern('\t', 9, 2)
" Returns: /^\t*\%9v\zs\t*\%11v\ze/
"
function! indent_guides#indent_highlight_pattern(indent_pattern, column_start, indent_size)
function! indent_guides#indent_highlight_pattern(indent_pattern, column_start, indent_size) abort
let l:pattern = '^' . a:indent_pattern . '*\%' . a:column_start . 'v\zs'
let l:pattern .= a:indent_pattern . '*\%' . (a:column_start + a:indent_size) . 'v'
let l:pattern .= '\ze'
@ -276,8 +280,13 @@ endfunction
"
" Detect if any of the buffer filetypes should be excluded.
"
function! indent_guides#exclude_filetype()
for ft in split(&ft, '\.')
function! indent_guides#exclude_filetype() abort
if exists('g:indent_guides_exclude_buftype')
if g:indent_guides_exclude_buftype && &buftype !=# ''
return 1
endif
endif
for ft in split(&ft, '\.', 1)
if index(g:indent_guides_exclude_filetypes, ft) > -1
return 1
end