diff options
| author | Elvis Claros Castro <elvis@claros.ar> | 2024-08-30 15:53:30 -0300 |
|---|---|---|
| committer | Elvis Claros Castro <elvis@claros.ar> | 2024-08-30 15:53:30 -0300 |
| commit | 066df483e9441e89d7af25b171784efcf3ffffec (patch) | |
| tree | 17110b5735eb1b6b9336d1e9e1fbb8779427080e /lua | |
| parent | 969aa6d3444f857c383b0e271febe087cd224349 (diff) | |
| download | nvim-conf-066df483e9441e89d7af25b171784efcf3ffffec.tar.gz nvim-conf-066df483e9441e89d7af25b171784efcf3ffffec.zip | |
Feat: key map for git merge
Diffstat (limited to 'lua')
| -rw-r--r-- | lua/config/autocmds.lua | 56 |
1 files changed, 40 insertions, 16 deletions
diff --git a/lua/config/autocmds.lua b/lua/config/autocmds.lua index 9030e4e..86d3e1d 100644 --- a/lua/config/autocmds.lua +++ b/lua/config/autocmds.lua @@ -38,25 +38,49 @@ vim.api.nvim_create_autocmd({ "BufWritePre" }, { end, }) -if vim.fn.has("persistent_undo") then - local target_path = vim.fn.expand('~/.cache/undodir') - -- crear el directorio y cualquier directorio padre - -- si la ubicación no existe. - if not vim.fn.isdirectory(target_path) then - vim.fn.mkdir(target_path, "p", 0700) - end +if vim.fn.has "persistent_undo" then + local target_path = vim.fn.expand "~/.cache/undodir" + -- crear el directorio y cualquier directorio padre + -- si la ubicación no existe. + if not vim.fn.isdirectory(target_path) then + vim.fn.mkdir(target_path, "p", 0700) + end - vim.o.undodir = target_path - vim.o.undofile = true + vim.o.undodir = target_path + vim.o.undofile = true end -- Función para alternar el ajuste de línea function ToggleWrap() - local wrap = vim.wo.wrap - vim.wo.wrap = not wrap - if vim.wo.wrap then - print("Ajuste de línea: Habilitado") - else - print("Ajuste de línea: Deshabilitado") - end + local wrap = vim.wo.wrap + vim.wo.wrap = not wrap + if vim.wo.wrap then + print "Ajuste de línea: Habilitado" + else + print "Ajuste de línea: Deshabilitado" + end end +vim.api.nvim_create_autocmd("BufEnter", { + pattern = "*", + callback = function() + if vim.opt.diff:get() then + local wk = require "which-key" + local opts = { + mode = "n", -- NORMAL mode + buffer = vim.api.nvim_get_current_buf(), -- Specify a buffer number for buffer local mappings + } + local mappings = { + ["<localleader>"] = { + --- get from REMOTE + ["1"] = { ":diffget LOCAL<CR>", "Get LOCAL" }, + --- get from BASE + ["2"] = { ":diffget BASE<CR>", "Get BASE" }, + --- get from LOCAL + ["3"] = { ":diffget REMOTE<CR>", "Get REMOTE" }, + }, + } + + wk.register(mappings, opts) + end + end, +}) |