nvim: move git config into own file
This commit is contained in:
parent
1c3d120b91
commit
f63b754fd1
|
@ -22,6 +22,7 @@ require('my/completion')
|
|||
require('my/lsp')
|
||||
require('my/tools')
|
||||
require('my/coding')
|
||||
require('my/git')
|
||||
require('my/net')
|
||||
require('my/commands')
|
||||
|
||||
|
|
|
@ -14,56 +14,7 @@ require('Comment').setup({
|
|||
below = '<Leader>co',
|
||||
eol = '<Leader>cA',
|
||||
},
|
||||
pre_hook = function(ctx)
|
||||
local comment_utils = require('Comment.utils')
|
||||
local context_utils = require('ts_context_commentstring.utils')
|
||||
local context_internal = require('ts_context_commentstring.internal')
|
||||
|
||||
local location = nil
|
||||
if ctx.ctype == comment_utils.ctype.block then
|
||||
location = context_utils.get_cursor_location()
|
||||
elseif ctx.cmotion == comment_utils.cmotion.v or
|
||||
ctx.cmotion == comment_utils.cmotion.V then
|
||||
location = context_utils.get_visual_start_location()
|
||||
end
|
||||
|
||||
return context_internal.calculate_commentstring {
|
||||
key = ctx.ctype == comment_utils.ctype.line and '__default' or
|
||||
'__multiline',
|
||||
location = location,
|
||||
}
|
||||
end
|
||||
})
|
||||
|
||||
local neogit = require('neogit')
|
||||
neogit.setup {
|
||||
disable_commit_confirmation = true,
|
||||
kind = 'tab',
|
||||
integrations = {
|
||||
diffview = true
|
||||
},
|
||||
disable_insert_on_commit = false
|
||||
}
|
||||
map('n', '<Leader>gg', neogit.open, 'Open Neogit')
|
||||
|
||||
-- start git commits in insert mode
|
||||
vim.api.nvim_create_augroup('config_coding', { clear = true })
|
||||
vim.api.nvim_create_autocmd({ 'FileType' }, {
|
||||
group = 'config_coding',
|
||||
pattern = { 'gitcommit', 'gitrebase' },
|
||||
command = [[startinsert | 1]]
|
||||
})
|
||||
|
||||
vim.api.nvim_create_autocmd({ 'FileType' }, {
|
||||
group = 'config_coding',
|
||||
pattern = { 'NeogitCommitMessage' },
|
||||
callback = require('autosplit')
|
||||
})
|
||||
|
||||
vim.api.nvim_create_autocmd({ 'FileType' }, {
|
||||
group = 'config_coding',
|
||||
pattern = { 'Neogit*' },
|
||||
command = [[set nolist]]
|
||||
pre_hook = require('ts_context_commentstring.integrations.comment_nvim').create_pre_hook(),
|
||||
})
|
||||
|
||||
require("nvim-autopairs").setup({})
|
||||
|
@ -72,15 +23,6 @@ require('luasnip.loaders.from_lua').load({
|
|||
paths = vim.fn.stdpath('config') .. '/snippets'
|
||||
})
|
||||
|
||||
require('gitsigns').setup({
|
||||
on_attach = function(bufnr)
|
||||
local gs = package.loaded.gitsigns
|
||||
|
||||
map('n', '<Leader>gb', function() gs.blame_line({ full = true }) end,
|
||||
'Show blame for current line', bufnr)
|
||||
end
|
||||
})
|
||||
|
||||
require('project_nvim').setup({
|
||||
detection_methods = { 'pattern', 'lsp' },
|
||||
patterns = require('my.functions').project_root_markers,
|
||||
|
@ -152,12 +94,3 @@ require('nvim-dap-virtual-text').setup({})
|
|||
require('femaco').setup({})
|
||||
map('n', '<Leader><S-E>', require('femaco.edit').edit_code_block,
|
||||
'Edit inline code block')
|
||||
|
||||
require('gitlinker').setup({
|
||||
callbacks = {
|
||||
['schlomp.space'] = function(url_data)
|
||||
url_data.host = 'schlomp.space'
|
||||
return require('gitlinker.hosts').get_gitea_type_url(url_data)
|
||||
end
|
||||
}
|
||||
})
|
||||
|
|
54
.config/nvim/lua/my/git.lua
Normal file
54
.config/nvim/lua/my/git.lua
Normal file
|
@ -0,0 +1,54 @@
|
|||
local map = require('my.functions').map
|
||||
|
||||
local neogit = require('neogit')
|
||||
neogit.setup {
|
||||
disable_commit_confirmation = true,
|
||||
kind = 'tab',
|
||||
integrations = {
|
||||
diffview = true
|
||||
},
|
||||
disable_insert_on_commit = false
|
||||
}
|
||||
map('n', '<Leader>gg', neogit.open, 'Open Neogit')
|
||||
|
||||
-- start git commits in insert mode
|
||||
gitgroup = vim.api.nvim_create_augroup('config_git', { clear = true })
|
||||
vim.api.nvim_create_autocmd({ 'FileType' }, {
|
||||
group = gitgroup,
|
||||
pattern = { 'gitcommit', 'gitrebase' },
|
||||
command = [[startinsert | 1]]
|
||||
})
|
||||
|
||||
-- split Neogit commit messages vertically if possible
|
||||
vim.api.nvim_create_autocmd({ 'FileType' }, {
|
||||
group = gitgroup,
|
||||
pattern = { 'NeogitCommitMessage' },
|
||||
callback = require('autosplit')
|
||||
})
|
||||
|
||||
-- don't show dots for spaces in Neogit buffers
|
||||
vim.api.nvim_create_autocmd({ 'FileType' }, {
|
||||
group = gitgroup,
|
||||
pattern = { 'Neogit*' },
|
||||
command = [[set nolist]]
|
||||
})
|
||||
|
||||
require('gitsigns').setup({
|
||||
on_attach = function(bufnr)
|
||||
local gs = package.loaded.gitsigns
|
||||
|
||||
map('n', '<Leader>gb', function() gs.blame_line({ full = true }) end,
|
||||
'Show blame for current line', bufnr)
|
||||
end
|
||||
})
|
||||
|
||||
require('gitlinker').setup({
|
||||
callbacks = {
|
||||
-- ['schlomp.space'] = function(url_data)
|
||||
-- url_data.host = 'schlomp.space'
|
||||
-- return require('gitlinker.hosts').get_gitea_type_url(url_data)
|
||||
-- end,
|
||||
['schlomp.space'] = require('gitlinker.hosts').get_gitea_type_url,
|
||||
['git.gentoo.org'] = require('gitlinker.hosts').get_cgit_type_url,
|
||||
}
|
||||
})
|
|
@ -149,24 +149,8 @@ require('packer').startup({ function(use)
|
|||
'https://github.com/numToStr/Comment.nvim',
|
||||
tag = '*'
|
||||
}
|
||||
use {
|
||||
'https://github.com/TimUntersberger/neogit',
|
||||
requires = {
|
||||
'https://github.com/nvim-lua/plenary.nvim',
|
||||
'https://github.com/folke/which-key.nvim',
|
||||
'https://github.com/sindrets/diffview.nvim'
|
||||
},
|
||||
}
|
||||
use { 'https://github.com/windwp/nvim-autopairs' }
|
||||
use { 'https://github.com/L3MON4D3/LuaSnip' }
|
||||
use {
|
||||
'https://github.com/tpope/vim-fugitive',
|
||||
tag = '*'
|
||||
}
|
||||
use {
|
||||
'https://github.com/lewis6991/gitsigns.nvim',
|
||||
tag = '*'
|
||||
}
|
||||
-- use { 'https://github.com/ahmedkhalf/project.nvim' }
|
||||
use { -- <https://github.com/ahmedkhalf/project.nvim/pull/89>
|
||||
'https://github.com/tastytea/project.nvim',
|
||||
|
@ -195,6 +179,24 @@ require('packer').startup({ function(use)
|
|||
use {
|
||||
'https://github.com/AckslD/nvim-FeMaco.lua'
|
||||
}
|
||||
|
||||
-- git
|
||||
use {
|
||||
'https://github.com/TimUntersberger/neogit',
|
||||
requires = {
|
||||
'https://github.com/nvim-lua/plenary.nvim',
|
||||
'https://github.com/folke/which-key.nvim',
|
||||
'https://github.com/sindrets/diffview.nvim'
|
||||
},
|
||||
}
|
||||
use {
|
||||
'https://github.com/tpope/vim-fugitive',
|
||||
tag = '*'
|
||||
}
|
||||
use {
|
||||
'https://github.com/lewis6991/gitsigns.nvim',
|
||||
tag = '*'
|
||||
}
|
||||
use {
|
||||
'https://github.com/ruifm/gitlinker.nvim',
|
||||
requires = { 'https://github.com/nvim-lua/plenary.nvim' }
|
||||
|
|
Loading…
Reference in New Issue
Block a user