Fork commentary to work with template files
This commit is contained in:
36
init.vim
36
init.vim
@@ -16,8 +16,9 @@ Plug 'junegunn/fzf', { 'do': { -> fzf#install() } } " Fast fuzzy file searching
|
||||
Plug 'junegunn/fzf.vim'
|
||||
Plug 'tpope/vim-fugitive' " Adds git support to vim
|
||||
Plug 'tpope/vim-surround' " Adds motions for dealing with parentheses
|
||||
Plug 'tpope/vim-commentary' " Easily comment/uncomment lines with `gc`
|
||||
" Plug 'tpope/vim-commentary' " Easily comment/uncomment lines with `gc` (updated to work with style/script)
|
||||
Plug 'tpope/vim-unimpaired' " A series of bindings for complementary actions [<space> and ]<space> for adding lines before and after
|
||||
Plug 'tpope/vim-vinegar' " Improvements to the file browser
|
||||
Plug 'jiangmiao/auto-pairs' " Creates closing parentheses when writing the opening, use <m-e> to wrap the next word/group, <m-p> to disable
|
||||
Plug 'mattn/emmet-vim' " Emmet support ,em to toggle it
|
||||
Plug 'dylanaraps/wal.vim' " Set the theme to match the system colours
|
||||
@@ -281,6 +282,24 @@ let g:chadtree_settings = {
|
||||
\ }
|
||||
\ }
|
||||
|
||||
" function s:set_commentary_format()
|
||||
" echo "running command"
|
||||
" if &filetype =~ 'vue\|html\|svelte'
|
||||
" if searchpair('<\(script\|style\)', '', '</\(script\|style\)>', 'Wn')
|
||||
" let b:commentary_format="// %s"
|
||||
" else
|
||||
" let b:commentary_format=&commentstring
|
||||
" endif
|
||||
" endif
|
||||
" endfunction
|
||||
|
||||
" xnoremap gc :call <SID>set_commentary_format()<CR><Plug>Commentary
|
||||
" nnoremap gc :call <SID>set_commentary_format()<CR><Plug>Commentary
|
||||
" onoremap gc :call <SID>set_commentary_format()<CR><Plug>Commentary
|
||||
" nnoremap gcc :call <SID>set_commentary_format()<CR><Plug>Commentary
|
||||
" nnoremap cgc :call <SID>set_commentary_format()<CR><Plug>Commentary
|
||||
" nnoremap cgu :call <SID>set_commentary_format()<CR><Plug>Commentary<Plug>Commentary
|
||||
|
||||
" }}}
|
||||
|
||||
" Moving around --- {{{
|
||||
@@ -325,6 +344,18 @@ augroup autofolding
|
||||
autocmd FileType zsh setlocal foldmethod=marker
|
||||
augroup END
|
||||
|
||||
"Set commentary formats
|
||||
function s:setcommentary()
|
||||
if &commentstring =~ '/\*\s*%s\s*\*/'
|
||||
let b:commentary_format="// %s"
|
||||
endif
|
||||
endfunction
|
||||
|
||||
augroup autocomment
|
||||
autocmd!
|
||||
autocmd FileType * call <SID>setcommentary()
|
||||
augroup END
|
||||
|
||||
"Automatically save files
|
||||
augroup autosaving
|
||||
autocmd!
|
||||
@@ -341,8 +372,7 @@ augroup END
|
||||
augroup suckless
|
||||
autocmd BufWritePost ~/.local/src/dwmblocks/config.h !cd ~/.local/src/dwmblocks/; doas make install && { killall -q dwmblocks;setsid -f dwmblocks }
|
||||
autocmd BufWritePost ~/.local/src/dwm/config.h !cd ~/.local/src/dwm/; doas make clean install
|
||||
autocmd BufWritePost ~/.local/src/st/config.h !cd ~/.local/st/dwm/; doas make clean install
|
||||
|
||||
autocmd BufWritePost ~/.local/src/st/config.h !cd ~/.local/src/st/; doas make clean install
|
||||
" }}}
|
||||
|
||||
" Notes and tips
|
||||
|
||||
Reference in New Issue
Block a user