-
Notifications
You must be signed in to change notification settings - Fork 0
/
init.vim
172 lines (123 loc) · 3.56 KB
/
init.vim
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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
" Some common settings
set number relativenumber
set ignorecase smartcase
let mapleader = ","
" Fast access to buffers
nnoremap <leader>n :bn<cr>
nnoremap <leader>m :bp<cr>
" Quick escape
imap jj <esc>
" Quick save
noremap <leader>w :w<cr>
" Quick close
noremap <leader>q :q<cr>
" Quick config-load
noremap <leader>l :source ~/.config/nvim/init.vim<cr>
" Quick plug-install
noremap <leader>p :PlugInstall<cr>
" Quick Nerdtree toggle
noremap <leader>n :NERDTreeToggle<cr>
" Quick buffer cycle
noremap <C-J> :bprev<cr>
noremap <C-K> :bnext<cr>
" Quick coc mappings
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)
nmap <silent> rn <Plug>(coc-rename)
" Launch Magit
noremap <leader>mg :Magit<cr>
" Instant floating terminal
let g:floaterm_keymap_toggle = '<F1>'
" Automatically download Vim-Plug
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
autocmd VimEnter * PlugInstall --sync | source $MYVIMRC
endif
" Install a bunch of stuff using Vim-Plug
call plug#begin()
Plug 'tpope/vim-surround'
Plug 'tpope/vim-fugitive'
Plug 'tpope/vim-commentary'
Plug 'cespare/vim-toml'
Plug 'dense-analysis/ale'
Plug 'neomake/neomake'
Plug 'neovim/nvim-lspconfig'
Plug 'tjdevries/lsp_extensions.nvim'
Plug 'nvim-lua/completion-nvim'
" Floating terminal
Plug 'voldikss/vim-floaterm'
Plug 'fatih/vim-go'
" Nix syntax
Plug 'LnL7/vim-nix'
" Status-line
Plug 'itchyny/lightline.vim'
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
" Completion
Plug 'ctrlpvim/ctrlp.vim'
" Multi-language support
Plug 'sheerun/vim-polyglot'
" Completion
Plug 'neoclide/coc.nvim', {'branch': 'release'}
" Themes
Plug 'joshdick/onedark.vim'
" Friendly neighborhood file explorer
Plug 'preservim/nerdtree'
" Better scrolling
Plug 'psliwka/vim-smoothie'
" Git info while we roll
Plug 'airblade/vim-gitgutter'
" Better commeting support
Plug 'preservim/nerdcommenter'
" Halfway-decent Git integration
Plug 'jreybert/vimagit'
" Rust/cargo integration
Plug 'rust-lang/rust.vim'
" Sneak around text just a little bit faster
Plug 'justinmk/vim-sneak'
call plug#end()
" Default theme
colorscheme onedark
" Status line config
let g:lightline = {
\ 'colorscheme': 'onedark',
\ }
let g:airline_theme='onedark'
"let g:airline_powerline_fonts = 1
let g:airline#extensions#tabline#enabled = 1
" Basic ctrl-p setup (more gory details at
" https://github.com/kien/ctrlp.vim/blob/master/doc/ctrlp.txt)
let g:ctrlp_working_path_mode = 'ra'
let g:ctrlp_map = '<c-p>'
" Rust-analyzer setup:
"
" Set completeopt to have a better completion experience
" :help completeopt
" menuone: popup even when there's only one match
" noinsert: Do not insert text until a selection is made
" noselect: Do not select, force user to select one from the menu
set completeopt=menuone,noinsert,noselect
" Avoid showing extra messages when using completion
set shortmess+=c
" Configure LSP
" https://github.com/neovim/nvim-lspconfig#rust_analyzer
lua <<EOF
-- nvim_lsp object
local nvim_lsp = require'lspconfig'
-- function to attach completion.
-- when setting up lsp
local on_attach = function(client)
require'completion'.on_attach(client)
end
-- Enable rust_analyzer
nvim_lsp.rust_analyzer.setup({ on_attach=on_attach })
EOF
" Go-analyzer setup:
lua <<EOF
require'lspconfig'.gopls.setup{}
EOF
" Some experimental lua stuff
command! Scratch lua require'tools'.makeScratch()