Skip to content

Commit

Permalink
chore: add ibl.config.scope example to the docs
Browse files Browse the repository at this point in the history
  • Loading branch information
lukas-reineke committed Sep 28, 2023
1 parent 4872a53 commit f5335ef
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions doc/indent_blankline.txt
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,31 @@ config.scope *ibl.config.scope*
indentation level where variables or functions are accessible. This depends
on the language you are writing.

Example: ~

In Python, an `if` block is not a new scope, variables defined inside `if`
are accessible outside. The scope is the function `foo`.
(please don't actually write code like this)
>python
def foo();
┋ if True:
┋ a = "foo █ar"
┋ # ↳ cursor here
┋ print(a)
<
In Rust on the other hand, `if` blocks are a new scope. Variables defined
inside are not accesible outside. Indent-blanklines scope reflects this, and
the scope is just the `if` block.
(this code would not compile)
>rust
fn foo() {
if true {
┋ let a = "foo █ar";
┋ // ↳ cursor here
}
print(a);
}
<
Note: Scope requires treesitter to be set up ~

Fields: ~
Expand Down

0 comments on commit f5335ef

Please sign in to comment.