dotfiles/.config/nvim/lua/my/coding.lua

80 lines
2.1 KiB
Lua
Raw Normal View History

require('my/plugins')
2022-08-13 17:04:51 +02:00
require('my/tools')
local map = require('my.functions').map
2022-08-16 02:49:33 +02:00
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
2022-08-16 02:49:33 +02:00
location = context_utils.get_cursor_location()
elseif ctx.cmotion == comment_utils.cmotion.v or ctx.cmotion == comment_utils.cmotion.V then
2022-08-16 03:30:01 +02:00
location = context_utils.get_visual_start_location()
2022-08-16 02:49:33 +02:00
end
return context_internal.calculate_commentstring {
key = ctx.ctype == comment_utils.ctype.line and "__default" or "__multiline",
2022-08-16 02:49:33 +02:00
location = location,
}
end
})
local neogit = require('neogit')
neogit.setup {
disable_commit_confirmation = true,
kind = 'tab',
integrations = {
diffview = true
}
}
2022-08-16 04:55:49 +02:00
map('n', '<Leader>gg', neogit.open, 'Open Neogit')
-- start git commits in insert mode
2022-08-10 17:52:25 +02:00
vim.api.nvim_create_augroup('config_coding', { clear = true })
vim.api.nvim_create_autocmd(
{ 'FileType' },
{
group = 'config_coding',
pattern = { 'gitcommit', 'gitrebase' },
command = [[startinsert | 1]]
2022-08-10 17:52:25 +02:00
})
2022-08-09 00:19:29 +02:00
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'
})
2022-08-16 05:00:13 +02:00
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
})