-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit.vim
More file actions
158 lines (154 loc) · 4.22 KB
/
init.vim
File metadata and controls
158 lines (154 loc) · 4.22 KB
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
"--------- GETTING STARTED ---------
" This is my NeoVim Configuration
" =================================
" | NeoVim Version | v0.11.2
" | Plugin Manager | vim-plug
"-----------------------------------
"------------ OPTIONS --------------
set number
set relativenumber
set tabstop=4
set shiftwidth=4
set smartindent
set smarttab
set cursorline
set mouse=a
set clipboard=unnamedplus
set splitright
set splitbelow
set ignorecase
set smartcase
set incsearch
set hlsearch
set noswapfile
filetype off
syntax on
if has('termguicolors')
set termguicolors
endif
"------------- KEYMAPS -------------
let mapleader = " "
" | Save File
nnoremap <C-s> :w<CR>
inoremap <C-s> <Esc>:w<CR>gi
" | Quit
nnoremap <C-q> :q<CR>
" | Select All
nnoremap <C-a> ggVG
" | Undo
nnoremap <C-z> u
" | Redo
nnoremap <C-y> <C-r>
" | Go To Line
nnoremap <C-g> :call GoToLine()<CR>
function! GoToLine()
let l:line = input('Go to line: ')
if l:line =~ '^\d\+$'
execute 'normal!' l:line . 'Gzz'
else
echo "Invalid line number"
endif
endfunction
" | Switch Between Tabs
nnoremap <leader><Right> :tabnext<CR>
inoremap <leader><Left> :tabprevious<CR>
"----------- ADDITIONAL ------------
autocmd VimEnter * intro
"------------- PLUGINS -------------
let g:loaded_netrw=1
let g:loaded_netrwPlugin=1
call plug#begin()
"---------- CODE EDITOR ------------
Plug 'scrooloose/nerdtree'
Plug 'scrooloose/nerdcommenter'
Plug 'neoclide/coc.nvim', {'branch': 'release'}
"------------- THEMES --------------
Plug 'ryanoasis/vim-devicons'
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
"-----------------------------------
Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
Plug 'junegunn/fzf.vim'
Plug 'liuchengxu/vim-which-key'
call plug#end()
"-- KEY BINDINGS AND CONFIGURATION -
" leader is <space>
"-----------------------------------
" | NerdTree
let g:NERDTreeGitStatusWithFlags=1
let g:WebDevIconsUnicodeDecorateFolderNodes=1
let g:NERDTreeGitStatusNodeColorization=1
let g:NERDTreeMinimalUI=0
" | Auto Close NERDTree
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif
" | Open/Close -> space + b
nnoremap <leader>b :NERDTreeToggle<CR>
" | Reveal Current File -> space + br
nnoremap <leader>br :NERDTreeFind<CR>
" | Focus -> space + bf
nnoremap <leader>bf :NERDTreeFocus<CR>
" | Get Back To Editor
nnoremap <leader>bu <C-w>l<CR>
"-----------------------------------
" | DevIcons
set encoding=UTF-8
"-----------------------------------
" | NerdCommenter
let g:NERDCreateDefaultMappings = 1
" | comment out the current line | <leader>cc
" | uncomment the current line | <leader>c<space>
let g:NERDSpaceDelims = 1
let g:NERDCompactSexyComs = 1
let g:NERDDefaultAlign = 'left'
" | Fuzzy Finder
function! FilesCurrentDirectory()
call fzf#vim#files(expand('%:p:h'), fzf#vim#with_preview(), 0)
endfunction
function! RgCurrentBuffer()
let l:tempfile = tempname()
execute 'w! ' . l:tempfile
call fzf#vim#grep(
\ 'rg --column --line-number --no-heading --color=always --smart-case "" ' . shellescape(l:tempfile),
\ 1,
\ fzf#vim#with_preview({'dir': ''}),
\ 0)
endfunction
" | Find Files
nnoremap <C-p> :call FilesCurrentDirectory()<CR>
" | Find in Files
nnoremap <leader>f :call RgCurrentBuffer()<CR>
" | Switch Between Open Buffers
nnoremap <leader>bb :Buffers<CR>
" | View Command History
nnoremap <leader>hh :History<CR>
" | WhichKey
" | timeout, by default it set to 1600ms
nnoremap <silent> <leader> :WhichKey '<Space>'<CR>
set timeoutlen=500
" | Conquer of Completion
set hidden
set cmdheight=2
set updatetime=100
set shortmess+=c
set signcolumn=yes
inoremap <silent><expr> <TAB>
\ pumvisible() ? "\<C-n>" :
\ <SID>check_back_space() ? "\<TAB>" :
\ coc#refresh()
inoremap <expr><S-TAB> pumvisible() ? "\<C-p>" : "\<C-h>"
function! s:check_back_space() abort
let col = col('.') - 1
return !col || getline('.')[col - 1] =~# '\s'
endfunction
" | show documentation
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
"-----------------------------------