From 083b7bcdc568f3db5bde5adb60f2c8a3d038751a Mon Sep 17 00:00:00 2001 From: Yigit Sever Date: Wed, 14 Dec 2022 17:01:15 +0300 Subject: feat(nvim): use barbar tabline plugin --- .config/nvim/lua/mappings.lua | 32 +++++++ .config/nvim/lua/plugin_settings.lua | 174 +++++++++++++++++++++++++++-------- .config/nvim/lua/plugins.lua | 3 +- 3 files changed, 169 insertions(+), 40 deletions(-) diff --git a/.config/nvim/lua/mappings.lua b/.config/nvim/lua/mappings.lua index 1512fee..4bf7cf3 100644 --- a/.config/nvim/lua/mappings.lua +++ b/.config/nvim/lua/mappings.lua @@ -152,4 +152,36 @@ vim.keymap.set('n', '`', '(leap-backward)', opts) vim.keymap.set('v', '`', '(leap-forward)', opts) vim.keymap.set('v', '`', '(leap-backward)', opts) +-- barbar.nvim mappings +local opts = { noremap = true, silent = true } + +-- move to previous/next +vim.keymap.set('n', '', 'BufferPrevious', opts) +vim.keymap.set('n', '', 'BufferNext', opts) +-- re-order to previous/next +vim.keymap.set('n', '', 'BufferMovePrevious', opts) +vim.keymap.set('n', '', 'BufferMoveNext', opts) +-- goto buffer in position... +vim.keymap.set('n', '', 'BufferGoto 1', opts) +vim.keymap.set('n', '', 'BufferGoto 2', opts) +vim.keymap.set('n', '', 'BufferGoto 3', opts) +vim.keymap.set('n', '', 'BufferGoto 4', opts) +vim.keymap.set('n', '', 'BufferGoto 5', opts) +vim.keymap.set('n', '', 'BufferGoto 6', opts) +vim.keymap.set('n', '', 'BufferGoto 7', opts) +vim.keymap.set('n', '', 'BufferGoto 8', opts) +vim.keymap.set('n', '', 'BufferGoto 9', opts) +vim.keymap.set('n', '', 'BufferLast', opts) +-- pin/unpin buffer +vim.keymap.set('n', '', 'BufferPin', opts) +-- close buffer +vim.keymap.set('n', '', 'BufferClose', opts) +-- magic buffer-picking mode +vim.keymap.set('n', 'dg', 'BufferPick', opts) +-- sort automatically by... +vim.keymap.set('n', 'db', 'BufferOrderByBufferNumber', opts) +vim.keymap.set('n', 'dd', 'BufferOrderByDirectory', opts) +vim.keymap.set('n', 'dl', 'BufferOrderByLanguage', opts) +vim.keymap.set('n', 'dw', 'BufferOrderByWindowNumber', opts) + -- }}} plug mappings -- diff --git a/.config/nvim/lua/plugin_settings.lua b/.config/nvim/lua/plugin_settings.lua index d03ad77..d103607 100644 --- a/.config/nvim/lua/plugin_settings.lua +++ b/.config/nvim/lua/plugin_settings.lua @@ -94,14 +94,7 @@ require'lualine'.setup { lualine_y = {}, lualine_z = {} }, - tabline = { - lualine_a = {'buffers'}, - lualine_b = {}, - lualine_c = {}, - lualine_x = {}, - lualine_y = {}, - lualine_z = {} - }, + tabline = {}, extensions = {} } @@ -454,37 +447,6 @@ npairs.add_rule(Rule('/*','*/',"c")) -- }}} nvim-autopairs -- --- nvim-tree {{{ -- - -require("nvim-tree").setup({ - sort_by = "case_sensitive", - diagnostics = { - enable = false, - icons = { - hint = "❔", - info = "❕", - warning = "❗", - error = "❌", - } - }, - view = { - adaptive_size = true, - mappings = { - list = { - { key = "u", action = "dir_up" }, - }, - }, - }, - renderer = { - group_empty = true, - }, - filters = { - dotfiles = true, - }, -}) - --- }}} nvim-tree -- - -- nvim-colorizer {{{ -- require 'colorizer'.setup() -- }}} nvim-colorizer -- @@ -640,3 +602,137 @@ require("fidget").setup{ } -- }}} fidget.nvim -- +-- nvim-tree {{{ -- + +require("nvim-tree").setup({ + sort_by = "case_sensitive", + diagnostics = { + enable = false, + icons = { + hint = "❔", + info = "❕", + warning = "❗", + error = "❌", + } + }, + view = { + adaptive_size = true, + mappings = { + list = { + { key = "u", action = "dir_up" }, + }, + }, + }, + renderer = { + group_empty = true, + }, + filters = { + dotfiles = true, + }, +}) + +-- }}} nvim-tree -- + +-- barbar.nvim {{{ -- + +require'bufferline'.setup { + -- disable animations + animation = false, + + -- auto-hide the tab bar when there is a single buffer + auto_hide = true, + + -- enable current/total tabpages indicator (top right corner) + tabpages = true, + + -- enable close button + closable = true, + + -- disable clickable tabs + clickable = false, + + -- Enables / disables diagnostic symbols + diagnostics = { + -- `vim.diagnostic.severity` + [vim.diagnostic.severity.ERROR] = {enabled = true, icon = '❌'}, + [vim.diagnostic.severity.WARN] = {enabled = false}, + [vim.diagnostic.severity.INFO] = {enabled = false}, + [vim.diagnostic.severity.HINT] = {enabled = true}, + }, + + -- -- Excludes buffers from the tabline + -- exclude_ft = {'javascript'}, + -- exclude_name = {'package.json'}, + + -- Hide inactive buffers and file extensions. Other options are `current` and `visible` + -- hide = {extensions = true, inactive = true}, + + -- Enable/disable icons + -- if set to 'numbers', will show buffer index in the tabline + -- if set to 'both', will show buffer index and icons in the tabline + icons = true, + + -- If set, the icon color will follow its corresponding buffer + -- highlight group. By default, the Buffer*Icon group is linked to the + -- Buffer* group (see Highlighting below). Otherwise, it will take its + -- default value as defined by devicons. + icon_custom_colors = false, + + -- Configure icons on the bufferline. + icon_separator_active = '▎', + icon_separator_inactive = '▎', + icon_close_tab = '', + icon_close_tab_modified = '•', + icon_pinned = '車', + + -- If true, new buffers will be inserted at the start/end of the list. + -- Default is to insert after current buffer. + insert_at_end = false, + insert_at_start = false, + + -- Sets the maximum padding width with which to surround each tab + maximum_padding = 1, + + -- Sets the minimum padding width with which to surround each tab + minimum_padding = 1, + + -- Sets the maximum buffer name length. + maximum_length = 30, + + -- If set, the letters for each buffer in buffer-pick mode will be + -- assigned based on their name. Otherwise or in case all letters are + -- already assigned, the behavior is to assign letters in order of + -- usability (see order below) + semantic_letters = true, + + -- New buffer letters are assigned in this order. This order is + -- optimal for the qwerty keyboard layout but might need adjustement + -- for other layouts. + -- letters = 'asdfjkl;ghnmxcvbziowerutyqpASDFJKLGHNMXCVBZIOWERUTYQP', + letters = 'arstneoidhqwfpluy;zxcvkmARSTNEOIDHQWFPLUYZXCVKM', + + -- Sets the name of unnamed buffers. By default format is "[Buffer X]" + -- where X is the buffer number. But only a static string is accepted here. + no_name_title = nil, +} + +local nvim_tree_events = require('nvim-tree.events') +local bufferline_api = require('bufferline.api') + +local function get_tree_size() + return require'nvim-tree.view'.View.width +end + +nvim_tree_events.subscribe('TreeOpen', function() + bufferline_api.set_offset(get_tree_size()) +end) + +nvim_tree_events.subscribe('Resize', function() + bufferline_api.set_offset(get_tree_size()) +end) + +nvim_tree_events.subscribe('TreeClose', function() + bufferline_api.set_offset(0) +end) + +-- }}} barbar.nvim -- diff --git a/.config/nvim/lua/plugins.lua b/.config/nvim/lua/plugins.lua index 1a36ce9..0c00437 100644 --- a/.config/nvim/lua/plugins.lua +++ b/.config/nvim/lua/plugins.lua @@ -29,7 +29,6 @@ return require('packer').startup(function(use) -- extra rust-analyzer functionality use 'simrat39/rust-tools.nvim' - -- annotation generator use { "danymat/neogen", @@ -145,6 +144,8 @@ return require('packer').startup(function(use) 'nvim-lualine/lualine.nvim', requires = {'kyazdani42/nvim-web-devicons', opt = true} } + -- tabline + use {'romgrk/barbar.nvim', wants = 'nvim-web-devicons'} -- colour theme of the $CURRENT_YEAR use 'rose-pine/neovim' -- cgit v1.2.3-70-g09d2