added latex support and reorg ftplugins

This commit is contained in:
Jeremie Fraeys 2024-08-20 01:31:44 -04:00
parent 7f1b34fd6f
commit f2eaf7c67a
38 changed files with 600 additions and 234 deletions

View file

@ -1,47 +1,46 @@
return {
'tpope/vim-fugitive',
config = function()
vim.keymap.set('n', '<leader>gs', vim.cmd.Git)
-- General key mappings for Fugitive
vim.keymap.set('n', '<leader>gs', vim.cmd.Git, { desc = 'Open Git status' })
local jfraeys_fugitive = vim.api.nvim_create_augroup('jfraeys_fugitive', {})
-- Create an autocommand group for Fugitive-specific settings
local fugitive_augroup = vim.api.nvim_create_augroup('fugitive', { clear = true })
local autocmd = vim.api.nvim_create_autocmd
autocmd('BufWinEnter', {
group = jfraeys_fugitive,
-- Set up autocommands for Fugitive buffers
vim.api.nvim_create_autocmd('BufWinEnter', {
group = fugitive_augroup,
pattern = '*',
callback = function()
if vim.bo.ft ~= 'fugitive' then
return
end
if vim.bo.ft ~= 'fugitive' then return end
local bufnr = vim.api.nvim_get_current_buf()
local opts = { buffer = bufnr, remap = false }
vim.keymap.set('n', '<leader>p', function()
vim.cmd.Git 'push'
end, opts)
-- rebase always
vim.keymap.set('n', '<leader>P', function()
vim.cmd.Git { 'pull', '--rebase' }
end, opts)
-- NOTE: It allows me to easily set the branch I am pushing and any tracking
-- needed if I did not set the branch up correctly
-- Key mappings specific to Fugitive buffers
vim.keymap.set('n', '<leader>p', function() vim.cmd.Git('push') end, opts)
vim.keymap.set('n', '<leader>P', function() vim.cmd.Git('pull --rebase') end, opts)
vim.keymap.set('n', '<leader>t', ':Git push -u origin ', opts)
end,
})
vim.keymap.set('n', 'gu', '<cmd>diffget //2<CR>')
vim.keymap.set('n', 'gh', '<cmd>diffget //3<CR>')
-- Additional key mappings outside of Fugitive buffers
vim.keymap.set('n', 'gu', '<cmd>diffget //2<CR>', { desc = 'Get diff for version 2' })
vim.keymap.set('n', 'gh', '<cmd>diffget //3<CR>', { desc = 'Get diff for version 3' })
-- Set up a faster command for Fugitive in Lua
local function git_command(args)
local cmd = 'Git ' .. args
vim.cmd(cmd)
end
vim.api.nvim_create_user_command('Git', function(params)
git_command(params.args)
end, { nargs = '*' })
end,
cond = function()
-- Function to check if the current directory is a Git repository
local is_git_repo = function()
local git_dir = vim.fn.finddir('.git', '.;')
return git_dir and #git_dir > 0
end
return is_git_repo()
-- Efficient Git repository check
return vim.fn.isdirectory('.git') == 1
end,
}