From 5a14fe163c4e419375d31d1695e288277060535e Mon Sep 17 00:00:00 2001 From: Christian Nieves Date: Mon, 20 Mar 2023 15:47:17 -0500 Subject: [PATCH] stuff --- vim/.vim/lua/config/google-comments.lua | 4 +- vim/.vim/lua/config/oscyank.lua | 6 +-- vim/.vim/lua/config/signify.lua | 4 ++ vim/.vim/lua/plugins.lua | 11 +++-- vim/.vim/prefs/mappings.vim | 66 +++++++++++++++++++++++-- 5 files changed, 78 insertions(+), 13 deletions(-) diff --git a/vim/.vim/lua/config/google-comments.lua b/vim/.vim/lua/config/google-comments.lua index 703008c..25f6029 100644 --- a/vim/.vim/lua/config/google-comments.lua +++ b/vim/.vim/lua/config/google-comments.lua @@ -41,8 +41,8 @@ end local map = require("utils").map -- here are some mappings you might want: -map('n', '[c', [[GoogleCommentsGotoNextComment]]) -map('n', ']c', [[GoogleCommentsGotoPrevComment]]) +map('n', ']c', [[GoogleCommentsGotoNextComment]]) +map('n', '[c', [[GoogleCommentsGotoPrevComment]]) map('n', 'nc', [[GoogleCommentsGotoNextComment]]) map('n', 'pc', [[GoogleCommentsGotoPrevComment]]) diff --git a/vim/.vim/lua/config/oscyank.lua b/vim/.vim/lua/config/oscyank.lua index 8f0255d..8609108 100644 --- a/vim/.vim/lua/config/oscyank.lua +++ b/vim/.vim/lua/config/oscyank.lua @@ -1,3 +1,3 @@ -local map = require("utils").map -map("n", "y", ":OSCYank", opts) -map("v", "y", ":OSCYank", opts) +vim.keymap.set('n', 'y', require('osc52').copy_operator, {expr = true}) +vim.keymap.set('n', 'yy', 'c_', {remap = true}) +vim.keymap.set('v', 'y', require('osc52').copy_visual) diff --git a/vim/.vim/lua/config/signify.lua b/vim/.vim/lua/config/signify.lua index 0bf3be9..56989cd 100644 --- a/vim/.vim/lua/config/signify.lua +++ b/vim/.vim/lua/config/signify.lua @@ -1,4 +1,8 @@ local map = require("utils").map +vim.g.signify_vcs_cmds = { + hg = 'hg cat %f -r p4base', +} + map('n', ']d', '(signify-next-hunk)') map('n', '[d', '(signify-prev-hunk)') diff --git a/vim/.vim/lua/plugins.lua b/vim/.vim/lua/plugins.lua index 180f978..69e64a0 100644 --- a/vim/.vim/lua/plugins.lua +++ b/vim/.vim/lua/plugins.lua @@ -220,12 +220,13 @@ require('packer').startup(function(use) config = [[require('config.gitsigns')]], event = 'User ActuallyEditing', }, - { 'TimUntersberger/neogit', cmd = 'Neogit', config = [[require('config.neogit')]] }, + -- { 'TimUntersberger/neogit', cmd = 'Neogit', config = [[require('config.neogit')]] }, { 'akinsho/git-conflict.nvim', tag = '*', config = [[require('git-conflict').setup()]] - } + }, + { 'rhysd/conflict-marker.vim' } } -- use { "catppuccin/nvim", as = "catppuccin" } @@ -237,10 +238,11 @@ require('packer').startup(function(use) 'christoomey/vim-tmux-navigator', 'whatyouhide/vim-tmux-syntax', 'tmux-plugins/vim-tmux-focus-events', + 'jabirali/vim-tmux-yank', 'skywind3000/asyncrun.vim', } use { - 'ojroques/vim-oscyank', + 'ojroques/nvim-osc52', config = [[ require("config.oscyank") ]] } @@ -278,7 +280,8 @@ require('packer').startup(function(use) use 'tpope/vim-surround' use 'scrooloose/nerdcommenter' - use 'mhinz/vim-signify' { + use { + 'mhinz/vim-signify', config= [[require('config.signify')]] } diff --git a/vim/.vim/prefs/mappings.vim b/vim/.vim/prefs/mappings.vim index cfe1d35..724fbd7 100644 --- a/vim/.vim/prefs/mappings.vim +++ b/vim/.vim/prefs/mappings.vim @@ -15,8 +15,8 @@ inoremap cnoremap %% =fnameescape(expand("%:p:h")."/") " move vertically by visual line -nnoremap j gj -nnoremap k gk +" nnoremap j gj +" nnoremap k gk " no shift for colon cmds nnoremap ; : @@ -43,9 +43,67 @@ nnoremap ]e :execute 'move +'. v:count1 nnoremap vv v nnoremap ss s -nnoremap CocCommand explorer - " always use very magic mode when searching "nnoremap / /\v "vnoremap / /\v nnoremap ww :call WindowSwap#EasyWindowSwap() + +function! s:createHabitsMappings(keys, message) abort + for key in a:keys + call nvim_set_keymap('n', key, ':call BreakHabitsWindow(' . string(a:message). ')', {'silent': v:true, 'nowait': v:true, 'noremap': v:true}) + endfor +endfunction + +function! BreakHabitsWindow(message) abort + " Define the size of the floating window + let width = 50 + let height = 10 + + " Create the scratch buffer displayed in the floating window + let buf = nvim_create_buf(v:false, v:true) + + " create the lines to draw a box + let horizontal_border = '+' . repeat('-', width - 2) . '+' + let empty_line = '|' . repeat(' ', width - 2) . '|' + let lines = flatten([horizontal_border, map(range(height-2), 'empty_line'), horizontal_border]) + " set the box in the buffer + call nvim_buf_set_lines(buf, 0, -1, v:false, lines) + + " Create the lines for the centered message and put them in the buffer + let offset = 0 + for line in a:message + let start_col = (width - len(line))/2 + let end_col = start_col + len(line) + let current_row = height/2-len(a:message)/2 + offset + let offset = offset + 1 + call nvim_buf_set_text(buf, current_row, start_col, current_row, end_col, [line]) + endfor + + " Set mappings in the buffer to close the window easily + let closingKeys = ['', '', ''] + for closingKey in closingKeys + call nvim_buf_set_keymap(buf, 'n', closingKey, ':close', {'silent': v:true, 'nowait': v:true, 'noremap': v:true}) + endfor + + " Create the floating window + let ui = nvim_list_uis()[0] + let opts = {'relative': 'editor', + \ 'width': width, + \ 'height': height, + \ 'col': (ui.width/2) - (width/2), + \ 'row': (ui.height/2) - (height/2), + \ 'anchor': 'NW', + \ 'style': 'minimal', + \ } + let win = nvim_open_win(buf, 1, opts) + + " Change highlighting + " call nvim_win_set_option(win, 'winhl', 'Normal:ErrorFloat') + + highlight CustomFloatingWindow ctermbg=11 guibg=black ctermfg=10 guifg=red + call nvim_win_set_option(win, 'winhl', 'Normal:CustomFloatingWindow') +endfunction + +" let windowHabitsKeys = [",tm"] +" let windowHabitsMessage = ["USE < ,fw > INSTEAD", "BREAK BAD HABITS"] +" call s:createHabitsMappings(windowHabitsKeys, windowHabitsMessage)