From 1441e907117fee2291ba85f1bd79859c194725f9 Mon Sep 17 00:00:00 2001 From: jiriks74 Date: Tue, 24 Sep 2024 21:42:42 +0200 Subject: [PATCH] feat(plugins): Add bufferline, remove rainbow ident-blankline Added: - [bufferline.nvim](https://github.com/akinsho/bufferline.nvim) - Overseer status to lualine Removed: - `{` and `}` keymaps for aerial (I like the default behavior more) --- nix/neovim-overlay.nix | 1 + nvim/plugin/aerial.lua | 10 ++-- nvim/plugin/ident-blankline.lua | 50 +++++++++--------- nvim/plugin/keymaps.lua | 45 ++++++++++++---- nvim/plugin/lualine.lua | 91 +++++++++++++++++++-------------- nvim/plugin/plugins.lua | 1 + 6 files changed, 118 insertions(+), 80 deletions(-) diff --git a/nix/neovim-overlay.nix b/nix/neovim-overlay.nix index e2b6a66..eddbc09 100644 --- a/nix/neovim-overlay.nix +++ b/nix/neovim-overlay.nix @@ -67,6 +67,7 @@ with final.pkgs.lib; let # UI lualine-nvim # Status line | https://github.com/nvim-lualine/lualine.nvim/ + bufferline-nvim # A snazzy bufferline for Neovim | https://github.com/akinsho/bufferline.nvim dressing-nvim # Improve the default vim.ui interfaces | https://github.com/stevearc/dressing.nvim nvim-navic # Add LSP location to lualine | https://github.com/SmiteshP/nvim-navic statuscol-nvim # Status column | https://github.com/luukvbaal/statuscol.nvim/ diff --git a/nvim/plugin/aerial.lua b/nvim/plugin/aerial.lua index 7440a94..d0d4627 100644 --- a/nvim/plugin/aerial.lua +++ b/nvim/plugin/aerial.lua @@ -5,11 +5,11 @@ vim.g.did_load_aerial_plugin = true require("aerial").setup({ -- optionally use on_attach to set keymaps when aerial has attached to a buffer - on_attach = function(bufnr) - -- Jump forwards/backwards with '{' and '}' - vim.keymap.set("n", "{", "AerialPrev", { buffer = bufnr }) - vim.keymap.set("n", "}", "AerialNext", { buffer = bufnr }) - end, + -- on_attach = function(bufnr) + -- -- Jump forwards/backwards with '{' and '}' + -- vim.keymap.set("n", "{", "AerialPrev", { buffer = bufnr }) + -- vim.keymap.set("n", "}", "AerialNext", { buffer = bufnr }) + -- end, }) -- You probably also want to set a keymap to toggle aerial vim.keymap.set("n", "a", "AerialToggle!") diff --git a/nvim/plugin/ident-blankline.lua b/nvim/plugin/ident-blankline.lua index a0365b5..9ec5a16 100644 --- a/nvim/plugin/ident-blankline.lua +++ b/nvim/plugin/ident-blankline.lua @@ -3,31 +3,31 @@ if vim.g.did_load_ibl_plugin then end vim.g.did_load_ibl_plugin = true -local highlight = { - "RainbowRed", - "RainbowYellow", - "RainbowBlue", - "RainbowOrange", - "RainbowGreen", - "RainbowViolet", - "RainbowCyan", -} - -local hooks = require "ibl.hooks" --- create the highlight groups in the highlight setup hook, so they are reset --- every time the colorscheme changes -hooks.register(hooks.type.HIGHLIGHT_SETUP, function() - vim.api.nvim_set_hl(0, "RainbowRed", { fg = "#E06C75" }) - vim.api.nvim_set_hl(0, "RainbowYellow", { fg = "#E5C07B" }) - vim.api.nvim_set_hl(0, "RainbowBlue", { fg = "#61AFEF" }) - vim.api.nvim_set_hl(0, "RainbowOrange", { fg = "#D19A66" }) - vim.api.nvim_set_hl(0, "RainbowGreen", { fg = "#98C379" }) - vim.api.nvim_set_hl(0, "RainbowViolet", { fg = "#C678DD" }) - vim.api.nvim_set_hl(0, "RainbowCyan", { fg = "#56B6C2" }) -end) +-- local highlight = { +-- "RainbowRed", +-- "RainbowYellow", +-- "RainbowBlue", +-- "RainbowOrange", +-- "RainbowGreen", +-- "RainbowViolet", +-- "RainbowCyan", +-- } +-- +-- local hooks = require "ibl.hooks" +-- -- create the highlight groups in the highlight setup hook, so they are reset +-- -- every time the colorscheme changes +-- -- hooks.register(hooks.type.HIGHLIGHT_SETUP, function() +-- vim.api.nvim_set_hl(0, "RainbowRed", { fg = "#E06C75" }) +-- vim.api.nvim_set_hl(0, "RainbowYellow", { fg = "#E5C07B" }) +-- vim.api.nvim_set_hl(0, "RainbowBlue", { fg = "#61AFEF" }) +-- vim.api.nvim_set_hl(0, "RainbowOrange", { fg = "#D19A66" }) +-- vim.api.nvim_set_hl(0, "RainbowGreen", { fg = "#98C379" }) +-- vim.api.nvim_set_hl(0, "RainbowViolet", { fg = "#C678DD" }) +-- vim.api.nvim_set_hl(0, "RainbowCyan", { fg = "#56B6C2" }) +-- end) require("ibl").setup{ - indent = { - highlight = highlight - } + -- indent = { + -- highlight = highlight + -- } } diff --git a/nvim/plugin/keymaps.lua b/nvim/plugin/keymaps.lua index bd10414..88d3416 100644 --- a/nvim/plugin/keymaps.lua +++ b/nvim/plugin/keymaps.lua @@ -11,11 +11,37 @@ local diagnostic = vim.diagnostic -- Yank from current position till end of current line keymap.set('n', 'Y', 'y$', { silent = true, desc = '[Y]ank to end of line' }) --- Buffer list navigation -keymap.set('n', '[b', vim.cmd.bprevious, { silent = true, desc = 'previous [b]uffer' }) -keymap.set('n', ']b', vim.cmd.bnext, { silent = true, desc = 'next [b]uffer' }) -keymap.set('n', '[B', vim.cmd.bfirst, { silent = true, desc = 'first [B]uffer' }) -keymap.set('n', ']B', vim.cmd.blast, { silent = true, desc = 'last [B]uffer' }) +require('which-key').add({ + -- Buffer list navigation, ordering, ... + { "", "BufferLineTogglePin", desc = '[p]in buffer' }, + { "gB", "BufferLinePick", desc = '[g]o to [b]uffer' }, + { '>b', "BufferLineMoveNext", desc = 'move [b]uffer right' }, + { 'BufferLineMovePrev", desc = 'move [b]uffer left' }, + { '[b', "BufferLineCyclePrev", desc = 'previous [b]uffer' }, + { ']b', "BufferLineCycleNext", desc = 'next [b]uffer' }, + { '[B', vim.cmd.bfirst, desc = 'first [B]uffer' }, + { ']B', vim.cmd.blast, desc = 'last [B]uffer' }, + { 'tn', vim.cmd.tabnew, desc = '[t]ab: [n]ew' }, + { 'tq', "bd", desc = '[t]ab: [q]uit/close' }, + { 'c', "bd", desc = '[c]lose tab' }, + + -- Window resizing + { "", "resize +2", desc = "resize split up" }, + { "", "resize -2", desc = "resize split down" }, + { "", "vertical resize -2", desc = "resize split left" }, + { "", "vertical resize +2", desc = "resize split right" }, + + -- ToggleTerm + { "Tf", "ToggleTerm direction=float", desc = "[T]oggleTerm [f]loat" }, + { "Th", "ToggleTerm size=10 direction=horizontal", desc = "[T]oggleTerm [h]orizontal split" }, + { "Tv", "ToggleTerm size=80 direction=vertical", desc = "[T]oggleTerm [v]ertical split" }, + { "", 'execute v:count . "ToggleTerm"', desc = "Toggle terminal" }, + { mode = "t", "", "ToggleTerm", desc = "Toggle terminal" }, + { mode = "i", "", "ToggleTerm", desc = "Toggle terminal" }, + { "", 'execute v:count . "ToggleTerm"', desc = "Toggle terminal" }, -- requires terminal that supports binding + { "", "ToggleTerm", desc = "Toggle terminal" }, -- requires terminal that supports binding + { "", "ToggleTerm", desc = "Toggle terminal" }, -- requires terminal that supports binding ` +}) -- Toggle the quickfix list (only opens if it is populated) local function toggle_qf_list() @@ -35,8 +61,8 @@ local function toggle_qf_list() end keymap.set('n', '', toggle_qf_list, { desc = 'toggle quickfix list' }) -keymap.set({ "v", "n" }, "gf", require("actions-preview").code_actions, { desc = '[l]sp [f]ix'}) -keymap.set({ "v", "n" }, "lf", require("actions-preview").code_actions, { desc = '[l]sp [f]ix'}) +keymap.set({ "v", "n" }, "gf", require("actions-preview").code_actions, { desc = '[l]sp [f]ix' }) +keymap.set({ "v", "n" }, "lf", require("actions-preview").code_actions, { desc = '[l]sp [f]ix' }) local function try_fallback_notify(opts) local success, _ = pcall(opts.try) @@ -130,9 +156,6 @@ keymap.set('c', '%%', function() end end, { expr = true, desc = "expand to current buffer's directory" }) -keymap.set('n', 'tn', vim.cmd.tabnew, { desc = '[t]ab: [n]ew' }) --- keymap.set('n', 'tq', vim.cmd.tabclose, { desc = '[t]ab: [q]uit/close' }) -keymap.set('n', 'tq', "bd", { desc = '[t]ab: [q]uit/close' }) local severity = diagnostic.severity @@ -194,7 +217,7 @@ keymap.set('n', '', 'wincmd j', { desc = 'focus bottom window' }) keymap.set('n', '', 'wincmd k', { desc = 'focus top window' }) keymap.set('n', '', 'wincmd l', { desc = 'focus right window' }) -keymap.set('n', 'tt', 'TodoTelescope', { desc = '[t]elescope [t]odo comments'}) +keymap.set('n', 'tt', 'TodoTelescope', { desc = '[t]elescope [t]odo comments' }) --- Disabled keymaps [enable at your own risk] diff --git a/nvim/plugin/lualine.lua b/nvim/plugin/lualine.lua index ce85f64..57139cd 100644 --- a/nvim/plugin/lualine.lua +++ b/nvim/plugin/lualine.lua @@ -34,6 +34,7 @@ require('lualine').setup { -- nvim-navic -- { navic.get_location, cond = navic.is_available }, }, + lualine_y = { "overseer" }, lualine_z = { -- (see above) { extra_mode_status }, @@ -41,48 +42,60 @@ require('lualine').setup { }, options = { theme = 'auto', + -- component_separators = { left = '', right = ''}, + component_separators = { left = '', right = ''}, + -- section_separators = { left = '', right = ''}, + section_separators = { left = '', right = ''}, + ignore_focus = { + "dapui_scopes", + "dapui_breakpoints", + "dapui_stacks", + "dapui_watches", + "dap-repl", + "dapui_console" + }, }, -- Example top tabline configuration (this may clash with other plugins) - tabline = { - -- lualine_a = { - -- { - -- 'tabs', - -- mode = 1, - -- }, - -- }, - -- lualine_b = { - lualine_a = { - { - 'buffers', - show_filename_only = true, - show_bufnr = true, - mode = 4, - filetype_names = { - TelescopePrompt = 'Telescope', - dashboard = 'Dashboard', - fzf = 'FZF', - }, - buffers_color = { - -- Same values as the general color option can be used here. - active = 'lualine_b_normal', -- Color for active buffer. - inactive = 'lualine_b_inactive', -- Color for inactive buffer. - }, - }, - }, - lualine_c = {}, - lualine_x = {}, - lualine_y = {}, - -- lualine_z = {}, -- Commented out so that buffers and file path are on the same line + -- tabline = { + -- lualine_a = { + -- { + -- 'tabs', + -- mode = 1, + -- }, + -- }, + -- lualine_b = { + -- lualine_a = { + -- { + -- 'buffers', + -- show_filename_only = true, + -- show_bufnr = true, + -- mode = 4, + -- filetype_names = { + -- TelescopePrompt = 'Telescope', + -- dashboard = 'Dashboard', + -- fzf = 'FZF', + -- }, + -- buffers_color = { + -- -- Same values as the general color option can be used here. + -- active = 'lualine_b_normal', -- Color for active buffer. + -- inactive = 'lualine_b_inactive', -- Color for inactive buffer. + -- }, + -- }, + -- }, + -- lualine_c = {}, + -- lualine_x = {}, + -- lualine_y = {}, + -- -- lualine_z = {}, -- Commented out so that buffers and file path are on the same line -- }, -- winbar = { - lualine_z = { - { - 'filename', - path = 1, - file_status = true, - newfile_status = true, - }, - }, - }, + -- lualine_z = { + -- { + -- 'filename', + -- path = 1, + -- file_status = true, + -- newfile_status = true, + -- }, + -- }, + -- }, extensions = { 'fugitive', 'fzf', 'toggleterm', 'quickfix' }, } diff --git a/nvim/plugin/plugins.lua b/nvim/plugin/plugins.lua index 96fe244..5731835 100644 --- a/nvim/plugin/plugins.lua +++ b/nvim/plugin/plugins.lua @@ -14,4 +14,5 @@ require('which-key').setup() require('Comment').setup() require("better_escape").setup() require("todo-comments").setup() +require("bufferline").setup{} require("toggleterm").setup()