Code Monkey home page Code Monkey logo

nvim-cokeline's Introduction

Stats

Top Langs

Neovim Rust Lua C TypeScript

nvim-cokeline's People

Contributors

alex-popov-tech avatar bendk avatar crivotz avatar danielnieto avatar equilibris avatar etiamnullam avatar ewok avatar folliehiyuki avatar gitgitchinchin avatar kadobot avatar lucassperez avatar matt-riley avatar miversen33 avatar neelfrost avatar nenikitov avatar noib3 avatar olimorris avatar plax-00 avatar prospectpyxis avatar sashalikesplanes avatar soifou avatar tamirzb avatar tris203 avatar utsavbalar1231 avatar webblitchy avatar willothy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

nvim-cokeline's Issues

Broken on neovim nighly

Hi,

This extension seems broken on neovim nightly... When activating it I got this:

packer.nvim: Error running config for nvim-cokeline: ...ack/packer/start/nvim-cokeline/lua/cokeline/defaults.lua:85: bad argument #1 to 'pairs' (table expected, got nil)

I'm configuring it like this:

use({
    "noib3/nvim-cokeline",
    requires = "kyazdani42/nvim-web-devicons",
    config = function()
        require("cokeline").setup()
    end,
})

Hi, I have a question

For now, I use standard tabline (with some rewrites).
When I use Nvim Tree, I tap "v" for vertical split, "b" for horizontal, and so on..
If I want to open new tab, I tap "t", but with your plugin (and other like bufferline) when I use vertical split, it opens new tab. How can I fix it or why is it works like that?

Thank you in advance!

Error `E937` displayed when closing `fugitive-summary` buffer with `focus_on_delete` set to `prev` or `next`

Error E937: Attempt to delete a buffer that is in use is shown when trying to close fugitive-summary with buffers.focus_on_delete set to prev or next:

Error detected while processing BufDelete Autocommands for "*":
E5108: Error executing lua ...sers\user\.vim-plug\cokeline.nvim/lua/cokeline/augroups.lua:15: Vim(buffer):E937: Attempt to delete a buffer that is in use
stack traceback:
	[C]: in function 'cmd'
	...sers\user\.vim-plug\cokeline.nvim/lua/cokeline/augroups.lua:15: in function 'close_bufnr'
	[string ":lua"]:1: in main chunk

Steps to reproduce:

  1. Set buffers.focus_on_delete to prev or next:
require('cokeline').setup {
    buffers = {
        focus_on_delete = 'prev',
    },
}
  1. Run :Git in a git repository to open fugitive-summary
  2. Close buffer with :bdelete
  3. Notice exception is thrown (see above)

Duplicate help tags due to old-cokeline.txt

Hello,

I'm trying to package this plugin for NixOS, but the build failes due to duplicate help tags.

Executing vimPluginGenTags
Building help tags
Error detected while processing command line:
E154: Duplicate tag "<Plug>(cokeline-focus-next)" in file /nix/store/priinwhs52q6k1gzqqr0nf5flfzw68i5-vimplugin-nvim-cokeline-latest/./doc/old-cokeline.txt
E154: Duplicate tag "<Plug>(cokeline-focus-prev)" in file /nix/store/priinwhs52q6k1gzqqr0nf5flfzw68i5-vimplugin-nvim-cokeline-latest/./doc/old-cokeline.txt
E154: Duplicate tag "<Plug>(cokeline-switch-next)" in file /nix/store/priinwhs52q6k1gzqqr0nf5flfzw68i5-vimplugin-nvim-cokeline-latest/./doc/old-cokeline.txt
E154: Duplicate tag "<Plug>(cokeline-switch-prev)" in file /nix/store/priinwhs52q6k1gzqqr0nf5flfzw68i5-vimplugin-nvim-cokeline-latest/./doc/old-cokeline.txt
E154: Duplicate tag "cokeline" in file /nix/store/priinwhs52q6k1gzqqr0nf5flfzw68i5-vimplugin-nvim-cokeline-latest/./doc/old-cokeline.txt
E154: Duplicate tag "cokeline-configuration" in file /nix/store/priinwhs52q6k1gzqqr0nf5flfzw68i5-vimplugin-nvim-cokeline-latest/./doc/old-cokeline.txt
E154: Duplicate tag "cokeline-contents" in file /nix/store/priinwhs52q6k1gzqqr0nf5flfzw68i5-vimplugin-nvim-cokeline-latest/./doc/old-cokeline.txt
E154: Duplicate tag "cokeline-mappings" in file /nix/store/priinwhs52q6k1gzqqr0nf5flfzw68i5-vimplugin-nvim-cokeline-latest/./doc/old-cokeline.txt
E154: Duplicate tag "cokeline.nvim" in file /nix/store/priinwhs52q6k1gzqqr0nf5flfzw68i5-vimplugin-nvim-cokeline-latest/./doc/old-cokeline.txt
E154: Duplicate tag "cokeline.txt" in file /nix/store/priinwhs52q6k1gzqqr0nf5flfzw68i5-vimplugin-nvim-cokeline-latest/./doc/old-cokeline.txtFailed to build help tags!

