aboutsummaryrefslogtreecommitdiffstats
path: root/nvim/init.vim
blob: e73dc86fec39595feb2f6ec05f2e6cbe42367ee1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
"""
" Plugins
"

call plug#begin(expand('$XDG_CONFIG_HOME/nvim/plugs'))

" Base16 colorschemes
Plug 'chriskempson/base16-vim'

" Statusline replacement
Plug 'itchyny/lightline.vim'

" Change working directory to project root when opening file
Plug 'airblade/vim-rooter'

" Fuzzy finder.  Requires fzf package to be installed
Plug 'junegunn/fzf.vim'

Plug 'rust-lang/rust.vim'
Plug 'tpope/vim-git'

call plug#end()


"""
" Plugin settings
"

" Base16
let base16colorspace=256

" Lightline
let g:lightline = {
      \ 'colorscheme': 'wombat',
      \ }

" Fzf
let g:fzf_command_prefix = 'Fzf'

" rust.vim
let g:rust_clip_command = 'xclip -selection clipboard'
vnoremap <Leader>= :'<,'>RustFmtRange<CR>
nnoremap <Leader>= :RustFmt<CR>


"""
" NVim settings
"

syntax on
filetype plugin indent on
set hidden            " Automatically hide buffers with changes instead of requiring bangcommands
set number            " Always show line numbers
set ignorecase        " Ignore case of normal letters
set smartcase         " Case-sensitive search unless pattern is all lowercase
set wildignore=*.swp,*.bak,*.pyc,*.o  " File patterns to ignore on wildcard expansion
set title             " Change the terminal's title to the filename
set visualbell        " Don't beep
set backup            " Always keep backup files in case of crashes
set undofile          " Save undo's after file closes
set shortmess+=I      " Don't show the nag-screen
set showcmd           " Show partial command in the last line of the screen
set scrolloff=4       " Minimum number of screen lines under/above the cursor
set linebreak         " Don’t wrap lines in the middle of a word
set spelllang=en_us
set backupdir=$XDG_DATA_HOME/nvim/backup " Don't write backups in current dir
set termguicolors     " Use -guifg/-guibg attributes (24-bit colors)
set colorcolumn=100   " Show colored line at column 100
set inccommand=nosplit

set tabstop=4
set shiftwidth=4
set softtabstop=4
set noexpandtab
set copyindent

" Show tabs, end-of-line whitespace, and non-breaking spaces
set listchars=tab:»·,trail:·,nbsp:◊
set list

" Colors
colorscheme base16-atelier-dune

" Color spaces at end of lines bright red for visibility
highlight ExtraWhitespace ctermbg=red guibg=red
match ExtraWhitespace /\s\+$/
autocmd BufWinEnter * match ExtraWhitespace /\s\+$/
autocmd InsertEnter * match ExtraWhitespace /\s\+\%#\@<!$/
autocmd InsertLeave * match ExtraWhitespace /\s\+$/
autocmd BufWinLeave * call clearmatches()


"""
" Filetypes
"
augroup filetypedetect
	autocmd BufRead,BufNewFile *mutt-*              setfiletype mail
	autocmd BufRead,BufNewFile *.h                  setfiletype c
augroup END


" Horrible hack to work-around weird corrupted lines on window resize
" https://github.com/neovim/neovim/issues/7861
autocmd VimResized * redraw!


"""
" Mappings
"

nnoremap <silent> <Leader>/ :nohlsearch<CR>

" Easier window moving
noremap <C-h> <C-w>h
noremap <C-j> <C-w>j
noremap <C-k> <C-w>k
noremap <C-l> <C-w>l

noremap <Leader>p :FzfFiles<CR>
noremap <Leader>P :FzfFiles<space>
nnoremap <Leader>b :FzfBuffers<CR>

noremap <Leader>s :Rg<space>
command! -bang -nargs=* Rg
  \ call fzf#vim#grep(
  \   'rg --column --line-number --no-heading --color=always '.shellescape(<q-args>), 1,
  \   <bang>0 ? fzf#vim#with_preview('up:60%')
  \           : fzf#vim#with_preview('right:50%:hidden', '?'),
  \   <bang>0)