luukvbaal / statuscol.nvim

Status column plugin that provides a configurable 'statuscolumn' and click handlers.
MIT License
519 stars 23 forks source link

getting rid of folding level numbers in status column #3

Closed rockneverdies55 closed 1 year ago

rockneverdies55 commented 1 year ago

Just installed the plugin. It's awesome to be able to toggle my breakpoints just like in IDEs. Thanks for the hard work.

By any chance, does this plugin provide any remedy for hiding those numbers in the status column ?

nvim_folding_level_numbers

luukvbaal commented 1 year ago

Not yet, I'll look into including an option for it.

luukvbaal commented 1 year ago

Added in latest commit. For now it just replaces the digits with the foldsep char. We could also consider using different colors for the foldsep char depending on the fold depth, or a different foldsep char ()?

p00f commented 1 year ago

Am I doing this right? require("statuscol").setup({foldfunc = "builtin"})

I still have numbers

rockneverdies55 commented 1 year ago

@p00f here's what works for me:

require("statuscol").setup({
  foldfunc = "builtin",
  setopt = true,
})
p00f commented 1 year ago

That works, thanks

Aneeqasif commented 1 year ago

for some reason i dont know why i cannot hide the number by using this config

luukvbaal commented 1 year ago

for some reason i dont know why i cannot hide the number by using this config

You now need to specify a builtin.foldfunc segment like so: https://github.com/luukvbaal/statuscol.nvim/issues/9#issuecomment-1471982148 @Aneeqasif.

Aneeqasif commented 1 year ago

for some reason i dont know why i cannot hide the number by using this config

You now need to specify a builtin.foldfunc segment like so: #9 (comment) @Aneeqasif.

local builtin = require("statuscol.builtin")
require("statuscol").setup({
  foldfunc = "builtin",
  setopt = true,
  relculright = true,
  segments = {
    {
      sign = { name = { "Diagnostic" }, maxwidth = 2, auto = true },
      click = "v:lua.ScSa"
    },
    { text = { builtin.lnumfunc }, click = "v:lua.ScLa", },
    { text = { builtin.foldfunc }, click = "v:lua.ScFa" },
    {
      sign = { name = { ".*" }, maxwidth = 1, colwidth = 1, auto = true },
      click = "v:lua.ScSa"
    },
  }
})

this is my config please have a look , i cant get it work to hide the numbers in folding levels. any suggestion?

luukvbaal commented 1 year ago

