138 Commits
1.0 ... master

Author SHA1 Message Date
Tomáš Janoušek
a1e1390c01 fix: Use basic colors when termguicolors is off (#155)
indent_guides#gui_highlight_colors only sets guifg/guibg and we don't
want that when termguicolors is off.

Fixes: 3a4f7a6b99 ("feat: Enable adaption of colors from termguicolors (#143)")
2023-03-18 22:37:41 +03:00
Sergey Vlasov
9a106c73f6 feat: Allow exclude files with no 'filetype' set
Closes #135 & #122
2023-02-22 11:53:28 +03:00
Caleb Maclennan
d96c8182d1 fix: Enable use in nested mappings by replacing :redir (#152)
Co-authored-by: Sergey Vlasov <sergey@vlasov.me>
2023-02-22 11:48:19 +03:00
Guangqing Chen
3a4f7a6b99 feat: Enable adaption of colors from termguicolors (#143) 2023-02-22 11:34:49 +03:00
Caleb Maclennan
c9d2473d5d refactor: Use robust operators ==# or ==? instead of == 2023-02-21 21:47:47 +03:00
somini
5111d5b10c feat: Add option to check buftype option before enabling
Closes #101

Instead of only having a big list of "naughty" filetypes, have an option
to check for the `buftype` and skip if set to anything.
2023-02-21 21:27:28 +03:00
Caleb Maclennan
36b2d8d33c Merge branch 'bugfix/GuideStyleClear' 2023-02-21 21:19:39 +03:00
mhaehnel
549dcf0d1f Process autocmds when sw, et or ts option changes (#133)
The autocmd is only enabled on vim newer than 7.4.786 where the OptionSet
autocmd feature was introduced.
2023-02-21 21:13:58 +03:00
Caleb Maclennan
7ce9d4ee7f ci: Add workflow running vimscript linter 2023-02-21 16:16:16 +03:00
Caleb Maclennan
63554a38bb Use robust operators ==# or ==? instead of == 2023-02-21 16:13:57 +03:00
Caleb Maclennan
8e6d5f7afd refactor: Prefer single quoted strings 2023-02-21 16:11:54 +03:00
Caleb Maclennan
425bdc51fd refactor: Use the abort attribute for functions in autoload 2023-02-21 16:10:14 +03:00
Caleb Maclennan
b507cbd39b docs: Drop 'unmaintained' notice from README, project open to contributions 2023-02-21 16:05:28 +03:00
Caleb Maclennan
30323b167d chore: Change GitHub namespace to new home under PreserVIM 2023-02-21 16:04:16 +03:00
yasuda
d382307613 IndentGuidesDisable: Clear IndentGuides{Even,Odd} matches 2022-06-27 18:20:44 +09:00
Nate Kane
765084d38b Update the readme 2021-10-13 23:27:39 +10:00
Nate Kane
42f6d45e61 Add license 2021-10-13 23:17:25 +10:00
Nate Kane
54d889a637 Merge branch 'marabesi-master'
* marabesi-master:
  Use bash syntax highlighting for terminal commands in the readme
  Add empty lines after fenced code blocks
  Update README.markdown
2018-05-14 21:32:31 +10:00
Nate Kane
c59f68f747 Use bash syntax highlighting for terminal commands in the readme 2018-05-14 21:29:28 +10:00
Nate Kane
d3cf41db52 Add empty lines after fenced code blocks 2018-05-14 21:25:22 +10:00
Matheus Marabesi
05e4cc018a Update README.markdown
added syntax highlight to make easier to read the options
2018-05-13 17:19:27 -03:00
Nate Kane
b40687195c Merge branch 'T99--master'
* T99--master:
  Revised README with Vundle install and better usage guide
2017-07-03 21:49:36 +10:00
Trevor Sears
b9657e0b8e Revised README with Vundle install and better usage guide 2017-07-03 21:46:48 +10:00
Nate Kane
018298ead9 Merge branch 'amerlyq-feature_showtab_switch'
* amerlyq-feature_showtab_switch:
  Update help file
  Formatting
  Added symmetrical option to disable indents for tab
2016-04-17 21:34:10 +10:00
Nate Kane
930eba1560 Update help file 2016-04-17 21:11:15 +10:00
Nate Kane
6637da8436 Formatting 2016-04-17 21:07:43 +10:00
Nate Kane
67f3020a31 Merge branch 'feature_showtab_switch' of https://github.com/amerlyq/vim-indent-guides into amerlyq-feature_showtab_switch
* 'feature_showtab_switch' of https://github.com/amerlyq/vim-indent-guides:
  Added symmetrical option to disable indents for tab
2016-04-17 21:03:37 +10:00
Nate Kane
705c5fdf0d Merge pull request #110 from dsummersl/master
Adds support for neovim.
2016-03-20 20:43:56 +10:00
Dane Summers
5d9c055689 Adds support for neovim.
gui highlighting was broken after neovim revision 79a698 (removed support for
gui_running hack to check for truecolor support).
2016-03-01 11:26:02 -05:00
Dmytro Kolomoiets
470ef5e55f Added symmetrical option to disable indents for tab
nathanaelkane/vim-indent-guides#102
2015-12-01 12:21:09 +02:00
Nate Kane
49bde6fa30 Update help file 2015-10-26 19:21:57 +10:00
Nate Kane
a0b7df69de Merge branch 'DerSaidin-patch-1'
* DerSaidin-patch-1:
  Whitespace
  Wording
  Exit gracefully if too old to support this plugin
2015-10-26 19:12:21 +10:00
Nate Kane
1b108fc9c9 Whitespace 2015-10-26 19:10:29 +10:00
Nate Kane
fef32d7481 Wording 2015-10-26 19:10:24 +10:00
Andrew Browne
9e2e492055 Exit gracefully if too old to support this plugin 2015-10-25 21:10:51 +10:00
Nate Kane
4895e86025 Merge pull request #85 from timoxley/patch-1
Put a screenshot up-front
2015-05-11 08:09:35 +10:00
Tim Oxley
aedd70ff35 Put a screenshot up-front
Serves as a tl;dr.
2015-05-11 05:23:15 +08:00
Nate Kane
184e55848d Update help file 2015-03-22 22:18:31 +10:00
Jacob Niehus
7ab92f7c3f Set size of indent guide to tabstop value when noexpandtab is used 2015-03-22 22:11:32 +10:00
Nate Kane
a397b3b549 Merge branch 'darkfeline-fix-57'
* darkfeline-fix-57:
  Update help file
  Add file for testing when `shiftwidth=0` is used
  Set size of indent guide to `tabstop` value when `shiftwidth=0` is used
2015-03-22 21:35:19 +10:00
Nate Kane
f4213240a3 Update help file 2015-03-22 21:34:51 +10:00
Nate Kane
4228b349f1 Add file for testing when shiftwidth=0 is used 2015-03-22 21:34:27 +10:00
Allen Li
7aac8169ea Set size of indent guide to tabstop value when shiftwidth=0 is used
Fixes #57
2015-03-22 21:33:55 +10:00
Nate Kane
eec1b629dc Help file wording 2013-06-27 20:07:58 +10:00
Nate Kane
3787ceb198 Use consistent GitHub username format 2013-06-27 20:06:04 +10:00
Nate Kane
e5634c01fc Update the help file for the g:indent_guides_default_mapping option 2013-06-27 19:54:06 +10:00
Nate Kane
3cfeff1930 Merge branch 'option-no-mapping' of git://github.com/suy/vim-indent-guides into suy-option-no-mapping
* 'option-no-mapping' of git://github.com/suy/vim-indent-guides:
  Add option g:indent_guides_default_mapping

Conflicts:
	plugin/indent_guides.vim
2013-06-27 19:43:10 +10:00
Nate Kane
48a4a8fda4 Update changelog 2013-06-27 19:40:58 +10:00
Nate Kane
1c60df40e0 Help file formatting 2013-06-27 19:40:53 +10:00
Nate Kane
869bfc948e Help file wording 2013-06-27 19:40:48 +10:00
Nate Kane
562cc0de84 Whitepace 2013-06-27 19:40:22 +10:00
Nate Kane
0996492531 Merge pull request #45 from sergey-vlasov/master
New `g:indent_guides_soft_pattern` option
2013-06-27 02:13:24 -07:00
Alejandro Exojo
c8f2f3c089 Add option g:indent_guides_default_mapping 2013-06-26 08:28:01 +02:00
Nate Kane
a5700082c7 Split multiple filetypes on ".".
Thanks @kljohann
2013-03-14 10:00:19 +10:00
Nate Kane
d29fbb3fa3 Bump version and update the doc. 2013-03-07 09:06:59 +10:00
Nate Kane
29037575e3 Disable the plugin when in a diff.
Closes #48.
2013-03-07 09:06:52 +10:00
Nate Kane
cf3948a3fb Update license in the doc. 2013-03-06 22:48:09 +10:00
Nate Kane
3b134f394d Fix comment. 2013-03-06 22:44:10 +10:00
Nate Kane
997bede1b5 Add option g:indent_guides_exclude_filetypes.
For specifying a list of filetypes to disable the plugin for.

Closes #20 and #26.
2013-03-06 22:43:57 +10:00
Nate Kane
0421be28b3 Trigger BufEnter and process modelines after loading the colorscheme. 2013-03-03 22:59:08 +10:00
Nate Kane
ac069a993e Process autocmds after loading the colorscheme. 2013-02-04 13:10:55 +10:00
Sergey Vlasov
74c8bdeecb Added new g:indent_guides_soft_pattern option 2012-10-11 15:51:43 +03:00
Nate
5bc809d055 Merge pull request #40 from sergey-vlasov/master
Foreground color fix for special characters
2012-07-15 01:37:15 -07:00
Sergey Vlasov
d9fe8b1fcf Setting foreground colors with respect to background 2012-07-10 15:14:26 +03:00
Nate Kane
66306748d8 Only check normal mode for existing <Plug>IndentGuidesToggle mapping. 2012-05-22 12:49:43 +10:00
Nate Kane
1cd149ed2e Don't perform default mapping if <Leader>ig is already mapped. 2012-05-22 12:40:41 +10:00
Nate Kane
c909e3193a Allow default mapping to be overridden. 2012-05-22 09:00:46 +10:00
Nate Kane
cf6f4d4661 Bump version to 1.6. 2012-01-01 21:44:16 +10:00
Nate Kane
2cbe919452 Update copyright year in help file. 2012-01-01 21:44:14 +10:00
Nate Kane
e8f50f3c8b Remove IRC as contact method in help file. 2012-01-01 21:44:10 +10:00
Nate
f1c115ce5d Merge pull request #25 from mutewinter/master
Fix E803 ID not found spam.
2011-11-28 14:43:13 -08:00
Nate
287132df04 Merge pull request #27 from acx0/master
Fix str2float issue with Vim 7.1.
2011-11-28 14:27:16 -08:00
Sam Lidder
bdf4ec3ff8 Added test to only use str2float if compiled with +float 2011-10-19 22:36:39 -04:00
Jeremy Mack
57b6da6d12 Fixes E803 ID not found spam 2011-09-28 21:19:41 -03:00
Nate
6854275667 Merge pull request #19 from scoz/ignore-space-option
Added a flag for ignoring spaces.
2011-08-30 05:21:42 -07:00
Nate
eb5644430a Merge pull request #22 from lenniboy/master
Add 'doc/tags' to gitgnore.
2011-08-30 05:09:31 -07:00
Leonard Ehrenfried
951619130f add doc/tags to gitgnore - helps to keep the vim/bundles dir clean if using pathogen with git submodules 2011-08-23 22:14:10 +02:00
Ryan Souza
9d189306aa Added a flag for ignoring spaces
Added flag g:indent_guides_enable_on_vim_startup
Controls whether spaces are considered for indent calculating
2011-07-31 18:11:04 -07:00
Nate Kane
62a2fd103f Updated the readme and help file. 2011-03-13 22:15:34 +11:00
Nate Kane
7826042406 Added new test file. 2011-03-13 21:38:26 +11:00
Nate Kane
6e145a10cf Whitespace. 2011-03-13 21:34:00 +11:00
Nate Kane
60f435ee57 Removed the indent_guides#get_indent_size function. 2011-03-13 21:32:28 +11:00
Nate Kane
5f48d29177 Refactored the regex for the highlight patterns. 2011-03-13 21:29:27 +11:00
Nate Kane
a3ba000ddb Updated help file. 2011-03-06 23:49:11 +10:00
Nate Kane
d9c596352a Fixed bug with calculating guide size. 2011-03-06 23:48:08 +10:00
Nate Kane
7af506c797 Tweaked highlight patterns. 2011-03-06 23:31:54 +10:00
Nate Kane
73703c93ad Updated test files. 2011-03-06 23:30:35 +10:00
Nate Kane
78d34d1018 Merge branch 'mixed-tabs-and-spaces' of https://github.com/graywh/vim-indent-guides into graywh-mixed-tabs-and-spaces
* 'mixed-tabs-and-spaces' of https://github.com/graywh/vim-indent-guides:
  Partial support for mixed tabs and spaces.
2011-03-06 22:35:16 +10:00
Will Gray
f7d5111c34 Partial support for mixed tabs and spaces.
Also account for 1 tab == 1 indent.
2011-02-21 14:08:05 -06:00
Will Gray
0a14a1558e Fix typo causing global settings to be stored as strings. 2011-02-21 13:23:21 -06:00
Nate Kane
ed8eff420b Updated the help file 2011-02-21 23:48:14 +10:00
Nate Kane
5146db837f Merge branch 'master' of https://github.com/voidus/vim-indent-guides into voidus-master
* 'master' of https://github.com/voidus/vim-indent-guides:
  Use str2float instead of plain floats. Fixes #10
2011-02-21 23:38:47 +10:00
Nate Kane
feba7e9fa7 Updated the help file 2011-02-21 23:36:22 +10:00
Nate Kane
2415d8b709 Merge branch 'graywh-issue5'
* graywh-issue5:
  Removed unnecessary exe calls for default highlights
  Don't clobber pre-set custom colors.
2011-02-21 23:31:51 +10:00
Nate Kane
fa67d46aca Removed unnecessary exe calls for default highlights 2011-02-21 23:29:30 +10:00
Simon Kohlmeyer
f972f0264f Use str2float instead of plain floats. Fixes #10
This is used to work around a vim bug throwing E806: using Float as String in
some Situations.
2011-02-21 10:34:27 +01:00
Nate Kane
3cd1b09fb3 Updated the help file. 2011-02-20 22:55:19 +10:00
Will Gray
9441c97e57 Enable chaining :commands with :bar. 2011-02-17 15:29:34 -06:00
Will Gray
10b809d187 Don't clobber pre-set custom colors. 2011-02-17 15:13:14 -06:00
Nate Kane
4a3c2d3d46 Updated the Last Change date 2011-02-06 22:54:48 +10:00
Nate Kane
353bef3dba Improved Windows support 2011-01-24 22:25:17 +10:00
Nate Kane
3c86647883 Added new global option to configure whether the plugin is enabled on Vim startup 2011-01-24 20:45:18 +10:00
Nate Kane
0c214805f2 Updated the help file to reflect the latest changes 2011-01-17 20:38:35 +10:00
Nate Kane
2ea3460539 Altered some comment wording 2011-01-17 20:35:37 +10:00
Nate Kane
bd16c77359 Changed the default value of g:indent_guides_color_change_percent to 10% 2011-01-17 20:35:17 +10:00
Nate Kane
349edc9da2 Added support for gVim themes that don't specify a hi Normal guibg color 2011-01-17 13:13:50 +10:00
Nate Kane
6bbbc619d6 Updated the last change date in the help file 2011-01-10 21:43:05 +10:00
Nate Kane
5344539e70 Tweaked the readme yet again 2011-01-10 21:38:06 +10:00
Nate Kane
80d96b425a Tweaked the readme again 2011-01-09 22:41:53 +10:00
Nate Kane
a0e3e35bd3 Tweaked the readme 2011-01-09 22:33:08 +10:00
Nate Kane
77bf750ed0 Replaced the screenshots in the readme 2011-01-09 22:25:56 +10:00
Nate Kane
c28e193772 Updated the readme and help file with details about the new start level option 2011-01-09 20:55:27 +10:00
Nate Kane
67398b8358 Added new global option to configure which indent level to start the indent guides from 2011-01-09 20:53:48 +10:00
Nate Kane
06d2b34874 Refactored some core logic and added some simple debugging 2011-01-05 14:07:53 +10:00
Nate Kane
d53103f9a8 Updated the readme and help file with details about the new customizable size option for indent guides 2011-01-05 13:22:40 +10:00
Nate Kane
f2608db67e Refactored some core functionality and implemented an initial version of the custom guide size feature [issue2] 2011-01-04 23:53:17 +10:00
Nate Kane
538554b19f Refactored the way global variables are initialized and added a new plugin option: g:indent_guides_indent_guide_size 2011-01-04 23:49:35 +10:00
Nate Kane
d639a48f04 Fixed a typo in the readme and help file 2010-12-30 20:35:22 +10:00
Nate Kane
b1f149ff71 Tweaked the readme and help file 2010-12-30 09:23:44 +10:00
Nate Kane
9dbc046d83 Fixed typo in the readme file 2010-12-29 22:15:42 +10:00
Nate Kane
23211a3b4f Oops, went over the textwidth in the help file 2010-12-29 21:53:05 +10:00
Nate Kane
8365779904 Added Windows support info to the readme and help file 2010-12-29 21:50:42 +10:00
Nate Kane
38a4501224 Couple more tweaks to the readme 2010-12-29 21:34:18 +10:00
Nate Kane
a7d8f3dce7 Updated the readme and help file (again) 2010-12-29 21:29:13 +10:00
Nate Kane
9712a19ba9 Updated the readme 2010-12-29 21:23:35 +10:00
Nate Kane
b9266fb158 Updated the readme and help file 2010-12-29 21:15:52 +10:00
Nate Kane
32b9f52837 Added more explicit variable scopes 2010-12-29 20:31:49 +10:00
Nate Kane
046104c2f0 Tweaked the indent_guides#cterm_highlight_colors() function a bit 2010-12-29 20:17:34 +10:00
Nate Kane
9b43f5c84c Refactored the color_helper#color_name_to_hex() function to use hex codes directly instead of calculating them (shoutout to godlygeek for the codes) 2010-12-29 20:12:10 +10:00
Nate Kane
b4b4ce9c76 Tweaked the indent_guides#cterm_highlight_colors() function so it works a bit more consistently 2010-12-29 14:43:42 +10:00
Nate Kane
51436e3677 Tweaked the indent_guides#cterm_highlight_colors() function 2010-12-22 21:44:46 +10:00
Joshua Hogendorn
b3656708cb Terminal colours are now based on the Normal BG
Instead of using the foreground and background of a search result, which
is usually designed to stand right out, the indents for terminal are now
colored according to the normal text background.
2010-12-22 10:31:06 +10:00
Joshua Hogendorn
0ebc1eb93d Fixes an error setting default colours to NONE
It needs to be NONE, not none.
2010-12-22 09:30:50 +10:00
Nate Kane
78f60359c8 Updated the readme file 2010-12-20 22:32:35 +10:00
Nate Kane
5d01603b9a Updated the help file 2010-12-20 22:30:18 +10:00
Nate Kane
14aae71298 Improved support for terminal vim 2010-12-20 22:26:45 +10:00
Nate Kane
6d903df6e7 Added early support for terminal vim 2010-12-20 21:51:02 +10:00
Nate Kane
0c0ac44889 Updated the help file and readme 2010-12-12 19:33:16 +10:00
17 changed files with 1650 additions and 914 deletions

15
.github/workflows/vint.yml vendored Normal file
View File

@@ -0,0 +1,15 @@
name: Vint
on: [push]
jobs:
vint:
name: vint
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
- name: Setup dependencies
run: pip install vim-vint
- name: Lint Vimscript
run: vint .

1
.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
doc/tags

21
LICENSE Normal file
View File

@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2021 Nathanael 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
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@@ -1,28 +1,114 @@
# Indent Guides
Indent Guides is a plugin for visually displaying indent levels in vim.
[![Vint](https://github.com/preservim/vim-indent-guides/workflows/Vint/badge.svg)](https://github.com/preservim/vim-indent-guides/actions?workflow=Vint)
Indent Guides is a plugin for visually displaying indent levels in Vim.
<img src="http://i.imgur.com/ONgoj.png" width="448" height="448" alt="" />
## Features:
* Can detect both tab and space indent styles.
* Automatically inspects your colorscheme and picks appropriate colors.
* Automatically inspects your colorscheme and picks appropriate colors (gVim only).
* Will highlight indent levels with alternating colors.
* Full support for gVim and basic support for Terminal Vim.
* Seems to work on Windows gVim 7.3 (haven't done any extensive tests though).
* Customizable size for indent guides, eg. skinny guides (soft-tabs only).
* Customizable start indent level.
* Highlight support for files with a mixture of tab and space indent styles.
## Requirements
* Vim 7.2+
## Installation
To install the plugin just copy `autoload`, `plugin`, `doc` directories into your .vim directory.
To install the plugin copy `autoload`, `plugin`, `doc` directories into your `.vim` directory.
Alternatively if you have [Pathogen](http://www.vim.org/scripts/script.php?script_id=2332) installed, just clone this repo into a subdirectory of your .vim/bundle directory like so:
### Pathogen
If you have [Pathogen](http://www.vim.org/scripts/script.php?script_id=2332) installed, clone this repo into a subdirectory of your `.vim/bundle` directory like so:
cd ~/.vim/bundle
git clone git://github.com/nathanaelkane/vim-indent-guides.git
```bash
cd ~/.vim/bundle
git clone git://github.com/preservim/vim-indent-guides.git
```
### Vundle
If you have [Vundle](https://github.com/VundleVim/Vundle.vim) installed, add the following line to your `~/.vimrc` in the appropriate spot (see the Vundle.vim README for help):
```vim
Plugin 'nathanaelkane/vim-indent-guides'
```
and then run the following command from inside Vim:
```vim
:PluginInstall
```
## Usage
The default mapping to toggle the plugin is `<Leader>ig`
The default mapping to toggle the plugin is `<Leader>ig`.
You can also use the following commands inside Vim:
```vim
:IndentGuidesEnable
:IndentGuidesDisable
:IndentGuidesToggle
```
If you would like to have indent guides enabled by default, you can add the following to your `~/.vimrc`:
```vim
let g:indent_guides_enable_on_vim_startup = 1
```
### gVim
**This plugin should work with gVim out of the box, no configuration needed.** It will automatically inspect your colorscheme and pick appropriate colors.
### Setting custom indent colors
Here's an example of how to define custom colors instead of using the ones the plugin automatically generates for you. Add this to your `.vimrc` file:
```vim
let g:indent_guides_auto_colors = 0
autocmd VimEnter,Colorscheme * :hi IndentGuidesOdd guibg=red ctermbg=3
autocmd VimEnter,Colorscheme * :hi IndentGuidesEven guibg=green ctermbg=4
```
Alternatively you can add the following lines to your colorscheme file.
```vim
hi IndentGuidesOdd guibg=red ctermbg=3
hi IndentGuidesEven guibg=green ctermbg=4
```
### Terminal Vim
At the moment Terminal Vim only has basic support. This means is that colors won't be automatically calculated based on your colorscheme. Instead, some preset colors are used depending on whether `background` is set to `dark` or `light`.
When `set background=dark` is used, the following highlight colors will be defined:
```vim
hi IndentGuidesOdd ctermbg=black
hi IndentGuidesEven ctermbg=darkgrey
```
Alternatively, when `set background=light` is used, the following highlight colors will be defined:
```vim
hi IndentGuidesOdd ctermbg=white
hi IndentGuidesEven ctermbg=lightgrey
```
If for some reason it's incorrectly defining light highlight colors instead of dark ones or vice versa, the first thing you should check is that the `background` value is being set correctly for your colorscheme. Sometimes it's best to manually set the `background` value in your `.vimrc`, for example:
```vim
colorscheme desert256
set background=dark
```
Alternatively you can manually setup the highlight colors yourself, see `:help indent_guides_auto_colors` for an example.
## Help
`:help indent-guides`
## Screenshots
<img src="https://dl.dropbox.com/u/1019520/vim-indent-guides/rdark.png" width="400" height="400" alt="Indent Guides screenshot: rdark" />
<img src="https://dl.dropbox.com/u/1019520/vim-indent-guides/bclear.png" width="400" height="400" alt="Indent Guides screenshot: bclear" />
<img src="https://dl.dropbox.com/u/1019520/vim-indent-guides/clarity.png" width="400" height="400" alt="Indent Guides screenshot: clarity" />
<img src="https://dl.dropbox.com/u/1019520/vim-indent-guides/moss.png" width="400" height="400" alt="Indent Guides screenshot: moss" />
<img src="http://i.imgur.com/7tMBl.png" width="448" height="448" alt="" />
<img src="http://i.imgur.com/EvrqK.png" width="448" height="448" alt="" />
<img src="http://i.imgur.com/hHqp2.png" width="448" height="448" alt="" />

File diff suppressed because it is too large Load Diff

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,25 +30,33 @@ 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
call indent_guides#clear_matches()
if g:indent_guides_auto_colors
call indent_guides#highlight_colors()
endif
if &diff || indent_guides#exclude_filetype()
call indent_guides#clear_matches()
return
end
call indent_guides#init_script_vars()
call indent_guides#highlight_colors()
call indent_guides#clear_matches()
" loop through each indent level and define a highlight pattern
" will automagically figure out whether to use tabs or spaces
for level in range(1, g:indent_guides_indent_levels)
let group = 'IndentGuides' . ((level % 2 == 0) ? 'Even' : 'Odd')
let multiplier = (&l:expandtab == 1) ? &l:shiftwidth : 1
let pattern = '^\s\{' . (level * multiplier - multiplier) . '\}\zs'
let pattern .= '\s\{' . multiplier . '\}'
let pattern .= '\ze'
for l:level in range(s:start_level, s:indent_levels)
let l:group = 'IndentGuides' . ((l:level % 2 == 0) ? 'Even' : 'Odd')
let l:column_start = (l:level - 1) * s:indent_size + 1
" define the higlight pattern and add to list
call add(w:indent_guides_matches, matchadd(group, pattern))
" define the higlight patterns and add to matches list
if g:indent_guides_space_guides
let l:soft_pattern = indent_guides#indent_highlight_pattern(g:indent_guides_soft_pattern, l:column_start, s:guide_size)
call add(w:indent_guides_matches, matchadd(l:group, l:soft_pattern))
end
if g:indent_guides_tab_guides
let l:hard_pattern = indent_guides#indent_highlight_pattern('\t', l:column_start, s:indent_size)
call add(w:indent_guides_matches, matchadd(l:group, l:hard_pattern))
end
endfor
endfunction
@@ -56,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
@@ -64,83 +72,224 @@ 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 index = 0
for match_id in w:indent_guides_matches
call matchdelete(match_id)
call remove(w:indent_guides_matches, index)
let index += index
let l:index = 0
for l:match_id in w:indent_guides_matches
try
call matchdelete(l:match_id)
catch /E803:/
" Do nothing
endtry
call remove(w:indent_guides_matches, l:index)
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()
if g:indent_guides_auto_colors
let hi_normal = indent_guides#capture_highlight('normal')
let hex_pattern = 'guibg=\zs'. g:indent_guides_hex_color_pattern . '\ze'
let name_pattern = "guibg='\\?\\zs[0-9A-Za-z ]\\+\\ze'\\?"
let hi_normal_guibg = ''
" capture the backgroud color from the normal highlight
if hi_normal =~ hex_pattern
" hex color code is being used, eg. '#FFFFFF'
let hi_normal_guibg = matchstr(hi_normal, hex_pattern)
elseif hi_normal =~ name_pattern
" color name is being used, eg. 'white'
let color_name = matchstr(hi_normal, name_pattern)
let hi_normal_guibg = color_helper#color_name_to_hex(color_name)
function! indent_guides#highlight_colors() abort
if s:auto_colors
if has('gui_running') || has('nvim') || (has('termguicolors') && &termguicolors)
call indent_guides#gui_highlight_colors()
else
call indent_guides#basic_highlight_colors()
endif
if hi_normal_guibg =~ g:indent_guides_hex_color_pattern
" calculate the highlight background colors
let hi_odd_bg = indent_guides#lighten_or_darken_color(hi_normal_guibg)
let hi_even_bg = indent_guides#lighten_or_darken_color(hi_odd_bg)
" define the new highlights
exe 'hi IndentGuidesOdd guibg=' . hi_odd_bg
exe 'hi IndentGuidesEven guibg=' . hi_even_bg
end
endif
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() 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]
endfunction
"
" Automagically calculates and defines the indent highlight colors for gui
" vim.
"
function! indent_guides#gui_highlight_colors() abort
let l:hi_normal_guibg = ''
" capture the backgroud color from the normal highlight
if s:hi_normal =~ s:color_hex_bg_pat
" hex color code is being used, eg. '#FFFFFF'
let l:hi_normal_guibg = matchstr(s:hi_normal, s:color_hex_bg_pat)
elseif s:hi_normal =~ s:color_name_bg_pat
" 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
" calculate the highlight background colors
let l:hi_odd_bg = indent_guides#lighten_or_darken_color(l:hi_normal_guibg)
let l:hi_even_bg = indent_guides#lighten_or_darken_color(l:hi_odd_bg)
" define the new highlights
exe 'hi IndentGuidesOdd guibg=' . l:hi_odd_bg . ' guifg=' . l:hi_even_bg
exe 'hi IndentGuidesEven guibg=' . l:hi_even_bg . ' guifg=' . l:hi_odd_bg
end
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)
let percent = g:indent_guides_color_change_percent
function! indent_guides#lighten_or_darken_color(color) abort
let l:new_color = ''
let new_color = (&g:background == 'dark') ?
\ color_helper#hex_color_lighten(a:color, percent) :
\ color_helper#hex_color_darken (a:color, percent)
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)
endif
return new_color
return l:new_color
endfunction
"
" Define default highlights.
"
function! indent_guides#define_default_highlights() abort
hi default clear IndentGuidesOdd
hi default clear IndentGuidesEven
endfunction
"
" Init the w:indent_guides_matches variable.
"
function! indent_guides#init_matches() abort
let w:indent_guides_matches = exists('w:indent_guides_matches') ? w:indent_guides_matches : []
endfunction
"
" We need to initialize these vars every time a buffer is entered while the
" plugin is enabled.
"
function! indent_guides#init_script_vars() abort
if &l:shiftwidth > 0 && &l:expandtab
let s:indent_size = &l:shiftwidth
else
let s:indent_size = &l:tabstop
endif
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
let s:auto_colors = g:indent_guides_auto_colors
let s:color_hex_pat = g:indent_guides_color_hex_pattern
let s:color_hex_bg_pat = g:indent_guides_color_hex_guibg_pattern
let s:color_name_bg_pat = g:indent_guides_color_name_guibg_pattern
let s:start_level = g:indent_guides_start_level
" str2float not available in vim versions <= 7.1
if has('float')
let s:change_percent = g:indent_guides_color_change_percent / str2float('100.0')
else
let s:change_percent = g:indent_guides_color_change_percent / 100.0
endif
if s:debug
echo 's:indent_size = ' . s:indent_size
echo 's:guide_size = ' . s:guide_size
echo 's:hi_normal = ' . s:hi_normal
echo 's:indent_levels = ' . s:indent_levels
echo 's:auto_colors = ' . s:auto_colors
echo 's:change_percent = ' . string(s:change_percent)
echo 's:color_hex_pat = ' . s:color_hex_pat
echo 's:color_hex_bg_pat = ' . s:color_hex_bg_pat
echo 's:color_name_bg_pat = ' . s:color_name_bg_pat
echo 's:start_level = ' . s:start_level
endif
endfunction
"
" Calculate the indent guide size. Ensures the guide size is less than or
" equal to the actual indent size, otherwise some weird things can occur.
"
" NOTE: Currently, this only works when soft-tabs are being used.
"
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
let l:guide_size = s:indent_size
endif
return l:guide_size
endfunction
"
" Captures and returns the output of highlight group definitions.
"
" Example: indent_guides#capture_highlight('normal')
" Returns: 'Normal xxx guifg=#323232 guibg=#ffffff
" Returns: 'Normal xxx guifg=#323232 guibg=#ffffff'
"
function! indent_guides#capture_highlight(group_name)
redir => output
exe "silent hi " . a:group_name
redir END
return output
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
"
" Init the w:indent_guides_matches variable.
" Returns a regex pattern for highlighting an indent level.
"
function! indent_guides#init_matches()
let w:indent_guides_matches =
\ exists('w:indent_guides_matches') ? w:indent_guides_matches : []
" Example: indent_guides#indent_highlight_pattern(' ', 1, 4)
" Returns: /^ *\%1v\zs *\%5v\ze/
"
" Example: indent_guides#indent_highlight_pattern('\s', 5, 2)
" Returns: /^\s*\%5v\zs\s*\%7v\ze/
"
" 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) 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'
return l:pattern
endfunction
"
" Detect if any of the buffer filetypes should be excluded.
"
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
endfor
return 0
endfunction

View File

@@ -1,4 +1,4 @@
*indent_guides.txt* A plugin for visually displaying indent levels in vim.
*indent_guides.txt* A plugin for visually displaying indent levels in Vim.
*indent-guides*
____ __ __ ______ _ __
@@ -9,29 +9,39 @@
Author: Nate Kane <nathanaelkane AT gmail DOT com>
Version: 1.0
Last Change: 12 Dec 2010
Version: 1.7
Last Change: 07 Mar 2013
==============================================================================
CONTENTS *indent-guides-contents*
1. Introduction.............................. |indent-guides-introduction|
2. Commands.................................. |indent-guides-commands|
3. Options................................... |indent-guides-options|
4. Mappings.................................. |indent-guides-mappings|
5. About..................................... |indent-guides-about|
6. Changelog................................. |indent-guides-changelog|
7. License................................... |indent-guides-license|
1. Introduction.......................... |indent-guides-introduction|
2. Commands.............................. |indent-guides-commands|
3. Options............................... |indent-guides-options|
4. Mappings.............................. |indent-guides-mappings|
5. Terminal Vim.......................... |indent-guides-terminal-vim|
6. About................................. |indent-guides-about|
7. Changelog............................. |indent-guides-changelog|
8. License............................... |indent-guides-license|
==============================================================================
1. INTRODUCTION *indent-guides-introduction*
Indent Guides is a plugin for visually displaying indent levels in vim.
Indent Guides is a plugin for visually displaying indent levels in Vim.
This plugin should work with gVim out of the box, no configuration needed.
Features:~
* Can detect both tab and space indent styles.
* Automatically inspects your colorscheme and picks appropriate colors.
* Automatically inspects your colorscheme and picks appropriate colors (gVim
only).
* Will highlight indent levels with alternating colors.
* Full support for gVim and basic support for Terminal Vim.
* Seems to work on Windows gVim 7.3 (haven't done any extensive tests
though).
* Customizable size for indent guides, eg. skinny guides (soft-tabs only).
* Customizable start indent level.
* Highlight support for files with a mixture of tab and space indent styles.
==============================================================================
2. COMMANDS *indent-guides-commands*
@@ -56,6 +66,7 @@ Features:~
------------------------------------------------------------------------------
*'indent_guides_indent_levels'*
Use this option to control how many indent levels to display guides for.
Default: 30. Values: integer.
>
let g:indent_guides_indent_levels = 30
@@ -66,24 +77,124 @@ Default: 30. Values: integer.
Use this option to control whether or not the plugin automatically calculates
the highlight colors. Will use the current colorscheme's background color as a
base color.
Default: 1. Values: 0 or 1.
>
let g:indent_guides_auto_colors = 1
<
If you set this option to 0, be sure to manually define some highlight colors.
If you set this option to 0, be sure to manually define some highlight colors
in an autocmd.
>
hi IndentGuidesOdd guibg=#EEEEEE
hi IndentGuidesEven guibg=#CCCCCC
let g:indent_guides_auto_colors = 0
autocmd VimEnter,Colorscheme * :hi IndentGuidesOdd guibg=red ctermbg=3
autocmd VimEnter,Colorscheme * :hi IndentGuidesEven guibg=green ctermbg=4
<
Alternatively you can add the following lines to your colorscheme file.
>
hi IndentGuidesOdd guibg=red ctermbg=3
hi IndentGuidesEven guibg=green ctermbg=4
<
------------------------------------------------------------------------------
*'indent_guides_color_change_percent'*
Use this option to control the percent at which the highlight colors will be
lightened or darkened.
Default: 0.05. Values: between 0 and 1.
Default: 10 (10%). Values: between 0 and 100.
>
let g:indent_guides_color_change_percent = 0.05
let g:indent_guides_color_change_percent = 10
<
------------------------------------------------------------------------------
*'indent_guides_guide_size'*
Use this option to customize the size of the indent guide. By default the
value is set to 0, which will set the guide size to be the same as the
|shiftwidth|. Setting this value to be larger than the |shiftwidth| is essentially
the same as setting it to 0.
A common use of this setting is to create skinny indent guides, which look
great with a |shiftwidth| of 4 or more.
NOTE: This option only works for soft-tabs (spaces) and not hard-tabs.
Default: 0. Values: between 0 and |shiftwidth|.
>
let g:indent_guides_guide_size = 1
<
------------------------------------------------------------------------------
*'indent_guides_start_level'*
Use this option to control which indent level to start showing guides from.
Default: 1. Values: between 1 and g:|indent_guides_indent_levels|.
>
let g:indent_guides_start_level = 2
<
------------------------------------------------------------------------------
*'indent_guides_space_guides'*
Use this option to control whether the plugin considers spaces as indention.
Default: 1. Values: 0 or 1.
>
let g:indent_guides_space_guides = 0
<
------------------------------------------------------------------------------
*'indent_guides_tab_guides'*
Use this option to control whether the plugin considers tabs as indention.
Default: 1. Values: 0 or 1.
>
let g:indent_guides_tab_guides = 0
<
------------------------------------------------------------------------------
*'indent_guides_soft_pattern'*
Use this option to explicitly specify a pattern for soft indentation. For
example to match spaces only in the beginning of line use ' ' pattern.
Default: '\s'. Values: Vim regexp.
>
let g:indent_guides_soft_pattern = ' '
<
------------------------------------------------------------------------------
*'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
<
------------------------------------------------------------------------------
*'indent_guides_exclude_buftype'*
Use this option to try and disable the plugin on non-file buffers
Default: 0. Values: 0 or 1
>
let g:indent_guides_exclude_buftype = 0
<
------------------------------------------------------------------------------
*'indent_guides_exclude_filetypes'*
Use this option to specify a list of filetypes to disable the plugin for. Use
'' for files with no filetypes set.
Default: ['help']. Values: list of strings.
>
let g:indent_guides_exclude_filetypes = ['help', 'nerdtree']
<
------------------------------------------------------------------------------
*'indent_guides_default_mapping'*
Use this option to control whether the default mapping (<Leader>ig) gets set.
Default: 1. Values: 0 or 1.
>
let g:indent_guides_default_mapping = 0
<
==============================================================================
@@ -92,49 +203,142 @@ Default: 0.05. Values: between 0 and 1.
The default mapping for toggling indent guides is <Leader>ig. You can easily
map it to other keys. For example:
>
:nmap <Leader>ig :IndentGuidesToggle<CR>
:nmap <silent> <Leader>ig <Plug>IndentGuidesToggle
<
You can also map some other commands that are not mapped by default. For
example:
>
:nmap <Leader>ie :IndentGuidesEnable<CR>
:nmap <Leader>id :IndentGuidesDisable<CR>
:nmap <silent> <Leader>ie <Plug>IndentGuidesEnable
:nmap <silent> <Leader>id <Plug>IndentGuidesDisable
<
==============================================================================
5. ABOUT *indent-guides-about*
5. TERMINAL VIM *indent-guides-terminal-vim*
At the moment Terminal Vim only has basic support. This means is that colors
won't be automatically calculated based on your colorscheme. Instead, some
preset colors are used depending on whether `background` is set to `dark` or
`light`.
When `set background=dark` is used, the following highlight colors will be
defined:
>
hi IndentGuidesOdd ctermbg=black
hi IndentGuidesEven ctermbg=darkgrey
<
Alternatively, when `set background=light` is used, the following highlight
colors will be defined:
>
hi IndentGuidesOdd ctermbg=white
hi IndentGuidesEven ctermbg=lightgrey
<
If for some reason it's incorrectly defining light highlight colors instead of
dark ones or vice versa, the first thing you should check is that the
`background` value is being set correctly for your colorscheme. Sometimes it's
best to manually set the `background` value in your `.vimrc`, for example:
>
colorscheme desert256
set background=dark
<
Alternatively you can manually setup the highlight colors yourself, see
|indent_guides_auto_colors| for an example.
==============================================================================
6. ABOUT *indent-guides-about*
Why did I build this plugin?~
* I believe indent guides make nested code easier to read and understand.
* Other editors have them and it's high time vim did.
* Other editors have them and it's high time Vim did.
* None of the existing indent guide plugins on the market suited my needs.
* I wanted to learn me some VimL.
Links:~
* Github: https://github.com/nathanaelkane/vim-indent-guides
* Bugs & Issues: https://github.com/nathanaelkane/vim-indent-guides/issues
* Github: https://github.com/preservim/vim-indent-guides
* Bugs & Issues: https://github.com/preservim/vim-indent-guides/issues
Credits:~
* Matt Wozniski (godlygeek) for letting me use the list of color names and
hex codes from his CSApprox plugin.
Contact:~
* Twitter: @nathanaelkane
* Email: <nathanaelkane AT gmail DOT com>
* IRC: nate- on Freenode (I usually idle in the #vim channel)
Bug reports, feedback, suggestions etc are welcomed.
==============================================================================
6. CHANGELOG *indent-guides-changelog*
7. CHANGELOG *indent-guides-changelog*
1.8 (pending release)~
* Allow exclude files with no 'filetype' set (thanks @noscript).
* Added option g:|indent_guides_soft_pattern| to control the pattern for
soft indentation (thanks @noscript).
* Added option g:|indent_guides_default_mapping| to control whether the
default mapping (<Leader>ig) gets set (thanks @suy).
* Set size of indent guide to `tabstop` value when `shiftwidth=0` or
`noexpandtab` is used (thanks @darkfeline and @wilywampa).
* Don't load plugin in unsupported versions of Vim (thanks @dersaidin).
* Added option g:|indent_guides_tab_guides| to control whether tabs are
considered as indention (thanks @amerlyq).
1.7~
* Added way to override the default mapping (thanks @xuhdev).
* Added option g:|indent_guides_exclude_filetypes| to specify a list of
filetypes to disable the plugin for.
* Disable the plugin when in a diff.
* Various bug fixes.
1.6~
* Added option g:|indent_guides_space_guides| to control whether spaces are
considered as indention (thanks @scoz).
* Added 'doc/tags' to gitignore (thanks @lenniboy).
* Fixed E803 ID not found spam (thanks @mutewinter).
* Fixed str2float issue with Vim 7.1 (thanks @acx0).
1.5~
* Added highlight support for files with a mixture of tab and space indent
styles (thanks @graywh).
* Added -bar to all the :commands so they can chain with other :commands
(thanks @graywh).
* No longer overriding pre-defined custom highlight colors (thanks @graywh).
* Using str2float to work around a float bug in some versions of Vim 7.2
(thanks @voidus).
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.
* Cut down on rgb to hex color conversions by adding a big dictionary of
color names and hex codes.
* Various bug fixes.
1.0~
* First public version.
==============================================================================
7. LICENSE *indent-guides-license*
8. LICENSE *indent-guides-license*
The MIT Licence
http://www.opensource.org/licenses/mit-license.php
Copyright (c) 2010 Nate Kane
Copyright (c) 2010-2013 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
@@ -155,4 +359,3 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
vim:tw=78:ts=2:ft=help:norl:

View File

@@ -1,11 +1,16 @@
" Author: Nate Kane <nathanaelkane AT gmail DOT com>
" Homepage: http://github.com/nathanaelkane/vim-indent-guides
" Homepage: http://github.com/preservim/vim-indent-guides
if exists('g:loaded_indent_guides') || &cp || !has('gui_running')
" Do not load if vim is too old
if (v:version == 701 && !exists('*matchadd')) || (v:version < 701)
finish
endif
if exists('g:loaded_indent_guides') || &cp
finish
endif
let g:loaded_indent_guides = 1
call indent_guides#define_default_highlights()
function! s:IndentGuidesToggle()
call indent_guides#toggle()
@@ -20,45 +25,71 @@ function! s:IndentGuidesDisable()
endfunction
" Commands
command! IndentGuidesToggle call s:IndentGuidesToggle()
command! IndentGuidesEnable call s:IndentGuidesEnable()
command! IndentGuidesDisable call s:IndentGuidesDisable()
" Default options
let g:indent_guides_indent_levels =
\ exists('g:indent_guides_indent_levels') ?
\ g:indent_guides_indent_levels : 30
let g:indent_guides_auto_colors =
\ exists('g:indent_guides_auto_colors') ?
\ g:indent_guides_auto_colors : 1
let g:indent_guides_color_change_percent =
\ exists('g:indent_guides_color_change_percent') ?
\ g:indent_guides_color_change_percent : 0.05
let g:indent_guides_debug =
\ exists('g:indent_guides_debug') ?
\ g:indent_guides_debug : 0
let g:indent_guides_autocmds_enabled = 0
command! -bar IndentGuidesToggle call s:IndentGuidesToggle()
command! -bar IndentGuidesEnable call s:IndentGuidesEnable()
command! -bar IndentGuidesDisable call s:IndentGuidesDisable()
"
" Regex pattern for a hex color.
" Initializes a given variable to a given value. The variable is only
" initialized if it does not exist prior.
"
" Example matches:
" - '#123ABC'
" - '#ffffff'
" - '#000000'
"
let g:indent_guides_hex_color_pattern = '#[0-9A-Fa-f]\{6\}'
function s:InitVariable(var, value)
if !exists(a:var)
if type(a:value) == type('')
exec 'let ' . a:var . ' = ' . "'" . a:value . "'"
else
exec 'let ' . a:var . ' = ' . a:value
endif
endif
endfunction
" Fixed global variables
let g:indent_guides_autocmds_enabled = 0
let g:indent_guides_color_hex_pattern = '#[0-9A-Fa-f]\{6\}'
let g:indent_guides_color_hex_guibg_pattern = 'guibg=\zs' . g:indent_guides_color_hex_pattern . '\ze'
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', 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)
call s:InitVariable('g:indent_guides_space_guides', 1)
call s:InitVariable('g:indent_guides_tab_guides', 1)
call s:InitVariable('g:indent_guides_soft_pattern', '\s')
call s:InitVariable('g:indent_guides_default_mapping', 1)
if !exists('g:indent_guides_exclude_filetypes')
let g:indent_guides_exclude_filetypes = ['help']
endif
" Default mapping
nmap <Leader>ig :IndentGuidesToggle<CR>
if !hasmapto('<Plug>IndentGuidesToggle', 'n') && maparg('<Leader>ig', 'n') ==# ''
\ && g:indent_guides_default_mapping != 0
nmap <silent><unique> <Leader>ig <Plug>IndentGuidesToggle
endif
" Plug mappings
nnoremap <unique><script> <Plug>IndentGuidesToggle :IndentGuidesToggle<CR>
nnoremap <unique><script> <Plug>IndentGuidesEnable :IndentGuidesEnable<CR>
nnoremap <unique><script> <Plug>IndentGuidesDisable :IndentGuidesDisable<CR>
" Auto commands
augroup indent_guides
autocmd!
autocmd BufEnter,WinEnter * call indent_guides#process_autocmds()
augroup END
if g:indent_guides_enable_on_vim_startup
autocmd VimEnter * :IndentGuidesEnable
endif
autocmd BufEnter,WinEnter,FileType * call indent_guides#process_autocmds()
if (v:version == 704 && has('patch786')) || (v:version > 704)
autocmd OptionSet tabstop,shiftwidth,expandtab call indent_guides#process_autocmds()
endif
" Trigger BufEnter and process modelines.
autocmd ColorScheme * doautocmd indent_guides BufEnter
augroup END

View File

@@ -0,0 +1,47 @@
vim:tw=78:ts=2:sw=0:et:nolist
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test

View File

@@ -1,4 +1,4 @@
vim:tw=78:ts=2:sw=2:et
vim:tw=78:ts=2:sw=2:et:nolist
test
test
@@ -23,3 +23,25 @@ test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test

View File

@@ -1,4 +1,27 @@
vim:tw=78:ts=2:sw=2:noet
vim:tw=78:ts=2:sw=2:noet:nolist
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
@@ -22,4 +45,3 @@ test
test
test
test

View File

@@ -0,0 +1,24 @@
vim:tw=78:ts=2:sw=4:noet:nolist
test
test
test
test
test
test
test
test
test
test test
test
test
test
test
test
test
test
test
test
test
test
test

View File

@@ -1,4 +1,4 @@
vim:tw=78:ts=4:sw=4:et
vim:tw=78:ts=4:sw=4:et:nolist
test
test
@@ -23,3 +23,25 @@ test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test

View File

@@ -1,4 +1,27 @@
vim:tw=78:ts=4:sw=4:noet
vim:tw=78:ts=4:sw=4:noet:nolist
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
@@ -22,4 +45,3 @@ test
test
test
test

View File

@@ -0,0 +1,24 @@
vim:tw=78:ts=8:sw=2:noet:nolist
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test

View File

@@ -1,4 +1,4 @@
vim:tw=78:ts=8:sw=8:et
vim:tw=78:ts=8:sw=8:et:nolist
test
test
@@ -23,3 +23,25 @@ test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test

View File

@@ -1,4 +1,27 @@
vim:tw=78:ts=8:sw=8:noet
vim:tw=78:ts=8:sw=8:noet:nolist
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
@@ -22,4 +45,3 @@ test
test
test
test