Skip to content

Commit c7d0ad1

Browse files
committed
Updated configuration.
1 parent bf3e7be commit c7d0ad1

File tree

1 file changed

+60
-11
lines changed

1 file changed

+60
-11
lines changed

init.lua

Lines changed: 60 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,8 @@ vim.g.maplocalleader = ' '
9393
-- Set to true if you have a Nerd Font installed
9494
vim.g.have_nerd_font = true
9595

96+
vim.g.autoformat = false
97+
9698
-- [[ Setting options ]]
9799
-- See `:help vim.opt`
98100
-- NOTE: You can change these options as you wish!
@@ -156,6 +158,7 @@ vim.opt.scrolloff = 10
156158

157159
-- [[ Basic Keymaps ]]
158160
-- See `:help vim.keymap.set()`
161+
vim.keymap.set('n', '<leader>pv', vim.cmd.Ex)
159162

160163
-- Set highlight on search, but clear on pressing <Esc> in normal mode
161164
vim.opt.hlsearch = true
@@ -194,6 +197,10 @@ vim.keymap.set('n', '<C-k>', '<C-w><C-k>', { desc = 'Move focus to the upper win
194197
vim.keymap.set('n', '<C-d>', '<C-d>zz', { desc = 'Center cursor after down half page' })
195198
vim.keymap.set('n', '<C-u>', '<C-u>zz', { desc = 'Center cursor after down half up' })
196199

200+
-- buffers
201+
vim.keymap.set("n", "<S-h>", "<cmd>bprevious<cr>", { desc = "Prev Buffer" })
202+
vim.keymap.set("n", "<S-l>", "<cmd>bnext<cr>", { desc = "Next Buffer" })
203+
197204
-- [[ Basic Autocommands ]]
198205
-- See `:help lua-guide-autocommands`
199206

@@ -259,9 +266,50 @@ require('lazy').setup({
259266
topdelete = { text = '' },
260267
changedelete = { text = '~' },
261268
},
269+
vim.keymap.set('n', '<leader>gp', ':Gitsigns preview_hunk<CR>', { desc = 'Preview [H]unk' }),
270+
vim.keymap.set('n', '<leader>tb', ':Gitsigns toggle_current_line_blame<CR>', { desc = '[T]oggle [B]lame' }),
262271
},
263272
},
264273

274+
{
275+
'tpope/vim-fugitive',
276+
config = function()
277+
vim.keymap.set("n", "<leader>gs", vim.cmd.Git)
278+
279+
local Sefcik_Fugitive = vim.api.nvim_create_augroup("Sefcik_Fugitive", {})
280+
281+
local autocmd = vim.api.nvim_create_autocmd
282+
autocmd("BufWinEnter", {
283+
group = Sefcik_Fugitive,
284+
pattern = "*",
285+
callback = function()
286+
if vim.bo.ft ~= "fugitive" then
287+
return
288+
end
289+
290+
local bufnr = vim.api.nvim_get_current_buf()
291+
local opts = {buffer = bufnr, remap = false}
292+
vim.keymap.set("n", "<leader>P", function()
293+
vim.cmd.Git('push')
294+
end, opts)
295+
296+
-- rebase always
297+
vim.keymap.set("n", "<leader>p", function()
298+
vim.cmd.Git({'pull', '--rebase'})
299+
end, opts)
300+
301+
-- NOTE: It allows me to easily set the branch i am pushing and any tracking
302+
-- needed if i did not set the branch up correctly
303+
vim.keymap.set("n", "<leader>t", ":Git push -u origin ", opts);
304+
end,
305+
})
306+
307+
308+
vim.keymap.set("n", "gu", "<cmd>diffget //2<CR>")
309+
vim.keymap.set("n", "gh", "<cmd>diffget //3<CR>")
310+
end
311+
},
312+
265313
-- NOTE: Plugins can also be configured to run Lua code when they are loaded.
266314
--
267315
-- This is often very useful to both group configuration, as well as handle
@@ -681,16 +729,17 @@ require('lazy').setup({
681729
},
682730
opts = {
683731
notify_on_error = false,
684-
format_on_save = function(bufnr)
685-
-- Disable "format_on_save lsp_fallback" for languages that don't
686-
-- have a well standardized coding style. You can add additional
687-
-- languages here or re-enable it for the disabled ones.
688-
local disable_filetypes = { c = true, cpp = true }
689-
return {
690-
timeout_ms = 500,
691-
lsp_fallback = not disable_filetypes[vim.bo[bufnr].filetype],
692-
}
693-
end,
732+
format_on_save = false,
733+
-- format_on_save = function(bufnr)
734+
-- -- Disable "format_on_save lsp_fallback" for languages that don't
735+
-- -- have a well standardized coding style. You can add additional
736+
-- -- languages here or re-enable it for the disabled ones.
737+
-- local disable_filetypes = { c = true, cpp = true }
738+
-- return {
739+
-- timeout_ms = 500,
740+
-- lsp_fallback = not disable_filetypes[vim.bo[bufnr].filetype],
741+
-- }
742+
-- end,
694743
formatters_by_ft = {
695744
lua = { 'stylua' },
696745
-- Conform can also run multiple formatters sequentially
@@ -893,7 +942,7 @@ require('lazy').setup({
893942
-- cursor location to LINE:COLUMN
894943
---@diagnostic disable-next-line: duplicate-set-field
895944
statusline.section_location = function()
896-
return '%2l:%-2v'
945+
return '%2l/%L:%-2v'
897946
end
898947

899948
-- ... and there is more!

0 commit comments

Comments
 (0)