1
0
mirror of https://github.com/SpaceVim/SpaceVim.git synced 2025-03-12 01:27:53 +08:00

chore(ui): update bundle indent-blankline.nvim

This commit is contained in:
wsdjeg 2023-07-05 13:20:39 +08:00
parent 3da610a107
commit 2755d4e660
7 changed files with 245 additions and 406 deletions

View File

@ -1,6 +1,6 @@
The MIT Licence The MIT Licence
Copyright (c) 2021 Lukas Reineke Copyright (c) 2022 Lukas Reineke
Permission is hereby granted, free of charge, to any person obtaining a copy Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal of this software and associated documentation files (the "Software"), to deal

View File

@ -2,7 +2,7 @@
This plugin adds indentation guides to all lines (including empty lines). This plugin adds indentation guides to all lines (including empty lines).
It uses Neovims virtual text feature and **no conceal** It uses Neovim's virtual text feature and **no conceal**
This plugin requires Neovim 0.5 or higher. It makes use of Neovim only This plugin requires Neovim 0.5 or higher. It makes use of Neovim only
features so it will not work in Vim. features so it will not work in Vim.
@ -13,28 +13,22 @@ branch `version-1`
Use your favourite plugin manager to install. Use your favourite plugin manager to install.
#### Example with Packer For [lazy.nvim](https://github.com/folke/lazy.nvim):
[wbthomason/packer.nvim](https://github.com/wbthomason/packer.nvim)
```lua ```lua
-- init.lua { "lukas-reineke/indent-blankline.nvim" },
require("packer").startup(
function()
use "lukas-reineke/indent-blankline.nvim"
end
)
``` ```
#### Example with Plug For [packer.nvim](https://github.com/wbthomason/packer.nvim):
[junegunn/vim-plug](https://github.com/junegunn/vim-plug) ```lua
use "lukas-reineke/indent-blankline.nvim"
```
For [vim-plug](https://github.com/junegunn/vim-plug):
```vim ```vim
" init.vim
call plug#begin('~/.vim/plugged')
Plug 'lukas-reineke/indent-blankline.nvim' Plug 'lukas-reineke/indent-blankline.nvim'
call plug#end()
``` ```
## Setup ## Setup
@ -62,7 +56,7 @@ All screenshots use [my custom onedark color scheme](https://github.com/lukas-re
```lua ```lua
vim.opt.list = true vim.opt.list = true
vim.opt.listchars:append("eol:↴") vim.opt.listchars:append "eol:↴"
require("indent_blankline").setup { require("indent_blankline").setup {
show_end_of_line = true, show_end_of_line = true,
@ -75,8 +69,8 @@ require("indent_blankline").setup {
```lua ```lua
vim.opt.list = true vim.opt.list = true
vim.opt.listchars:append("space:⋅") vim.opt.listchars:append "space:⋅"
vim.opt.listchars:append("eol:↴") vim.opt.listchars:append "eol:↴"
require("indent_blankline").setup { require("indent_blankline").setup {
show_end_of_line = true, show_end_of_line = true,
@ -98,8 +92,8 @@ vim.cmd [[highlight IndentBlanklineIndent5 guifg=#61AFEF gui=nocombine]]
vim.cmd [[highlight IndentBlanklineIndent6 guifg=#C678DD gui=nocombine]] vim.cmd [[highlight IndentBlanklineIndent6 guifg=#C678DD gui=nocombine]]
vim.opt.list = true vim.opt.list = true
vim.opt.listchars:append("space:⋅") vim.opt.listchars:append "space:⋅"
vim.opt.listchars:append("eol:↴") vim.opt.listchars:append "eol:↴"
require("indent_blankline").setup { require("indent_blankline").setup {
space_char_blankline = " ", space_char_blankline = " ",
@ -143,8 +137,8 @@ require("indent_blankline").setup {
```lua ```lua
vim.opt.list = true vim.opt.list = true
vim.opt.listchars:append("space:⋅") vim.opt.listchars:append "space:⋅"
vim.opt.listchars:append("eol:↴") vim.opt.listchars:append "eol:↴"
require("indent_blankline").setup { require("indent_blankline").setup {
space_char_blankline = " ", space_char_blankline = " ",
@ -153,7 +147,11 @@ require("indent_blankline").setup {
} }
``` ```
<img width="900" src="https://user-images.githubusercontent.com/12900252/140518531-522aa67a-b377-498c-ad39-85113b2b56df.png" alt="Screenshot" /> <img width="900" src="https://user-images.githubusercontent.com/12900252/188080732-5b7d98b9-3cb8-4789-b28d-67cad0bfbcde.png" alt="Screenshot" />
`show_current_context_start` uses underline, so to achieve the best result you
might need to tweak the underline position. In Kitty terminal for example you
can do that with [modify_font](https://sw.kovidgoyal.net/kitty/conf/#opt-kitty.modify_font)
## Thanks ## Thanks

View File

@ -2,7 +2,7 @@
Author: Lukas Reineke <lukas.reineke@protonmail.com> Author: Lukas Reineke <lukas.reineke@protonmail.com>
Version: 2.17.0 Version: 2.20.6
============================================================================== ==============================================================================
CONTENTS *indent-blankline* CONTENTS *indent-blankline*
@ -12,15 +12,14 @@ CONTENTS *indent-blankline*
3. Setup |indent-blankline-setup| 3. Setup |indent-blankline-setup|
4. Variables |indent-blankline-variables| 4. Variables |indent-blankline-variables|
5. Commands |indent-blankline-commands| 5. Commands |indent-blankline-commands|
6. Changelog |indent-blankline-changelog| 6. License |indent-blankline-license|
7. License |indent-blankline-license|
============================================================================== ==============================================================================
1. INTRODUCTION *indent-blankline-introduction* 1. INTRODUCTION *indent-blankline-introduction*
This plugin adds indentation guides to all lines (including empty lines). This plugin adds indentation guides to all lines (including empty lines).
It uses Neovims virtual text feature and **no conceal** It uses Neovim's virtual text feature and **no conceal**
This plugin requires Neovim 0.5 or higher. It makes use of Neovim only This plugin requires Neovim 0.5 or higher. It makes use of Neovim only
features so it will not work in Vim. features so it will not work in Vim.
@ -78,6 +77,18 @@ IndentBlanklineContextChar *hl-IndentBlanklineContextChar*
highlight IndentBlanklineContextChar guifg=#00FF00 gui=nocombine highlight IndentBlanklineContextChar guifg=#00FF00 gui=nocombine
------------------------------------------------------------------------------
IndentBlanklineContextSpaceChar *hl-IndentBlanklineContextSpaceChar*
Highlight of space characters one indent level of the current context.
Only used when |g:indent_blankline_show_current_context| is active
Default: takes guifg color from 'Label' ~
Example: >
highlight IndentBlanklineContextSpaceChar guifg=#00FF00 gui=nocombine
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
IndentBlanklineContextStart *hl-IndentBlanklineContextStart* IndentBlanklineContextStart *hl-IndentBlanklineContextStart*
@ -94,11 +105,13 @@ IndentBlanklineContextStart *hl-IndentBlanklineContextStart*
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
Note: Define your highlight group after setting colorscheme or your colorscheme will clear your highlight group
When defining the highlight group, it is important to set |nocombine| as a When defining the highlight group, it is important to set |nocombine| as a
gui option. This is to make sure the character does not inherit gui options gui option. This is to make sure the character does not inherit gui options
from the underlying text, like italic or bold. from the underlying text, like italic or bold.
Highlight groups get reset on |ColorScheme| autocommand, *if* both fg and bg Highlight groups get reset on |ColorScheme| autocommand, if both fg and bg
are empty. are empty.
The set more than one highlight group that changes based on indentation level, The set more than one highlight group that changes based on indentation level,
@ -126,7 +139,7 @@ Example: >
============================================================================== ==============================================================================
4. VARIABLES *indent-blankline-variables* 4. VARIABLES *indent-blankline-variables*
All variables can be set gobally |g:var|, per tab |t:var|, or per buffer |b:var| All variables can be set globally |g:var|, per tab |t:var|, or per buffer |b:var|
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
g:indent_blankline_char *g:indent_blankline_char* g:indent_blankline_char *g:indent_blankline_char*
@ -190,7 +203,6 @@ g:indent_blankline_char_list_blankline *g:indent_blankline_char_list_blankline*
let g:indent_blankline_char_list_blankline = ['|', '¦', '┆', '┊'] let g:indent_blankline_char_list_blankline = ['|', '¦', '┆', '┊']
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
g:indent_blankline_char_highlight_list *g:indent_blankline_char_highlight_list* g:indent_blankline_char_highlight_list *g:indent_blankline_char_highlight_list*
Specifies the list of character highlights for each indentation level. Specifies the list of character highlights for each indentation level.
@ -215,7 +227,6 @@ g:indent_blankline_space_char_blankline *g:indent_blankline_space_char_blankline
let g:indent_blankline_space_char_blankline = ' ' let g:indent_blankline_space_char_blankline = ' '
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
g:indent_blankline_space_char_highlight_list *g:indent_blankline_space_char_highlight_list* g:indent_blankline_space_char_highlight_list *g:indent_blankline_space_char_highlight_list*
Specifies the list of space character highlights for each indentation Specifies the list of space character highlights for each indentation
@ -229,7 +240,6 @@ g:indent_blankline_space_char_highlight_list *g:indent_blankline_space_char_high
let g:indent_blankline_space_char_highlight_list = ['Error', 'Function'] let g:indent_blankline_space_char_highlight_list = ['Error', 'Function']
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
g:indent_blankline_space_char_blankline_highlight_list *g:indent_blankline_space_char_blankline_highlight_list* g:indent_blankline_space_char_blankline_highlight_list *g:indent_blankline_space_char_blankline_highlight_list*
Specifies the list of space character highlights for each indentation Specifies the list of space character highlights for each indentation
@ -341,7 +351,7 @@ g:indent_blankline_enabled *g:indent_blankline_enabled*
Also set by |g:indentLine_enabled| Also set by |g:indentLine_enabled|
Note: the buffer version of this variable overwrites all other Note: the buffer version of this variable overwrites all other
enabled/disalbed checks. enabled/disabled checks.
Default: v:true ~ Default: v:true ~
@ -409,6 +419,7 @@ g:indent_blankline_buftype_exclude *g:indent_blankline_buftype_exclude*
"terminal", ~ "terminal", ~
"nofile", ~ "nofile", ~
"quickfix", ~ "quickfix", ~
"prompt", ~
] ~ ] ~
Example: > Example: >
@ -451,7 +462,9 @@ g:indent_blankline_show_current_context *g:indent_blankline_show_current_context
When on, use treesitter to determine the current context. Then show the When on, use treesitter to determine the current context. Then show the
indent character in a different highlight. indent character in a different highlight.
Requires treesitter
Note: Requires https://github.com/nvim-treesitter/nvim-treesitter to be
installed
Note: With this option enabled, the plugin refreshes on |CursorMoved|, Note: With this option enabled, the plugin refreshes on |CursorMoved|,
which might be slower which might be slower
@ -469,6 +482,9 @@ g:indent_blankline_show_current_context_start *g:indent_blankline_show_current_c
line of the current context. line of the current context.
By default this will underline. By default this will underline.
Note: Requires https://github.com/nvim-treesitter/nvim-treesitter to be
installed
Note: You need to have set |gui-colors| and it depends on your terminal Note: You need to have set |gui-colors| and it depends on your terminal
emulator if this works as expected. emulator if this works as expected.
If you are using kitty and tmux, take a look at this article to If you are using kitty and tmux, take a look at this article to
@ -562,6 +578,28 @@ g:indent_blankline_context_highlight_list *g:indent_blankline_context_highlight_
let g:indent_blankline_context_highlight_list = ['Error', 'Warning'] let g:indent_blankline_context_highlight_list = ['Error', 'Warning']
------------------------------------------------------------------------------
g:indent_blankline_char_priority *g:indent_blankline_char_priority*
Specifies the |extmarks| priority for chars.
Default: 1 ~
Example: >
let g:indent_blankline_char_priority = 50
------------------------------------------------------------------------------
g:indent_blankline_context_start_priority *g:indent_blankline_context_start_priority*
Specifies the |extmarks| priority for the context start.
Default: 10000 ~
Example: >
let g:indent_blankline_context_start_priority = 50
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
g:indent_blankline_context_patterns *g:indent_blankline_context_patterns* g:indent_blankline_context_patterns *g:indent_blankline_context_patterns*
@ -591,12 +629,33 @@ g:indent_blankline_context_patterns *g:indent_blankline_context_patterns*
"element", ~ "element", ~
"table", ~ "table", ~
"tuple", ~ "tuple", ~
"do_block", ~
"Block", ~
"InitList", ~
"FnCallArguments", ~
"IfStatement", ~
"ContainerDecl", ~
"SwitchExpr", ~
"IfExpr", ~
"ParamDeclList", ~
] ~ ] ~
Example: > Example: >
let g:indent_blankline_context_patterns = ['^if'] let g:indent_blankline_context_patterns = ['^if']
------------------------------------------------------------------------------
g:indent_blankline_use_treesitter_scope *g:indent_blankline_use_treesitter_scope*
Instead of using |g:indent_blankline_context_patterns|, use the current
scope defined by nvim-treesitter as the context.
Default: false ~
Example: >
let g:indent_blankline_use_treesitter_scope = true
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
g:indent_blankline_context_pattern_highlight *g:indent_blankline_context_pattern_highlight* g:indent_blankline_context_pattern_highlight *g:indent_blankline_context_pattern_highlight*
@ -636,17 +695,6 @@ g:indent_blankline_disable_warning_message *g:indent_blankline_disable_warning_m
let g:indent_blankline_disable_warning_message = v:true let g:indent_blankline_disable_warning_message = v:true
------------------------------------------------------------------------------
g:indent_blankline_debug *g:indent_blankline_debug*
Turns on error logging.
Default: v:false ~
Example: >
let g:indent_blankline_debug = v:true
============================================================================== ==============================================================================
5. COMMANDS *indent-blankline-commands* 5. COMMANDS *indent-blankline-commands*
@ -666,7 +714,7 @@ g:indent_blankline_debug *g:indent_blankline_debug*
4. |CompleteChanged| * 4. |CompleteChanged| *
5. |BufWinEnter| * 5. |BufWinEnter| *
6. |Filetype| * 6. |Filetype| *
7. |OptionSet| shiftwidth,tabstop,expandtab 7. |OptionSet| list,listchars,shiftwidth,tabstop,expandtab
Example: > Example: >
@ -712,251 +760,12 @@ g:indent_blankline_debug *g:indent_blankline_debug*
With bang (IndentBlanklineToggle!) toggles globally With bang (IndentBlanklineToggle!) toggles globally
============================================================================== ==============================================================================
6. CHANGELOG *indent-blankline-changelog* 6. LICENSE *indent-blankline-license*
2.17.0
Update defaults for |g:indent_blankline_buftype_exclude|
2.16.0
Add `man` to |g:indent_blankline_filetype_exclude|
Stylua update
2.15.1
Fix for nvim 0.5.1
2.15.0
* Add |g:indent_blankline_context_char_blankline| and
|g:indent_blankline_context_char_list_blankline| options
2.14.0
* Add |g:indent_blankline_char_blankline| and
|g:indent_blankline_char_list_blankline| options
2.13.0
* Support both the concatenated string, as well as the individual |filetypes|
in |g:indent_blankline_filetype_exclude| when a buffer has multiple filetypes
2.12.1
* Add ext mark priority
2.12.0
* Remove old vimscript functions
* Better default values for |g:indent_blankline_context_patterns| and
|g:indent_blankline_filetype_exclude|
2.11.0
* Add |g:indent_blankline_show_current_context_start_on_current_line|
2.10.6
* Update example setup in the readme and docs
2.10.5
* Run refresh without autocmds
* Check that the window is valid before returning to it after refresh
2.10.4
* Remove `nocombine` from |hl-IndentBlanklineContextStart| again..
2.10.3
* Fix context start highlight column for files indent with tab
* Fix context start highlight on lines with no indent
2.10.2
* Apply context start highlight after indentation
2.10.1
* Remove `nocombine` from |hl-IndentBlanklineContextStart|
2.10.0
* Add |g:indent_blankline_show_current_context_start|
* Add |hl-IndentBlanklineContextStart|
2.9.3
* Fix indent cache for scrolling
* Fix documentation tags
2.9.2
* Fix refresh argument types for 0.5
2.9.1
* Fix horizontal scroll update
2.9.0
* Add |g:indent_blankline_context_char|
* Add |g:indent_blankline_context_char_list|
2.8.0
* Add |IndentBlanklineRefreshScroll|
2.7.0
* Add support for 0 width |g:indent_blankline_char|
2.6.4
* Remove memo from `find_indent`, it made the performance worse
2.6.3
* Fix issue when calling setup more than once
2.6.2
* Memoize the find indent function
* Run init on VimEnter to initialize indents in all open windows
* Run init on plugin load to work with lazy loading
2.6.1
* Wait until buffer is loaded before doing anything
2.6.0
* Add |g:indent_blankline_context_pattern_highlight|
2.5.7
* Update the README to not overwrite all listchars
* Handle listchars without a tab character
2.5.6
* Fix trailing space for blanklines
2.5.5
* Fix typo in readme
* Fix initialization of |g:indent_blankline_space_char_blankline_highlight_list|
* Refactor `find_indent`
2.5.4
* Fix wrong indent for empty lines with only extra
2.5.3
* Remove old reference to `indent_blankline_space_char`
2.5.2
* Fix background highlight example
2.5.1
* Only load treesitter libs if needed
2.5.0
* Add |g:indent_blankline_max_indent_increase|
2.4.0
* Remove `indent_blankline_respect_list`
* Add |g:indent_blankline_disable_with_nolist|
2.3.0
* Add |g:indent_blankline_respect_list| option
2.2.2
* Remove old vimscript code
2.2.1
* Fix first indent on a line with whitespace less than the current shift
width
2.2.0
* Correctly display listchars under the indent guides
Huge thanks to @Daxtorim
* Remove options:
`indent_blankline_space_char` - listchars is used to get the correct space
character
2.1.4
* Fix race condition in `is_indent_blankline_enabled`
2.1.3
* Refresh on |CompleteChanged|
2.1.2
* Fix lazy loading
2.1.1
* Fix bug were setup function is not run
2.1.0
* Added setup function
* Added buffer variables
* Fix horizontal scroll
2.0.1
* Fix typo in docs
2.0.0
* Complete lua rewrite
* Drop support for Neovim 0.4
* Trigger on `TextChanged`, `TextChangedI` and `WinScrolled`
* Removed IndentGuide dependency
* Removed commands
- IndentBlanklineEnableAll
- IndentBlanklineDisableAll
- IndentBlanklineToggleAll
* Added Bang for commands
- IndentBlanklineRefresh
- IndentBlanklineEnable
- IndentBlanklineDisable
- IndentBlanklineToggle
* New options:
|g:indent_blankline_char_highlight_list|
|g:indent_blankline_space_char_highlight_list|
|g:indent_blankline_show_end_of_line|
|g:indent_blankline_show_foldtext|
|g:indent_blankline_show_current_context|
|g:indent_blankline_context_highlight_list|
|g:indent_blankline_context_patterns|
|g:indent_blankline_viewport_buffer|
|g:indent_blankline_disable_warning_message|
* Remove options:
`indent_blankline_extra_indent_level`
1.4.1
* Fix windows working directory bug
1.4.0
* Don't create jumps in embedded nvim instance
* Restore cursor and close buffer after every search
* Only clear the namespace on disable if it exists
1.3.2
* Call indentexpr with `silent!` to not exit early on errors
1.3.1
* Moved more of init function in the try/catch block
1.3.0
* Error logs have more context
* More error logs
* Added `g:indent_blankline_debug` option to only display the errors logs
when needed
1.2.2
* Apply `indent_blankline_indent_level` after
`indent_blankline_extra_indent_level`
1.2.1
* Fixed out of range bug with `g:indent_blankline_extra_indent_level`
1.2.0
* Added `g:indent_blankline_extra_indent_level` option.
1.1.0
* Don't throw errors when `rpcnotify` fails. Just print the error message and
try again next time.
1.0.3
* Fixed wrong help tag
1.0.2
* Fixed wrong variable reference form `indentLine_bufTypeExclude`
to `indent_blankline_buftype_exclude`
1.0.1
* Fixed typo in docs
1.0.0
* First release
==============================================================================
7. LICENSE *indent-blankline-license*
The MIT Licence The MIT Licence
http://www.opensource.org/licenses/mit-license.php http://www.opensource.org/licenses/mit-license.php
Copyright (c) 2021 Lukas Reineke Copyright (c) 2023 Lukas Reineke
Permission is hereby granted, free of charge, to any person obtaining a copy Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal of this software and associated documentation files (the "Software"), to deal

View File

@ -5,6 +5,7 @@ local char_highlight = "IndentBlanklineChar"
local space_char_highlight = "IndentBlanklineSpaceChar" local space_char_highlight = "IndentBlanklineSpaceChar"
local space_char_blankline_highlight = "IndentBlanklineSpaceCharBlankline" local space_char_blankline_highlight = "IndentBlanklineSpaceCharBlankline"
local context_highlight = "IndentBlanklineContextChar" local context_highlight = "IndentBlanklineContextChar"
local context_space_char_highlight = "IndentBlanklineContextSpaceChar"
M.init = function() M.init = function()
if not vim.g.indent_blankline_namespace then if not vim.g.indent_blankline_namespace then
@ -25,43 +26,26 @@ M.setup = function(options)
vim.g.indent_blankline_char = o(options.char, vim.g.indent_blankline_char, vim.g.indentLine_char, "") vim.g.indent_blankline_char = o(options.char, vim.g.indent_blankline_char, vim.g.indentLine_char, "")
vim.g.indent_blankline_char_blankline = o(options.char_blankline, vim.g.indent_blankline_char_blankline) vim.g.indent_blankline_char_blankline = o(options.char_blankline, vim.g.indent_blankline_char_blankline)
vim.g.indent_blankline_char_list = o( vim.g.indent_blankline_char_list =
options.char_list, o(options.char_list, vim.g.indent_blankline_char_list, vim.g.indentLine_char_list)
vim.g.indent_blankline_char_list, vim.g.indent_blankline_char_list_blankline =
vim.g.indentLine_char_list o(options.char_list_blankline, vim.g.indent_blankline_char_list_blankline)
) vim.g.indent_blankline_context_char =
vim.g.indent_blankline_char_list_blankline = o( o(options.context_char, vim.g.indent_blankline_context_char, vim.g.indent_blankline_char)
options.char_list_blankline,
vim.g.indent_blankline_char_list_blankline
)
vim.g.indent_blankline_context_char = o(
options.context_char,
vim.g.indent_blankline_context_char,
vim.g.indent_blankline_char
)
vim.g.indent_blankline_context_char_blankline = o( vim.g.indent_blankline_context_char_blankline = o(
options.context_char_blankline, options.context_char_blankline,
vim.g.indent_blankline_context_char_blankline, vim.g.indent_blankline_context_char_blankline,
vim.g.indent_blankline_char_blankline vim.g.indent_blankline_char_blankline
) )
vim.g.indent_blankline_context_char_list = o(options.context_char_list, vim.g.indent_blankline_context_char_list) vim.g.indent_blankline_context_char_list = o(options.context_char_list, vim.g.indent_blankline_context_char_list)
vim.g.indent_blankline_context_char_list_blankline = o( vim.g.indent_blankline_context_char_list_blankline =
options.context_char_list_blankline, o(options.context_char_list_blankline, vim.g.indent_blankline_context_char_list)
vim.g.indent_blankline_context_char_list vim.g.indent_blankline_char_highlight_list =
) o(options.char_highlight_list, vim.g.indent_blankline_char_highlight_list)
vim.g.indent_blankline_char_highlight_list = o( vim.g.indent_blankline_space_char_highlight_list =
options.char_highlight_list, o(options.space_char_highlight_list, vim.g.indent_blankline_space_char_highlight_list)
vim.g.indent_blankline_char_highlight_list vim.g.indent_blankline_space_char_blankline =
) o(options.space_char_blankline, vim.g.indent_blankline_space_char_blankline, " ")
vim.g.indent_blankline_space_char_highlight_list = o(
options.space_char_highlight_list,
vim.g.indent_blankline_space_char_highlight_list
)
vim.g.indent_blankline_space_char_blankline = o(
options.space_char_blankline,
vim.g.indent_blankline_space_char_blankline,
" "
)
vim.g.indent_blankline_space_char_blankline_highlight_list = o( vim.g.indent_blankline_space_char_blankline_highlight_list = o(
options.space_char_blankline_highlight_list, options.space_char_blankline_highlight_list,
vim.g.indent_blankline_space_char_blankline_highlight_list, vim.g.indent_blankline_space_char_blankline_highlight_list,
@ -70,11 +54,8 @@ M.setup = function(options)
) )
vim.g.indent_blankline_indent_level = o(options.indent_level, vim.g.indent_blankline_indent_level, 20) vim.g.indent_blankline_indent_level = o(options.indent_level, vim.g.indent_blankline_indent_level, 20)
vim.g.indent_blankline_enabled = o(options.enabled, vim.g.indent_blankline_enabled, true) vim.g.indent_blankline_enabled = o(options.enabled, vim.g.indent_blankline_enabled, true)
vim.g.indent_blankline_disable_with_nolist = o( vim.g.indent_blankline_disable_with_nolist =
options.disable_with_nolist, o(options.disable_with_nolist, vim.g.indent_blankline_disable_with_nolist, false)
vim.g.indent_blankline_disable_with_nolist,
false
)
vim.g.indent_blankline_filetype = o(options.filetype, vim.g.indent_blankline_filetype, vim.g.indentLine_fileType) vim.g.indent_blankline_filetype = o(options.filetype, vim.g.indent_blankline_filetype, vim.g.indentLine_fileType)
vim.g.indent_blankline_filetype_exclude = o( vim.g.indent_blankline_filetype_exclude = o(
options.filetype_exclude, options.filetype_exclude,
@ -82,16 +63,13 @@ M.setup = function(options)
vim.g.indentLine_fileTypeExclude, vim.g.indentLine_fileTypeExclude,
{ "lspinfo", "packer", "checkhealth", "help", "man", "" } { "lspinfo", "packer", "checkhealth", "help", "man", "" }
) )
vim.g.indent_blankline_bufname_exclude = o( vim.g.indent_blankline_bufname_exclude =
options.bufname_exclude, o(options.bufname_exclude, vim.g.indent_blankline_bufname_exclude, vim.g.indentLine_bufNameExclude)
vim.g.indent_blankline_bufname_exclude,
vim.g.indentLine_bufNameExclude
)
vim.g.indent_blankline_buftype_exclude = o( vim.g.indent_blankline_buftype_exclude = o(
options.buftype_exclude, options.buftype_exclude,
vim.g.indent_blankline_buftype_exclude, vim.g.indent_blankline_buftype_exclude,
vim.g.indentLine_bufTypeExclude, vim.g.indentLine_bufTypeExclude,
{ "terminal", "nofile", "quickfix" } { "terminal", "nofile", "quickfix", "prompt" }
) )
vim.g.indent_blankline_viewport_buffer = o(options.viewport_buffer, vim.g.indent_blankline_viewport_buffer, 10) vim.g.indent_blankline_viewport_buffer = o(options.viewport_buffer, vim.g.indent_blankline_viewport_buffer, 10)
vim.g.indent_blankline_use_treesitter = o(options.use_treesitter, vim.g.indent_blankline_use_treesitter, false) vim.g.indent_blankline_use_treesitter = o(options.use_treesitter, vim.g.indent_blankline_use_treesitter, false)
@ -101,41 +79,26 @@ M.setup = function(options)
options.indent_level, options.indent_level,
vim.g.indent_blankline_indent_level vim.g.indent_blankline_indent_level
) )
vim.g.indent_blankline_show_first_indent_level = o( vim.g.indent_blankline_show_first_indent_level =
options.show_first_indent_level, o(options.show_first_indent_level, vim.g.indent_blankline_show_first_indent_level, true)
vim.g.indent_blankline_show_first_indent_level, vim.g.indent_blankline_show_trailing_blankline_indent =
true o(options.show_trailing_blankline_indent, vim.g.indent_blankline_show_trailing_blankline_indent, true)
) vim.g.indent_blankline_show_end_of_line =
vim.g.indent_blankline_show_trailing_blankline_indent = o( o(options.show_end_of_line, vim.g.indent_blankline_show_end_of_line, false)
options.show_trailing_blankline_indent,
vim.g.indent_blankline_show_trailing_blankline_indent,
true
)
vim.g.indent_blankline_show_end_of_line = o(
options.show_end_of_line,
vim.g.indent_blankline_show_end_of_line,
false
)
vim.g.indent_blankline_show_foldtext = o(options.show_foldtext, vim.g.indent_blankline_show_foldtext, true) vim.g.indent_blankline_show_foldtext = o(options.show_foldtext, vim.g.indent_blankline_show_foldtext, true)
vim.g.indent_blankline_show_current_context = o( vim.g.indent_blankline_show_current_context =
options.show_current_context, o(options.show_current_context, vim.g.indent_blankline_show_current_context, false)
vim.g.indent_blankline_show_current_context, vim.g.indent_blankline_show_current_context_start =
false o(options.show_current_context_start, vim.g.indent_blankline_show_current_context_start, false)
) vim.g.indent_blankline_use_treesitter_scope =
vim.g.indent_blankline_show_current_context_start = o( o(options.use_treesitter_scope, vim.g.indent_blankline_use_treesitter_scope, false)
options.show_current_context_start,
vim.g.indent_blankline_show_current_context_start,
false
)
vim.g.indent_blankline_show_current_context_start_on_current_line = o( vim.g.indent_blankline_show_current_context_start_on_current_line = o(
options.show_current_context_start_on_current_line, options.show_current_context_start_on_current_line,
vim.g.indent_blankline_show_current_context_start_on_current_line, vim.g.indent_blankline_show_current_context_start_on_current_line,
true true
) )
vim.g.indent_blankline_context_highlight_list = o( vim.g.indent_blankline_context_highlight_list =
options.context_highlight_list, o(options.context_highlight_list, vim.g.indent_blankline_context_highlight_list)
vim.g.indent_blankline_context_highlight_list
)
vim.g.indent_blankline_context_patterns = o(options.context_patterns, vim.g.indent_blankline_context_patterns, { vim.g.indent_blankline_context_patterns = o(options.context_patterns, vim.g.indent_blankline_context_patterns, {
"class", "class",
"^func", "^func",
@ -146,6 +109,7 @@ M.setup = function(options)
"with", "with",
"try", "try",
"except", "except",
"match",
"arguments", "arguments",
"argument_list", "argument_list",
"object", "object",
@ -153,25 +117,31 @@ M.setup = function(options)
"element", "element",
"table", "table",
"tuple", "tuple",
"do_block",
"Block",
"InitList",
"FnCallArguments",
"IfStatement",
"ContainerDecl",
"SwitchExpr",
"IfExpr",
"ParamDeclList",
}) })
vim.g.indent_blankline_context_pattern_highlight = o( vim.g.indent_blankline_context_pattern_highlight =
options.context_pattern_highlight, o(options.context_pattern_highlight, vim.g.indent_blankline_context_pattern_highlight)
vim.g.indent_blankline_context_pattern_highlight
)
vim.g.indent_blankline_strict_tabs = o(options.strict_tabs, vim.g.indent_blankline_strict_tabs, false) vim.g.indent_blankline_strict_tabs = o(options.strict_tabs, vim.g.indent_blankline_strict_tabs, false)
vim.g.indent_blankline_disable_warning_message = o( vim.g.indent_blankline_disable_warning_message =
options.disable_warning_message, o(options.disable_warning_message, vim.g.indent_blankline_disable_warning_message, false)
vim.g.indent_blankline_disable_warning_message, vim.g.indent_blankline_char_priority = o(options.char_priority, vim.g.indent_blankline_char_priority, 1)
false vim.g.indent_blankline_context_start_priority =
) o(options.context_start_priority, vim.g.indent_blankline_context_start_priority, 10000)
vim.g.indent_blankline_debug = o(options.debug, vim.g.indent_blankline_debug, false)
if vim.g.indent_blankline_show_current_context then if vim.g.indent_blankline_show_current_context then
vim.cmd [[ vim.cmd [[
augroup IndentBlanklineContextAutogroup augroup IndentBlanklineContextAutogroup
autocmd! autocmd!
autocmd CursorMoved * IndentBlanklineRefresh autocmd CursorMoved,CursorMovedI * IndentBlanklineRefresh
augroup END augroup END
]] ]]
end end
@ -277,6 +247,8 @@ local refresh = function(scroll)
local space_char_highlight_list = v "indent_blankline_space_char_highlight_list" or {} local space_char_highlight_list = v "indent_blankline_space_char_highlight_list" or {}
local space_char_blankline_highlight_list = v "indent_blankline_space_char_blankline_highlight_list" or {} local space_char_blankline_highlight_list = v "indent_blankline_space_char_blankline_highlight_list" or {}
local space_char_blankline = v "indent_blankline_space_char_blankline" local space_char_blankline = v "indent_blankline_space_char_blankline"
local char_priority = v "indent_blankline_char_priority"
local context_start_priority = v "indent_blankline_context_start_priority"
local list_chars local list_chars
local no_tab_character = false local no_tab_character = false
@ -321,6 +293,11 @@ local refresh = function(scroll)
local ts_indent local ts_indent
if v "indent_blankline_use_treesitter" then if v "indent_blankline_use_treesitter" then
local ts_query_status, ts_query = pcall(require, "nvim-treesitter.query") local ts_query_status, ts_query = pcall(require, "nvim-treesitter.query")
if not ts_query_status then
vim.schedule_wrap(function()
utils.error_handler("nvim-treesitter not found. Treesitter indent will not work", vim.log.levels.WARN)
end)()
end
local ts_indent_status local ts_indent_status
ts_indent_status, ts_indent = pcall(require, "nvim-treesitter.indent") ts_indent_status, ts_indent = pcall(require, "nvim-treesitter.indent")
use_ts_indent = ts_query_status and ts_indent_status and ts_query.has_indents(vim.bo.filetype) use_ts_indent = ts_query_status and ts_indent_status and ts_query.has_indents(vim.bo.filetype)
@ -340,9 +317,8 @@ local refresh = function(scroll)
local show_current_context_start = v "indent_blankline_show_current_context_start" local show_current_context_start = v "indent_blankline_show_current_context_start"
local show_current_context_start_on_current_line = v "indent_blankline_show_current_context_start_on_current_line" local show_current_context_start_on_current_line = v "indent_blankline_show_current_context_start_on_current_line"
if v "indent_blankline_show_current_context" then if v "indent_blankline_show_current_context" then
context_status, context_start, context_end, context_pattern = utils.get_current_context( context_status, context_start, context_end, context_pattern =
v "indent_blankline_context_patterns" utils.get_current_context(v "indent_blankline_context_patterns", v "indent_blankline_use_treesitter_scope")
)
end end
local get_virtual_text = local get_virtual_text =
@ -351,11 +327,8 @@ local refresh = function(scroll)
local current_left_offset = left_offset local current_left_offset = left_offset
local local_max_indent_level = math.min(max_indent_level, prev_indent + max_indent_increase) local local_max_indent_level = math.min(max_indent_level, prev_indent + max_indent_increase)
local indent_char = utils._if(blankline and char_blankline, char_blankline, char) local indent_char = utils._if(blankline and char_blankline, char_blankline, char)
local context_indent_char = utils._if( local context_indent_char =
blankline and context_char_blankline, utils._if(blankline and context_char_blankline, context_char_blankline, context_char)
context_char_blankline,
context_char
)
local indent_char_list = utils._if(blankline and #char_list_blankline > 0, char_list_blankline, char_list) local indent_char_list = utils._if(blankline and #char_list_blankline > 0, char_list_blankline, char_list)
local context_indent_char_list = utils._if( local context_indent_char_list = utils._if(
blankline and #context_char_list_blankline > 0, blankline and #context_char_list_blankline > 0,
@ -432,7 +405,11 @@ local refresh = function(scroll)
utils._if( utils._if(
blankline, blankline,
utils.get_from_list(space_char_blankline_highlight_list, i, space_char_blankline_highlight), utils.get_from_list(space_char_blankline_highlight_list, i, space_char_blankline_highlight),
utils.get_from_list(space_char_highlight_list, i, space_char_highlight) utils.get_from_list(
space_char_highlight_list,
i,
utils._if(context, context_space_char_highlight, space_char_highlight)
)
), ),
}) })
end end
@ -503,6 +480,12 @@ local refresh = function(scroll)
and show_current_context_start and show_current_context_start
and (show_current_context_start_on_current_line or lnum ~= context_start) and (show_current_context_start_on_current_line or lnum ~= context_start)
then then
if
not vim.api.nvim_buf_is_loaded(bufnr)
or not vim.api.nvim_buf_get_var(bufnr, "__indent_blankline_active")
then
return
end
xpcall( xpcall(
vim.api.nvim_buf_set_extmark, vim.api.nvim_buf_set_extmark,
utils.error_handler, utils.error_handler,
@ -513,7 +496,7 @@ local refresh = function(scroll)
{ {
end_col = #lines[i], end_col = #lines[i],
hl_group = "IndentBlanklineContextStart", hl_group = "IndentBlanklineContextStart",
priority = 10000, priority = context_start_priority,
} }
) )
end end
@ -536,6 +519,12 @@ local refresh = function(scroll)
max_indent_level, max_indent_level,
{} {}
) )
if
not vim.api.nvim_buf_is_loaded(bufnr)
or not vim.api.nvim_buf_get_var(bufnr, "__indent_blankline_active")
then
return
end
xpcall( xpcall(
vim.api.nvim_buf_set_extmark, vim.api.nvim_buf_set_extmark,
utils.error_handler, utils.error_handler,
@ -543,7 +532,12 @@ local refresh = function(scroll)
vim.g.indent_blankline_namespace, vim.g.indent_blankline_namespace,
i - 1 + offset, i - 1 + offset,
0, 0,
{ virt_text = virtual_text, virt_text_pos = "overlay", hl_mode = "combine", priority = 1 } {
virt_text = virtual_text,
virt_text_pos = "overlay",
hl_mode = "combine",
priority = char_priority,
}
) )
end)() end)()
return async:close() return async:close()
@ -552,13 +546,8 @@ local refresh = function(scroll)
local indent, extra local indent, extra
local virtual_string = {} local virtual_string = {}
if not blankline then if not blankline then
indent, extra, virtual_string = utils.find_indent( indent, extra, virtual_string =
whitespace, utils.find_indent(whitespace, only_whitespace, shiftwidth, strict_tabs, list_chars)
only_whitespace,
shiftwidth,
strict_tabs,
list_chars
)
elseif empty_line_counter > 0 then elseif empty_line_counter > 0 then
empty_line_counter = empty_line_counter - 1 empty_line_counter = empty_line_counter - 1
indent = next_indent indent = next_indent
@ -575,13 +564,8 @@ local refresh = function(scroll)
end end
local j_whitespace = string.match(lines[j], "^%s+") local j_whitespace = string.match(lines[j], "^%s+")
local j_only_whitespace = j_whitespace == lines[j] local j_only_whitespace = j_whitespace == lines[j]
indent, extra, _ = utils.find_indent( indent, extra, _ =
j_whitespace, utils.find_indent(j_whitespace, j_only_whitespace, shiftwidth, strict_tabs, list_chars)
j_only_whitespace,
shiftwidth,
strict_tabs,
list_chars
)
end end
next_indent = indent next_indent = indent
next_extra = extra next_extra = extra
@ -598,6 +582,12 @@ local refresh = function(scroll)
and (show_current_context_start_on_current_line or lnum ~= context_start) and (show_current_context_start_on_current_line or lnum ~= context_start)
then then
vim.schedule_wrap(function() vim.schedule_wrap(function()
if
not vim.api.nvim_buf_is_loaded(bufnr)
or not vim.api.nvim_buf_get_var(bufnr, "__indent_blankline_active")
then
return
end
xpcall( xpcall(
vim.api.nvim_buf_set_extmark, vim.api.nvim_buf_set_extmark,
utils.error_handler, utils.error_handler,
@ -608,7 +598,7 @@ local refresh = function(scroll)
{ {
end_col = #lines[i], end_col = #lines[i],
hl_group = "IndentBlanklineContextStart", hl_group = "IndentBlanklineContextStart",
priority = 10000, priority = context_start_priority,
} }
) )
end)() end)()
@ -633,6 +623,12 @@ local refresh = function(scroll)
virtual_string virtual_string
) )
vim.schedule_wrap(function() vim.schedule_wrap(function()
if
not vim.api.nvim_buf_is_loaded(bufnr)
or not vim.api.nvim_buf_get_var(bufnr, "__indent_blankline_active")
then
return
end
xpcall( xpcall(
vim.api.nvim_buf_set_extmark, vim.api.nvim_buf_set_extmark,
utils.error_handler, utils.error_handler,
@ -640,7 +636,12 @@ local refresh = function(scroll)
vim.g.indent_blankline_namespace, vim.g.indent_blankline_namespace,
i - 1 + offset, i - 1 + offset,
0, 0,
{ virt_text = virtual_text, virt_text_pos = "overlay", hl_mode = "combine", priority = 1 } {
virt_text = virtual_text,
virt_text_pos = "overlay",
hl_mode = "combine",
priority = char_priority,
}
) )
end)() end)()
return async:close() return async:close()

View File

@ -38,12 +38,16 @@ M.memo = setmetatable({
end, end,
}) })
M.error_handler = function(err) M.error_handler = function(err, level)
if vim.g.indent_blankline_debug then if err:match "Invalid buffer id.*" then
vim.cmd "echohl Error" return
vim.cmd('echomsg "' .. err .. '"')
vim.cmd "echohl None"
end end
if not pcall(require, "notify") then
err = string.format("indent-blankline: %s", err)
end
vim.notify_once(err, level or vim.log.levels.DEBUG, {
title = "indent-blankline",
})
end end
M.is_indent_blankline_enabled = M.memo( M.is_indent_blankline_enabled = M.memo(
@ -182,10 +186,29 @@ M.find_indent = function(whitespace, only_whitespace, shiftwidth, strict_tabs, l
return indent + math.floor(spaces / shiftwidth), table.maxn(virtual_string) % shiftwidth ~= 0, virtual_string return indent + math.floor(spaces / shiftwidth), table.maxn(virtual_string) % shiftwidth ~= 0, virtual_string
end end
M.get_current_context = function(type_patterns) M.get_current_context = function(type_patterns, use_treesitter_scope)
local ts_utils = require "nvim-treesitter.ts_utils" local ts_utils_status, ts_utils = pcall(require, "nvim-treesitter.ts_utils")
if not ts_utils_status then
vim.schedule_wrap(function()
M.error_handler("nvim-treesitter not found. Context will not work", vim.log.levels.WARN)
end)()
return false
end
local locals = require "nvim-treesitter.locals"
local cursor_node = ts_utils.get_node_at_cursor() local cursor_node = ts_utils.get_node_at_cursor()
if use_treesitter_scope then
local current_scope = locals.containing_scope(cursor_node, 0)
if not current_scope then
return false
end
local node_start, _, node_end, _ = current_scope:range()
if node_start == node_end then
return false
end
return true, node_start + 1, node_end + 1, current_scope:type()
end
while cursor_node do while cursor_node do
local node_type = cursor_node:type() local node_type = cursor_node:type()
for _, rgx in ipairs(type_patterns) do for _, rgx in ipairs(type_patterns) do

View File

@ -32,7 +32,7 @@ lua require("indent_blankline").init()
augroup IndentBlanklineAutogroup augroup IndentBlanklineAutogroup
autocmd! autocmd!
autocmd OptionSet list,shiftwidth,tabstop,expandtab IndentBlanklineRefresh autocmd OptionSet list,listchars,shiftwidth,tabstop,expandtab IndentBlanklineRefresh
autocmd FileChangedShellPost,TextChanged,TextChangedI,CompleteChanged,BufWinEnter,Filetype * IndentBlanklineRefresh autocmd FileChangedShellPost,TextChanged,TextChangedI,CompleteChanged,BufWinEnter,Filetype * IndentBlanklineRefresh
autocmd WinScrolled * IndentBlanklineRefreshScroll autocmd WinScrolled * IndentBlanklineRefreshScroll
autocmd ColorScheme * lua require("indent_blankline.utils").reset_highlights() autocmd ColorScheme * lua require("indent_blankline.utils").reset_highlights()

8
bundle/plugins.toml vendored
View File

@ -16,3 +16,11 @@
username = 'rakr' username = 'rakr'
repo = 'vim-one' repo = 'vim-one'
commit = '187f5c85b682c1933f8780d4d419c55d26a82e24' commit = '187f5c85b682c1933f8780d4d419c55d26a82e24'
[[repos]]
# https://github.com/lukas-reineke/indent-blankline.nvim/tree/7075d7861f7a6bbf0de0298c83f8a13195e6ec01
url = 'https://github.com/'
directory = 'indent-blankline.nvim'
username = 'lukas-reineke'
repo = 'indent-blankline.nvim'
commit = '7075d7861f7a6bbf0de0298c83f8a13195e6ec01'