Last active
February 16, 2021 13:49
-
-
Save C-Sinclair/79cc517a3f235da7127cf1d9e930caa3 to your computer and use it in GitHub Desktop.
My holy nvim config
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let mapleader =";" | |
if ! filereadable(system('echo -n "${XDG_CONFIG_HOME:-$HOME/.config}/nvim/autoload/plug.vim"')) | |
echo "Downloading junegunn/vim-plug to manage plugins..." | |
silent !mkdir -p ${XDG_CONFIG_HOME:-$HOME/.config}/nvim/autoload/ | |
silent !curl "https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim" > ${XDG_CONFIG_HOME:-$HOME/.config}/nvim/autoload/plug.vim | |
autocmd VimEnter * PlugInstall | |
endif | |
call plug#begin(system('echo -n "${XDG_CONFIG_HOME:-$HOME/.config}/nvim/plugged"')) | |
" Tags/Brackets | |
Plug 'tpope/vim-surround' | |
Plug 'tpope/vim-endwise' | |
Plug 'alvan/vim-closetag' | |
" Search | |
Plug 'junegunn/fzf', { 'do': { -> fzf#install() } } | |
Plug 'junegunn/fzf.vim' | |
" Git | |
Plug 'jreybert/vimagit' | |
" Powerbar | |
Plug 'bling/vim-airline' | |
Plug 'vim-airline/vim-airline-themes' | |
" Comments | |
Plug 'tpope/vim-commentary' | |
" Testing | |
Plug 'vim-test/vim-test' | |
" Close buffers | |
Plug 'moll/vim-bbye' | |
" Autocomplete | |
Plug 'neoclide/coc.nvim', { 'do': 'yarn install --frozen-lockfile' } | |
" Theme | |
" Plug 'artanikin/vim-synthwave84' | |
" Plug 'rktjmp/lush.nvim' | |
Plug 'liuchengxu/space-vim-dark' | |
call plug#end() | |
" Appearance | |
set termguicolors " enable true colors support | |
" colorscheme synthwave84 | |
colorscheme space-vim-dark | |
hi Comment cterm=italic | |
" Airline | |
let g:airline_powerline_fonts = 1 | |
let g:airline_theme='ouo' | |
let g:airline#extensions#hunks#enabled=0 | |
let g:airline_section_warning = 0 | |
let g:airline_section_y = 0 | |
let g:airline_section_z = 0 | |
" Misc | |
set mouse=a | |
set clipboard+=unnamedplus | |
nnoremap c "_c | |
set nocompatible | |
filetype plugin on | |
syntax on | |
set encoding=utf-8 | |
set number relativenumber | |
" Undo | |
let myUndoDir = system('echo -n $HOME/.local/undo') | |
let &undodir = myUndoDir | |
set undofile | |
" Settings for COC | |
set hidden | |
set nobackup | |
set nowritebackup | |
set updatetime=300 | |
set signcolumn=yes | |
set cmdheight=2 | |
set shortmess+=c | |
nmap <silent> gd <Plug>(coc-definition) | |
nmap <silent> gy <Plug>(coc-type-definition) | |
nmap <silent> gi <Plug>(coc-implementation) | |
nmap <silent> gr <Plug>(coc-references) | |
let g:go_def_mapping_enabled = 0 | |
" Used in the tab autocompletion for coc | |
function! s:check_back_space() abort | |
let col = col('.') - 1 | |
return !col || getline('.')[col - 1] =~# '\s' | |
endfunction | |
" Use <c-space> to trigger completion. | |
inoremap <silent><expr> <c-space> coc#refresh() | |
" Use `[g` and `]g` to navigate diagnostics | |
nmap <silent> [g <Plug>(coc-diagnostic-prev) | |
nmap <silent> ]g <Plug>(coc-diagnostic-next) | |
" Remap keys for gotos | |
nmap <silent> gd <Plug>(coc-definition) | |
nmap <silent> gy <Plug>(coc-type-definition) | |
nmap <silent> gi <Plug>(coc-implementation) | |
nmap <silent> gr <Plug>(coc-references) | |
" Tabs | |
set tabstop=4 | |
set shiftwidth=4 | |
set expandtab | |
" Buffers | |
nmap <Leader><Tab> :bn<cr> " Switch buffers | |
nmap <Leader><S-Tab> :bN<cr> " Switch buffers | |
nmap \q :Bdelete<cr> " Close buffer | |
" Enable autocompletion: | |
set wildmode=longest,list,full | |
" Disables automatic commenting on newline: | |
autocmd FileType * setlocal formatoptions-=c formatoptions-=r formatoptions-=o | |
" Splits open at the bottom and right, which is non-retarded, unlike vim defaults. | |
set splitbelow splitright | |
" Autocomplete with Coc | |
command! -nargs=0 Prettier :CocCommand prettier.formatFile | |
let g:coc_global_extensions = [ | |
\ 'coc-pairs', | |
\ 'coc-tsserver', | |
\ 'coc-css', | |
\ 'coc-prettier' | |
\ ] | |
" File explorer | |
map <leader>a :CocCommand explorer<CR> | |
" Shortcutting split navigation | |
map <C-h> <C-w>h | |
map <C-j> <C-w>j | |
map <C-k> <C-w>k | |
map <C-l> <C-w>l | |
" Open and close splits | |
map <Leader>l :vsp<cr> | |
map <Leader><Esc> :close<cr> | |
" Fuzzy search | |
map <C-p> :Files<cr> | |
map <C-b> :Buffers<cr> | |
map <C-f> :Lines<cr> | |
map <C-F> :Ag<cr> | |
" Search for selection | |
set hls | |
vmap * y:let @/ = @"<cr> | |
" Replace all is aliased to S. | |
nnoremap S :%s//g<Left><Left> | |
" Compile document, be it groff/LaTeX/markdown/etc. | |
map <leader>c :w! \| !compiler <c-r>%<CR> | |
" Open corresponding .pdf/.html or preview | |
map <leader>p :!opout <c-r>%<CR><CR> | |
" Runs a script that cleans out tex build files whenever I close out of a .tex file. | |
autocmd VimLeave *.tex !texclear % | |
" Save file as sudo on files that require root permission | |
cnoremap w!! execute 'silent! write !sudo tee % >/dev/null' <bar> edit! | |
" Automatically deletes all trailing whitespace and newlines at end of file on save. | |
autocmd BufWritePre * %s/\s\+$//e | |
autocmd BufWritepre * %s/\n\+\%$//e | |
" When shortcut files are updated, renew bash and ranger configs with new material: | |
autocmd BufWritePost files,directories !shortcuts | |
" Run xrdb whenever Xdefaults or Xresources are updated. | |
autocmd BufWritePost *Xresources,*Xdefaults !xrdb % | |
" Update binds when sxhkdrc is updated. | |
autocmd BufWritePost *sxhkdrc !pkill -USR1 sxhkd | |
" Turns off highlighting on the bits of code that are changed, so the line that is changed is highlighted but the actual text that has changed stands out on the line and is readable. | |
if &diff | |
highlight! link DiffText MatchParen | |
endif | |
" Rebuild DWMblocks on config file change | |
autocmd BufWritePost ~/.local/src/dwmblocks/config.h !cd ~/.local/src/dwmblocks/; sudo make install && { killall -q dwmblocks;setsid dwmblocks & } | |
" Scala | |
" Help Vim recognize *.sbt and *.sc as Scala files | |
au BufRead,BufNewFile *.sbt,*.sc set filetype=scala | |
" Terminal | |
nnoremap <leader>t :terminal<cr> | |
tnoremap <Esc> <C-\><C-n> | |
tnoremap <C-h> <C-h> | |
tnoremap <C-l> <C-l> | |
" Testing | |
nnoremap <C-t>n :TestNearest<cr> | |
nnoremap <C-t>l :TestLast<cr> | |
nnoremap <C-t>f :TestFile<cr> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment