diff --git a/init.lua b/init.lua index ccd5a563..5bae27c5 100644 --- a/init.lua +++ b/init.lua @@ -93,6 +93,8 @@ vim.g.maplocalleader = ' ' -- Set to true if you have a Nerd Font installed vim.g.have_nerd_font = true +vim.g.autoformat = false + -- [[ Setting options ]] -- See `:help vim.opt` -- NOTE: You can change these options as you wish! @@ -156,6 +158,7 @@ vim.opt.scrolloff = 10 -- [[ Basic Keymaps ]] -- See `:help vim.keymap.set()` +vim.keymap.set('n', 'pv', vim.cmd.Ex) -- Set highlight on search, but clear on pressing in normal mode vim.opt.hlsearch = true @@ -194,6 +197,10 @@ vim.keymap.set('n', '', '', { desc = 'Move focus to the upper win vim.keymap.set('n', '', 'zz', { desc = 'Center cursor after down half page' }) vim.keymap.set('n', '', 'zz', { desc = 'Center cursor after down half up' }) +-- buffers +vim.keymap.set("n", "", "bprevious", { desc = "Prev Buffer" }) +vim.keymap.set("n", "", "bnext", { desc = "Next Buffer" }) + -- [[ Basic Autocommands ]] -- See `:help lua-guide-autocommands` @@ -259,9 +266,50 @@ require('lazy').setup({ topdelete = { text = '‾' }, changedelete = { text = '~' }, }, + vim.keymap.set('n', 'gp', ':Gitsigns preview_hunk', { desc = 'Preview [H]unk' }), + vim.keymap.set('n', 'tb', ':Gitsigns toggle_current_line_blame', { desc = '[T]oggle [B]lame' }), }, }, + { + 'tpope/vim-fugitive', + config = function() + vim.keymap.set("n", "gs", vim.cmd.Git) + + local Sefcik_Fugitive = vim.api.nvim_create_augroup("Sefcik_Fugitive", {}) + + local autocmd = vim.api.nvim_create_autocmd + autocmd("BufWinEnter", { + group = Sefcik_Fugitive, + pattern = "*", + callback = function() + 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", "P", function() + vim.cmd.Git('push') + end, opts) + + -- rebase always + vim.keymap.set("n", "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 + vim.keymap.set("n", "t", ":Git push -u origin ", opts); + end, + }) + + + vim.keymap.set("n", "gu", "diffget //2") + vim.keymap.set("n", "gh", "diffget //3") + end + }, + -- NOTE: Plugins can also be configured to run Lua code when they are loaded. -- -- This is often very useful to both group configuration, as well as handle @@ -681,16 +729,17 @@ require('lazy').setup({ }, opts = { notify_on_error = false, - format_on_save = function(bufnr) - -- Disable "format_on_save lsp_fallback" for languages that don't - -- have a well standardized coding style. You can add additional - -- languages here or re-enable it for the disabled ones. - local disable_filetypes = { c = true, cpp = true } - return { - timeout_ms = 500, - lsp_fallback = not disable_filetypes[vim.bo[bufnr].filetype], - } - end, + format_on_save = false, + -- format_on_save = function(bufnr) + -- -- Disable "format_on_save lsp_fallback" for languages that don't + -- -- have a well standardized coding style. You can add additional + -- -- languages here or re-enable it for the disabled ones. + -- local disable_filetypes = { c = true, cpp = true } + -- return { + -- timeout_ms = 500, + -- lsp_fallback = not disable_filetypes[vim.bo[bufnr].filetype], + -- } + -- end, formatters_by_ft = { lua = { 'stylua' }, -- Conform can also run multiple formatters sequentially @@ -893,7 +942,7 @@ require('lazy').setup({ -- cursor location to LINE:COLUMN ---@diagnostic disable-next-line: duplicate-set-field statusline.section_location = function() - return '%2l:%-2v' + return '%2l/%L:%-2v' end -- ... and there is more!