The errors come form old-cokeline.txt as it has the same tags as cokeline.txt. Does this file serve any purpose or is it just deprecated and could be removed?

Exception when deleting a file that has open buffer

When a buffer is open and you delete the underlying file in NvimTree, an exception is thrown:

E5108: Error executing lua ...are/nvim/plugged/nvim-cokeline//lua/cokeline/buffers.lua:231: attempt to perform arithmetic on a nil value
stack traceback:
        ...are/nvim/plugged/nvim-cokeline//lua/cokeline/buffers.lua:231: in function <...are/nvim/plugged/nvim-cokeline//lua/cokeline/buffers.lua:227>
        [C]: in function 'tbl_sort'
        ...are/nvim/plugged/nvim-cokeline//lua/cokeline/buffers.lua:277: in function 'get_valid_buffers'
        ...are/nvim/plugged/nvim-cokeline//lua/cokeline/buffers.lua:293: in function 'get_visible_buffers'
        .../share/nvim/plugged/nvim-cokeline//lua/cokeline/init.lua:26: in function <.../share/nvim/plugged/nvim-cokeline//lua/cokeline/init.lua:25>

Handle sizing of components when there is not enough space

This issue is to discuss what to do when tabs are smaller than needed to display all of their components. This is very likely to happen if tabs are forced to fit the tab line rather than overflowing, but it can also happen if vertical tabs are implemented.

There are two pieces of functionality that needs to be added:

  1. A method of truncating strings that are too long.
  2. A way of determining which components are hidden when under space pressure, and in what priority order.

For #1, I would recommend the configuration takes a function reference that would be called with the buffer info object, a number representing the available width, and the full list of buffers being displayed. We could provide three built-in functions for convenience:

a. left truncating: ....lename.txt
b. right truncating: filename....
c. mid truncating: filena...txt

The reason for also providing the full list of buffers as an argument is to allow for more advanced truncation that takes into account what else is displayed. For instance, you might want to intelligently truncate out the parts of the name that multiple files have in common.

For #2, it might be easiest to add a "min_line_width" option, and if the available width is smaller than that number then the component will be collapsed. It would also be nice to accept a function ref which is called with the buffer info and available width as arguments and return a boolean. I would personally use that option and determine whether or not the component is collapsed based on how much of the filename will be truncated.

Let me know what you think. I would be happy to contribute some work on all or part of this.

Thanks!

This the bufferline plugin I've been looking for! The API is really easy to get started with and is really powerful in it's simplicity versus the other bufferline plugins I've used.

Just wanted to give you a thanks since I know working on open source can be pretty thankless

Filename starts with special character breaks the line

Step to reproduce

Enter the command line window by q:, then the error happens:

E5108: Error executing lua ...e/pack/packer/opt/nvim-cokeline/lua/cokeline/buffers.lua:108: malformed pattern (missing ']')
stack traceback:
[C]: in function 'find'
...e/pack/packer/opt/nvim-cokeline/lua/cokeline/buffers.lua:108: in function 'get_pick_letter'
...e/pack/packer/opt/nvim-cokeline/lua/cokeline/buffers.lua:193: in function <...e/pack/packer/opt/nvim-cokeline/lua/cokeline/buffers.lua:168>
vim/shared.lua: in function 'vim_map'
...e/pack/packer/opt/nvim-cokeline/lua/cokeline/buffers.lua:297: in function 'get_valid_buffers'
...e/pack/packer/opt/nvim-cokeline/lua/cokeline/buffers.lua:332: in function 'get_visible_buffers'
...site/pack/packer/opt/nvim-cokeline/lua/cokeline/init.lua:26: in function <...site/pack/packer/opt/nvim-cokeline/lua/cokeline/init.lua:25>

