-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathinit.vim
124 lines (90 loc) · 2.49 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
" Set options
" ===========
set expandtab
set foldlevel=99
set foldmethod=indent
set list
set listchars=tab:▸\ ,eol:¬
set nowrap
set number
set shiftwidth=2
set splitbelow
set splitright
set tabstop=2
"use system clipboard when yanking/putting
set clipboard=unnamedplus
"allow local nvimrc files and allow us of :autocmd, shell and write commands
set exrc
set secure
" Key binds
" =========
"Remap leader to SPACE
let mapleader="\<SPACE>"
"open project file drawer
nmap <leader>b :NERDTreeToggle<CR>
"open fuzzy search
nmap <leader>f :FZF<CR>
"toggle code folding
nmap <leader>l za
nmap <leader>r :so ~/.config/nvim/init.vim<CR>
"run tests in the current file (or last file if not in a test file)
nmap <leader>tf :TestFile<CR>
"run the whole test suite
nmap <leader>ta :TestSuite<CR>
" Find the alternate file for the current path and open it
nnoremap <leader>. :w<cr>:call AltCommand(expand('%'), ':e')<cr>
" copy the realtive path to the current file to the clipboard
nmap cp :let @+ = expand("%")<CR>
" Functions
" =========
" Function to source only if file exists
function! SourceIfExists(file)
if filereadable(expand(a:file))
exe 'source' a:file
endif
endfunction
" Run a given vim command on the results of alt from a given path.
function! AltCommand(path, vim_command)
let l:alternate = system("alt " . a:path)
if empty(l:alternate)
echo "No alternate file for " . a:path . " exists!"
else
exec a:vim_command . " " . l:alternate
endif
endfunction
" Plugins
" =======
call plug#begin('~/.local/share/nvim/plugged')
" languages
Plug 'elixir-lang/vim-elixir'
Plug 'pangloss/vim-javascript'
Plug 'slashmili/alchemist.vim'
Plug 'tpope/vim-rails'
Plug 'vim-ruby/vim-ruby'
" tools
Plug 'airblade/vim-gitgutter'
Plug 'benmills/vimux'
Plug 'editorconfig/editorconfig-vim'
Plug 'ervandew/supertab'
Plug 'janko-m/vim-test'
Plug '/usr/local/opt/fzf' | Plug 'junegunn/fzf.vim'
Plug 'mattn/emmet-vim'
Plug 'ntpeters/vim-better-whitespace'
Plug 'scrooloose/nerdtree'
Plug 'tpope/vim-commentary'
Plug 'tpope/vim-repeat'
Plug 'tpope/vim-surround'
Plug 'Xuyuanp/nerdtree-git-plugin'
" Custom
call SourceIfExists("~/.config/nvim/custom_plugins.vim")
call plug#end()
" Plugin options
" ==============
" use the neovim terminal to run tests
let test#strategy = "neovim"
" Colorscheme
" ===========
call SourceIfExists("~/.config/nvim/custom_color.vim")
" Overrides - Don't like any of the options in this file? Override them!
" =========
call SourceIfExists("~/.config/nvim/custom_overrides.vim")