-
Notifications
You must be signed in to change notification settings - Fork 0
/
.vimrc
209 lines (184 loc) · 7.41 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
202
203
204
205
206
207
208
" ============================================================
" Basic Settings
" ============================================================
" Ensure Vim is not in compatibility mode with vi
set nocompatible
" Keep a large history of commands for easy recall
set history=500
" Show the cursor's current position
set ruler
" Set the height of the command bar for better visibility
set cmdheight=2
" Enable case-insensitive searching for convenience
set ignorecase
" Use smart case searching for more refined results
set smartcase
" Highlight search results to make them stand out
set hlsearch
" Incremental search improves search interaction
set incsearch
" Enable magic mode for powerful regular expressions
set magic
" Highlight matching brackets for easier code navigation
set showmatch
" Set the blink time for matching brackets
set mat=2
" Avoid annoying error sounds
set noerrorbells
" Disable visual bells as well
set novisualbell
set t_vb=
" Set time to wait for a mapped sequence
set tm=500
" Optimize performance by not redrawing during macros
set lazyredraw
" Enhance backspace functionality
set backspace=eol,start,indent
" Allow cursor to move past screen edge
set whichwrap+=<,>,h,l
" Use UTF-8 encoding for universal compatibility
set encoding=utf8
" Support multiple file formats
set ffs=unix,dos,mac
" Set scroll offset for better context visibility
set so=7
" Use TAB for command line expansion
set wildchar=<TAB>
" Ignore case in command line expansion for usability
set wildignorecase
" Exclude certain files and directories from command line expansion
set wildignore+=*.o,*~,*.pyc,*.swp,*.zip,*/.git/*,*/.hg/*,*/.svn/*,*/.DS_Store,*/node_modules/*,*/bower_components/*
" ============================================================
" UI Configurations
" ============================================================
" Enable enhanced command line completion
set wildmenu
" Exclude more file types and directories in wildmenu
set wildignore+=*.o,*~,*.pyc,*.swp,*.zip
set wildignore+=*/.git/*,*/.hg/*,*/.svn/*,*/.DS_Store
set wildignore+=*/node_modules/*,*/bower_components/*
" Set wildmenu completion behavior
set wildmode=list:longest,full
" Show line numbers for reference
set number
" Show relative line numbers for easier navigation
set relativenumber
" Highlight the current line for focus
set cursorline
" Always display the status line for information
set laststatus=2
" Configure the folding column for code organization
set foldcolumn=1
" ============================================================
" Filetype Indentation and Syntax Highlighting
" ============================================================
" Enable filetype detection and plugins
filetype plugin on
" Enable filetype-based indentation
filetype indent on
" Turn on syntax highlighting for readability
syntax enable
" Configure indentation for specific file types
autocmd FileType python setlocal expandtab shiftwidth=4 softtabstop=4
autocmd FileType javascript setlocal expandtab shiftwidth=2 softtabstop=2
autocmd FileType bash setlocal expandtab shiftwidth=4 softtabstop=4
autocmd FileType yaml setlocal expandtab shiftwidth=2 softtabstop=2
autocmd FileType typescript setlocal expandtab shiftwidth=2 softtabstop=2
" ============================================================
" Leader Key and Mappings
" ============================================================
" Define the leader key for custom shortcuts
let mapleader = ","
" Create a shortcut for quick saving
nmap <leader>w :w!<CR>
" Toggle spell checking
nmap <leader>ss :setlocal spell!<CR>
" Clear search highlighting quickly
nmap <silent> <leader><cr> :noh<CR>
" ============================================================
" Backup, Undo, and File Reading
" ============================================================
" Enable backup files
set backup
" Specify backup file directory
set backupdir=~/.vim/backups
" Exclude certain files from backups
set backupskip=/tmp/*,*.tmp
" Specify undo file directory for persistent undo
set undodir=~/.vim_runtime/temp_dirs/undodir
" Enable persistent undo
set undofile
" ============================================================
" Performance Optimization
" ============================================================
" Configure plugin lazy loading for performance (specific configurations depend on the plugins used)
" ============================================================
" Plugin Configuration (Vim-Plug)
" ============================================================
" Install Vim-Plug if it's not already present
if empty(glob('~/.vim/autoload/plug.vim'))
silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs
\ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
autocmd VimEnter * PlugInstall | source $MYVIMRC
endif
" Begin plugin configurations
call plug#begin('~/.vim/plugged')
" Plugin declarations go here
" Language support for YAML, JSON, Python, TypeScript, Bash, JavaScript
Plug 'sheerun/vim-polyglot'
Plug 'leafgarland/typescript-vim'
Plug 'pangloss/vim-javascript'
Plug 'peitalin/vim-jsx-typescript'
Plug 'HerringtonDarkholme/yats.vim'
" Visualize indent across languages
Plug 'Yggdroot/indentLine'
" Git integration
Plug 'tpope/vim-fugitive'
" Interactive Debugger
Plug 'puremourning/vimspector'
" Linting automatically
Plug 'dense-analysis/ale'
call plug#end()
" ============================================================
" Terminal and Color Support
" ============================================================
" Enable 256 color support for certain terminals
if $COLORTERM == 'gnome-terminal' || $TERM_PROGRAM == 'iTerm.app'
set t_Co=256
endif
" ============================================================
" Additional Custom Functions
" ============================================================
" Custom functions and key mappings for enhanced functionality
" Speed up mode transitions
if ! has('gui_running')
set ttimeoutlen=10
augroup FastEscape
autocmd!
au InsertEnter * set timeoutlen=200
au InsertLeave * set timeoutlen=1000
augroup END
endif
" Autoclose brackets with line breaks, useful for JSON
inoremap {<CR> {<CR>}<Esc>O
" Abbreviations for faster typing
iab xdate <C-r>=strftime("%d/%m/%y %H:%M:%S")<cr>
" Bindings for efficient JSON editing
inoremap aa <ESC>la
inoremap <leader>i <ESC>o
" Key mappings to move between window splits
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>
" ============================================================
" Auto-commands and Fine Tuning
" ============================================================
" Additional auto-commands and tweaks based on personal preferences
" ============================================================
" Language-Specific Settings
" ============================================================
" Additional settings for specific programming languages
" ============================================================
" End of .vimrc
" ============================================================