From 47f493b2036849b298a0483d53ffaa875066efa4 Mon Sep 17 00:00:00 2001 From: Daniel Carrillo Date: Sat, 7 Oct 2023 19:15:40 +0200 Subject: [PATCH] [neovim] Show the base directory of the current project to the left side of the buffer line --- .config/nvim/lua/plugins/bufferline.lua | 27 ++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/.config/nvim/lua/plugins/bufferline.lua b/.config/nvim/lua/plugins/bufferline.lua index feb537e..9278b7d 100644 --- a/.config/nvim/lua/plugins/bufferline.lua +++ b/.config/nvim/lua/plugins/bufferline.lua @@ -1,4 +1,18 @@ -require("bufferline").setup({ +local bufferline = require("bufferline") + +local function is_buffer_loaded(name) + local bufs = vim.api.nvim_list_bufs() + + for _, buffer in pairs(bufs) do + if vim.fn.getbufvar(buffer, "&filetype") == name then + return true + end + end + + return false +end + +bufferline.setup({ options = { close_command = "Bdelete! %d", right_mouse_command = "Bdelete! %d", @@ -13,5 +27,16 @@ require("bufferline").setup({ enabled = false, }, separator_style = "slant", + + custom_areas = { + left = function() + local text = "" + if not is_buffer_loaded("neo-tree") then + text = "  " .. string.gsub(vim.loop.cwd(), "^" .. os.getenv("HOME"), "~") .. "  " + end + + return { { text = text, fg = "#636E7B" } } + end, + }, }, })