瀏覽代碼

use new plugins + surround autocmd's with agroups

Noah Vogt 3 年之前
父節點
當前提交
fbecfe8317

+ 47 - 14
dot-config/nvim/general/auto.vim

@@ -1,4 +1,8 @@
-autocmd FileType plaintex,tex,latex syntax spell toplevel
+" fix latex commenting
+augroup fixLatexComments
+  autocmd!
+  autocmd FileType plaintex,tex,latex syntax spell toplevel
+augroup END
 " Automatically wrap at 80 characters for Markdown
 " autocmd BufRead,BufNewFile *.md setlocal textwidth=80
 
@@ -24,26 +28,55 @@ function! MathAndLiquid()
 endfunction
 
 " Call everytime we open a Markdown file
-autocmd BufRead,BufNewFile,BufEnter *.md,*.markdown call MathAndLiquid()
-"Plug 'vim-pandoc/vim-pandoc-syntax'
-let g:vim_markdown_math = 1
+augroup callMathFunction
+  autocmd!
+  autocmd BufRead,BufNewFile,BufEnter *.md,*.markdown call MathAndLiquid()
+augroup END
 
 " active to autocompile docs on saving
 "autocmd BufWritePost *.ms !compile % | fold -w200
 "autocmd BufWritePost *.tex !compile % | fold -w200
 
 " disable automatic comment
-autocmd FileType * setlocal formatoptions-=c formatoptions-=r formatoptions-=o
+augroup disableAutoComment
+  autocmd!
+  autocmd FileType * setlocal formatoptions-=c formatoptions-=r formatoptions-=o
+augroup END
 
 " clear a TeX build after exiting vim
-autocmd VimLeavePre *.tex !texclear "%"
-autocmd VimLeavePre *.md !texclear "%"
-autocmd VimLeavePre *.c !rm -rf .ccls-cache
-autocmd VimLeavePre *.cc !rm -rf .ccls-cache
-autocmd VimLeavePre *.cpp !rm -rf .ccls-cache
-autocmd VimLeavePre *.h !rm -rf .ccls-cache
-autocmd VimLeavePre *.hh !rm -rf .ccls-cache
+augroup texclear
+  autocmd!
+  autocmd VimLeavePre *.tex !texclear "%"
+  autocmd VimLeavePre *.md !texclear "%"
+augroup END
+
+"autocmd VimLeavePre *.c !rm -rf .ccls-cache
+"autocmd VimLeavePre *.cc !rm -rf .ccls-cache
+"autocmd VimLeavePre *.cpp !rm -rf .ccls-cache
+"autocmd VimLeavePre *.h !rm -rf .ccls-cache
+"autocmd VimLeavePre *.hh !rm -rf .ccls-cache
 
 " use python syntax highlighting for .tibasic files
-autocmd BufNewFile,BufRead *.tibasic set filetype=python
-autocmd BufNewFile,BufRead *.tib set filetype=python
+augroup tibasic
+  autocmd!
+  autocmd BufNewFile,BufRead *.tibasic set filetype=python
+  autocmd BufNewFile,BufRead *.tib set filetype=python
+augroup END
+
+function! FernInitReload() abort
+  augroup FernGroupLocal
+    autocmd! * <buffer>
+    autocmd BufEnter <buffer> silent execute "normal \<Plug>(fern-action-reload)"
+  augroup END
+endfunction
+
+augroup OnEnteringFernWindow
+  autocmd!
+  autocmd FileType fern call FernInitReload()
+augroup END
+
+" enable emmet only for html / css files
+augroup EmmetEnabler
+  autocmd!
+  autocmd FileType html,css EmmetInstall
+augroup END

+ 12 - 3
dot-config/nvim/keys/bindings.vim

@@ -40,9 +40,11 @@ map <F6> :w<CR>:!glosscompile "%"; pkill -HUP mupdf<CR>
 vnoremap <Space><Space> <Esc>/<++><Enter>"_c4l
 map <Space><Space> <Esc>/<++><Enter>"_c4l
 
-" copy from / to clipboard
-vnoremap <C-c> "+y
-map <C-p> "+P
+"copy from / to clipboard
+vnoremap <leader>y "+y
+vnoremap <leader>Y "+Y
+nmap <leader>p "+p
+nmap <leader>P "+P
 
 " Use <c-space> to trigger completion.
 inoremap <silent><expr> <c-space> coc#refresh()
@@ -133,3 +135,10 @@ nmap <leader>qf  <Plug>(coc-fix-current)
 
 " Run the Code Lens action on the current line.
 nmap <leader>cl  <Plug>(coc-codelens-action)
+
+" auto center view when walking through searches
+nnoremap n nzzzv
+nnoremap N Nzzzv
+
+" toggle tag bar
+nmap <leader>g :TagbarToggle<CR>

+ 2 - 0
dot-config/nvim/plug-conf/emmet.vim

@@ -0,0 +1,2 @@
+" disable emmet by default
+let g:user_emmet_install_global = 0

+ 13 - 2
dot-config/nvim/vim-plug/plugins.vim

@@ -9,7 +9,6 @@ call plug#begin('~/.cache/vim/plugged')
 " colorshemes
 "Plug 'morhetz/gruvbox'
 "Plug 'itchyny/landscape.vim'
-"Plug 'rakr/vim-one'
 Plug 'joshdick/onedark.vim'
 
 " better syntax support
@@ -49,6 +48,18 @@ Plug 'romainl/vim-cool'
 " graphical debugger
 "Plug 'puremourning/vimspector'
 
-Plug 'kien/rainbow_parentheses.vim'
+" use when there are too many parentheses
+"Plug 'kien/rainbow_parentheses.vim'
+
+" auto close pairs, etc.
+Plug 'jiangmiao/auto-pairs'
+
+" easy commenting
+Plug 'tpope/vim-commentary'
+
+" tag bar for easy navigation
+Plug 'preservim/tagbar'
+
+Plug 'mattn/emmet-vim'
 
 call plug#end()