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

Auto-indent/format with = doesn't work with some code blocks #1100

Closed
2 tasks done
leongjs98 opened this issue Sep 28, 2023 · 3 comments
Closed
2 tasks done

Auto-indent/format with = doesn't work with some code blocks #1100

leongjs98 opened this issue Sep 28, 2023 · 3 comments
Labels
bug Issues related to bugs. Please attach a severity, a priority and category with this label.

Comments

@leongjs98
Copy link
Contributor

leongjs98 commented Sep 28, 2023

mentioned by @pysan3 in this issue

Prerequisites

  • I am using the latest stable release of Neovim
  • I am using the latest version of the plugin

Neovim Version

v0.9.2

Neorg setup

require('neorg').setup {
  load = {
    ["core.defaults"] = {},
    ["core.concealer"] = {
      config = {
        icon_preset = "diamond"
      }
    },
    ["core.completion"] = {
      config = {
        engine = "nvim-cmp"
      }
    },
    ["core.summary"] = {},
    ["core.presenter"] = {
      config = {
        zen_mode = "zen-mode"
      }
    },
    ["core.dirman"] = {
      config = {
        workspaces = {
          main = "~/Documents/notes",
          personal = "~/Documents/notes/personal",
          work = "~/Documents/notes/work",
        },
        default_workspace = "work"
      },
    },
    ["core.journal"] = {
      config = {
        workspace = "personal"
      }
    },
    ["core.keybinds"] = {
      config = {
        hook = function(keybinds)
          keybinds.remap_event("norg", "n", "<LocalLeader>t ", "core.qol.todo_items.todo.task_cycle")
        end,
      }
    }
  },
}

Actual behavior

@code bash
#!/bin/bash

for number in {1..5}; do
    echo "Number: $number"
done
@end

Expected behavior

@code bash
#!/bin/bash

for number in {1..5}; do
echo "Number: $number"
done
@end

Steps to reproduce

Indent the bash code blocks with =

Potentially conflicting plugins

No response

Other information

Tested some other languages and these are the result

code auto-indent result
Bash not working
Go working
JavaScript working
Lua working
Norg not working

I have lsp installed for all of them

Help

Yes, but I don't know how to start. I would need guidance (check question below)

Implementation help

I am not familiar with lua or neovim ecosystem. So, it will take some time to learn it. I may also need someone to guide me when I am hard stuck.

But I am a keen learner and I am passionate about neorg and neovim. So, I can probably solve it, and if I get stuck, I will ask for help in the discord.

@leongjs98 leongjs98 added the bug Issues related to bugs. Please attach a severity, a priority and category with this label. label Sep 28, 2023
@github-project-automation github-project-automation bot moved this to added-updated-reopened in sorting neorg issue tracker Sep 28, 2023
@max397574
Copy link
Contributor

max397574 commented Sep 29, 2023

I think we just try to use treesitter indentation (or that's what used automatically when you have injections) inside code blocks.
So you should install the bash parser and I think for norg we just have to write better indent queries.
@vhyrro should know more about this though

@vhyrro
Copy link
Member

vhyrro commented Oct 6, 2023

Languages that use the off-side rule tend to break because they rely on indentation levels moreso than free-form languages like JS or lua or whatever. This is a core limitation of the current treesitter injection engine that simply can't be fixed from our end, sorry :/

Closing the issue as wontfix for the time being. If there ever is a solution I'll be sure to implement it :)

@vhyrro vhyrro closed this as not planned Won't fix, can't repro, duplicate, stale Oct 6, 2023
@github-project-automation github-project-automation bot moved this from added-updated-reopened to done in sorting neorg issue tracker Oct 6, 2023
@austinbutler
Copy link
Contributor

austinbutler commented Jan 12, 2024

Is there a way to exclude a code block from being reformatted?

It's not so bad that it won't automatically format it correctly, but the indentation getting wrecked every time you format the Neorg file makes it to where adding code snippets for these languages is just about untenable. Or even better excluding entire languages via config.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issues related to bugs. Please attach a severity, a priority and category with this label.
Projects
None yet
Development

No branches or pull requests

4 participants