-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvimrc
201 lines (159 loc) · 4.83 KB
/
vimrc
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
set nocompatible
syntax on
set encoding=utf8
set modelines=0
filetype plugin indent on
set backspace=indent,eol,start
set autoindent
set background=dark
set hidden
set noswapfile
set mouse=a "switch on mouse scrolling
" disable Q for not automatically entering Ex mode
nnoremap Q <nop>
" highlight found words on search
set hlsearch
" show file path in status line
set statusline+=%F
" Hightlight current line
set cursorline
" change cursor shape for insert mode
let &t_SI = "\<Esc>]50;CursorShape=1\x7"
let &t_EI = "\<Esc>]50;CursorShape=0\x7"
" remapping commands
" set leader to space
let mapleader=" "
" automatically save when escaping insert mode
inoremap <Esc> <Esc>:w<CR>
" remap jf to escape
inoremap jf <Esc>:w<CR>
" show in NerdTree
map <leader>nf <Esc>:NERDTreeFind<cr>
" fit specific test
map <leader>fit <Esc>/^\s*it(<cr>N0f(i.only<Esc>
" unfit specific test
map <leader>unfit <Esc>/^\s*it.only(<cr>fodiwhx<Esc>
" remove highlighting with leader j
map <leader>j <Esc>:noh<CR>
" set nopaste with leader np
map <leader>np <Esc>:set nopaste<CR>
" eliminate white space with leader ;
nnoremap <leader>; mz:%s/\s\+$//<cr>:let @/=''<cr>`z<cr>:w<cr>
" indent entire page"
map <Leader>i mzgg=G`z
"navigating splits more easily
nnoremap <C-J> <C-W><C-J>
nnoremap <C-K> <C-W><C-K>
nnoremap <C-L> <C-W><C-L>
nnoremap <C-H> <C-W><C-H>
"show line number
set number
"use mac clipboard to copy and paste between other applications and vim
set clipboard+=unnamedplus
colorscheme wellsokai
set expandtab
set tabstop=2
set shiftwidth=2
"white space highlighting
highlight ExtraWhitespace ctermbg=blue
"line breaks
set wrap
set linebreak
set nolist "list disables linebreak
set textwidth=0
set wrapmargin=0
"spell check
"set spell check for markdown files only
autocmd FileType markdown setlocal spell spelllang=en_gb
"turn on spell check
set spellfile=$HOME/.vim-spell-en.utf-8.add
set complete+=kspell
let g:ale_fixers = {
\ 'javascript': ['prettier', 'eslint'],
\ 'typescript': ['prettier', 'eslint'],
\}
map <leader>af :ALEFix<CR>
"open nerdtree using Ctrl+n
map <C-n> :NERDTreeToggle<CR>
"show hidden files by default
let NERDTreeShowHidden=1
noremap j gj
noremap k gk
noremap gj j
noremap gk k
"Syntastic default settings
set statusline+=%#warningmsg#
set statusline+=%{SyntasticStatuslineFlag()}
set statusline+=%*
let g:syntastic_always_populate_loc_list = 1
let g:syntastic_auto_loc_list = 1
let g:syntastic_check_on_open = 1
let g:syntastic_check_on_wq = 0
"Enable jsx syntax highlighting for any js file
let g:jsx_ext_required = 0
"Hash rocket
imap <C-L> <SPACE>=><SPACE>
"snippets for console.log
" Console log from insert mode; Puts focus inside parentheses
imap cll console.log();<Esc>==f(a
" Console log from visual mode on next line, puts visual selection inside parentheses
vmap cll yocll<Esc>p
" Console log from normal mode, inserted on next line with word your on inside parentheses
nmap cll yiwocll<Esc>pF(a'<Esc>lyiwea', <Esc>p<Esc>
" add stars
imap cstar console.log('***********************');<Esc>
" stars from normal mode
nmap clo yiwocstar<Esc>hi, <ESC>p ")
" JavaScript try/catch block
nmap trca otry {<Esc>li<Enter><Esc>A catch (err<Esc>la {<Enter><Esc>kk
" JavaScript object one line to multi line
nmap ml V:s/, /,<C-v><Enter>/g<Enter><C-o>f{a<Enter><Esc>vi{=
" Elixir debugging log
nmap puts oIO.puts("\n***************************")<Esc>odbg()<Esc>i
" Elixir inspect in pipeline
nmap pi o\|> dbg()<Esc>
" eex tag
nmap eex o<%= %><Esc>F=
" end tag
nmap end o<% end %><Esc>
" use ripgrep to search files with ctrlp
if executable('rg')
let g:ctrlp_user_command = 'rg %s --files --hidden --color=never --glob ""'
endif
let g:ctrlp_custom_ignore = {
\ 'dir': '\.git$\|\.yardoc\|node_modules\|deps\|build\|coverage\|log\|tmp$',
\ 'file': '\.so$\|\.dat$|\.DS_Store$'
\ }
"find dotfiles
let g:ctrlp_show_hidden = 1
"supposed to make it faster
let g:ctrlp_max_files=0
let g:ctrlp_max_depth=40
"need to create a .vim/coAuthors file for this
"example syntax:
"nmap shortcutname oCo-authored-by: First Last <[email protected]><Esc>
" source ~/.vim/coAuthors.vim
"Fixes for vim-elixir plugin not detecting filetypes
au BufRead,BufNewFile *.ex,*.exs set filetype=elixir
au BufRead,BufNewFile *.eex,*.heex,*.leex,*.sface,*.lexs set filetype=eelixir
au BufRead,BufNewFile mix.lock set filetype=elixir
call plug#begin('~/.vim/plugged')
Plug 'raimondi/delimitMate'
Plug 'mattn/emmet-vim'
Plug 'scrooloose/nerdcommenter'
Plug 'scrooloose/nerdtree'
Plug 'Xuyuanp/nerdtree-git-plugin'
Plug 'vim-syntastic/syntastic'
Plug 'ntpeters/vim-better-whitespace'
Plug 'slashmili/alchemist.vim'
Plug 'tpope/vim-surround'
Plug 'dense-analysis/ale'
Plug 'tpope/vim-fugitive'
Plug 'ctrlpvim/ctrlp.vim'
Plug 'BurntSushi/ripgrep'
Plug 'tpope/vim-endwise'
Plug 'elixir-editors/vim-elixir'
Plug 'pangloss/vim-javascript'
Plug 'MaxMEllon/vim-jsx-pretty'
Plug 'github/copilot.vim'
call plug#end()