mirror of
https://github.com/m-housh/dotfiles.git
synced 2026-02-14 14:12:41 +00:00
Added neogit
This commit is contained in:
@@ -12,4 +12,3 @@ require('autocmd')
|
||||
|
||||
-- Theme
|
||||
require('theme')
|
||||
|
||||
|
||||
112
nvim/.config/nvim/lua/config/cmp.lua
Normal file
112
nvim/.config/nvim/lua/config/cmp.lua
Normal file
@@ -0,0 +1,112 @@
|
||||
-- Setup nvim-cmp.
|
||||
local cmp = require "cmp"
|
||||
local lspkind = require("lspkind")
|
||||
|
||||
local has_words_before = function()
|
||||
local line, col = unpack(vim.api.nvim_win_get_cursor(0))
|
||||
return col ~= 0
|
||||
and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(
|
||||
col, col):match("%s") == nil
|
||||
end
|
||||
|
||||
local feedkey = function(key, mode)
|
||||
vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes(key, true, true, true),
|
||||
mode, true)
|
||||
end
|
||||
|
||||
lspkind.init({
|
||||
symbol_map = {
|
||||
Text = "",
|
||||
Method = "",
|
||||
Function = "",
|
||||
Constructor = "",
|
||||
Field = "ﰠ",
|
||||
Variable = "",
|
||||
Class = "ﴯ",
|
||||
Interface = "",
|
||||
Module = "",
|
||||
Property = "ﰠ",
|
||||
Unit = "塞",
|
||||
Value = "",
|
||||
Enum = "",
|
||||
Keyword = "",
|
||||
Snippet = "",
|
||||
Color = "",
|
||||
File = "",
|
||||
Reference = "",
|
||||
Folder = "",
|
||||
EnumMember = "",
|
||||
Constant = "",
|
||||
Struct = "פּ",
|
||||
Event = "",
|
||||
Operator = "",
|
||||
TypeParameter = ""
|
||||
}
|
||||
})
|
||||
|
||||
cmp.setup({
|
||||
formatting = {
|
||||
format = lspkind.cmp_format {
|
||||
with_text = false,
|
||||
maxwidth = 50,
|
||||
menu = {
|
||||
buffer = "BUF",
|
||||
nvim_lsp = "LSP",
|
||||
path = "PATH",
|
||||
vsnip = "SNIP",
|
||||
calc = "CALC",
|
||||
spell = "SPELL",
|
||||
emoji = "EMOJI"
|
||||
}
|
||||
}
|
||||
},
|
||||
experimental = {native_menu = false, ghost_text = false},
|
||||
snippet = {
|
||||
expand = function(args)
|
||||
vim.fn["vsnip#anonymous"](args.body) -- For `vsnip` users.
|
||||
end
|
||||
},
|
||||
mapping = {
|
||||
["<C-p>"] = cmp.mapping.select_prev_item(),
|
||||
["<C-n>"] = cmp.mapping.select_next_item(),
|
||||
["<C-d>"] = cmp.mapping.scroll_docs(-4),
|
||||
["<C-f>"] = cmp.mapping.scroll_docs(4),
|
||||
["<C-Space>"] = cmp.mapping.complete(),
|
||||
["<C-e>"] = cmp.mapping.close(),
|
||||
["<CR>"] = cmp.mapping.confirm {
|
||||
behavior = cmp.ConfirmBehavior.Replace,
|
||||
select = false
|
||||
},
|
||||
["<Tab>"] = cmp.mapping(function(fallback)
|
||||
if cmp.visible() then
|
||||
cmp.select_next_item()
|
||||
elseif vim.fn["vsnip#available"](1) == 1 then
|
||||
feedkey("<Plug>(vsnip-expand-or-jump)", "")
|
||||
elseif has_words_before() then
|
||||
cmp.complete()
|
||||
else
|
||||
fallback() -- The fallback function sends a already mapped key. In this case, it's probably `<Tab>`.
|
||||
end
|
||||
end, {"i", "s"}),
|
||||
["<S-Tab>"] = cmp.mapping(function()
|
||||
if cmp.visible() then
|
||||
cmp.select_prev_item()
|
||||
elseif vim.fn["vsnip#jumpable"](-1) == 1 then
|
||||
feedkey("<Plug>(vsnip-jump-prev)", "")
|
||||
end
|
||||
end, {"i", "s"})
|
||||
},
|
||||
sources = {
|
||||
{name = "nvim_lsp"}, {name = "buffer", keyword_length = 5},
|
||||
{name = "vsnip"}, {name = "calc"}, {name = "emoji"}, {name = "spell"},
|
||||
{name = "path"}
|
||||
}
|
||||
})
|
||||
|
||||
-- Use buffer source for `/`.
|
||||
cmp.setup.cmdline("/", {sources = {{name = "buffer"}}})
|
||||
|
||||
-- Use cmdline & path source for ':'.
|
||||
cmp.setup.cmdline(":", {
|
||||
sources = cmp.config.sources({{name = "path"}}, {{name = "cmdline"}})
|
||||
})
|
||||
37
nvim/.config/nvim/lua/config/diffview.lua
Normal file
37
nvim/.config/nvim/lua/config/diffview.lua
Normal file
@@ -0,0 +1,37 @@
|
||||
local cb = require'diffview.config'.diffview_callback
|
||||
|
||||
require'diffview'.setup {
|
||||
diff_binaries = false, -- Show diffs for binaries
|
||||
use_icons = true, -- Requires nvim-web-devicons
|
||||
file_panel = {
|
||||
width = 35,
|
||||
},
|
||||
key_bindings = {
|
||||
disable_defaults = false, -- Disable the default key bindings
|
||||
-- The `view` bindings are active in the diff buffers, only when the current
|
||||
-- tabpage is a Diffview.
|
||||
view = {
|
||||
["<tab>"] = cb("select_next_entry"), -- Open the diff for the next file
|
||||
["<s-tab>"] = cb("select_prev_entry"), -- Open the diff for the previous file
|
||||
["<leader>e"] = cb("focus_files"), -- Bring focus to the files panel
|
||||
["<leader>b"] = cb("toggle_files"), -- Toggle the files panel.
|
||||
},
|
||||
file_panel = {
|
||||
["j"] = cb("next_entry"), -- Bring the cursor to the next file entry
|
||||
["<down>"] = cb("next_entry"),
|
||||
["k"] = cb("prev_entry"), -- Bring the cursor to the previous file entry.
|
||||
["<up>"] = cb("prev_entry"),
|
||||
["<cr>"] = cb("select_entry"), -- Open the diff for the selected entry.
|
||||
["o"] = cb("select_entry"),
|
||||
["<2-LeftMouse>"] = cb("select_entry"),
|
||||
["-"] = cb("toggle_stage_entry"), -- Stage / unstage the selected entry.
|
||||
["S"] = cb("stage_all"), -- Stage all entries.
|
||||
["U"] = cb("unstage_all"), -- Unstage all entries.
|
||||
["R"] = cb("refresh_files"), -- Update stats and entries in the file list.
|
||||
["<tab>"] = cb("select_next_entry"),
|
||||
["<s-tab>"] = cb("select_prev_entry"),
|
||||
["<leader>e"] = cb("focus_files"),
|
||||
["<leader>b"] = cb("toggle_files"),
|
||||
}
|
||||
}
|
||||
}
|
||||
32
nvim/.config/nvim/lua/config/neogit.lua
Normal file
32
nvim/.config/nvim/lua/config/neogit.lua
Normal file
@@ -0,0 +1,32 @@
|
||||
local neogit = require('neogit')
|
||||
--neogit.config.use_magit_keybindings()
|
||||
|
||||
neogit.setup {
|
||||
disable_signs = false,
|
||||
disable_context_highlighting = false,
|
||||
disable_commit_confirmation = false,
|
||||
-- customize displayed signs
|
||||
signs = {
|
||||
-- { CLOSED, OPENED }
|
||||
section = { ">", "v" },
|
||||
item = { ">", "v" },
|
||||
hunk = { "", "" },
|
||||
},
|
||||
integrations = {
|
||||
diffview = true
|
||||
},
|
||||
-- override/add mappings
|
||||
mappings = {
|
||||
-- modify status buffer mappings
|
||||
status = {
|
||||
-- Adds a mapping with "B" as key that does the "BranchPopup" command
|
||||
-- ["B"] = "BranchPopup",
|
||||
-- ["C"] = "CommitPopup",
|
||||
-- ["P"] = "PullPopup",
|
||||
-- ["S"] = "Stage",
|
||||
-- ["D"] = "Discard",
|
||||
-- Removes the default mapping of "s"
|
||||
-- ["s"] = "",
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -54,7 +54,21 @@ use {
|
||||
|
||||
use "nvim-treesitter/nvim-treesitter-textobjects"
|
||||
|
||||
use {
|
||||
"hrsh7th/nvim-cmp",
|
||||
requires = {
|
||||
{"hrsh7th/cmp-nvim-lsp"}, {"hrsh7th/cmp-buffer"}, {"hrsh7th/cmp-path"},
|
||||
{"hrsh7th/cmp-cmdline"}, {"hrsh7th/cmp-vsnip"},
|
||||
{"f3fora/cmp-spell", {"hrsh7th/cmp-calc"}, {"hrsh7th/cmp-emoji"}}
|
||||
},
|
||||
config = get_config("cmp")
|
||||
}
|
||||
|
||||
use {"onsails/lspkind-nvim", requires = {{"famiu/bufdelete.nvim"}}}
|
||||
|
||||
-- LSP
|
||||
use {"ray-x/lsp_signature.nvim", requires = {{"neovim/nvim-lspconfig"}}}
|
||||
|
||||
use {
|
||||
"neovim/nvim-lspconfig",
|
||||
config = get_config("lsp")
|
||||
@@ -64,9 +78,25 @@ use {
|
||||
config = get_config("lsp-installer")
|
||||
}
|
||||
|
||||
|
||||
use {"folke/which-key.nvim", event = "VimEnter", config = get_config("which")}
|
||||
|
||||
-- requirement for Neogit
|
||||
use {
|
||||
"sindrets/diffview.nvim",
|
||||
cmd = {
|
||||
"DiffviewOpen", "DiffviewClose", "DiffviewToggleFiles",
|
||||
"DiffviewFocusFiles"
|
||||
},
|
||||
config = get_config("diffview")
|
||||
}
|
||||
|
||||
use {
|
||||
"TimUntersberger/neogit",
|
||||
requires = {"nvim-lua/plenary.nvim"},
|
||||
cmd = "Neogit",
|
||||
config = get_config("neogit")
|
||||
}
|
||||
|
||||
-- Theme
|
||||
use {
|
||||
'EdenEast/nightfox.nvim',
|
||||
|
||||
@@ -69,24 +69,105 @@ end
|
||||
time([[try_loadstring definition]], false)
|
||||
time([[Defining packer_plugins]], true)
|
||||
_G.packer_plugins = {
|
||||
["bufdelete.nvim"] = {
|
||||
loaded = true,
|
||||
path = "/Users/michael/.local/share/nvim/site/pack/packer/start/bufdelete.nvim",
|
||||
url = "https://github.com/famiu/bufdelete.nvim"
|
||||
},
|
||||
["cmp-buffer"] = {
|
||||
loaded = true,
|
||||
path = "/Users/michael/.local/share/nvim/site/pack/packer/start/cmp-buffer",
|
||||
url = "https://github.com/hrsh7th/cmp-buffer"
|
||||
},
|
||||
["cmp-calc"] = {
|
||||
loaded = true,
|
||||
path = "/Users/michael/.local/share/nvim/site/pack/packer/start/cmp-calc",
|
||||
url = "https://github.com/hrsh7th/cmp-calc"
|
||||
},
|
||||
["cmp-cmdline"] = {
|
||||
loaded = true,
|
||||
path = "/Users/michael/.local/share/nvim/site/pack/packer/start/cmp-cmdline",
|
||||
url = "https://github.com/hrsh7th/cmp-cmdline"
|
||||
},
|
||||
["cmp-emoji"] = {
|
||||
loaded = true,
|
||||
path = "/Users/michael/.local/share/nvim/site/pack/packer/start/cmp-emoji",
|
||||
url = "https://github.com/hrsh7th/cmp-emoji"
|
||||
},
|
||||
["cmp-nvim-lsp"] = {
|
||||
loaded = true,
|
||||
path = "/Users/michael/.local/share/nvim/site/pack/packer/start/cmp-nvim-lsp",
|
||||
url = "https://github.com/hrsh7th/cmp-nvim-lsp"
|
||||
},
|
||||
["cmp-path"] = {
|
||||
loaded = true,
|
||||
path = "/Users/michael/.local/share/nvim/site/pack/packer/start/cmp-path",
|
||||
url = "https://github.com/hrsh7th/cmp-path"
|
||||
},
|
||||
["cmp-spell"] = {
|
||||
loaded = true,
|
||||
path = "/Users/michael/.local/share/nvim/site/pack/packer/start/cmp-spell",
|
||||
url = "https://github.com/f3fora/cmp-spell"
|
||||
},
|
||||
["cmp-vsnip"] = {
|
||||
loaded = true,
|
||||
path = "/Users/michael/.local/share/nvim/site/pack/packer/start/cmp-vsnip",
|
||||
url = "https://github.com/hrsh7th/cmp-vsnip"
|
||||
},
|
||||
["diffview.nvim"] = {
|
||||
commands = { "DiffviewOpen", "DiffviewClose", "DiffviewToggleFiles", "DiffviewFocusFiles" },
|
||||
config = { 'require("config/diffview")' },
|
||||
loaded = false,
|
||||
needs_bufread = false,
|
||||
only_cond = false,
|
||||
path = "/Users/michael/.local/share/nvim/site/pack/packer/opt/diffview.nvim",
|
||||
url = "https://github.com/sindrets/diffview.nvim"
|
||||
},
|
||||
["lsp_signature.nvim"] = {
|
||||
loaded = true,
|
||||
path = "/Users/michael/.local/share/nvim/site/pack/packer/start/lsp_signature.nvim",
|
||||
url = "https://github.com/ray-x/lsp_signature.nvim"
|
||||
},
|
||||
["lspkind-nvim"] = {
|
||||
loaded = true,
|
||||
path = "/Users/michael/.local/share/nvim/site/pack/packer/start/lspkind-nvim",
|
||||
url = "https://github.com/onsails/lspkind-nvim"
|
||||
},
|
||||
["lualine.nvim"] = {
|
||||
config = { 'require("config/lualine")' },
|
||||
loaded = true,
|
||||
path = "/Users/michael/.local/share/nvim/site/pack/packer/start/lualine.nvim",
|
||||
url = "https://github.com/nvim-lualine/lualine.nvim"
|
||||
},
|
||||
neogit = {
|
||||
commands = { "Neogit" },
|
||||
config = { 'require("config/neogit")' },
|
||||
loaded = false,
|
||||
needs_bufread = true,
|
||||
only_cond = false,
|
||||
path = "/Users/michael/.local/share/nvim/site/pack/packer/opt/neogit",
|
||||
url = "https://github.com/TimUntersberger/neogit"
|
||||
},
|
||||
["nightfox.nvim"] = {
|
||||
config = { 'require("config/nightfox")' },
|
||||
loaded = true,
|
||||
path = "/Users/michael/.local/share/nvim/site/pack/packer/start/nightfox.nvim",
|
||||
url = "https://github.com/EdenEast/nightfox.nvim"
|
||||
},
|
||||
["nvim-cmp"] = {
|
||||
config = { 'require("config/cmp")' },
|
||||
loaded = true,
|
||||
path = "/Users/michael/.local/share/nvim/site/pack/packer/start/nvim-cmp",
|
||||
url = "https://github.com/hrsh7th/nvim-cmp"
|
||||
},
|
||||
["nvim-lsp-installer"] = {
|
||||
config = { 'require("config/lsp-installer")' },
|
||||
loaded = true,
|
||||
path = "/Users/michael/.local/share/nvim/site/pack/packer/start/nvim-lsp-installer",
|
||||
url = "https://github.com/williamboman/nvim-lsp-installer"
|
||||
},
|
||||
["nvim-lspconfig"] = {
|
||||
config = { 'require("config/lsp")' },
|
||||
loaded = true,
|
||||
path = "/Users/michael/.local/share/nvim/site/pack/packer/start/nvim-lspconfig",
|
||||
url = "https://github.com/neovim/nvim-lspconfig"
|
||||
@@ -140,6 +221,30 @@ _G.packer_plugins = {
|
||||
}
|
||||
|
||||
time([[Defining packer_plugins]], false)
|
||||
-- Config for: nvim-lsp-installer
|
||||
time([[Config for nvim-lsp-installer]], true)
|
||||
require("config/lsp-installer")
|
||||
time([[Config for nvim-lsp-installer]], false)
|
||||
-- Config for: nvim-cmp
|
||||
time([[Config for nvim-cmp]], true)
|
||||
require("config/cmp")
|
||||
time([[Config for nvim-cmp]], false)
|
||||
-- Config for: nightfox.nvim
|
||||
time([[Config for nightfox.nvim]], true)
|
||||
require("config/nightfox")
|
||||
time([[Config for nightfox.nvim]], false)
|
||||
-- Config for: nvim-lspconfig
|
||||
time([[Config for nvim-lspconfig]], true)
|
||||
require("config/lsp")
|
||||
time([[Config for nvim-lspconfig]], false)
|
||||
-- Config for: telescope.nvim
|
||||
time([[Config for telescope.nvim]], true)
|
||||
require("config/telescope")
|
||||
time([[Config for telescope.nvim]], false)
|
||||
-- Config for: nvim-treesitter
|
||||
time([[Config for nvim-treesitter]], true)
|
||||
require("config/treesitter")
|
||||
time([[Config for nvim-treesitter]], false)
|
||||
-- Config for: nvim-tree.lua
|
||||
time([[Config for nvim-tree.lua]], true)
|
||||
require("config/nvim-tree")
|
||||
@@ -148,18 +253,16 @@ time([[Config for nvim-tree.lua]], false)
|
||||
time([[Config for lualine.nvim]], true)
|
||||
require("config/lualine")
|
||||
time([[Config for lualine.nvim]], false)
|
||||
-- Config for: nvim-treesitter
|
||||
time([[Config for nvim-treesitter]], true)
|
||||
require("config/treesitter")
|
||||
time([[Config for nvim-treesitter]], false)
|
||||
-- Config for: telescope.nvim
|
||||
time([[Config for telescope.nvim]], true)
|
||||
require("config/telescope")
|
||||
time([[Config for telescope.nvim]], false)
|
||||
-- Config for: nightfox.nvim
|
||||
time([[Config for nightfox.nvim]], true)
|
||||
require("config/nightfox")
|
||||
time([[Config for nightfox.nvim]], false)
|
||||
|
||||
-- Command lazy-loads
|
||||
time([[Defining lazy-load commands]], true)
|
||||
pcall(vim.cmd, [[command -nargs=* -range -bang -complete=file Neogit lua require("packer.load")({'neogit'}, { cmd = "Neogit", l1 = <line1>, l2 = <line2>, bang = <q-bang>, args = <q-args>, mods = "<mods>" }, _G.packer_plugins)]])
|
||||
pcall(vim.cmd, [[command -nargs=* -range -bang -complete=file DiffviewOpen lua require("packer.load")({'diffview.nvim'}, { cmd = "DiffviewOpen", l1 = <line1>, l2 = <line2>, bang = <q-bang>, args = <q-args>, mods = "<mods>" }, _G.packer_plugins)]])
|
||||
pcall(vim.cmd, [[command -nargs=* -range -bang -complete=file DiffviewClose lua require("packer.load")({'diffview.nvim'}, { cmd = "DiffviewClose", l1 = <line1>, l2 = <line2>, bang = <q-bang>, args = <q-args>, mods = "<mods>" }, _G.packer_plugins)]])
|
||||
pcall(vim.cmd, [[command -nargs=* -range -bang -complete=file DiffviewToggleFiles lua require("packer.load")({'diffview.nvim'}, { cmd = "DiffviewToggleFiles", l1 = <line1>, l2 = <line2>, bang = <q-bang>, args = <q-args>, mods = "<mods>" }, _G.packer_plugins)]])
|
||||
pcall(vim.cmd, [[command -nargs=* -range -bang -complete=file DiffviewFocusFiles lua require("packer.load")({'diffview.nvim'}, { cmd = "DiffviewFocusFiles", l1 = <line1>, l2 = <line2>, bang = <q-bang>, args = <q-args>, mods = "<mods>" }, _G.packer_plugins)]])
|
||||
time([[Defining lazy-load commands]], false)
|
||||
|
||||
vim.cmd [[augroup packer_load_aucmds]]
|
||||
vim.cmd [[au!]]
|
||||
-- Event lazy-loads
|
||||
|
||||
Reference in New Issue
Block a user