-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinit.vim
251 lines (231 loc) · 7.74 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
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
" Alex's nvimrc
"{{{
" Set up vim-plug
let s:vim_plugger = expand('$HOME/.config/nvim/autoload/plug.vim')
if filewritable(s:vim_plugger) == 0
!curl -fLo ~/.config/nvim/autoload/plug.vim --create-dirs
\ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
autocmd VimEnter * PlugInstall
endif
" Touch untracked config files
let colourme=1
let colour_vim=expand('~/.config/nvim/colours.vim')
if !filereadable(colour_vim)
echo "Creating colour file - declare colorscheme in colours.vim"
echo ""
silent !echo 'colorscheme onedark' > ~/.config/nvim/colours.vim
let colourme=0
endif
"}}}
" Plugins go here:
"{{{
call plug#begin()
Plug 'tpope/vim-fugitive'
Plug 'tpope/vim-surround'
Plug 'tpope/vim-unimpaired'
Plug 'tpope/vim-eunuch'
Plug 'tpope/vim-commentary'
Plug 'tpope/vim-repeat'
Plug 'w0rp/ale'
Plug 'sheerun/vim-polyglot'
Plug 'Shougo/deoplete.nvim'
Plug 'Shougo/neosnippet.vim'
Plug 'Shougo/neosnippet-snippets'
Plug 'Shougo/neco-vim'
Plug 'Shougo/neoinclude.vim'
Plug 'majutsushi/tagbar'
Plug 'szw/vim-tags'
Plug 'NLKNguyen/c-syntax.vim'
Plug 'joshdick/onedark.vim'
Plug 'junegunn/rainbow_parentheses.vim'
Plug 'lilydjwg/colorizer'
Plug 'mhinz/vim-startify'
Plug 'molok/vim-smartusline'
Plug 'lluchs/vim-wren'
Plug 'hashivim/vim-terraform'
Plug 'hashivim/vim-consul'
call plug#end()
"}}}
" END BUNDLES / START MAIN RC
"{{{
" Basic Settings
let mapleader="," " change the leader to be a comma vs slash
set number " Display line numbers
set relativenumber
set lazyredraw " macros go faster when you don't redraw during them.
set numberwidth=1 " using only 1 column (and 1 space) while possible
source ~/.config/nvim/colours.vim
source ~/.config/nvim/statusline.vim
source ~/.config/nvim/ScratchEdit.vim
set title " show title in console title bar
set wildignore+=*.o,*.obj,.git,*.pyc " Ignore these files when completing
set completeopt=menuone,longest,preview " don't select first item, follow typing in autocomplete
set pumheight=6 " Keep a small completion window
set omnifunc=syntaxcomplete#Complete
set grepprg=ack-grep " replace the default grep program with ack
set splitbelow
set splitright
set vb t_vb= " Disable all bells. I hate ringing/flashing.
set confirm " Y-N-C prompt if closing with unsaved changes.
set showcmd " Show incomplete normal mode commands as I type.
set report=0 " : commands always print changed line count.
set shortmess+=a " Use [+]/[RO]/[w] for modified/readonly/written.
set ruler " Show some info, even without statuslines.
set rulerformat=%30(%=\:b%n%y%m%r%w\ %l,5c5V\ %P%) " a ruler on steroids
set listchars=tab:▸\ ,eol:¶,trail:·,precedes:«,extends:» " Easily see tabs, spaces, end of line etc.
set fillchars=vert:▎,fold:▂
set list
au TermOpen * setlocal nolist nocursorline nocursorcolumn " Clean up for :terminal
set ignorecase " Default to using case insensitive searches,
set smartcase " unless uppercase letters are used in the regex.
" True Colours
set termguicolors
" Pane independent search
augroup last_search
autocmd!
autocmd WinLeave * let w:last_search = @/
autocmd WinEnter * if exists('w:last_search') | let @/ = w:last_search | endif
augroup END
set noswapfile " Turn off swap files
set nowb "no writebackup
"keep undo history across sessions by storing in file
let s:vim_cache = expand('$HOME/.config/nvim/backups')
if filewritable(s:vim_cache) == 0 && exists("*mkdir")
call mkdir(s:vim_cache, "p", 0700)
endif
set undodir=~/.config/nvim/backups
set undofile
set cursorline " have a line indicate the cursor location
set cursorcolumn " have a column to indicate the cursor location
set nostartofline " Avoid moving cursor to BOL when jumping around
set virtualedit=block " Let cursor move past the last char in <C-v> mode
set scrolloff=5 " Keep 3 context lines above and below the cursor
set showmatch " Briefly jump to a paren once it's balanced
set matchtime=2 " (for only .2 seconds).
set nowrap " don't wrap text
set linebreak " don't wrap textin the middle of a word
set matchpairs+=<:> " show matching <> (html mainly) as well
set cinoptions=:0,g0,(0,Ws,l1 " Set a few indentation parameters.
set switchbuf=useopen,usetab
map <leader>q :tabclose<cr>
map gp :tabprevious<cr>
" ctrl-jklm changes to that split
map <c-j> <c-w>j
map <c-k> <c-w>k
map <c-l> <c-w>l
map <c-h> <c-w>h
" and lets make these all work in insert mode too
imap <c-j> <c-o><c-w>j
imap <c-k> <c-o><c-w>k
imap <c-l> <c-o><c-w>l
imap <c-h> <c-o><c-w>h
" Use ctrl-g in insert mode to input digraphs
inoremap <c-g> <c-k>
set clipboard+=unnamedplus "Neovim uses xclip or xsel
noremap x "_x
vnoremap p "_c<Esc>P
" show a line at column 80
set colorcolumn=80
autocmd BufReadPost *
\ if line("'\"") > 1 && line("'\"") <= line("$") |
\ exe "normal! g`\"" |
\ endif
"Spell Check (f for fuckup)
map <silent> <leader>f :set spell!<CR>
" Set working directory
nnoremap <leader>. :lcd %:p:h<CR>
"Remove trailing whitespace on <leader>S
nnoremap <leader>S :%s/\s\+$//<cr>:let @/=' '<CR>
"Use pandoc to create a pdf of current file
nnoremap <Leader>p :!pandoc % -s -o %:r.pdf<CR>
"""" Reading/Writing
set ffs=unix,dos,mac " Try recognizing dos, unix, and mac line endings.
autocmd BufWritePre * set ff=unix
" Prevent vim from setting filetype to `plaintex`
let g:tex_flavor='latex'
set t_Co=256 " Some terminals *REALLY* need this
"}}}
" Plugin Configurations
"{{{
let g:smartusline_string_to_highlight = '[%t]'
" Quick open startify
map <leader>s :Startify<CR>
" close preview window automatically when we move around
autocmd CursorMovedI * if pumvisible() == 0|pclose|endif
autocmd InsertLeave * if pumvisible() == 0|pclose|endif
" Fugitive - go to repo root
nnoremap <leader>/ :Glcd<CR>
" Map TagBar toggle to F8
nmap <F8> :TagbarToggle<CR>
"Rainbow Parentheses
au VimEnter * RainbowParentheses
let g:rainbow#max_level = 16
let g:rainbow#pairs = [['(', ')'], ['[', ']'], ['{', '}']]
let g:rainbow#blacklist = [233, 234]
" NeoSnippet mappings (^k to expand a selected snippet)
imap <C-k> <Plug>(neosnippet_expand_or_jump)
smap <C-k> <Plug>(neosnippet_expand_or_jump)
xmap <C-k> <Plug>(neosnippet_expand_target)
" SuperTab like NeoSnippet mappings (tab to jump to next field)
imap <expr><TAB> neosnippet#expandable_or_jumpable() ?
\ "\<Plug>(neosnippet_expand_or_jump)"
\: pumvisible() ? "\<C-n>" : "\<TAB>"
smap <expr><TAB> neosnippet#expandable_or_jumpable() ?
\ "\<Plug>(neosnippet_expand_or_jump)"
\: "\<TAB>"
" For snippet complete marker
if has('conceal')
set conceallevel=2 concealcursor=inv
endif
autocmd InsertLeave * NeoSnippetClearMarkers
"Deoplete
let g:deoplete#enable_at_startup = 1
let g:deoplete#auto_completion_start_length = 1
" <TAB> completion
imap <silent><expr> <TAB>
\ pumvisible() ? "\<C-n>" :
\ <SID>check_back_space() ? "\<TAB>" :
\ deoplete#mappings#manual_complete()
function! s:check_back_space()
let col = col('.') - 1
return !col || getline('.')[col - 1] =~ '\s'
endfunction
" Open Plug window bottom, horizontal
let g:plug_window='botright new'
" Allow Vim-Terraform to override indentation and syntax
let g:terraform_align=1
" Hack to disable colorcolumn for startify
autocmd FileType startify setlocal colorcolumn&
let g:startify_files_number = 3
let g:startify_change_to_vcs_root = 1
let g:startify_session_persistence = 1
let g:startify_session_dir = '~/.config/nvim/sessions'
let g:startify_change_to_dir = 1
let g:startify_list_order = [
\ [' My Sessions'],
\ 'sessions',
\ [' Recently Edited Here'],
\ 'dir',
\ [' Recently Edited'],
\ 'files',
\ [' My Bookmarks'],
\ 'bookmarks',
\ ]
let g:startify_skiplist = [
\ '.git/',
\ $VIMRUNTIME .'/doc',
\ 'bundle/.*/doc',
\ 'plugged/.*/doc',
\ '^/tmp',
\ '.*history',
\ '.*lock',
\ '.news_time',
\ '.viminfo',
\ '.nviminfo',
\ '.zcompdump*',
\ '.*session-errors*',
\ '.nvim*',
\]
source ~/.config/nvim/headers/kraken.vim
"}}}
" vim:ft=vim:fdm=marker