Add bufferline options to always show the bufferline, use ordinal numbers, and sort by insert position in the current setup
This commit is contained in:
		
							parent
							
								
									e7b27047e2
								
							
						
					
					
						commit
						606b0572d2
					
				| 
						 | 
					@ -10,3 +10,5 @@ vim.opt.scrolloff = 8
 | 
				
			||||||
vim.opt.colorcolumn = "80"
 | 
					vim.opt.colorcolumn = "80"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
vim.opt.swapfile = false
 | 
					vim.opt.swapfile = false
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					vim.o.cmdheight = 2
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,17 @@
 | 
				
			||||||
 | 
					set grepprg=rg\ --vimgrep
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					function! Grep(...)
 | 
				
			||||||
 | 
						return system(join([&grepprg] + [expandcmd(join(a:000, ' '))], ' '))
 | 
				
			||||||
 | 
					endfunction
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					command! -nargs=+ -complete=file_in_path -bar Grep  cgetexpr Grep(<f-args>)
 | 
				
			||||||
 | 
					command! -nargs=+ -complete=file_in_path -bar LGrep lgetexpr Grep(<f-args>)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					cnoreabbrev <expr> grep  (getcmdtype() ==# ':' && getcmdline() ==# 'grep')  ? 'Grep'  : 'grep'
 | 
				
			||||||
 | 
					cnoreabbrev <expr> lgrep (getcmdtype() ==# ':' && getcmdline() ==# 'lgrep') ? 'LGrep' : 'lgrep'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					augroup quickfix
 | 
				
			||||||
 | 
						autocmd!
 | 
				
			||||||
 | 
						autocmd QuickFixCmdPost cgetexpr TroubleToggle quickfix
 | 
				
			||||||
 | 
						autocmd QuickFixCmdPost lgetexpr TroubleToggle loclist
 | 
				
			||||||
 | 
					augroup END
 | 
				
			||||||
| 
						 | 
					@ -1,5 +1,4 @@
 | 
				
			||||||
local function open_nvim_tree(data)
 | 
					local function open_nvim_tree(data)
 | 
				
			||||||
 | 
					 | 
				
			||||||
  -- buffer is a real file on the disk
 | 
					  -- buffer is a real file on the disk
 | 
				
			||||||
  local real_file = vim.fn.filereadable(data.file) == 1
 | 
					  local real_file = vim.fn.filereadable(data.file) == 1
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -18,8 +17,8 @@ end
 | 
				
			||||||
-- vim.api.nvim_create_autocmd({ "VimEnter" }, { callback = open_nvim_tree })
 | 
					-- vim.api.nvim_create_autocmd({ "VimEnter" }, { callback = open_nvim_tree })
 | 
				
			||||||
 | 
					
 | 
				
			||||||
-- Auto close
 | 
					-- Auto close
 | 
				
			||||||
vim.api.nvim_create_autocmd({"QuitPre"}, {
 | 
					vim.api.nvim_create_autocmd({ "QuitPre" }, {
 | 
				
			||||||
    callback = function() vim.cmd("NvimTreeClose") end,
 | 
					  callback = function() vim.cmd("NvimTreeClose") end,
 | 
				
			||||||
})
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
-- Go to last used hidden buffer when deleting a buffer
 | 
					-- Go to last used hidden buffer when deleting a buffer
 | 
				
			||||||
| 
						 | 
					@ -32,9 +31,9 @@ vim.api.nvim_create_autocmd("BufEnter", {
 | 
				
			||||||
      -- Required to let the close event complete. An error is thrown without this.
 | 
					      -- Required to let the close event complete. An error is thrown without this.
 | 
				
			||||||
      vim.defer_fn(function()
 | 
					      vim.defer_fn(function()
 | 
				
			||||||
        -- close nvim-tree: will go to the last hidden buffer used before closing
 | 
					        -- close nvim-tree: will go to the last hidden buffer used before closing
 | 
				
			||||||
        api.tree.toggle({find_file = true, focus = true})
 | 
					        api.tree.toggle({ find_file = true, focus = true })
 | 
				
			||||||
        -- re-open nivm-tree
 | 
					        -- re-open nivm-tree
 | 
				
			||||||
        api.tree.toggle({find_file = true, focus = true})
 | 
					        api.tree.toggle({ find_file = true, focus = true })
 | 
				
			||||||
        -- nvim-tree is still the active window. Go to the previous window.
 | 
					        -- nvim-tree is still the active window. Go to the previous window.
 | 
				
			||||||
        vim.cmd("wincmd p")
 | 
					        vim.cmd("wincmd p")
 | 
				
			||||||
      end, 0)
 | 
					      end, 0)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,39 +1,11 @@
 | 
				
			||||||
local keymap = vim.keymap.set
 | 
					local keymap = vim.keymap.set
 | 
				
			||||||
local trouble = require("trouble")
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
vim.api.nvim_create_autocmd('DiagnosticChanged', {
 | 
					 | 
				
			||||||
    callback = function()
 | 
					 | 
				
			||||||
        vim.diagnostic.setqflist({ open = false })
 | 
					 | 
				
			||||||
        vim.diagnostic.setloclist({ open = false })
 | 
					 | 
				
			||||||
    end,
 | 
					 | 
				
			||||||
})
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
function QuickFixToggle()
 | 
					 | 
				
			||||||
    if trouble.is_open() then
 | 
					 | 
				
			||||||
        trouble.close()
 | 
					 | 
				
			||||||
    else
 | 
					 | 
				
			||||||
        trouble.open({
 | 
					 | 
				
			||||||
            mode = "quickfix"
 | 
					 | 
				
			||||||
        })
 | 
					 | 
				
			||||||
    end
 | 
					 | 
				
			||||||
end
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
function LocationListToggle()
 | 
					 | 
				
			||||||
    if trouble.is_open() then
 | 
					 | 
				
			||||||
        trouble.close()
 | 
					 | 
				
			||||||
    else
 | 
					 | 
				
			||||||
        trouble.open({
 | 
					 | 
				
			||||||
            mode = "loclist"
 | 
					 | 
				
			||||||
        })
 | 
					 | 
				
			||||||
    end
 | 
					 | 
				
			||||||
end
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
-- Quickfix
 | 
					-- Quickfix
 | 
				
			||||||
keymap("n", "<leader>qq", ":lua QuickFixToggle()<CR>", { desc = "[Q]uickfix [Q]uick" })
 | 
					keymap("n", "<leader>qq", ":TroubleToggle quickfix<CR>", { desc = "[Q]uickfix [Q]uick" })
 | 
				
			||||||
keymap("n", "<leader>qn", "<cmd>cnext<CR>zz", { desc = "[Q]uick [N]ext" })
 | 
					keymap("n", "<leader>qn", "<cmd>cnext<CR>zz", { desc = "[Q]uick [N]ext" })
 | 
				
			||||||
keymap("n", "<leader>qp", "<cmd>cprev<CR>zz", { desc = "[Q]uick [P]revious" })
 | 
					keymap("n", "<leader>qp", "<cmd>cprev<CR>zz", { desc = "[Q]uick [P]revious" })
 | 
				
			||||||
 | 
					
 | 
				
			||||||
-- Location List
 | 
					-- Location List
 | 
				
			||||||
keymap("n", "<leader>ll", ":lua LocationListToggle()<CR>", { desc = "[L]ocation [L]ist" })
 | 
					keymap("n", "<leader>ll", ":TroubleToggle loclist<CR>", { desc = "[L]ocation [L]ist" })
 | 
				
			||||||
keymap("n", "<leader>ln", "<cmd>lnext<CR>zz", { desc = "[L]ocation [N]ext" })
 | 
					keymap("n", "<leader>ln", "<cmd>lnext<CR>zz", { desc = "[L]ocation [N]ext" })
 | 
				
			||||||
keymap("n", "<leader>lp", "<cmd>lprev<CR>zz", { desc = "[L]ocation [P]revious" })
 | 
					keymap("n", "<leader>lp", "<cmd>lprev<CR>zz", { desc = "[L]ocation [P]revious" })
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										2
									
								
								init.lua
								
								
								
								
							
							
						
						
									
										2
									
								
								init.lua
								
								
								
								
							| 
						 | 
					@ -399,7 +399,7 @@ local on_attach = function(_, bufnr)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  -- See `:help K` for why this keymap
 | 
					  -- See `:help K` for why this keymap
 | 
				
			||||||
  nmap('K', vim.lsp.buf.hover, 'Hover Documentation')
 | 
					  nmap('K', vim.lsp.buf.hover, 'Hover Documentation')
 | 
				
			||||||
  nmap('<C-K>', vim.lsp.buf.signature_help, 'Signature Documentation')
 | 
					  -- nmap('<C-K>', vim.lsp.buf.signature_help, 'Signature Documentation')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  -- Lesser used LSP functionality
 | 
					  -- Lesser used LSP functionality
 | 
				
			||||||
  nmap('gD', vim.lsp.buf.declaration, '[G]oto [D]eclaration')
 | 
					  nmap('gD', vim.lsp.buf.declaration, '[G]oto [D]eclaration')
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -4,12 +4,14 @@ return {
 | 
				
			||||||
        config = function()
 | 
					        config = function()
 | 
				
			||||||
            require("bufferline").setup {
 | 
					            require("bufferline").setup {
 | 
				
			||||||
                options = {
 | 
					                options = {
 | 
				
			||||||
 | 
					                    numbers = "ordinal",
 | 
				
			||||||
                    indicator = { style = "icon", icon = "▎" },
 | 
					                    indicator = { style = "icon", icon = "▎" },
 | 
				
			||||||
                    diagnostics = 'nvim_lsp', -- | "nvim_lsp" | "coc",
 | 
					                    diagnostics = 'nvim_lsp', -- | "nvim_lsp" | "coc",
 | 
				
			||||||
                    diagnostics_update_in_insert = false,
 | 
					                    diagnostics_update_in_insert = false,
 | 
				
			||||||
                    offsets = { { filetype = "NvimTree", text = "File Explorer", padding = 1 } },
 | 
					                    offsets = { { filetype = "NvimTree", text = "File Explorer", padding = 1 } },
 | 
				
			||||||
                    separator_style = "thin", -- | "thick" | "thin" | { 'any', 'any' },
 | 
					                    separator_style = "thin", -- | "thick" | "thin" | { 'any', 'any' },
 | 
				
			||||||
                    always_show_bufferline = true,
 | 
					                    always_show_bufferline = true,
 | 
				
			||||||
 | 
					                    sort_by = "insert_after_current"
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        end
 | 
					        end
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue