Skip to content

Commit

Permalink
feat: add scope include wildcard
Browse files Browse the repository at this point in the history
  • Loading branch information
lukas-reineke committed Sep 29, 2023
1 parent f5335ef commit 8fe91f4
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,18 @@ require("ibl").setup()

### Scope

Scope requires treesitter to be setup.
Scope requires treesitter to be set up.

```lua
require("ibl").setup()
```

<img width="900" src="https://github.com/lukas-reineke/indent-blankline.nvim/assets/12900252/a9d2426f-56a4-44bd-8bb5-2a3c5f5ca384" alt="Screenshot" />

The scope is _not_ the current indentation level! Instead, it is the
indentation level where variables or functions are accessible, as in [Wikipedia Scope (Computer Science)](<https://en.wikipedia.org/wiki/Scope_(computer_science)>). This depends
on the language you are writing. For more information, see `:help ibl.config.scope`.

The start and end of scope 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)
Expand Down
9 changes: 8 additions & 1 deletion doc/indent_blankline.txt
Original file line number Diff line number Diff line change
Expand Up @@ -451,15 +451,22 @@ config.scope.include *ibl.config.scope.include*
map of language to a list of node types which can be
used as scope

Use `*` as a wildcard for all languages
Use `*` as a wildcard as the key for all languages
Use `*` as a wildcard as a type for all types

Default: empty ~

Example: ~
>lua
-- Add some node types to lua
{
node_type = { lua = { "return_statement", "table_constructor" } },
}
-- Make every node type valid. Note that this can lead to some weird
-- behavior
{
node_type = { ["*"] = { "*" } },
}


config.scope.exclude *ibl.config.scope.exclude*
Expand Down
1 change: 1 addition & 0 deletions lua/ibl/scope.lua
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ M.get = function(bufnr, config)
if
(scope_lang[lang][type] and not vim.tbl_contains(excluded_node_types, type))
or vim.tbl_contains(include_node_types, type)
or vim.tbl_contains(include_node_types, "*")
then
return node
else
Expand Down

0 comments on commit 8fe91f4

Please sign in to comment.