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

feature: Add condition option in statuscolumn. #288

Closed
1 task done
spencer-thompson opened this issue Dec 14, 2024 · 3 comments · Fixed by #285
Closed
1 task done

feature: Add condition option in statuscolumn. #288

spencer-thompson opened this issue Dec 14, 2024 · 3 comments · Fixed by #285
Labels
enhancement New feature or request

Comments

@spencer-thompson
Copy link

Did you check the docs?

  • I have read all the snacks.nvim docs

Is your feature request related to a problem? Please describe.

No, just want to have some added functionality

Describe the solution you'd like

statuscol has a feature where an optional cond is passed to each section of the statuscolumn. Additionally, if possible, it would be nice to configure the amount of extra space between the signs and the normal contents of the buffer (between line numbers and buffer content)

Describe alternatives you've considered

A padding value could help.

Additional context

A big motivation for this change is to integrate nicely with neominimap.nvim. This is an awesome plugin, that uses that condition to make the mini map have a more compact look.

Thanks for the awesome plugin. You are the man.

@spencer-thompson spencer-thompson added the enhancement New feature or request label Dec 14, 2024
@folke
Copy link
Owner

folke commented Dec 14, 2024

Can you be more explicit on what you want here?
There's is no real padding. Numbers are full width. And there will be reserved space for git signs if you have those enabled.
So a padding param doesn't really make sense.

@spencer-thompson
Copy link
Author

Of course, I think I don't have a huge understanding of how the plugin works. I just finished finals so I will have more time to explore. But what I mean, more specifically, is having a condition parameter to render signs, or the column itself.

Here is exactly why that is useful, from the neominimap.nvim wiki:

local function is_neominimap(arg)
    return vim.bo[arg.buf].filetype == "neominimap"
end

local function is_not_neominimap(arg)
    return not is_neominimap(arg)
end

return {
    "luukvbaal/statuscol.nvim",
    opts = function()
        local builtin = require("statuscol.builtin")
        return {
            setopt = true,
            relculright = true,
            segments = {
              -- These segments will be shown for normal buffers
              {
                  sign = {
                      namespace = { ".*" },
                      name = { ".*" },
                  },
                  condition = { is_not_neominimap },
              },
              {
                  text = {
                      builtin.lnumfunc,
                      " ",
                      builtin.foldfunc,
                  },
                  condition = { is_not_neominimap },
              },
              {
                  sign = {
                      namespace = { "gitsigns_" },
                  },
                  condition = { is_not_neominimap },
              },

              -- These segments will be shown for minimap buffers
              {
                  sign = {
                      namespace = { "neominimap_search" },
                      maxwidth = 1,
                      colwidth = 1, -- For more compact look
                  },
                  condition = { is_neominimap },
              },
              {
                  sign = {
                      namespace = { "neominimap_git" },
                      maxwidth = 1,
                      colwidth = 1,
                  },
                  condition = { is_neominimap },
              },
            },
        }
    end,
}

From my understanding, neominimap.nvim essentially duplicates the window but with braille to show a "mini map". So the code above allows neominimap to be more compact.

All in all this is probably not an important change, although it would allow me move from statuscol completely over to Snacks.

As far as the "padding", It would be nice if the statuscolumn had one less column, but after looking through the other issues, I can't be confident in ruling out that there isn't another plugin that is messing with the statuscolumn. I will be looking into that when I have time this week.

@folke folke closed this as completed in cb42b95 Dec 15, 2024
@folke
Copy link
Owner

folke commented Dec 15, 2024

Just added something where you can now have left/right be a function:

      statuscolumn = {
        left = function(win, buf)
          local is_neominimap = vim.bo[buf].filetype == "neominimap"
          return is_neominimap and { "mark" } or { "mark", "sign" }
        end,
        right = function(win, buf)
          local is_neominimap = vim.bo[buf].filetype == "neominimap"
          return is_neominimap and { "fold" } or { "fold", "git" }
        end,
      },

folke pushed a commit that referenced this issue Dec 15, 2024
🤖 I have created a release *beep* *boop*
---


##
[2.11.0](v2.10.0...v2.11.0)
(2024-12-15)


### Features

* **indent:** properly handle continuation indents. Closes
[#286](#286)
([f2bb7fa](f2bb7fa))
* **input:** allow configuring position of prompt and icon
([d0cb707](d0cb707))
* **notifier:** notification `history` option
([#297](#297))
([8f56e19](8f56e19))
* **scope:** `Scope:inner` for indent based and treesitter scopes
([8a8b1c9](8a8b1c9))
* **scope:** added `__tostring` for debugging
([94e0849](94e0849))
* **scope:** added `opts.cursor` to take cursor column into account for
scope detection. (defaults to true). Closes
[#282](#282)
([54bc6ba](54bc6ba))
* **scope:** text objects now use treesitter scopes by default. See
[#231](#231)
([a953697](a953697))
* **statuscolumn:** allow left/right to be a function. Closes
[#288](#288)
([cb42b95](cb42b95))
* **util:** on_key handler
([002d5eb](002d5eb))
* **win:** win:line()
([17494ad](17494ad))


### Bug Fixes

* **dashboard:** telescope can't be run from a `vim.schedule` for some
reason
([dcc5338](dcc5338))
* **indent:** `opts.indent.blank` now defaults to `listchars.space`.
Closes [#291](#291)
([31bc409](31bc409))
* **indent:** fixup
([14d71c3](14d71c3))
* **indent:** honor lead listchar
([#303](#303))
([7db0cc9](7db0cc9))
* **indent:** honor listchars and list when blank is `nil`. Closes
[#296](#296)
([0e150f5](0e150f5))
* **indent:** lower priorities of indent guides
([7f66818](7f66818))
* **input:** check if parent win still exists. Fixes
[#287](#287)
([db768a5](db768a5))
* **input:** go back to insert mode if input was started from insert
mode. Fixes [#287](#287)
([5d00e6d](5d00e6d))
* **input:** missing padding if neither title nor icon positioned left
([#292](#292))
([97542a7](97542a7))
* **input:** open input window with `noautocmd=true` set. Fixes
[#287](#287)
([26b7d4c](26b7d4c))
* **scope:** add `indent` to `__eq`
([be2779e](be2779e))
* **scope:** better treesitter scope edge detection
([b7355c1](b7355c1))
* **scroll:** check mousescroll before spamming
([3d67bda](3d67bda))
* **util:** on_key compat with Neovim 0.9
([effa885](effa885))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants