mirror of
https://github.com/nmasur/dotfiles
synced 2024-12-26 03:34:53 +00:00
clean up vimrc
This commit is contained in:
parent
76fd99dd2b
commit
cd8fd18427
@ -34,7 +34,7 @@ Plug 'tpope/vim-vinegar' " Fixes netrw file explorer
|
||||
Plug 'lambdalisue/fern.vim' " File explorer / project drawer
|
||||
Plug 'christoomey/vim-tmux-navigator' " Hotkeys for tmux panes
|
||||
|
||||
" CoC
|
||||
" CoC (Language Server Protocol, requires NodeJS)
|
||||
Plug 'neoclide/coc.nvim', {'branch': 'release'} " Code completion
|
||||
|
||||
call plug#end()
|
||||
@ -52,24 +52,22 @@ set relativenumber " Relative numbers instead of absolute
|
||||
set list " Reveal whitespace with ---
|
||||
set expandtab " Tabs into spaces
|
||||
set shiftwidth=4 " Amount to shift with > key
|
||||
set softtabstop=4 " Amount to shift with TAB key
|
||||
set softtabstop=4 " Amount to shift with <TAB> key
|
||||
set ignorecase " Ignore case when searching
|
||||
set smartcase " Check case when using capitals in search
|
||||
set incsearch " Search while typing
|
||||
set visualbell " No sounds
|
||||
set scrolljump=1 " Scroll more than one line (or 1 line)
|
||||
set scrolloff=3 " Margin of lines when scrolling
|
||||
set pastetoggle=<F3> " Use F3 to enter paste mode
|
||||
set scrolloff=3 " Margin of lines when to start scrolling
|
||||
set pastetoggle=<F3> " Use F3 to enter raw paste mode
|
||||
set clipboard+=unnamedplus " Uses system clipboard for yanking
|
||||
set updatetime=300 " Faster diagnostics
|
||||
set mouse=nv " Mouse interaction / scrolling
|
||||
|
||||
" Neovim only
|
||||
set inccommand=split " Live preview search and replace
|
||||
set inccommand=split " Live preview search and replace
|
||||
|
||||
" Mouse interaction / scrolling
|
||||
set mouse=nv
|
||||
|
||||
" Remember last position
|
||||
" Remember last position when reopening file
|
||||
if has("autocmd")
|
||||
au BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$") | exe "normal! g`\"" | endif
|
||||
endif
|
||||
@ -79,7 +77,7 @@ set noswapfile " Instead of swaps, create backups (les
|
||||
set backup " Easier to recover and more secure
|
||||
set undofile " Keeps undos after quit
|
||||
set backupdir=~/.config/nvim/dirs/backup
|
||||
set undodir=~/.config/vim/dirs/undo
|
||||
set undodir=~/.config/nvim/dirs/undo
|
||||
|
||||
" Create backup directories if they don't exist
|
||||
if !isdirectory(&backupdir)
|
||||
@ -89,7 +87,9 @@ if !isdirectory(&undodir)
|
||||
call mkdir(&undodir, "p")
|
||||
endif
|
||||
|
||||
" Custom commands
|
||||
" Custom Commands
|
||||
"----------------
|
||||
|
||||
command Vimrc edit ~/.config/nvim/init.vim " Edit .vimrc (this file)
|
||||
|
||||
" Custom Keybinds
|
||||
@ -113,6 +113,12 @@ nnoremap <Leader>q :quit<cr>
|
||||
" Save file
|
||||
nnoremap <Leader>fs :write<cr>
|
||||
|
||||
" Make file executable
|
||||
nnoremap <silent> <Leader>fe :!chmod 755 %<cr><cr>
|
||||
|
||||
" Make file normal permissions
|
||||
nnoremap <silent> <Leader>fn :!chmod 644 %<cr><cr>
|
||||
|
||||
" Open file in this directory
|
||||
nnoremap <Leader>ff :Files<cr>
|
||||
|
||||
@ -149,9 +155,71 @@ nnoremap <Leader>wm :only<cr>
|
||||
" Open file tree
|
||||
noremap <silent> <Leader>ft :Fern . -drawer -width=35 -toggle<CR><C-w>=
|
||||
|
||||
" LaTeX Settings
|
||||
"---------------
|
||||
|
||||
" LaTeX Hotkeys
|
||||
autocmd FileType tex inoremap ;bf \textbf{}<Esc>i
|
||||
" Jump to the next occurence of <> and replace it with insert mode
|
||||
autocmd FileType tex nnoremap <Leader><Space> /<><Esc>:noh<CR>c2l
|
||||
|
||||
" Autocompile LaTeX on save
|
||||
autocmd BufWritePost *.tex silent! execute "!pdflatex -output-directory=%:p:h % >/dev/null 2>&1" | redraw!
|
||||
|
||||
" Plugin Settings
|
||||
"----------------
|
||||
|
||||
" Built-in file explorer plugin
|
||||
let g:netrw_liststyle = 3 " Change style to 'tree' view
|
||||
let g:netrw_banner = 0 " Remove useless banner
|
||||
let g:netrw_winsize = 15 " Explore window takes % of page
|
||||
let g:netrw_browse_split = 4 " Open in previous window
|
||||
let g:netrw_altv = 1 " Always split left
|
||||
|
||||
" Gitgutter plugin
|
||||
let g:gitgutter_enabled = 1 " Enabled on start
|
||||
|
||||
" Polyglot syntax plugin
|
||||
let g:terraform_fmt_on_save=1 " Formats with terraform plugin
|
||||
let g:rustfmt_autosave = 1 " Formats with rust plugin
|
||||
|
||||
" VimWiki plugin
|
||||
let g:vimwiki_list = [
|
||||
\ {
|
||||
\ 'path': $NOTES_PATH,
|
||||
\ 'syntax': 'markdown',
|
||||
\ 'index': 'home',
|
||||
\ 'ext': '.md'
|
||||
\ }
|
||||
\ ]
|
||||
let g:vimwiki_key_mappings =
|
||||
\ {
|
||||
\ 'all_maps': 1,
|
||||
\ 'mouse': 1,
|
||||
\ }
|
||||
let g:vimwiki_auto_chdir = 1
|
||||
|
||||
" Quickscope only highlight on keypress
|
||||
let g:qs_highlight_on_keys = ['f', 'F', 't', 'T']
|
||||
|
||||
" Lightline status bar plugin
|
||||
let g:lightline = {
|
||||
\ 'colorscheme': 'jellybeans',
|
||||
\ 'active': {
|
||||
\ 'right': [[ 'lineinfo' ]],
|
||||
\ 'left': [[ 'mode', 'paste' ],
|
||||
\ [ 'cocstatus', 'readonly', 'relativepath', 'gitbranch', 'modified' ]]
|
||||
\ },
|
||||
\ 'component_function': {
|
||||
\ 'gitbranch': 'fugitive#head',
|
||||
\ 'cocstatus': 'coc#status'
|
||||
\ },
|
||||
\ }
|
||||
|
||||
" CoC Settings
|
||||
"-------------
|
||||
|
||||
" Extensions to auto-install and enable
|
||||
let g:coc_global_extensions = [
|
||||
\ 'coc-rust-analyzer',
|
||||
\ 'coc-pairs',
|
||||
@ -207,66 +275,5 @@ nmap <leader>rn <Plug>(coc-rename)
|
||||
nmap <silent> <C-s> <Plug>(coc-range-select)
|
||||
xmap <silent> <C-s> <Plug>(coc-range-select)
|
||||
|
||||
" LaTeX Settings
|
||||
"---------------
|
||||
|
||||
" LaTeX Hotkeys
|
||||
autocmd FileType tex inoremap ;bf \textbf{}<Esc>i
|
||||
" Jump to the next occurence of <> and replace it with insert mode
|
||||
autocmd FileType tex nnoremap <Leader><Space> /<><Esc>:noh<CR>c2l
|
||||
|
||||
" Autocompile LaTeX on save
|
||||
autocmd BufWritePost *.tex silent! execute "!pdflatex -output-directory=%:p:h % >/dev/null 2>&1" | redraw!
|
||||
|
||||
" Plugin Settings
|
||||
"----------------
|
||||
|
||||
" Built-in explorer plugin
|
||||
let g:netrw_liststyle = 3 " Change style to 'tree' view
|
||||
let g:netrw_banner = 0 " Remove useless banner
|
||||
let g:netrw_winsize = 15 " Explore window takes % of page
|
||||
let g:netrw_browse_split = 4 " Open in previous window
|
||||
let g:netrw_altv = 1 " Always split left
|
||||
|
||||
" Gitgutter plugin
|
||||
let g:gitgutter_enabled = 1 " Enabled on start
|
||||
|
||||
" Polyglot syntax plugin
|
||||
let g:terraform_fmt_on_save=1 " Formats with terraform plugin
|
||||
let g:rustfmt_autosave = 1 " Formats with rust plugin
|
||||
|
||||
" VimWiki plugin
|
||||
let g:vimwiki_list = [
|
||||
\ {
|
||||
\ 'path': $NOTES_PATH,
|
||||
\ 'syntax': 'markdown',
|
||||
\ 'index': 'home',
|
||||
\ 'ext': '.md'
|
||||
\ }
|
||||
\ ]
|
||||
let g:vimwiki_key_mappings =
|
||||
\ {
|
||||
\ 'all_maps': 1,
|
||||
\ 'mouse': 1,
|
||||
\ }
|
||||
let g:vimwiki_auto_chdir = 1
|
||||
|
||||
" Quickscope only highlight on keypress
|
||||
let g:qs_highlight_on_keys = ['f', 'F', 't', 'T']
|
||||
|
||||
" Lightline status bar plugin
|
||||
let g:lightline = {
|
||||
\ 'colorscheme': 'jellybeans',
|
||||
\ 'active': {
|
||||
\ 'right': [[ 'lineinfo' ]],
|
||||
\ 'left': [[ 'mode', 'paste' ],
|
||||
\ [ 'cocstatus', 'readonly', 'relativepath', 'gitbranch', 'modified' ]]
|
||||
\ },
|
||||
\ 'component_function': {
|
||||
\ 'gitbranch': 'fugitive#head',
|
||||
\ 'cocstatus': 'coc#status'
|
||||
\ },
|
||||
\ }
|
||||
|
||||
" Use autocmd to force lightline update.
|
||||
autocmd User CocStatusChange,CocDiagnosticChange call lightline#update()
|
||||
|
Loading…
Reference in New Issue
Block a user