Update: pretty comments in vim

This commit is contained in:
Akemi Izuko 2023-03-09 23:36:32 -07:00
parent a7b87689de
commit 1a6f1afae4
No known key found for this signature in database
GPG key ID: 905D444F6A5E4BE4
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
nnoremap <C-g> 1<C-g>
" Change cwd to current buffer's
nnoremap gf :cd %:p:h<CR>
" Editing remaps ========================================
" Uppercase previous word from Insert mode
inoremap <C-y> <ESC>vbU`>a
@ -156,11 +159,11 @@ nnoremap <silent> <leader>ourl :silent call OpenURL()<CR>
command! Url :silent call OpenURL()
" Create a pretty block comment. Supports 3 types of comments
nnoremap <leader>opretty :call PrettySectionComment()<CR>
command! Pretty :call PrettySectionComment('#')
command! Prettyc :call PrettySectionComment('/*')
command! Prettypy :call PrettySectionComment('#')
command! Prettyhtml :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
nnoremap <leader>onet :EditVifm getcwd()<CR>

View file

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

View file

@ -89,7 +89,7 @@ function! SetGlobalPrimaryColor()
let l:mode = mode() " Returns vim's current mode
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
elseif l:mode ==# 'i'
let g:StatlnPrimaryColor = GuiColors(synIDattr(synIDtrans(hlID('Function')), 'fg', 'gui'), '#83ADAD')