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

bug: Indent could not be customized #389

Closed
4 tasks done
hrdm opened this issue Dec 25, 2024 · 5 comments
Closed
4 tasks done

bug: Indent could not be customized #389

hrdm opened this issue Dec 25, 2024 · 5 comments
Labels
bug Something isn't working

Comments

@hrdm
Copy link

hrdm commented Dec 25, 2024

Did you check docs and existing issues?

  • I have read all the snacks.nvim docs
  • I have updated the plugin to the latest version before submitting this issue
  • I have searched the existing issues of snacks.nvim
  • I have searched the existing issues of plugins related to this issue

Neovim version (nvim -v)

0.10.3

Operating system/version

MacOS Sequoia Versionar 15.2

Describe the bug

Hello folke,
I've noticed that it's not possible to customize Snack.indent at the moment, for instance, if the char option of indent (scope, chunk, or other) is changed in the custom user files, this change doesn't have any effects.
This issue does not only affect the char option, but also other options.

In the next screenshot the char options is changed to another character, then the config is reloaded, and another nvim session is open one more time, but the change is not visible:
issue

So, I've checked the snacks code in snacks.nvim/lua/snacks/indent.lua that (for example) for indent, the code just test the enable option, and then the default configuration is loaded.
issue2

I think, this is a minor issue, But I still tried to communicate it.
Thank for your time

Steps To Reproduce

  1. In the `nvim/lua/plugins/ui.lua', I've tried to customize the snacks indent options:
{
  "folke/snacks.nvim",
  ---@type snacks.Config
  opts = {
    ---@class smacks.indent.Config
    ---@field enabled? boolean
    indent = {
      enabled = true,
      char = "",
    },
    scope = {
      enabled = true,
      underline = true,
      char = "",
    },
  },
}
  1. Then, I reloaded the configuration and open another nvim session.
  2. The changes do not have any effects.
    issue

Expected Behavior

  • The expected behavior is that the custom changes are visible.
  • I've done some direct changes in ~/.local/share/nvim/lazy/snacks.nvim/lua/snacks/indent.lua with success:
local defaults = {
  indent = {
    priority = 1,
    enabled = true, -- enable indent guides
    char = "", -- **Here**
    ...
  scope = {
    enabled = true, -- enable highlighting the current scope
    priority = 200,
    char = "", -- **Here**
    underline = true, -- **Here**
  ...
}

Repro

vim.env.LAZY_STDPATH = ".repro"
load(vim.fn.system("curl -s https://raw.githubusercontent.com/folke/lazy.nvim/main/bootstrap.lua"))()

require("lazy.minit").repro({
  spec = {
    { "folke/snacks.nvim", opts = {} },
    -- add any other plugins here
  },
})
@hrdm hrdm added the bug Something isn't working label Dec 25, 2024
@dpetka2001
Copy link
Contributor

You're using wrong syntax. It should be

opts = {
  indent = {
    indent = { -- whatever you want },
    scope = { -- whatever you want },
  },
}

@hrdm
Copy link
Author

hrdm commented Dec 25, 2024

Hey @dpetka2001, thanks a lot, it works!

@hrdm
Copy link
Author

hrdm commented Dec 25, 2024

BTW, is it possible to exclude some files (for example markdown) from indenting ?

@dpetka2001
Copy link
Contributor

dpetka2001 commented Dec 25, 2024

See the config docs. Right at the bottom there'a a filter property that you can use to block out filetypes. You could add vim.bo[buf].filetype ~= "markdown"

@hrdm
Copy link
Author

hrdm commented Dec 26, 2024

Hi @dpetka2001, you’re amazing! Thanks so much for your help! The snacks indent is finally working perfectly here! 😉

      indent = {
        indent = {
          enabled = true,
          char = "",
        },
        scope = {
          enabled = true,
          underline = true,
          char = "",
        },
        filter = function(buf)
          local b = vim.b[buf]
          local bo = vim.bo[buf]
          local excluded_filetypes = {
            markdown = true,
            text = true,
          }
          return vim.g.snacks_indent ~= false
            and b.snacks_indent ~= false
            and bo.buftype == ""
            and not excluded_filetypes[bo.filetype]
        end,
      },

@hrdm hrdm closed this as completed Dec 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants