-
Notifications
You must be signed in to change notification settings - Fork 15
Common Pitfalls
If you are having issues getting indent-bars working, you may have encountered one of the issues described below.
If you have (setq indent-bars-treesit-support t)
, there are additional
steps you need to take to get treesitter working with indent-bars. This option
enables integration with treesitter, but unless treesitter is configured
correctly, it won't provide indent-bars with any additional context.
Additionally, this article describes treesitter in detail for those who need/want to delve deep into its inner workings.
As mentioned in the README, Treesitter requires a language grammar to be
installed for each language mode. Use M-x treesit-install-language-grammar
and follow the instructions to complete this step.
Many languages have a language grammar available from the community on Github. A small collection has been curated below for convenience.
By default, Treesitter doesn't create parsers automatically in non-*-ts
modes, even after
the language grammar has been installed. When a treesitter parser is not
running, setting indent-bars-treesit-support
will then seem to have no effect.
This can be fixed by adding a hook for your language mode. For example:
(add-hook 'c-mode-common-hook (lambda () (treesit-parser-create 'c)))
Make sure that any mode-specific indentation configuration is initialized
before calling (indent-bars-mode)
. If you configure indent widths in a mode
hook, those configurations may take effect after indent-bars is started. When
this happens, indent-bars may use the language mode's default indentation
values. One way to ensure this is to use a large depth
in the call to add-hook
. Another is to configure indentation for a mode in the :custom
section of a use-package
stanza.