vimrc

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | Submodules

commit a2bc3b4acda87c0d1f38509dd76c28853f85cfb4
parent 6011950ef40a8fdb8ae561bec84109a7a8b32412
Author: Pablo Cárdenas <pablo.cardenas@imca.edu.pe>
Date:   Mon, 27 Apr 2026 01:58:30 -0300

Update

Diffstat:
M.gitmodules | 3+++
Mafter/pack/thirdparty/opt/vimtex/plugin/vimtex.vim | 6+++---
Aftplugin/lua.vim | 3+++
Apack/pablo/opt/marks/plugin/marks.vim | 48++++++++++++++++++++++++++++++++++++++++++++++++
Mpack/pablo/opt/snippets/plugin/snippets.vim | 62++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----
Apack/pablo/opt/spaced-repetition/plugin/spaced-repetition.vim | 77+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mpack/pablo/opt/tmux/plugin/tmux.vim | 2--
Apack/thirdparty/opt/vim-indent-object | 1+
8 files changed, 193 insertions(+), 9 deletions(-)

diff --git a/.gitmodules b/.gitmodules @@ -10,3 +10,6 @@ [submodule "pack/thirdparty/opt/vimtex"] path = pack/thirdparty/opt/vimtex url = https://github.com/lervag/vimtex.git +[submodule "pack/thirdparty/opt/vim-indent-object"] + path = pack/thirdparty/opt/vim-indent-object + url = https://github.com/michaeljsmith/vim-indent-object.git diff --git a/after/pack/thirdparty/opt/vimtex/plugin/vimtex.vim b/after/pack/thirdparty/opt/vimtex/plugin/vimtex.vim @@ -5,7 +5,7 @@ let g:vimtex_mappings_override_existing = 1 "let g:vimtex_imaps_enabled = 0 -let g:vimtex_compiler_enabled = 0 +"let g:vimtex_compiler_enabled = 0 "let g:vimtex_complete_enabled = 0 "let g:vimtex_doc_enabled = 0 "let g:vimtex_fold_bib_enabled = 0 @@ -30,7 +30,7 @@ let g:vimtex_syntax_conceal = { \ 'ligatures': 1, \ 'cites': 1, \ 'fancy': 1, -\ 'spacing': 1, +\ 'spacing': 0, \ 'greek': 1, \ 'math_bounds': 0, \ 'math_delimiters': 1, @@ -56,6 +56,6 @@ let g:vimtex_env_toggle_math_map = { \ '\[': '\(', \} -if empty(v:servername) && exists('*remote_startserver') +if !empty($DISPLAY) && empty(v:servername) && exists('*remote_startserver') call remote_startserver('VIM') endif diff --git a/ftplugin/lua.vim b/ftplugin/lua.vim @@ -0,0 +1,3 @@ +setlocal softtabstop=3 +setlocal shiftwidth=3 +setlocal expandtab diff --git a/pack/pablo/opt/marks/plugin/marks.vim b/pack/pablo/opt/marks/plugin/marks.vim @@ -0,0 +1,48 @@ +vim9script + +var marks_highlight = false + + +def g:GetListMarks(): string + final list_marks = [] + for mark in getmarklist('%') + list_marks->add(mark.mark[1 : ]) + endfor + return '(' .. list_marks->join(' ') .. ')' +enddef + + +def ToggleHighlightMarks() + marks_highlight = !marks_highlight + + if marks_highlight + prop_type_add('MarksPropType', {highlight: 'Pmenu'}) + HighlightMarks() + setlocal statusline=%<%f\ %h%w%m%r%=%{GetListMarks()}\ \ %-14.(%l,%c%V%)\ %P + setlocal laststatus=2 + else + prop_type_delete('MarksPropType') + setlocal statusline= + setlocal laststatus=1 + endif +enddef + + +def HighlightMarks() + if !marks_highlight + return + endif + + prop_clear(1, line('$'), {type: 'MarksPropType'}) + + for mark in getmarklist('%') + mark.pos[2] = min([mark.pos[2], strcharlen(getline(mark.mark)) + 1]) + prop_add(mark.pos[1], mark.pos[2], {type: 'MarksPropType', text: mark.mark[1 : ]}) + endfor +enddef + + +nnoremap <localleader>` <Cmd>call <SID>ToggleHighlightMarks()<CR> +autocmd CursorMoved,CursorMovedI * HighlightMarks() + +# vim: et sts=4 sw=4 diff --git a/pack/pablo/opt/snippets/plugin/snippets.vim b/pack/pablo/opt/snippets/plugin/snippets.vim @@ -43,7 +43,7 @@ def g:Snippet_InsertCharPre() var lnum = pos[1] var coln = pos[2] var line = getline('.') - if line[coln - 2] == 'm' + if line[ : coln - 2] =~# '\<m$' command = '\(...\)' endif elseif v:char == 'm' && !vimtex#syntax#in_mathzone() @@ -51,7 +51,7 @@ def g:Snippet_InsertCharPre() var lnum = pos[1] var coln = pos[2] var line = getline('.') - if line[coln - 2] == 'd' + if line[ : coln - 2] =~# '^\s*d$' command = '\[...\]' endif elseif v:char == '=' && vimtex#syntax#in_mathzone() @@ -62,6 +62,30 @@ def g:Snippet_InsertCharPre() if line[coln - 2] == '<' command = '<=' endif + elseif v:char == '=' && vimtex#syntax#in_mathzone() + var pos = getcharpos('.') + var lnum = pos[1] + var coln = pos[2] + var line = getline('.') + if line[coln - 2] == '>' + command = '>=' + endif + elseif v:char == 'v' && vimtex#syntax#in_mathzone() + var pos = getcharpos('.') + var lnum = pos[1] + var coln = pos[2] + var line = getline('.') + if line[coln - 2] == 'v' + command = 'vv' + endif + elseif v:char == 'V' && vimtex#syntax#in_mathzone() + var pos = getcharpos('.') + var lnum = pos[1] + var coln = pos[2] + var line = getline('.') + if line[coln - 2] == 'V' + command = 'VV' + endif endif if command != "" @@ -108,6 +132,14 @@ def g:Snippet_TextChangedI() line[coln - 1 : ] ) setcharpos('.', [0, lnum, coln + 3 - 2, 0]) + elseif command == '>=' + setline( + ".", + strcharpart(line, 0, coln - 3) .. + '\ge' .. + line[coln - 1 : ] + ) + setcharpos('.', [0, lnum, coln + 3 - 2, 0]) elseif command == '\(...\)' setline( ".", @@ -132,15 +164,37 @@ def g:Snippet_TextChangedI() line[coln - 1 : ] ) setcharpos('.', [0, lnum, coln + 6 - 2, 0]) + elseif command == 'vv' + setline( + ".", + strcharpart(line, 0, coln - 3) .. + '\lvert \rvert<++>' .. + line[coln - 1 : ] + ) + setcharpos('.', [0, lnum, coln + 7 - 2, 0]) + elseif command == 'VV' + setline( + ".", + strcharpart(line, 0, coln - 3) .. + '\lVert \rVert<++>' .. + line[coln - 1 : ] + ) + setcharpos('.', [0, lnum, coln + 7 - 2, 0]) endif command = '' endif enddef +def g:JumpPlaceholder() + if search('<++>') > 0 + feedkeys("\<Esc> \"_ca>") + endif +enddef + g:surround_insert_tail = "<++>" -inoremap <silent> <C-J> <Esc>:call search('<++>')<CR>"_c4l -noremap <silent> <C-J> :call search('<++>')<CR>"_c4l +inoremap <silent> <C-J> <Cmd>:call JumpPlaceholder()<CR> +nnoremap <silent> <C-J> <Cmd>:call JumpPlaceholder()<CR> # vim: et sts=4 sw=4 diff --git a/pack/pablo/opt/spaced-repetition/plugin/spaced-repetition.vim b/pack/pablo/opt/spaced-repetition/plugin/spaced-repetition.vim @@ -0,0 +1,77 @@ +vim9script + +sign_define("TodaySign", { + "text": ">>", + "texthl": "Search", + # "linehl": "DiffAdd", +}) + +def g:SRSign() + sign_unplace("SRGroup") + const now = localtime() + const lines = getline(1, '$') + for idx in range(len(lines)) + if lines[idx][ : 5] != '% SR: ' + continue + endif + const line_split = lines[idx][6 : ]->split() + const scheduled = float2nr(strptime("%Y-%m-%dT%H:%M:%S%z", line_split[0]) + str2float(line_split[1]) * 24 * 60 * 60) + if now > scheduled + sign_place(0, "SRGroup", "TodaySign", bufnr(), {lnum: idx + 1}) + endif + endfor +enddef + +def g:SRQuickFix() + const now = localtime() + final qf_list = [] + for file_path in glob('*.tex', 1, 1) + if file_path < "lecture_07" + continue + endif + const file_lines = readfile(file_path) + for idx in range(len(file_lines)) + if file_lines[idx][ : 5] != '% SR: ' + continue + endif + var line_split = file_lines[idx][6 : ]->split() + var scheduled = float2nr(strptime("%Y-%m-%dT%H:%M:%S%z", line_split[0]) + str2float(line_split[1]) * 24 * 60 * 60) + if now > scheduled + qf_list->add({ + filename: fnamemodify(file_path, ':p'), + lnum: idx + 1, + text: strftime("%Y-%m-%dT%H:%M:%S%z ", scheduled) .. file_lines[idx + 1]->substitute('\\begin{\(.[^}]\+\)}\[\(.*\)\]', '\1: \2', ''), + scheduled: scheduled, + }) + endif + endfor + endfor + + #qf_list->sort((a, b) => a.scheduled - b.scheduled) + + if !empty(qf_list) + setqflist(qf_list, 'r') + copen + echo $"Found {len(qf_list)} items across all .tex files." + else + cclose + echo "No SR tasks found for now." + endif +enddef + +def g:SRReview() + var line_split = getline('.')[6 : ]->split() + var interval = str2float(line_split[1]) + var easiness_factor = str2float(line_split[2]) + var quality = str2nr(line_split[3]) + var new_interval = interval * easiness_factor + var new_easiness_factor = easiness_factor + (0.1 - (5 - quality) * (0.08 + (5 - quality) * 0.02)) + setline('.', $'% SR: {strftime('%Y-%m-%dT%H:%M:%S%z')} {printf("%.02f", new_interval)} {printf("%.02f", new_easiness_factor)} {quality}') +enddef + + +nnoremap <localleader>sq <CMD>call SRQuickFix()<CR> +nnoremap <localleader>sr <CMD>call SRReview()<CR> +nnoremap <localleader>ss <CMD>call SRSign()<CR> + +# vim: et sts=4 sw=4 diff --git a/pack/pablo/opt/tmux/plugin/tmux.vim b/pack/pablo/opt/tmux/plugin/tmux.vim @@ -5,7 +5,6 @@ def g:TmuxSendKeysToMarkedVisual() try silent execute 'normal! "ay' call system('tmux send-keys -t {marked} -- ' .. "\e[200~" .. shellescape(@a) .. "\e[201~" ) - call system('tmux send-keys -t {marked} -- ' .. "Enter" ) finally @a = a_save endtry @@ -22,7 +21,6 @@ def g:TmuxSendKeysToMarkedNormal(type: string) silent execute "normal! `[\<C-v>`]\"ay" endif call system('tmux send-keys -t {marked} -- ' .. "\e[200~" .. shellescape(@a) .. "\e[201~" ) - call system('tmux send-keys -t {marked} -- ' .. "Enter" ) finally @a = a_save set operatorfunc= diff --git a/pack/thirdparty/opt/vim-indent-object b/pack/thirdparty/opt/vim-indent-object @@ -0,0 +1 @@ +Subproject commit 8ab36d5ec2a3a60468437a95e142ce994df598c6