Does the plugin work at all for you? Did you update to the latest version? What does :set stc? say? (you should remove foldfunc = "builtin (no longer exists) and setopt = true is default now.

Aneeqasif commented 1 year ago

What does :set stc? say?

Unknown option but it is listed in loaded plugins in lazy

sorry for confusion ig iam on nvim 0.8 so this plugin is not working

luukvbaal commented 1 year ago

You need a newer version of neovim, build from source or download the latest nightly.

Aneeqasif commented 1 year ago

You need a newer version of neovim, build from source or download the latest nightly.

yeah i did this ant this works but there is on e issue

image

that the coloumn of lsp symbols and the coloumn of the folds are too wide they are taking more width then wanted,

local builtin = require("statuscol.builtin")
cfg={
  setopt = true,
  relculright = true,
  segments = {
    { text = { "%s" }, click = "v:lua.scsa",  },
    {
      text = { " ", builtin.foldfunc, " " },
      condition = { builtin.not_empty, true, builtin.not_empty },
      click = "v:lua.scfa"
    },
    { text = { builtin.lnumfunc }, click = "v:lua.scla", },
  }
}

require("statuscol").setup(cfg)

all i want is something like below , just folde numbers removed Screenshot_20230329_064239

luukvbaal commented 1 year ago

Remove the whitespace segments " "...

Aneeqasif commented 1 year ago

Remove the whitespace segments " "...

last thing if i want to change the highlight/color of the fold unfold symbol line the same as comments color what should i do

local builtin = require("statuscol.builtin")
cfg={
  setopt = true,
  relculright = true,
  segments = {

    { text = { builtin.foldfunc, " " }, 
      click = "v:lua.ScFa",
      hl = "Comment",
    },

    { text = { "%s"}, click = "v:lua.ScSa" },
    { text = { builtin.lnumfunc, " " }, click = "v:lua.ScLa", },

  }}

require("statuscol").setup(cfg)

is not working

nvim-ufo might be setting it idk

vim.o.foldcolumn = '1' -- '0' is not bad
vim.o.foldlevel = 99 -- Using ufo provider need a large value, feel free to decrease the value
vim.o.foldlevelstart = 99
vim.o.foldenable = true
vim.o.fillchars = [[eob: ,fold: ,foldopen:,foldsep:│,foldclose:]]

local ftMap = {
    vim = 'indent',
    python = {'indent'},
    git = ''
}

local filetypes = { nvdash = '' }

require('ufo').setup({
    open_fold_hl_timeout = 150,
    close_fold_kinds = {'imports', 'comment'},
    preview = {
        win_config = {
            border = {'', '─', '', '', '', '─', '', ''},
            -- winhighlight = 'Normal:Normal',
            -- winhighlight = 'IncSearch:Folded',
            winhighlight = 'Normal:UfoPreviewNormal,FloatBorder:UfoPreviewBorder,CursorLine:UfoPreviewCursorLine',
            winblend = 0
        },
        mappings = {
            scrollU = '<C-u>',
            scrollD = '<C-d>',
            jumpTop = '[',
            jumpBot = ']'
        }
    },

    provider_selector = function(_, ft)
        return filetypes[ft] or { 'treesitter', 'indent' }
      end
})
vim.keymap.set('n', 'zR', require('ufo').openAllFolds)
vim.keymap.set('n', 'zM', require('ufo').closeAllFolds)
vim.keymap.set('n', 'zr', require('ufo').openFoldsExceptKinds)
vim.keymap.set('n', 'zm', require('ufo').closeFoldsWith) -- closeAllFolds == closeFoldsWith(0)
vim.keymap.set('n', '<leader>op', function()
    local winid = require('ufo').peekFoldedLinesUnderCursor()
    if not winid then
        -- choose one of coc.nvim and nvim lsp
        vim.fn.CocActionAsync('definitionHover') -- coc.nvim
        vim.lsp.buf.hover()
    end
end)

local handler = function(virtText, lnum, endLnum, width, truncate)
    local newVirtText = {}
    local suffix = ('  %d '):format(endLnum - lnum)
    local sufWidth = vim.fn.strdisplaywidth(suffix)
    local targetWidth = width - sufWidth
    local curWidth = 0
    for _, chunk in ipairs(virtText) do
        local chunkText = chunk[1]
        local chunkWidth = vim.fn.strdisplaywidth(chunkText)
        if targetWidth > curWidth + chunkWidth then
            table.insert(newVirtText, chunk)
        else
            chunkText = truncate(chunkText, targetWidth - curWidth)
            local hlGroup = chunk[2]
            table.insert(newVirtText, {chunkText, hlGroup})
            chunkWidth = vim.fn.strdisplaywidth(chunkText)
            -- str width returned from truncate() may less than 2nd argument, need padding
            if curWidth + chunkWidth < targetWidth then
                suffix = suffix .. (' '):rep(targetWidth - curWidth - chunkWidth)
            end
            break
        end
        curWidth = curWidth + chunkWidth
    end
    table.insert(newVirtText, {suffix, 'MoreMsg'})
    return newVirtText
end

require('ufo').setup({
    fold_virt_text_handler = handler
})
Aneeqasif commented 1 year ago

go the answer (chatgpt guru)

vim.cmd("highlight FoldColumn guifg=" .. vim.fn.synIDattr(vim.fn.synIDtrans(vim.fn.hlID('Comment')), 'fg'))