-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvimrc
176 lines (146 loc) · 7.42 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
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Author: Sojharo
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" UI Config
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
syntax enable " Turn on syntax highlighting.
filetype plugin on " Enable vim to recognize different file types
set termguicolors " Set 24-bit RGB colors
set background=dark
colorscheme codedark " Color Scheme
set shortmess+=I " Disable the default Vim startup message.
set showcmd " Display an incomplete command
set hidden " Hide the unsaved buffers
set backspace=indent,eol,start " Backspace behaves normally
" Finding Files "
" Provides tab-completion for all file-related tasks
set path+=server/**,pages/**,src/** " Search down into subfolders
set path+=public/**
set path+=service/**
set wildmenu " display completion matches in a status line
" Split Config "
set splitbelow " Open new vertical split bottom
set splitright " Open new horizontal splits right
nnoremap <silent> <C-Left> :vertical resize +3<CR>
nnoremap <silent> <C-Right> :vertical resize -3<CR>
nnoremap <silent> <C-Up> :resize +3<CR>
nnoremap <silent> <C-Down> :resize -3<CR>
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Spaces, Tabs, folds and Completion
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set tabstop=2 " number of visual spaces per TAB
set softtabstop=2 " number of spaces in tab when editing
set expandtab " tabs are spaces, mainly because of python
set shiftwidth=2 " tabs when inserted with >>
filetype indent on " Setup for file type indents
set autoindent " enable the autoindent
set dictionary+=/usr/share/dict/words " completion from dictionary
" In insert mode, enter should confirm the completion shown
inoremap <expr> <cr> pumvisible() ? "\<C-y>" : "\<C-g>u\<CR>"
" Folding
set foldmethod=syntax "syntax highlighting items specify folds
set foldcolumn=1 "defines 1 col at window left, to indicate folding
let javaScript_fold=1 "activate folding by JS syntax
set foldlevelstart=99 "start file with all folds opened
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Searching
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set incsearch " search as characters are entered
set hlsearch " highlight matches
set ignorecase " Ignore case in searches by default
set smartcase " But make it case sensitive if an uppercase is entered
" Remove the highlighting when I insert ,<space>
nnoremap <silent> ,<space> :nohlsearch<CR>
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Line Numbering
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set number " Show line numbers.
set relativenumber " Show relative line numbers
" Automatic toggling between line number modes "
augroup numbertoggle
autocmd!
autocmd BufEnter,FocusGained,InsertLeave * set relativenumber
autocmd BufLeave,FocusLost,InsertEnter * set norelativenumber
augroup END
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Cursor Line and Column Configuration
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set cursorline " Highlight current line
set cursorcolumn " Highlight cursor column for code indents matching
" Automatic toggling cursor highlight on different modes
augroup cursorlinetoggle
autocmd!
autocmd InsertLeave * set cursorline
autocmd InsertEnter * set nocursorline
augroup END
" Automatic toggling cursor column highlight on different modes
augroup cursorcolumntoggle
autocmd!
autocmd InsertLeave * set cursorcolumn
autocmd InsertEnter * set nocursorcolumn
augroup END
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Status line Configuration
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
source $HOME/dotfiles/config_vim/statusline.vim
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" snippets & mappings for making coding easy
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" be careful to use your own path here instead of mine
nnoremap ;route :-1read $HOME/dotfiles/config_vim/snippets/skeleton.route.js<CR>fi
inoremap ,log console.log()<left>
nnoremap ;/ I// <ESC>
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" External Vim Configurations
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Be careful to use your own path here instead of mine
source $HOME/dotfiles/config_vim/autoclose.vim
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" File type specific settings
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Not using it for now. May use in future when I need it for other files
" Further discussion on https://www.reddit.com/r/vim/comments/gqxmcd/just_published_my_vim_configuration_trying_to_go/
" autocmd FileType javascript setlocal tabstop=2 softtabstop=2 expandtab shiftwidth=2 omnifunc=javascriptcomplete#CompleteJS
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Plugin settings
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Coc for Intellisense
nmap <silent> gd <Plug>(coc-definition)
nmap <silent> gy <Plug>(coc-type-definition)
nmap <silent> gi <Plug>(coc-implementation)
nmap <silent> gr <Plug>(coc-references)
" Use K to show documentation in preview window.
nnoremap <silent> K :call <SID>show_documentation()<CR>
function! s:show_documentation()
if (index(['vim','help'], &filetype) >= 0)
execute 'h '.expand('<cword>')
elseif (coc#rpc#ready())
call CocActionAsync('doHover')
else
execute '!' . &keywordprg . " " . expand('<cword>')
endif
endfunction
" Use ,k to close the floating window opened to show documentation using K
nnoremap <silent> ,k :call coc#float#close_all()<CR>
" Symbol renaming. (sometimes :%s/target/new/g works for me :) )
nmap <leader>rn <Plug>(coc-rename)
" Configuration for git messenger
let g:git_messenger_no_default_mappings = v:true
nmap <leader>b <Plug>(git-messenger)
let g:git_messenger_floating_win_opts = { 'border': 'single' }
let g:git_messenger_always_into_popup = v:true
" FZF settings
set rtp+=/opt/homebrew/opt/fzf
nmap <leader>f :call fzf#run({'sink': 'e', 'options': '--height 40% --reverse --border'})<CR>
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Other Resources
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" For vim colorschemes:
"
" https://github.com/crusoexia/vim-monokai
" https://github.com/ParamagicDev/vim-medic_chalk
" https://github.com/NLKNguyen/papercolor-theme
" https://github.com/tomasiser/vim-code-dark *
"
" vim colorschemes are stored in ~/.vim/colors on macos