mirror of
https://github.com/preservim/vim-indent-guides.git
synced 2025-11-16 21:53:39 -05:00
Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4a3c2d3d46 | ||
|
|
353bef3dba | ||
|
|
3c86647883 | ||
|
|
0c214805f2 | ||
|
|
2ea3460539 | ||
|
|
bd16c77359 | ||
|
|
349edc9da2 |
@@ -82,22 +82,21 @@ function! indent_guides#highlight_colors()
|
||||
if has('gui_running')
|
||||
call indent_guides#gui_highlight_colors()
|
||||
else
|
||||
call indent_guides#cterm_highlight_colors()
|
||||
call indent_guides#basic_highlight_colors()
|
||||
endif
|
||||
endif
|
||||
endfunction
|
||||
|
||||
"
|
||||
" Defines the indent highlight colors for terminal vim.
|
||||
" Defines some basic indent highlight colors that work for Terminal Vim and
|
||||
" gVim when colors can't be automatically calculated.
|
||||
"
|
||||
" NOTE: This function contains no magic at the moment, it will simply use some
|
||||
" light or dark preset colors depending on the `set background=` value.
|
||||
"
|
||||
function! indent_guides#cterm_highlight_colors()
|
||||
let l:colors = (&g:background == 'dark') ? ['darkgrey', 'black'] : ['lightgrey', 'white']
|
||||
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']
|
||||
|
||||
exe 'hi IndentGuidesEven ctermbg=' . l:colors[0]
|
||||
exe 'hi IndentGuidesOdd ctermbg=' . l:colors[1]
|
||||
exe 'hi IndentGuidesEven guibg=' . l:gui_colors[0] . ' ctermbg=' . l:cterm_colors[0]
|
||||
exe 'hi IndentGuidesOdd guibg=' . l:gui_colors[1] . ' ctermbg=' . l:cterm_colors[1]
|
||||
endfunction
|
||||
|
||||
"
|
||||
@@ -116,6 +115,10 @@ function! indent_guides#gui_highlight_colors()
|
||||
" color name is being used, eg. 'white'
|
||||
let l:color_name = matchstr(s:hi_normal, s:color_name_bg_pat)
|
||||
let l:hi_normal_guibg = color_helper#color_name_to_hex(l:color_name)
|
||||
|
||||
else
|
||||
" background color could not be detected, default to basic colors
|
||||
call indent_guides#basic_highlight_colors()
|
||||
endif
|
||||
|
||||
if l:hi_normal_guibg =~ s:color_hex_pat
|
||||
@@ -169,6 +172,9 @@ function! indent_guides#init_script_vars()
|
||||
let s:guide_size = indent_guides#calculate_guide_size()
|
||||
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:]\+', "", "")
|
||||
|
||||
" shortcuts to the global variables - this makes the code easier to read
|
||||
let s:debug = g:indent_guides_debug
|
||||
let s:indent_levels = g:indent_guides_indent_levels
|
||||
|
||||
@@ -9,8 +9,8 @@
|
||||
|
||||
|
||||
Author: Nate Kane <nathanaelkane AT gmail DOT com>
|
||||
Version: 1.2
|
||||
Last Change: 10 Jan 2011
|
||||
Version: 1.4
|
||||
Last Change: 6 Feb 2011
|
||||
|
||||
==============================================================================
|
||||
CONTENTS *indent-guides-contents*
|
||||
@@ -95,9 +95,9 @@ in an autocmd.
|
||||
Use this option to control the percent at which the highlight colors will be
|
||||
lightened or darkened.
|
||||
|
||||
Default: 5 (5%). Values: between 0 and 100.
|
||||
Default: 10 (10%). Values: between 0 and 100.
|
||||
>
|
||||
let g:indent_guides_color_change_percent = 5
|
||||
let g:indent_guides_color_change_percent = 10
|
||||
<
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
@@ -126,6 +126,15 @@ Default: 1. Values: between 1 and g:|indent_guides_indent_levels|.
|
||||
let g:indent_guides_start_level = 2
|
||||
<
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
*'indent_guides_enable_on_vim_startup'*
|
||||
Use this option to control whether the plugin is enabled on Vim startup.
|
||||
|
||||
Default: 0. Values: 0 or 1.
|
||||
>
|
||||
let g:indent_guides_enable_on_vim_startup = 0
|
||||
<
|
||||
|
||||
==============================================================================
|
||||
4. MAPPINGS *indent-guides-mappings*
|
||||
|
||||
@@ -203,10 +212,20 @@ Bug reports, feedback, suggestions etc are welcomed.
|
||||
==============================================================================
|
||||
7. CHANGELOG *indent-guides-changelog*
|
||||
|
||||
1.4~
|
||||
* Added the new plugin option g:|indent_guides_enable_on_vim_startup|.
|
||||
* Improved Windows support.
|
||||
|
||||
1.3~
|
||||
* Changed the default value of g:|indent_guides_color_change_percent| to 10.
|
||||
* Added support for gVim themes that don't specify a `hi Normal guibg`
|
||||
color.
|
||||
|
||||
1.2~
|
||||
* Customizable size for indent guides, eg. skinny guides (soft-tabs only).
|
||||
* Customizable start indent level.
|
||||
* Refactored some internal logic.
|
||||
|
||||
1.1~
|
||||
* Added basic support for Terminal Vim. See |indent-guides-terminal-vim| for
|
||||
more information.
|
||||
@@ -223,7 +242,7 @@ Bug reports, feedback, suggestions etc are welcomed.
|
||||
The MIT Licence
|
||||
http://www.opensource.org/licenses/mit-license.php
|
||||
|
||||
Copyright (c) 2010 Nate Kane
|
||||
Copyright (c) 2010-2011 Nate Kane
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -45,12 +45,13 @@ let g:indent_guides_color_hex_guibg_pattern = 'guibg=\zs' . g:indent_guides_col
|
||||
let g:indent_guides_color_name_guibg_pattern = "guibg='\\?\\zs[0-9A-Za-z ]\\+\\ze'\\?"
|
||||
|
||||
" Configurable global variables
|
||||
call s:InitVariable('g:indent_guides_indent_levels', 30)
|
||||
call s:InitVariable('g:indent_guides_auto_colors', 1 )
|
||||
call s:InitVariable('g:indent_guides_color_change_percent', 5 ) " ie. 5%
|
||||
call s:InitVariable('g:indent_guides_guide_size', 0 )
|
||||
call s:InitVariable('g:indent_guides_start_level', 1 )
|
||||
call s:InitVariable('g:indent_guides_debug', 0 )
|
||||
call s:InitVariable('g:indent_guides_indent_levels', 30)
|
||||
call s:InitVariable('g:indent_guides_auto_colors', 1 )
|
||||
call s:InitVariable('g:indent_guides_color_change_percent', 10) " ie. 10%
|
||||
call s:InitVariable('g:indent_guides_guide_size', 0 )
|
||||
call s:InitVariable('g:indent_guides_start_level', 1 )
|
||||
call s:InitVariable('g:indent_guides_enable_on_vim_startup', 0 )
|
||||
call s:InitVariable('g:indent_guides_debug', 0 )
|
||||
|
||||
" Default mapping
|
||||
nmap <Leader>ig :IndentGuidesToggle<CR>
|
||||
@@ -58,6 +59,11 @@ nmap <Leader>ig :IndentGuidesToggle<CR>
|
||||
" Auto commands
|
||||
augroup indent_guides
|
||||
autocmd!
|
||||
|
||||
if g:indent_guides_enable_on_vim_startup
|
||||
autocmd VimEnter * :IndentGuidesEnable
|
||||
endif
|
||||
|
||||
autocmd BufEnter,WinEnter * call indent_guides#process_autocmds()
|
||||
augroup END
|
||||
|
||||
|
||||
Reference in New Issue
Block a user