Update: pretty comments in vim

This commit is contained in:
Akemi Izuko 2023-12-23 20:14:12 -07:00
parent 9a2bd97715
commit 2b483acf56
Signed by: akemi
GPG key ID: 8DE0764E1809E9FC
3 changed files with 15 additions and 5 deletions

View file

@ -123,6 +123,9 @@ nnoremap <leader><leader>= :vertical resize 84<CR>
" Show full file path " Show full file path
nnoremap <C-g> 1<C-g> nnoremap <C-g> 1<C-g>
" Change cwd to current buffer's
nnoremap gf :cd %:p:h<CR>
" Editing remaps ======================================== " Editing remaps ========================================
" Uppercase previous word from Insert mode " Uppercase previous word from Insert mode
inoremap <C-y> <ESC>vbU`>a inoremap <C-y> <ESC>vbU`>a
@ -156,11 +159,11 @@ nnoremap <silent> <leader>ourl :silent call OpenURL()<CR>
command! Url :silent call OpenURL() command! Url :silent call OpenURL()
" Create a pretty block comment. Supports 3 types of comments " Create a pretty block comment. Supports 3 types of comments
nnoremap <leader>opretty :call PrettySectionComment()<CR> command! Prettypy :call PrettySectionComment('#')
command! Pretty :call PrettySectionComment('#') command! Prettyhtml :call PrettySectionComment("<!--")
command! Prettyc :call PrettySectionComment('/*')
command! Prettyrs :call PrettySectionComment('//') command! Prettyrs :call PrettySectionComment('//')
command! Prettyjs :call PrettySectionComment('//') command! Prettycss :call PrettySectionComment('/*')
nnoremap <leader>opretty :echom "use :Pretty{rs,py,css}"<cr>
" Open with vifm " Open with vifm
nnoremap <leader>onet :EditVifm getcwd()<CR> nnoremap <leader>onet :EditVifm getcwd()<CR>

View file

@ -21,6 +21,11 @@ function! PrettySectionComment(type)
\ "/*─────────────────────────────────────────────────────────────────────────────╗") \ "/*─────────────────────────────────────────────────────────────────────────────╗")
call append(line("."), call append(line("."),
\ "╚─────────────────────────────────────────────────────────────────────────────*/") \ "╚─────────────────────────────────────────────────────────────────────────────*/")
elseif a:type ==# "<!--"
call append(line(".") - 1,
\ "<!--───────────────────────────────────────────────────────────────────────────╗")
call append(line("."),
\ "╚────────────────────────────────────────────────────────────────────────────-->")
elseif a:type ==# '//' elseif a:type ==# '//'
call append(line(".") - 1, call append(line(".") - 1,
\ "//╔────────────────────────────────────────────────────────────────────────────╗") \ "//╔────────────────────────────────────────────────────────────────────────────╗")
@ -41,6 +46,8 @@ function! PrettySectionComment(type)
" Paste back in commented text " Paste back in commented text
if a:type ==# '/*' if a:type ==# '/*'
exe "normal! 0i│ \<C-r>\"\<esc>" exe "normal! 0i│ \<C-r>\"\<esc>"
elseif a:type ==# "<!--"
exe "normal! 0i│ \<C-r>\"\<esc>"
elseif a:type ==# '//' elseif a:type ==# '//'
exe "normal! 0i//│ \<C-r>\"\<esc>" exe "normal! 0i//│ \<C-r>\"\<esc>"
else else

View file

@ -89,7 +89,7 @@ function! SetGlobalPrimaryColor()
let l:mode = mode() " Returns vim's current mode let l:mode = mode() " Returns vim's current mode
if l:mode ==# 'n' if l:mode ==# 'n'
let g:StatlnPrimaryColor = GuiColors(synIDattr(synIDtrans(hlID('String')), 'fg', 'gui'), '#AFAF00') let g:StatlnPrimaryColor = GuiColors(synIDattr(synIDtrans(hlID('String')), 'fg', 'gui'), '#b8bb26')
let g:mode_str = 'NORMAL' " Light green let g:mode_str = 'NORMAL' " Light green
elseif l:mode ==# 'i' elseif l:mode ==# 'i'
let g:StatlnPrimaryColor = GuiColors(synIDattr(synIDtrans(hlID('Function')), 'fg', 'gui'), '#83ADAD') let g:StatlnPrimaryColor = GuiColors(synIDattr(synIDtrans(hlID('Function')), 'fg', 'gui'), '#83ADAD')