From c8a88f5f15dc853777612026f07f2db4e8c86c43 Mon Sep 17 00:00:00 2001 From: RhiobeT Date: Tue, 12 Jul 2022 14:23:56 +0200 Subject: [PATCH] [NeoVim] Add diffview --- .config/nvim/init.lua | 29 +++++++++++++++++++++++++---- .config/nvim/lua/plugins.lua | 2 ++ 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/.config/nvim/init.lua b/.config/nvim/init.lua index 8fb8020..fd52c45 100644 --- a/.config/nvim/init.lua +++ b/.config/nvim/init.lua @@ -38,7 +38,8 @@ require('feline').setup { '^fugitive$', '^fugitiveblame$', '^qf$', - '^help$' + '^help$', + '^DiffviewFileHistory' }, buftypes = { '^terminal$' @@ -80,13 +81,16 @@ require('neo-tree').setup({ filtered_items = { visible = true }, - follow_current_file = true,window = { + follow_current_file = true, + window = { mappings = { ["/"] = "noop", ["g/"] = "fuzzy_finder", ["f"] = "noop", ["ff"] = function() vim.cmd([[Telescope find_files]]) end, - ["fg"] = function() vim.cmd([[Telescope live_grep]]) end + ["fg"] = function() vim.cmd([[Telescope live_grep]]) end, + [""] = function() end, + [""] = function() end } } }, @@ -216,6 +220,23 @@ require('telescope').setup({ }) +require('diffview').setup({ + keymaps = { + view = { + ["q"] = "tabc" + }, + file_panel = { + ["q"] = "tabc" + }, + file_history_panel = { + ["q"] = "tabc" + } + } +}) +vim.keymap.set("n", "r", "DiffviewOpen") +vim.keymap.set("n", "R", "DiffviewFileHistory %") + + vim.o.clipboard = 'unnamedplus' vim.o.expandtab = true vim.o.fileencoding = 'utf-8' @@ -230,7 +251,7 @@ vim.o.spelllang = 'en' vim.o.tabstop = 2 -if vim.fn.expand('%') == '' then +if vim.fn.expand('%') == '' or vim.fn.isdirectory(vim.fn.expand('%')) ~= 0 then require("neo-tree.command")._command(vim.fn.getcwd()) else require("neo-tree.command")._command("show", vim.fn.getcwd()) diff --git a/.config/nvim/lua/plugins.lua b/.config/nvim/lua/plugins.lua index 9c39cdd..f87a6f3 100644 --- a/.config/nvim/lua/plugins.lua +++ b/.config/nvim/lua/plugins.lua @@ -44,4 +44,6 @@ return require('packer').startup(function() use {'nvim-telescope/telescope.nvim', requires = 'nvim-lua/plenary.nvim'} + use { 'sindrets/diffview.nvim', requires = 'nvim-lua/plenary.nvim' } + end)