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

84 lines
2.2 KiB
Lua
Raw Normal View History

require('my/plugins')
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)
2022-08-18 01:16:57 +02:00
local comment_utils = require('Comment.utils')
2022-08-16 02:49:33 +02:00
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 {
2022-08-18 01:16:57 +02:00
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 })
2022-08-18 01:16:57 +02:00
vim.api.nvim_create_autocmd({ 'FileType' }, {
group = 'config_coding',
pattern = { 'gitcommit', 'gitrebase' },
command = [[startinsert | 1]]
})
2022-08-09 00:19:29 +02:00
2022-08-18 01:16:57 +02:00
vim.api.nvim_create_autocmd({ 'FileType' }, {
group = 'config_coding',
pattern = { 'Neogit*' },
command = [[set nolist]]
})
require("nvim-autopairs").setup({})
2022-08-18 01:16:57 +02:00
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,
2022-08-16 05:00:13 +02:00
'Show blame for current line', bufnr)
end
})
2022-08-17 19:55:12 +02:00
2022-08-18 01:16:57 +02:00
require('project_nvim').setup({
2022-08-17 19:55:12 +02:00
patterns = require('my.functions').project_root_markers,
show_hidden = false,
fallback_buffer_dir = true
2022-08-17 19:55:12 +02:00
})