dotfiles/.config/nvim/init.vim

172 lines
4.5 KiB
VimL

" Use 24-bit (true-color) mode in Vim/Neovim when outside tmux.
" If you're using tmux version 2.2 or later, you can remove the outermost $TMUX check and use tmux's 24-bit color support
" (see < http://sunaku.github.io/tmux-24bit-color.html#usage > for more information.)
if (empty($TMUX))
if (has("nvim"))
" For Neovim 0.1.3 and 0.1.4 < https://github.com/neovim/neovim/pull/2198 >
let $NVIM_TUI_ENABLE_TRUE_COLOR=1
endif
" For Neovim > 0.1.5 and Vim > patch 7.4.1799 < https://github.com/vim/vim/commit/61be73bb0f965a895bfb064ea3e55476ac175162 >
" Based on Vim patch 7.4.1770 (`guicolors` option) < https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd >
" < https://github.com/neovim/neovim/wiki/Following-HEAD#20160511 >
if (has("termguicolors"))
set termguicolors
endif
endif
" Shortcuts
nnoremap <silent><nowait> <space>o :NERDTreeToggle<CR>
nnoremap <silent><nowait> <space>s :TagbarToggle<CR>
" Remove Highlight
nnoremap <esc><esc> :let @/=""<cr>
" Always show the signcolumn
if has("patch-8.1.1564")
" Recently vim can merge signcolumn and number column into one
set signcolumn=number
else
set signcolumn=yes
endif
" Required for operations modifying multiple buffers like rename.
" Used by coc.nvim
set hidden
" Set more space for displaying messages
" Used by coc.nvim
set cmdheight=2
" Highlight the symbol and its references when holding the cursor.
autocmd CursorHold * silent call CocActionAsync('highlight')
" C-Space triggers autocompletion
inoremap <silent><expr> <c-space> coc#refresh()
" coc.nvim quick fix
nmap <leader>qf <Plug>(coc-fix-current)
" Use tab for trigger completion with characters ahead and navigate.
" Used by coc.nvim
inoremap <silent><expr> <TAB>
\ pumvisible() ? "\<C-n>" :
\ <SID>check_back_space() ? "\<TAB>" :
\ coc#refresh()
inoremap <expr><S-TAB> pumvisible() ? "\<C-p>" : "\<C-h>"
function! s:check_back_space() abort
let col = col('.') - 1
return !col || getline('.')[col - 1] =~# '\s'
endfunction
" Use <cr> to confirm completion, `<C-g>u` means break undo chain at current
" position.
" Used by coc.nvim
if exists('*complete_info')
inoremap <expr> <cr> complete_info()["selected"] != "-1" ? "\<C-y>" : "\<C-g>u\<CR>"
else
inoremap <expr> <cr> pumvisible() ? "\<C-y>" : "\<C-g>u\<CR>"
endif
" Use K to show documentation in preview window.
" Used by coc.nvim
nnoremap <silent> K :call <SID>show_documentation()<CR>
function! s:show_documentation()
if (index(['vim','help'], &filetype) >= 0)
execute 'h '.expand('<cword>')
else
call CocAction('doHover')
endif
endfunction
" CoC Status in LightLine
" Used by coc.nvim lightline.nvim
let g:lightline = {
\ 'colorscheme': 'one',
\ 'active': {
\ 'left': [ [ 'mode', 'paste' ],
\ [ 'cocstatus', 'readonly', 'filename', 'modified' ] ]
\ },
\ 'component_function': {
\ 'cocstatus': 'coc#status'
\ },
\ }
" Use auocmd to force lightline update.
" Used by coc.nvim lightline.nvim
autocmd User CocStatusChange,CocDiagnosticChange call lightline#update()
" Add `:Format` command to format current buffer.
" Used by coc.nvim
command! -nargs=0 Format :call CocAction('format')
" TODO: Pick and Chose the ones I want
" Mappings for CoCList
nnoremap <silent><nowait> <space>a :<C-u>CocList diagnostics<cr>
nnoremap <silent><nowait> <space>e :<C-u>CocList extensions<cr>
nnoremap <silent><nowait> <space>c :<C-u>CocList commands<cr>
" Plugged Plugins
call plug#begin(stdpath('data') . '/plugged')
" Blue Theme
Plug 'wadackel/vim-dogrun'
" Indent Detection
Plug 'tpope/vim-sleuth'
" One Dark Theme
Plug 'rakr/vim-one'
" Activity Tracking
" Plug 'ActivityWatch/aw-watcher-vim'
" Monokai Theme
Plug 'tomasr/molokai'
" Tender Theme
Plug 'jacoborus/tender.vim'
" Powerline Bar at bottom of screen
Plug 'itchyny/lightline.vim'
" Autocomplete
Plug 'neoclide/coc.nvim', {'branch': 'release'}
" Scope Tags
Plug 'majutsushi/tagbar'
" Rust Support
Plug 'rust-lang/rust.vim'
" TOML Support
Plug 'toml-lang/toml'
" Fuzzy Search
Plug 'junegunn/fzf'
" Multiple Cursors
Plug 'terryma/vim-multiple-cursors'
" File Browser
Plug 'preservim/nerdtree'
" NerdTree Icons (Should be last according to docs)
Plug 'ryanoasis/vim-devicons'
" Better Rust Synatax Highlighting
Plug 'arzg/vim-rust-syntax-ext'
" Auto-close brackets
Plug 'jiangmiao/auto-pairs'
call plug#end()
" Autosave with rust-fmt (Rust Only)
let g:rustfmt_autosave = 1
" Configuration
set noshowmode " Not Needed because we have Lightline
colorscheme one