dotfiles/nvim.configlink/init.vim

169 lines
5.7 KiB
VimL
Raw Normal View History

2020-07-26 20:15:21 +00:00
" Vim Config
2020-08-02 02:33:54 +00:00
" Plugins
"--------
2020-08-02 02:29:33 +00:00
" Install vim-plugged if not installed
if empty(glob('~/.config/nvim/autoload/plug.vim'))
silent !curl -fLo ~/.config/nvim/autoload/plug.vim --create-dirs
\ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
2020-08-02 02:33:54 +00:00
autocmd VimEnter * PlugInstall --sync | source ~/.config/nvim/init.vim
2020-08-02 02:29:33 +00:00
endif
2020-08-02 02:33:54 +00:00
" All plugins
2020-07-31 04:02:41 +00:00
call plug#begin('~/.config/nvim/plugged')
2020-08-02 02:29:33 +00:00
Plug 'morhetz/gruvbox' " Colorscheme
2020-07-31 04:02:41 +00:00
Plug 'junegunn/fzf', { 'do': { -> fzf#install() } } " Required for fuzzyfinder
Plug 'junegunn/fzf.vim' " Actual fuzzyfinder
2020-07-31 13:28:06 +00:00
Plug 'tpope/vim-surround' " Enables paren editing
2020-08-02 02:29:33 +00:00
Plug 'tmsvg/pear-tree' " Auto- and smart-parentheses
2020-07-31 13:28:06 +00:00
Plug 'tpope/vim-commentary' " Use gc or gcc to comment
2020-08-02 00:06:16 +00:00
Plug 'sheerun/vim-polyglot' " Syntax for every language
Plug 'vimwiki/vimwiki' " Wiki Markdown System
2020-08-01 00:44:02 +00:00
Plug 'jreybert/vimagit' " Git 'gui' buffer
Plug 'airblade/vim-gitgutter' " Git next to line numbers
Plug 'tpope/vim-fugitive' " Other git commands
Plug 'machakann/vim-highlightedyank' " Highlight text when copied
Plug 'itchyny/lightline.vim' " Status bar
Plug 'tpope/vim-vinegar' " Fixes netrw file explorer
2020-08-02 02:29:33 +00:00
Plug 'lambdalisue/fern.vim' " File explorer / project drawer
2020-08-02 00:06:16 +00:00
Plug 'christoomey/vim-tmux-navigator' " Hotkeys for tmux panes
2020-08-02 02:29:33 +00:00
Plug 'neoclide/coc.nvim', {'branch': 'release'} " Code completion
2020-07-31 04:02:41 +00:00
call plug#end()
2020-08-02 00:06:16 +00:00
" Basic Settings
2020-07-31 04:02:41 +00:00
filetype plugin on " Load the plugin for current filetype (vimwiki)
2020-07-26 20:15:21 +00:00
syntax enable " Syntax highlighting
set termguicolors " Set to truecolor
colorscheme gruvbox " Installed in autoload/ and colors/
2020-08-02 00:06:16 +00:00
" Options
2020-07-26 20:15:21 +00:00
set number " Show line numbers
set relativenumber " Relative numbers instead of absolute
2020-07-31 13:39:17 +00:00
set list " Reveal whitespace with ---
2020-07-26 20:15:21 +00:00
set expandtab " Tabs into spaces
2020-07-27 17:00:26 +00:00
set shiftwidth=4 " Amount to shift with > key
set softtabstop=4 " Amount to shift with TAB key
2020-07-26 20:15:21 +00:00
set ignorecase " Ignore case when searching
set smartcase " Check case when using capitals in search
set incsearch " Search while typing
2020-07-31 04:02:41 +00:00
set visualbell " No sounds
set scrolljump=1 " Scroll more than one line (or 1 line)
set scrolloff=3 " Margin of lines when scrolling
2020-08-02 00:06:16 +00:00
set pastetoggle=<F3> " Use F3 to enter paste mode
2020-07-27 17:00:26 +00:00
set clipboard+=unnamedplus " Uses system clipboard for yanking
2020-08-02 00:06:16 +00:00
" Neovim only
set inccommand=split " Live preview search and replace
2020-08-02 02:29:33 +00:00
" Mouse interaction / scrolling
set mouse=nv
2020-07-26 20:15:21 +00:00
" Remember last position
2020-06-03 14:31:58 +00:00
if has("autocmd")
au BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$") | exe "normal! g`\"" | endif
endif
2020-07-26 20:15:21 +00:00
" Better backup, swap and undo storage
set noswapfile " Instead of swaps, create backups (less annoying)
set backup " Easier to recover and more secure
set undofile " Keeps undos after quit
2020-07-31 04:02:41 +00:00
set backupdir=~/.config/nvim/dirs/backup
set undodir=~/.config/vim/dirs/undo
2020-07-26 20:15:21 +00:00
" Create backup directories if they don't exist
2020-06-03 14:31:58 +00:00
if !isdirectory(&backupdir)
call mkdir(&backupdir, "p")
endif
if !isdirectory(&undodir)
call mkdir(&undodir, "p")
endif
2020-08-02 00:06:16 +00:00
" Custom commands
command Vimrc edit ~/.config/nvim/init.vim " Edit .vimrc (this file)
" Custom Keybinds
"----------------
2020-08-01 13:46:48 +00:00
2020-07-31 13:28:06 +00:00
" Map the leader key
map <Space> <Leader>
2020-08-02 00:06:16 +00:00
"This unsets the `last search pattern` register by hitting return
nnoremap <silent> <CR> :noh<CR><CR>
2020-07-31 13:28:06 +00:00
" Jump to text in this directory
2020-08-01 00:44:02 +00:00
nnoremap <Leader>/ :Rg<CR>
2020-07-31 13:28:06 +00:00
" Open file in this directory
nnoremap <Leader>f :Files<cr>
2020-08-02 02:29:33 +00:00
" Open a recent file
nnoremap <Leader>r :History<cr>
2020-07-31 13:28:06 +00:00
" Switch between multiple open files
nnoremap <Leader>b :Buffers<cr>
" Jump to text in this file
nnoremap <Leader>s :BLines<cr>
2020-08-01 00:44:02 +00:00
" Start Magit buffer
nnoremap <Leader>g :Magit<cr>
" Toggle Git gutter (by line numbers)
nnoremap <Leader>` :GitGutterToggle<cr>
" Git push
nnoremap <Leader>p :Git push<cr>
" Close all other splits
nnoremap <Leader>m :only<cr>
" Open file tree
2020-08-02 02:29:33 +00:00
noremap <silent> <Leader>t :Fern . -drawer -width=35 -toggle<CR><C-w>=
2020-06-03 14:31:58 +00:00
2020-08-02 00:06:16 +00:00
" Plugin Settings
"----------------
2020-08-01 00:44:02 +00:00
" 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
2020-08-02 02:29:33 +00:00
let g:netrw_altv = 1 " Always split left
" Pear Tree parentheses plugin
let g:pear_tree_repeatable_expand = 0 " Don't hide paren until escape
let g:pear_tree_smart_openers = 1 " Smart paren mode, which checks outer or inners
let g:pear_tree_smart_closers = 1
let g:pear_tree_smart_backspace = 1
2020-08-01 00:44:02 +00:00
" Gitgutter plugin
let g:gitgutter_enabled = 0 " Disable on start
2020-08-02 02:29:33 +00:00
" Polyglot syntax plugin
let g:terraform_fmt_on_save=1 " Formats with terraform plugin
2020-07-31 04:02:41 +00:00
2020-08-02 02:29:33 +00:00
" VimWiki plugin
let g:vimwiki_list = [
\ {
\ 'path': '~/Documents/notes/',
\ 'syntax': 'markdown',
\ 'ext': '.md'
\ }
\ ]
2020-07-31 04:02:41 +00:00
2020-08-02 02:29:33 +00:00
" Lightline status bar plugin
2020-08-01 00:44:02 +00:00
let g:lightline = {
\ 'colorscheme': 'jellybeans',
\ 'active': {
\ 'right': [[ 'lineinfo' ]],
\ 'left': [[ 'mode', 'paste' ],
\ [ 'readonly', 'relativepath', 'gitbranch', 'modified' ]]
\ },
\ 'component_function': {
\ 'gitbranch': 'fugitive#head'
\ }
\ }