Add sidebar, adjust settings for nvim-tree and aerial to work together

This commit is contained in:
Evie Litherland-Smith 2023-01-25 18:36:39 +00:00
parent d6e2c38ef7
commit 79bc4e86f5
7 changed files with 105 additions and 41 deletions

View file

@ -1,14 +1,16 @@
require('aerial').setup {
backends = { "treesitter", "lsp", "markdown", "man" },
local aerial = require('aerial')
aerial.setup {
backends = { "lsp", "treesitter", "markdown", "man" },
layout = {
default_direction = "right", -- "float",
default_direction = "float",
placement = "edge",
},
attach_mode = "global",
highlight_mode = "none",
lazy_load = false,
on_attach = function(bufnr)
-- Toggle the aerial window with <leader>a
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>k', '<cmd>AerialToggle!<CR>', {})
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>a', '<cmd>AerialToggle!<CR>', {})
-- Jump forwards/backwards with '{' and '}'
vim.api.nvim_buf_set_keymap(bufnr, 'n', '{', '<cmd>AerialPrev<CR>', {})
vim.api.nvim_buf_set_keymap(bufnr, 'n', '}', '<cmd>AerialNext<CR>', {})
@ -17,4 +19,6 @@ require('aerial').setup {
vim.api.nvim_buf_set_keymap(bufnr, 'n', ']]', '<cmd>AerialNextUp<CR>', {})
end,
open_automatic = false,
close_automatic_events = { "unfocus", "switch_buffer", "unsupported" },
show_guides = true,
}

View file

@ -5,21 +5,41 @@ require('gitsigns').setup {
current_line_blame = true,
word_diff = false,
on_attach = function(bufnr)
-- Setup keymaps
vim.api.nvim_buf_set_keymap(bufnr, 'n', '[g', '<cmd>Gitsigns prev_hunk<CR>', {})
vim.api.nvim_buf_set_keymap(bufnr, 'n', ']g', '<cmd>Gitsigns next_hunk<CR>', {})
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>d', '<cmd>Gitsigns diffthis<CR>', {})
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>gq', '<cmd>Gitsigns setqflist<CR>', {})
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>gl', '<cmd>Gitsigns setloclist<CR>', {})
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>hp', '<cmd>Gitsigns preview_hunk<CR>', {})
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>hs', '<cmd>Gitsigns stage_hunk<CR>', {})
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>hr', '<cmd>Gitsigns reset_hunk<CR>', {})
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>bs', '<cmd>Gitsigns stage_buffer<CR>', {})
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>br', '<cmd>Gitsigns reset_buffer<CR>', {})
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>lb', '<cmd>Gitsigns blame_line<CR>', {})
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>btn', '<cmd>Gitsigns toggle_numhl<CR>', {})
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>btl', '<cmd>Gitsigns toggle_linehl<CR>', {})
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>btc', '<cmd>Gitsigns toggle_current_line_blame<CR>', {})
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>btw', '<cmd>Gitsigns toggle_word_diff<CR>', {})
local gs = package.loaded.gitsigns
local function map(mode, l, r, opts)
opts = opts or {}
opts.buffer = bufnr
vim.keymap.set(mode, l, r, opts)
end
-- Navigation
map('n', ']c', function()
if vim.wo.diff then return ']c' end
vim.schedule(function() gs.next_hunk() end)
return '<Ignore>'
end, {expr=true})
map('n', '[c', function()
if vim.wo.diff then return '[c' end
vim.schedule(function() gs.prev_hunk() end)
return '<Ignore>'
end, {expr=true})
-- Actions
map({'n', 'v'}, '<leader>hs', ':Gitsigns stage_hunk<CR>')
map({'n', 'v'}, '<leader>hr', ':Gitsigns reset_hunk<CR>')
map('n', '<leader>hS', gs.stage_buffer)
map('n', '<leader>hu', gs.undo_stage_hunk)
map('n', '<leader>hR', gs.reset_buffer)
map('n', '<leader>hp', gs.preview_hunk)
map('n', '<leader>hb', function() gs.blame_line{full=true} end)
map('n', '<leader>tb', gs.toggle_current_line_blame)
map('n', '<leader>hd', gs.diffthis)
map('n', '<leader>hD', function() gs.diffthis('~') end)
map('n', '<leader>td', gs.toggle_deleted)
-- Text object
map({'o', 'x'}, 'ih', ':<C-U>Gitsigns select_hunk<CR>')
end,
}

View file

@ -1,20 +1,47 @@
vim.g.loaded_netrw = 1
vim.g.loaded_netrwPlugin = 1
vim.opt.termguicolors = true
require('nvim-tree').setup {
open_on_setup=false,
open_on_setup_file=false,
hijack_cursor=false,
sync_root_with_cwd=true,
disable_netrw = true,
open_on_setup = true,
open_on_setup_file = true,
hijack_cursor = true,
update_focused_file = {
enable = true,
update_root = true,
},
diagnostics = {
enable = true,
show_on_dirs = false,
show_on_dirs = true,
show_on_open_dirs = false,
},
git = {
enable = true,
show_on_dirs = true,
show_on_open_dirs = false,
},
modified = {
enable = true,
show_on_dirs = true,
show_on_open_dirs = false,
},
view = {
centralize_selection = true,
},
filters = { custom = { "^.git$" } },
renderer = {
add_trailing = true,
group_empty = true,
full_name = true,
highlight_git = true,
highlight_modified = "name",
indent_markers = {
enable = true,
},
icons = {
show = {
git = false,
modified = false,
},
},
},
}

View file

@ -0,0 +1,17 @@
require("sidebar-nvim").setup({
disable_default_keybindings = 0,
bindings = nil,
open = true,
side = "right",
initial_width = 35,
hide_statusline = false,
update_interval = 1000,
sections = { "git", "diagnostics", "symbols" },
section_separator = { "-----" },
section_title_separator = { "" },
containers = {
attach_shell = "/bin/sh", show_all = true, interval = 5000,
},
datetime = { format = "%a %b %d, %H:%M", clocks = { { name = "local" } } },
todos = { ignored_paths = { "~" } },
})

View file

@ -13,33 +13,26 @@ end
vim.g.mapleader = ' '
-- Misc
imap('jk', '<Esc>')
nmap('<leader>gu', '<cmd>Git pull<cr>')
nmap('<leader>gl', '<cmd>Git pull<cr>')
nmap('<leader>gp', '<cmd>Git push<cr>')
nmap('<leader>cc', '<cmd>Git commit<cr>')
-- Telescope
nmap('<leader>;', '<cmd>Telescope builtin<cr>')
nmap('<leader>ff', '<cmd>Telescope find_files<cr>')
nmap('<leader>fr', '<cmd>Telescope resume<cr>')
nmap('<leader>fb', '<cmd>Telescope buffers<cr>')
nmap('<leader>fh', '<cmd>Telescope help_tags<cr>')
nmap('<leader>fk', '<cmd>Telescope aerial<cr>')
nmap('<leader>fa', '<cmd>Telescope aerial<cr>')
nmap('<leader>fd', '<cmd>Telescope lsp_document_symbols<cr>')
nmap('<leader>fe', '<cmd>Telescope diagnostics<cr>')
nmap('<leader>fn', '<cmd>Telescope notify<cr>')
nmap('<leader>ft', '<cmd>Telescope treesitter<cr>')
nmap('<leader>fz', '<cmd>Telescope current_buffer_fuzzy_find<cr>')
nmap('<leader>gg', '<cmd>Telescope git_status<cr>')
nmap('<leader>gc', '<cmd>Telescope git_commits<cr>')
nmap('<leader>gb', '<cmd>Telescope git_bcommits<cr>')
nmap('<leader>co', '<cmd>Telescope git_branches<cr>')
-- Hop
nmap('<leader>hl', '<cmd>HopLine<cr>')
nmap('<leader>hw', '<cmd>HopWord<cr>')
-- Nvim-tree
nmap('<leader>nt', '<cmd>NvimTreeToggle<cr>')
nmap('<leader>n', '<cmd>NvimTreeToggle<cr>')
nmap('<leader>s', '<cmd>SidebarNvimToggle<cr>')
-- Trouble
nmap('<leader>xx', '<cmd>TroubleToggle<cr>')
@ -47,6 +40,3 @@ nmap('<leader>xw', '<cmd>TroubleToggle workspace_diagnostics<cr>')
nmap('<leader>xd', '<cmd>TroubleToggle document_diagnostics<cr>')
nmap('<leader>xq', '<cmd>TroubleToggle quickfix<cr>')
nmap('<leader>xl', '<cmd>TroubleToggle loclist<cr>')
-- SnipRun
nmap('<leader>sr', '<cmd>%SnipRun<cr>')

View file

@ -7,7 +7,7 @@ vim.g.python_indent = {
closed_paren_align_last_line = 'v:false',
}
vim.opt.termguicolors = true
vim.opt.mouse = "nvi"
vim.opt.mouse = "nv"
vim.opt.shiftwidth = 4
vim.opt.number = true
vim.opt.relativenumber = true

View file

@ -84,6 +84,12 @@ require('packer').startup {
require 'config_plugins.config_nvim-tree'
end
}
use {
'sidebar-nvim/sidebar.nvim',
config = function()
require 'config_plugins.config_sidebar'
end
}
use {
'akinsho/toggleterm.nvim',
tag = 'v2.*',