Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v3: Context different between v2 and v3 #632

Closed
kristijanhusak opened this issue Sep 22, 2023 · 6 comments
Closed

v3: Context different between v2 and v3 #632

kristijanhusak opened this issue Sep 22, 2023 · 6 comments

Comments

@kristijanhusak
Copy link

Hey!

I'm giving v3 a test, and I noticed that context is working differently between the old (v2) and new (v3) versions.
Old version:
old-version

New version:
new-version

I saw this in the help:

 The scope is *not* the current indentation level! Instead, it is the
 indentation level where variables or functions are accessible. This depends
 on the language you are writing.

And I'm assuming this is by design.
Is there a way to get the old behavior with the new version? I couldn't find anything in the config besides exclude that does the opposite.

@lukas-reineke
Copy link
Owner

Yeah, it's by design, and there isn't a way to get the old behavior. The way this worked by default in v2 wasn't great. And it only worked for some languages.
I also think the new behavior is much more useful.

I could add a hook for the scope, but there is quite a bit of complex logic for getting it right. I'm a bit afraid people will use it wrong. 🤔

@lukas-reineke
Copy link
Owner

You could monkey patch :lua =require("ibl.scope_languages") to add any scope you want, but that would be a massive amount of maintenance you need to do for all the languages.
Maybe it's fine if you use only a couple languages.

Maybe I can add an include for scope for that.
Still would be a lot of work for the end user, so not sure how useful that would be.

@kristijanhusak
Copy link
Author

include scope that works similarly to exclude would be perfectly fine. I'm aware it can be maintenance heavy, but since I work with only a few languages on a daily basis, I think I'll be able to manage those.

I have this from a very old version of indent blankline :)

vim.g.indent_blankline_context_patterns = {'class', 'function', 'method', '^if', '^while', '^for', '^object', '^table', 'block', 'arguments'}

@lukas-reineke
Copy link
Owner

I'm fine with that. Adding include doesn't hurt. 👍
I've implemented it already, but I also added some changes today that crash Neovim on nightly without a fix from ~5 hours ago, so I won't push it until some time tomorrow, I think.

lukas-reineke added a commit that referenced this issue Sep 23, 2023
@lukas-reineke
Copy link
Owner

pushed now

@kristijanhusak
Copy link
Author

Works like a charm!
In case anyone needs it, here's what I set for lua and typescript for now:

{
          node_type = {
            lua = {
              'chunk',
              'do_statement',
              'while_statement',
              'repeat_statement',
              'if_statement',
              'for_statement',
              'function_declaration',
              'function_definition',
              'table_constructor',
              'assignment_statement',
            },
            typescript = {
              'statement_block',
              'function',
              'arrow_function',
              'function_declaration',
              'method_definition',
              'for_statement',
              'for_in_statement',
              'catch_clause',
              'object_pattern',
              'arguments',
              'switch_case',
              'switch_statement',
              'switch_default',
              'object',
              'object_type',
              'ternary_expression',
            },
          },
        }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants