-
Notifications
You must be signed in to change notification settings - Fork 0
/
dot_vimrc.tmpl
207 lines (172 loc) · 5.51 KB
/
dot_vimrc.tmpl
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
" -------------------
" | Plugin settings |
" -------------------
call plug#begin('~/.vim/plugged')
" Vim setup
Plug 'xolox/vim-misc'
Plug 'tmux-plugins/vim-tmux-focus-events'
Plug 'christoomey/vim-tmux-navigator'
" Syntax highlighting and coloring
Plug 'sheerun/vim-polyglot'
Plug 'morhetz/gruvbox'
" File navigation / finding
Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
Plug 'junegunn/fzf.vim'
Plug 'preservim/nerdtree'
Plug 'airblade/vim-rooter'
" Easier coding
Plug 'tpope/vim-commentary'
Plug 'dense-analysis/ale'
Plug 'vim-airline/vim-airline'
Plug 'tpope/vim-surround'
Plug 'jiangmiao/auto-pairs'
" Git
Plug 'Xuyuanp/nerdtree-git-plugin'
" Web programming
Plug 'alvan/vim-closetag'
Plug 'AndrewRadev/tagalong.vim'
" Chezmoi
Plug 'alker0/chezmoi.vim'
" Initialize plugin system
call plug#end()
runtime macros/matchit.vim
" -------------------
" | Editor settings |
" -------------------
let mapleader = ","
imap jj <Esc>
set backspace=indent,eol,start " More powerful backspacing
map <C-f> :FZF<CR>
map <leader>b :Buffers<CR>
nnoremap <leader>g :Rg<CR>
nnoremap <leader>t :Tags<CR>
nnoremap <leader>m :Marks<CR>
nnoremap <leader>h :History<CR>
" ---------------
" | UI settings |
" ---------------
let $FZF_DEFAULT_COMMAND = 'ag --hidden --ignore .git -l -g ""'
" Save file with leader w
nnoremap <leader>w :w<cr>
" Let higlight dissapear after pressing enter in search mode
nnoremap <leader><space> :noh<CR><CR>:<backspace>
" TAB in general mode will move to text buffer
nnoremap <TAB> :bnext<CR>
" SHIFT-TAB will go back
nnoremap <S-TAB> :bprevious<CR>
"
" <TAB>: completion.
inoremap <expr><TAB> pumvisible() ? "\<C-n>" : "\<TAB>"
"Remove all trailing whitespace by pressing F5
nnoremap <F5> :let _s=@/<Bar>:%s/\s\+$//e<Bar>:let @/=_s<Bar><CR>
set incsearch "Search as chars are entered
set hlsearch "Highlight searches
set splitbelow
set splitright
set smarttab
set smartindent
set laststatus=0
set cursorline
set tabline=2
set noshowmode
set nobackup
set nowritebackup
set updatetime=300
set timeoutlen=500
set clipboard=unnamedplus
" Live update vim files as they are changed outside the scope of Vim
set autoread
au FocusGained,BufEnter * :checktime
"
" Set standard clipboard settings
set clipboard=unnamedplus
" Line numbers in hybrid mode
set number relativenumber
" Toggle between relative and absolute line number according to
augroup numbertoggle
autocmd!
autocmd BufEnter,FocusGained,InsertLeave * set relativenumber
autocmd BufLeave,FocusLost,InsertEnter * set norelativenumber
:augroup END
" Set proper tabs and spaces per filetype
autocmd Filetype html setlocal ts=2 sw=2 expandtab
autocmd Filetype json setlocal ts=2 sw=2 expandtab
autocmd Filetype vue setlocal ts=2 sw=2 expandtab
autocmd Filetype javascript setlocal ts=2 sw=2 expandtab
autocmd Filetype php setlocal ts=2 sw=2 expandtab
" ------------------------------------------
" | Theme and syntax highlighting settings |
" ------------------------------------------
"Use 24-bit (true-color) mode in Vim/Neovim when outside tmux.
"If you're using tmux version 2.2 or later, you can remove the outermost $TMUX check and use tmux's 24-bit color support
"(see < http://sunaku.github.io/tmux-24bit-color.html#usage > for more information.)
if (empty($TMUX))
if (has("nvim"))
"For Neovim 0.1.3 and 0.1.4 < https://github.com/neovim/neovim/pull/2198 >
let $NVIM_TUI_ENABLE_TRUE_COLOR=1
endif
"For Neovim > 0.1.5 and Vim > patch 7.4.1799 < https://github.com/vim/vim/commit/61be73bb0f965a895bfb064ea3e55476ac175162 >
"Based on Vim patch 7.4.1770 (`guicolors` option) < https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd >
" < https://github.com/neovim/neovim/wiki/Following-HEAD#20160511 >
if (has("termguicolors"))
set termguicolors
endif
endif
" Enable syntax highlighting
syntax on
" Set onedark theme
set bg=dark
colorscheme gruvbox
if !has("gui_running")
let g:gruvbox_termcolors=16
endif
" ---------------------
" | NERDTree settings |
" ---------------------
" Exit NERDTree if last file has been closed
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif
nnoremap <F2> :NERDTreeToggle<CR>
" ----------------
" | Ale settings |
" ----------------
let g:ale_sign_column_always = 1
let g:airline#extensions#ale#enabled = 1
nmap <F10> :ALEFix<cr>
let g:ale_fix_on_save = 1
let g:ale_fixers = {
\'vue': ['prettier'],
\'javascript': ['prettier'],
\'python': ["black"],
\'json': ['jq'],
\}
let g:ale_linters = {
\"python": ["flake8", "pylint", "mypy", "black"],
\}
let g:ale_python_mypy_options = '--ignore-missing-imports'
let g:ale_python_flake8_options = '--max-line-length=88'
" --------------------------------
" | HTML auto close tag settings |
" --------------------------------
let g:closetag_filesnames = '*.html,*.vue*,.xhtml,*.phtml'
let g:closetag_xhtml_filenames = '*.xhtml,*.jsx'
let g:closetag_filetypes = 'html,vue,xhtml,phtml'
let g:closetag_xhtml_filetypes = 'xhtml,jsx'
let g:closetag_emptyTags_caseSensitive = 1
let g:closetag_regions = {
\ 'typescript.tsx': 'jsxRegion,tsxRegion',
\ 'javascript.jsx': 'jsxRegion',
\ }
"Standard close tag shortcut
let g:closetag_shortcut = '>'
" Add > at current position without closing the current tag, default is
let g:closetag_close_shortcut = '<leader>>'
" Highlight matching tags for html and Vue files
let g:mta_filetypes = {
\ 'html' : 1,
\ 'xhtml' : 1,
\ 'xml' : 1,
\ 'jinja' : 1,
\ 'vue' : 1,
\}
" Fix for not showing css within style tags
let html_no_rendering=1