It is because the filename for the command line window is [Command Line], while [ is a special character in lua pattern. Perhaps the filename should be escaped in advance?

Make default_hl accept functions

It would be nice if it was possible to pass function as an alternative to string for default_hl similar to how its already possible in components. I managed to change background of buffer (in bufferline) that is modified and I believe currently the best way is to override background of every component like so:

components = {
  {
    text = function(buffer) return buffer.filename .. ' ' end,
    hl = {
      fg = function(buffer)
        return buffer.is_modified
          and get_hex('ErrorMsg', 'bg')
      end,
      bg = function(buffer)
        return buffer.is_modified
          and get_hex('ErrorMsg', 'fg')
      end,
    }
  },
}

When it would be more convenient to just do something like this in default_hl:

default_hl = {
  focused = {
    fg = function(buffer) -- seems like currently you can't provide a function here
      return buffer.is_modified
        and get_hex('ErrorMsg', 'bg')
        or get_hex('ColorColumn', 'bg')
    end,
    bg = function(buffer) -- seems like currently you can't provide a function here
      return buffer.is_modified
        and get_hex('ErrorMsg', 'bg')
        or get_hex('Normal', 'fg')
    end,
  },
},

Above example would make required config much smaller by reducing lots of repetition. I'm not sure about impact on performance but running it once per buffer instead once for every component in every buffer sounds better.

An alternative that I can imagine is to add default_hl group - modified that will provide default color for modified buffers:

default_hl = {
  modified = {
    fg = get_hex('ErrorMsg', 'bg'),
    bg = get_hex('ErrorMsg', 'fg'),
  },
},

Correct me if I'm doing something wrong or if there is already a way to do that. Maybe I'm just missing something.

NOTE: Highlight groups I've used in my examples might not look good for every colorscheme.

Error when opening a sidebar

I'm using this rendering configuration

    rendering = {
        max_buffer_width = 20,

        left_sidebar = {
            filetype = 'NvimTree',
            components = {
                text = 'NvimTree',
                hl = {
                    fg = get_hex('Normal', 'fg'),
                    bg = get_hex('NvimTreeNormal', 'bg'),
                    style = 'bold',
                },
            },
        },
    },

Whenever I open NvimTree (with NvimTreeToggle), I get the below error.

E5108: Error executing lua ...ack/packer/start/nvim-cokeline/lua/cokeline/sidebars.lua:46: attempt to index a nil value
stack traceback:
	...ack/packer/start/nvim-cokeline/lua/cokeline/sidebars.lua:46: in function 'get_sidebar_components'
	...ack/packer/start/nvim-cokeline/lua/cokeline/sidebars.lua:85: in function 'get_left_right_sidebar_components'
	...ck/packer/start/nvim-cokeline/lua/cokeline/rendering.lua:186: in function <...ck/packer/start/nvim-cokeline/lua/cokeline/rendering.lua:172>

The error is coming from the second of these lines:

    components[#components].text = components[#components].text
      .. str_rep(" ", space_left)

After this error is dismissed the bufferline goes back to default, but works as configured before the error is triggered.

Filter out filetypes from buffer list

Sometimes I may get a rogue terminal or a filetype appear in my buffer list which I'd rather not see. In bufferline you can filter these out through a custom function. Is this something that can be done already in our beloved cokeline?

My config

Thought I'd share my config as in about 10 mins I've got this looking exactly how I wanted. bufferline was always a touch too opinionated for myself. My general principle with theming is "if I don't need to see something, it shouldn't be a visual burden". This is just perfect and I love the power.

My config

Screen Shot 2021-10-04 at 20 13 27

To enable the theme change, I load in my theme's colors and with a colorscheme autocommand, refresh cokeline on any change. I have also added in a modified button.

Click to see configuration
local M = {}

function M.setup()
	local present, cokeline = pcall(require, "cokeline")
	if not present then
		return
	end

	local colors = require("colors").get()

	cokeline.setup({

		hide_when_one_buffer = true,
		cycle_prev_next_mappings = true,

		default_hl = {
			focused = {
				fg = colors.purple,
				bg = "NONE",
				style = "bold",
			},
			unfocused = {
				fg = colors.gray,
				bg = "NONE",
			},
		},

		components = {
			{
				text = function(buffer)
					return buffer.index ~= 1 and "  "
				end,
			},
			{
				text = function(buffer)
					return buffer.index .. ": "
				end,
				hl = {
					style = function(buffer)
						return buffer.is_focused and "bold" or nil
					end,
				},
			},
			{
				text = function(buffer)
					return buffer.unique_prefix
				end,
				hl = {
					fg = function(buffer)
						return buffer.is_focused and colors.purple or colors.gray
					end,
					style = "italic",
				},
			},
			{
				text = function(buffer)
					return buffer.filename .. " "
				end,
				hl = {
					style = function(buffer)
						return buffer.is_focused and "bold" or nil
					end,
				},
			},
			{
				text = function(buffer)
					return buffer.is_modified and " ●"
				end,
				hl = {
					fg = function(buffer)
						return buffer.is_focused and colors.red
					end,
				},
			},
			{
				text = "  ",
			},
		},
	})
end

return M

When I first used cokeline I was surprised that cycle_prev_next_mappings = true was not the default option. It's something I am so used to with all other buffer plugins.

Btw...happy to move this to a "Users Config" thread

Add default value to `left_sidebar.components.hl.style`

When left_sidebar.components.hl.style is not specified, an error occurs.

E5108: Error executing lua ...ack/packer/start/nvim-cokeline/lua/cokeline/hlgroups.lua:30: Vim(highlight):E418: Illegal value: false
stack traceback:
        [C]: in function 'vim_cmd'
        ...ack/packer/start/nvim-cokeline/lua/cokeline/hlgroups.lua:30: in function 'hlgroup_exec'
        ...ack/packer/start/nvim-cokeline/lua/cokeline/hlgroups.lua:52: in function 'new_hlgroup'
        ...k/packer/start/nvim-cokeline/lua/cokeline/components.lua:110: in function <...k/packer/start/nvim-cokeline/lua/cokeline/components.lua:82>
        vim/shared.lua: in function 'vim_map'
        ...ack/packer/start/nvim-cokeline/lua/cokeline/sidebars.lua:25: in function 'get_sidebar_components'
        ...ack/packer/start/nvim-cokeline/lua/cokeline/sidebars.lua:85: in function 'get_left_right_sidebar_components'
        ...ck/packer/start/nvim-cokeline/lua/cokeline/rendering.lua:186: in function <...ck/packer/start/nvim-cokeline/lua/cokeline/rendering.lua:172>

I used this by removing the style = 'bold' line from this setting.

It seems to use false if there is no value.

max_line_width only for certain components

This is a potentially tricky issue to solve...

When I implement max_line_width, it quite correctly trims each buffer to the integer I set. Unfortunately I have a component which sticks a nice big red circle if the buffer has been modified and not saved. The max_line_width chops this off, as intended.

It would be great to be able to get max_line_width to ignore components which have a certain property like ignore_truncate = true, that way the filename of the buffer (which I do want truncated) is trimmed, but not my modified icon.

Default highlighting overrides highlighting for specific components

I was trying to configure my setup, when I realized trying to change the highlights of certain elements was just not working. Here's my config for an example:

local is_picking_focus = require('cokeline/mappings').is_picking_focus
local is_picking_close = require('cokeline/mappings').is_picking_close
local get_hex = require('cokeline/utils').get_hex

local components_cokeline = {
	space = {
		text = ' ',
	},
	separator_left = {
		text = function(buffer)
			return buffer.index == 1 and 'ξ‚°' or ''
		end,
		hl = {
			focused = {
				fg = '#ff0000',
				bg = '#00ffff',
			},
			unfocused = {
				fg = '#00ffff',
				bg = '#ff0000',
			},
		},
	},
	separator_right = {
		text = 'ξ‚°',
		hl = {
			unfocused = {
				fg = get_hex('Comment', 'fg'),
				bg = get_hex('ColorColumn', 'bg'),
			},
			focused = {
				fg = get_hex('ColorColumn', 'fg'),
				bg = get_hex('Normal', 'bg'),
			},
		},
	},
	devicon = {
		text = function(buffer)
			return
			(is_picking_focus() or is_picking_close())
			and buffer.pick_letter .. ' '
			or buffer.devicon.icon
		end,
		hl = {
			fg = function(buffer)
				return
				(is_picking_focus() and yellow)
				or (is_picking_close() and red)
				or buffer.devicon.color
			end,
			style = function(_)
				return
				(is_picking_focus() or is_picking_close())
				and 'italic,bold'
				or nil
			end,
		}
	},
	index = {
		text = function(buffer)
			return buffer.index .. ': '
		end,
	},
	filename = {
		text = function(buffer) return buffer.filename .. '  ' end,
		hl = {
			style = function(buffer)
				return buffer.is_focused and 'bold' or nil
			end,
		}
	},
	close_button = {
		text = 'ο™•',
		delete_buffer_on_left_click = true,
    },
}

require('cokeline').setup({
	default_hl = {
		focused = {
			fg = '#ffff00',
			bg = '#ff00ff',
		},
		unfocused = {
			bg = '#ffff00',
			fg = '#ff00ff',
		},
	},
	components = {
		components_cokeline.separator_left,
		components_cokeline.space,
		components_cokeline.devicon,
		components_cokeline.space,
		components_cokeline.index,
		components_cokeline.filename,
		components_cokeline.space,
		components_cokeline.separator_right,
	},
})

In the hl section for the separator_left component, I chose red and cyan as the foreground and background respectively. However, here's a screenshot of what actually happens:

image

Instead, cokeline chooses the default colors here instead of the ones I specified in the separator_left component. Either I'm configuring this incorrectly, or there's a bug in the plugin.

Support for equivalent to `Bufferline`'s `BufferLinePick` and `BufferLinePickClose`

First, let me say what a cool project.
As an avid user of Bufferline I like that "competition" is happening with each having its own set of cool features and implementation that the others then implement, so on, so forth.
Kudos!

To the point: Bufferline has two great features, listed in the title: BufferLinePick which, when triggered displays a sigil on each buffer that lets you do a one-click goto to any buffer (more so: since the sigils are unique and constant per session, if you know the sigil of a buffer not displayed on the buffer line itself, you can trigger the function and go to the hidden buffer by its sigil... hidden or not).

BufferLinePickClose, as you can imagine, does the same as its non-destructive counterpart, but closes the selected buffer, allowing for pinpoint closing of buffers without first having to switch over to them and then :bdelete.

More than any visual candy, I, personally, find these two functions to be indispensable, now that I started using them.
It would be great if, at some point, cokeline could have them too.

And, again, great project.
Looking really, really cool!
(BTW, if you need "inspiration", πŸ˜†, another cool, up-and-coming buffer line plugin is barbar).

Feature: sidebar offset support multiples filetypes

It would be great if this option accepts multiple filetypes.

sidebar = {
  { 
    filetype = 'NvimTree',
    components = {
      {
        text = ' ',
        fg = colors.fg,
        bg = colors.bg_alt,
        style = 'bold',
      },
    },
  },
  {
    filetype = 'DiffviewFiles',
    components = {
      {
        text = ' ',
        fg = colors.fg,
        bg = colors.bg_alt,
        style = 'bold',
      },
    },
  }
},

Attempt to index upvalue 'keymap' (a nil value)

Just upgraded to 0.3 and getting this error:

packer.nvim: Error running config for cokeline.nvim: ...ack/packer/start/cokeline.nvim/lua/cokeline/mappings.lua:89: attempt to index upvalue 'keymap' (a nil value)

My config is:

require("cokeline").setup()

Offset for NvimTree?

Hi! Thank you for writing and releasing your plugin.

I have a question, what would be the best approach to have the bar have an offset when NvimTree is opened? Bufferline and others are able to detect this and have the output above the buffer only, not above the NvimTree window.

Not a biggie, but a nice to have perhaps.

Configuration option "style" does not exist!

Another day, another newbie question from yours truly. Alas, the latest commit has broken my glorious config πŸ˜‰ .

This time with the error message:

[cokeline.nvim]: Configuration option "style" does not exist!
My config is here
local M = {}

function M.setup()
	local present, bufferline = pcall(require, "cokeline")
	if not present then
		return
	end

	local spacer = "  "
	local colors = require("onedarkpro").get_colors(vim.g.onedarkpro_style)

	bufferline.setup({

		cycle_prev_next_mappings = true,
		show_if_buffers_are_at_least = 2,

		default_hl = {
			focused = {
				fg = colors.purple,
				bg = "NONE",
				style = "bold",
			},
			unfocused = {
				fg = colors.gray,
				bg = "NONE",
			},
		},
		buffers = {
                new_buffers_position = 'last',
			filter = function(buffer)
				return buffer.type ~= "terminal" and buffer.type ~= "quickfix"
			end,
		},
		rendering = {
			max_line_width = 25,
		},
		components = {
			{
				text = function(buffer)
					return buffer.index ~= 1 and spacer
				end,
			},
			{
				text = function(buffer)
					return buffer.index .. ": "
				end,
				hl = {
					style = function(buffer)
						return buffer.is_focused and "bold" or nil
					end,
				},
			},
			{
				text = function(buffer)
					return buffer.unique_prefix
				end,
				hl = {
					fg = function(buffer)
						return buffer.is_focused and colors.purple or colors.gray
					end,
					style = "italic",
				},
			},
			{
				text = function(buffer)
					return buffer.filename
				end,
				hl = {
					style = function(buffer)
						return buffer.is_focused and "bold" or nil
					end,
				},
			},
			{
				text = function(buffer)
					return buffer.is_modified and " ●"
				end,
				truncation = {
					priority = 1,
				},
				hl = {
					fg = function(buffer)
						return buffer.is_focused and colors.red
					end,
				},
			},
			{
				text = spacer,
			},
		},
	})
end

return M

This is a bit of a surprise as the readme contains plenty of references to the style aspects of highlight groups.

Buffer Limit?

My neovim tends to get sluggish with many buffers open (>15), which happens pretty fast when coding. What would be the best way to auto-close "old" buffers when opening a new one? Is this something this plugin could do or do I need to do some hacking elsewhere?

Thanks again for your awesome plugin, does the job perfectly!

Bad argument #2 to 'sort ' (function expected, got boolean)

The latest commits seem to be throwing an error for me:

Error detected while processing VimEnter Autocommands for "*":
E5108: Error executing lua ...pack/packer/start/cokeline.nvim/lua/cokeline/buffers.lua:245: bad argument #2 to 'sort
' (function expected, got boolean)
My config is here
local M = {}

function M.setup()
	local present, bufferline = pcall(require, "cokeline")
	if not present then
		return
	end

	local spacer = "  "
	local colors = require("onedarkpro").get_colors(vim.g.onedarkpro_style)

	bufferline.setup({

		cycle_prev_next_mappings = true,
		show_if_buffers_are_at_least = 2,

		default_hl = {
			focused = {
				fg = colors.purple,
				bg = "NONE",
				style = "bold",
			},
			unfocused = {
				fg = colors.gray,
				bg = "NONE",
			},
		},
		buffers = {
			filter = function(buffer)
				return buffer.type ~= "terminal" and buffer.type ~= "quickfix"
			end,
		},
		rendering = {
			max_line_width = 25,
		},
		components = {
			{
				text = function(buffer)
					return buffer.index ~= 1 and spacer
				end,
			},
			{
				text = function(buffer)
					return buffer.index .. ": "
				end,
				hl = {
					style = function(buffer)
						return buffer.is_focused and "bold" or nil
					end,
				},
			},
			{
				text = function(buffer)
					return buffer.unique_prefix
				end,
				hl = {
					fg = function(buffer)
						return buffer.is_focused and colors.purple or colors.gray
					end,
					style = "italic",
				},
			},
			{
				text = function(buffer)
					return buffer.filename
				end,
				hl = {
					style = function(buffer)
						return buffer.is_focused and "bold" or nil
					end,
				},
			},
			{
				text = function(buffer)
					return buffer.is_modified and " ●"
				end,
				truncation = {
					priority = 1,
				},
				hl = {
					fg = function(buffer)
						return buffer.is_focused and colors.red
					end,
				},
			},
			{
				text = spacer,
			},
		},
	})
end

return M

Commit 176fe67c4f5139fc88c3185d012b6d9f2b64cee2 from 15 November worked absolutely fine.

vim.diagnostic is nil

Hey,

I am running into some issues, while trying out this nice tab bar.

I am getting following error messages when starting up nvim:
E5108: Error executing lua ...pack/packer/start/cokeline.nvim/lua/cokeline/buffers.lua:126: attempt to index field 'diagnostic' (a nil value)

This happens when trying to check if vim.diagnostic.get. I also can't find this in the neovim docs. Do you mean vim.lsp.diagnostic?

Greetings,
Patrick

Getting white background where there are no buffers

Basically like the title says. This is how it looks:

image

How can I get the rest of the line to have the same background as the buffers? I'm assuming I miss a configuration/setting a highlight group but I couldn't find anything in the documentation about this.

Conflicts with neogit

Every action in neogit which modifies the view throws this error:

Error detected while processing BufUnload Autocommands for "*":
E5108: Error executing lua ...ack/packer/start/nvim-cokeline/lua/cokeline/augroups.lua:34: Vim(buffer):E937: Attempt to dele
te a buffer that is in use
stack traceback:
[C]: in function 'cmd'
...ack/packer/start/nvim-cokeline/lua/cokeline/augroups.lua:34: in function 'focus_on_delete'
[string ":lua"]:1: in main chunk
[C]: in function 'nvim_buf_delete'
.../site/pack/packer/start/neogit/lua/neogit/lib/buffer.lua:85: in function 'close'
...m/site/pack/packer/start/neogit/lua/neogit/lib/popup.lua:61: in function 'close'
...m/site/pack/packer/start/neogit/lua/neogit/lib/popup.lua:215: in function 'cb'
.../site/pack/packer/start/neogit/lua/neogit/lib/buffer.lua:301: in function <.../site/pack/packer/start/neogit/lua/
neogit/lib/buffer.lua:300>
.../packer/start/neogit/lua/neogit/lib/mappings_manager.lua:9: in function 'invoke'
[string ":lua"]:1: in main chunk

`focused_line.width` is nil

In cokeline/init.lua the variable focused_lineis being assigned in a for loop through the buffers. But if no buffer is focused focused_line remains an empty table, which results in a nil indexing.

I added the line if focused_line then cokeline:render(focused_line) end in _G.cokeline() , which solved the problem for me. This usually happened if I opened an empty buffer.

Could focus-prev focus-next ignore buffers from the filter

Would it be possible for the cokeline-focus-prev and cokeline-focus-next commands to also skip the buffers ignored by the buffer filter in the config? In my case I ignore e.g. terminals as I have a utility terminal floating at the bottom, and when I cycle through my buffers I end up in that one although I don't expect it to.

Great plugin btw!

Focusing the next/previous buffer should wrap around

Would it be possible for cokeline-focus-next/cokeline-focus-previous to wrap around the list of buffers? E.g. if the last buffer in the list was currently selected, calling cokeline-focus-next would focus the first buffer.

Key mapping improvement

Hello!

I've came up with a little bit more reliable keybinding for <Plug>(cokeline-focus-<index>).
Instead of setting up new keybinding for each buffer number separately in a loop, we could use count variable like so:

vim.keymap.set('n', '<tab>', function()
  return ('<Plug>(cokeline-focus-%s)'):format(vim.v.count > 0 and vim.v.count or 'next')
end, { silent = true, expr = true })

now whenever we precede Tab with a count, we will go directly to that buffer. Otherwise the Tab will just move to the next buffer in a list. You can add this into the documentation if you feel like it's worth mentioning.

Thank you for creating nvim-cokeline!

Error with [No name] buffer

I updated cokeline and started to get this error when opening neovim without a filename:

E5108: Error executing lua ...e/pack/packer/opt/cokeline.nvim/lua/cokeline/buffers.lua:107: malformed pattern (missing ']')
stack traceback:
        [C]: in function 'find'
        ...e/pack/packer/opt/cokeline.nvim/lua/cokeline/buffers.lua:107: in function 'get_pick_letter'
        ...e/pack/packer/opt/cokeline.nvim/lua/cokeline/buffers.lua:190: in function 'func'
        vim/shared.lua:191: in function 'vim_map'
        ...e/pack/packer/opt/cokeline.nvim/lua/cokeline/buffers.lua:292: in function 'get_valid_buffers'
        ...e/pack/packer/opt/cokeline.nvim/lua/cokeline/buffers.lua:327: in function 'get_visible_buffers'
        ...site/pack/packer/opt/cokeline.nvim/lua/cokeline/init.lua:26: in function <...site/pack/packer/opt/cokeline.nvim/lua
/cokeline/init.lua:25>

I tried to disable buffer picking, but there doesn't seem to be an option for doing that. Maybe should there be one?

Buffers are now duplicated

With 0.3, I notice that my components are now duplicated:

Screen Shot 2022-03-06 at 12 56 50@2x

My config is:

local M = {}

function M.setup()
    require("cokeline").setup({
        components = {
            {
                text = function(buffer)
                    return buffer.filename .. " "
                end,
            },
        },
    })
end

return M

option for never show tabline

I only use the tabs when I have more 4 tabs open so when I try to set showtabline = 0, its complement keeps looking for them, I have already configured a map to do toggle

Vertical tabs

I've been thinking about making a plugin that shows open buffers in a sidebar instead of in the tab bar. The reason for this is I usually have more buffers open than can fit in the tab bar, and to me it that ruins the purpose of showing buffers as tabs.

This is my favorite implementation of a buffer based tab line, and I think it would be a good idea to just add vertical tabs as a feature to this project rather than starting from scratch. The question is, are you interested in adding this feature to the project? I would be willing to do the work and put in a PR if you think it is something you would want to have here.

Switch mapping doesn't work in the 0.3

I've noticed that since I've upgraded to 0.3 the switch mappings have stopped working. I've successfully downgraded to the prior release and they worked perfectly.

My mappings are:

for i = 1, 9 do
  -- Switch a buffer with another buffer with a given index of i
  vim.api.nvim_set_keymap("n", ("<Leader>%s"):format(i), ("<Plug>(cokeline-switch-%s)"):format(i), { silent = true })
end

Running :verbose nmap <Leader>1 gives me the following output:

Screen Shot 2022-03-09 at 07 47 59@2x

nil value errors when there are no listed buffers

If I don't set hide_when_one_buffer = true, and I open nvim without a file, I get errors about nil values and cokeline fails to load properly. I use Startify and normally open nvim without arguments and then launch a session from Startify (which is an unlisted buffer) so I hit that every time.

Here is the error I get:
E5108: Error executing lua ...ack/packer/start/cokeline.nvim/lua/cokeline/cokeline.lua:83: attempt to perform arithmetic on field 'width' (a nil value)

I worked around the issue by adding this check to _G.cokeline() in init.lua:

... 

function _G.cokeline() 
    state.buffers = buffers.get_listed(state.order) 
    if #state.buffers < 1 then
        opt.showtabline = 0
        return
    end

...

I'm not sure if that's the ideal solution for everyone or not, but it works for me.

Error when component in sidebar has zero width

After updating to 0.3 I started getting the following error when opening NvimTree:

stack traceback:
  ...e/pack/packer/opt/cokeline.nvim/lua/cokeline/sidebar.lua:86: in function 'get_components'
  ...pack/packer/opt/cokeline.nvim/lua/cokeline/rendering.lua:85: in function 
<...pack/packer/opt/cokeline.nvim/lua/cokeline/rendering.lua:84>

I took a look at the source code and this condition seems to be causing the error (sidebar.lua:68):

 if component.width > 0 then
    insert(sidebar_components, component)
    width = width + component.width
 end

My sidebar config is as follows:

sidebar = {
  filetype = 'NvimTree',
  components = {
    {
      text = '',
      hl = { bg = colors.bg_d, style = 'none' },
    },
  },
},

I can workaround it by setting text to ' ' instead of an empty string, but since it used to work before 0.3 I think it might be a bug.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.