dotfiles/.config/nvim/lua/my/coding.lua
2022-08-17 19:55:12 +02:00

86 lines
2.2 KiB
Lua

require('my/plugins')
local map = require('my.functions').map
require('Comment').setup({
toggler = {
line = '<Leader>cc',
block = '<Leader>CC'
},
opleader = {
line = '<Leader>c',
block = '<Leader>C'
},
extra = {
above = '<Leader>cO',
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
}
}
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 = { 'Neogit*' },
command = [[set nolist]]
})
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({
patterns = require('my.functions').project_root_markers,
show_hidden = true
})