From 0cc4ed7dd6fc5b06de245246723138996d449571 Mon Sep 17 00:00:00 2001 From: Saumit Dinesan Date: Fri, 14 Jul 2023 22:49:04 +0530 Subject: nvim: Adding basic neovim config --- .config/nvim/lua/justsaumit/bufferline-config.lua | 71 +++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 .config/nvim/lua/justsaumit/bufferline-config.lua (limited to '.config/nvim/lua/justsaumit/bufferline-config.lua') diff --git a/.config/nvim/lua/justsaumit/bufferline-config.lua b/.config/nvim/lua/justsaumit/bufferline-config.lua new file mode 100644 index 0000000..493bafc --- /dev/null +++ b/.config/nvim/lua/justsaumit/bufferline-config.lua @@ -0,0 +1,71 @@ +--vim.opt.termguicolors = true + +local status, bufferline = pcall(require, "bufferline") +if not status then + return +end + +require('bufferline').setup { + options = { + mode = "buffers", + numbers = "none", + close_command = "bdelete! %d", -- can be a string | function, see "Mouse actions" + right_mouse_command = "bdelete! %d", -- can be a string | function, see "Mouse actions" + left_mouse_command = "buffer %d", -- can be a string | function, see "Mouse actions" + middle_mouse_command = nil, -- can be a string | function, see "Mouse actions" + indicator = { + icon = '▎', + style = 'icon', + }, + buffer_close_icon = '󰠳', + modified_icon = '●', + close_icon = '', + -- close_icon = '', + left_trunc_marker = '', + right_trunc_marker = '', + max_name_length = 30, + max_prefix_length = 30, -- prefix used when a buffer is de-duplicated + tab_size = 22, + diagnostics = false, + diagnostics_update_in_insert = false, + offsets = { { filetype = "NvimTree", text = "", padding = 1 } }, + color_icons = true, + show_buffer_icons = true, + show_buffer_close_icons = true, + show_close_icon = true, + show_tab_indicators = true, + persist_buffer_sort = true, + separator_style = "thin", -- | "thick" | "thin" | slant, + enforce_regular_tabs = true, + always_show_bufferline = true, + name_formatter = function(buf) -- buf contains a "name", "path" and "bufnr" + -- remove extension from markdown files for example + if buf.name:match('%.md') then + return vim.fn.fnamemodify(buf.name, ':t:r') + end + end + } +} + +local opts = { noremap = true, silent = true } +local keymap = vim.keymap.set +keymap("", "", "", opts) +vim.g.mapleader = " " +vim.g.maplocalleader = " " + +--Leader+number -> tab change +for i = 1, 9 do + keymap("n", "" .. i, function() + require("bufferline").go_to_buffer(i, true) + end, opts) +end + +--Ctrl+W to close a buffer +keymap("n", "W", ":bdelete!", opts) + + +--Tab or Ctrl+Tab for Forward Cycle //terminals don't see a difference between and +--Shift+Tab for Backward Cycle +keymap("n", "", ":BufferLineCycleNext", opts) +keymap("n", "", ":BufferLineCyclePrev", opts) + -- cgit v1.2.3