├── coc-settings.json
├── README.md
└── init.vim
/coc-settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "suggest.noselect": false,
3 | "coc.preferences.formatOnSaveFiletypes": [
4 | "javascript",
5 | "typescript",
6 | "python",
7 | "typescriptreact",
8 | "json",
9 | "javascriptreact",
10 | "typescript.tsx",
11 | "graphql"
12 | ]
13 | }
14 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Make your NeoVim looks like VSCode
2 | This is a public repo, that contains some settings and plugins that allows you to use NeoVim like Visual Studio Code.
3 | #### You can clone the repository into your nvim folder, or enter the repository files, and copy only the settings you need
4 | #### After that, you just have to open your ```init.vim```, probably located at ```/home/your_user/.config/nvim```, press ```ESC```, and then type ```:PlugInstall``` to auto-detect the plugins and install them
5 | #### To display the icons correctly, make sure your terminal is using a Nerd Font, here is the link to check the fonts: https://github.com/ryanoasis/nerd-fonts#patched-fonts
6 |
7 |
8 |
9 |
10 | Why should you use NeoVim instead of VSCode? 🤔
11 |
12 | - If you haven't a lot of RAM and CPU available, NeoVim is a good alternative
13 | - NeoVim is an improved version of the traditional and famous editor Vim
14 | - NeoVim is an open-source text-editor, and also is a highly extensible editor
15 | - You can customize it by using plugins, or VimScript
16 | - NeoVim is very light, does not lock, its startup is fast and consumes very little resources on your machine
17 |
18 |
19 | By using this settings, how will my NeoVim looks like?
20 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/init.vim:
--------------------------------------------------------------------------------
1 | " Specify a directory for plugins
2 | call plug#begin('~/.vim/plugged')
3 |
4 | Plug 'dense-analysis/ale'
5 | Plug 'mattn/emmet-vim'
6 | Plug 'neoclide/coc.nvim', {'branch': 'release'}
7 | Plug 'scrooloose/nerdtree'
8 | "Plug 'tsony-tsonev/nerdtree-git-plugin'
9 | Plug 'Xuyuanp/nerdtree-git-plugin'
10 | Plug 'tiagofumo/vim-nerdtree-syntax-highlight'
11 | Plug 'ryanoasis/vim-devicons'
12 | Plug 'airblade/vim-gitgutter'
13 | Plug 'ctrlpvim/ctrlp.vim' " fuzzy find files
14 | Plug 'scrooloose/nerdcommenter'
15 | "Plug 'prettier/vim-prettier', { 'do': 'yarn install' }"
16 | Plug 'christoomey/vim-tmux-navigator'
17 | Plug 'sheerun/vim-polyglot'
18 | Plug 'morhetz/gruvbox'
19 | Plug 'rafi/awesome-vim-colorschemes'
20 | Plug 'vim-airline/vim-airline'
21 | Plug 'Yggdroot/indentLine'
22 | Plug 'HerringtonDarkholme/yats.vim' " TS Syntax
23 | Plug 'tomasiser/vim-code-dark'
24 |
25 | " Initialize plugin system
26 | call plug#end()
27 |
28 | inoremap jk
29 | nmap :NERDTreeToggle
30 | vmap ++ NERDCommenterToggle
31 | nmap ++ NERDCommenterToggle
32 |
33 | set mouse=a
34 | set number
35 | set hidden
36 | set cursorline
37 | set expandtab
38 | set autoindent
39 | set smartindent
40 | set shiftwidth=4
41 | set tabstop=4
42 | set encoding=utf8
43 | set history=5000
44 | set clipboard=unnamedplus
45 |
46 | " open NERDTree automatically
47 | autocmd StdinReadPre * let s:std_in=1
48 | autocmd VimEnter * NERDTree
49 |
50 | let g:NERDTreeGitStatusWithFlags = 1
51 | "let g:WebDevIconsUnicodeDecorateFolderNodes = 1
52 | "let g:NERDTreeGitStatusNodeColorization = 1
53 | "let g:NERDTreeColorMapCustom = {
54 | "\ "Staged" : "#0ee375",
55 | "\ "Modified" : "#d9bf91",
56 | "\ "Renamed" : "#51C9FC",
57 | "\ "Untracked" : "#FCE77C",
58 | "\ "Unmerged" : "#FC51E6",
59 | "\ "Dirty" : "#FFBD61",
60 | "\ "Clean" : "#87939A",
61 | "\ "Ignored" : "#808080"
62 | "\ }
63 |
64 |
65 | let g:NERDTreeIgnore = ['^node_modules$']
66 |
67 | " vim-prettier
68 | "let g:prettier#quickfix_enabled = 0
69 | "let g:prettier#quickfix_auto_focus = 0
70 | " prettier command for coc
71 | command! -nargs=0 Prettier :CocCommand prettier.formatFile
72 | " run prettier on save
73 | "let g:prettier#autoformat = 0
74 | "autocmd BufWritePre *.js,*.jsx,*.mjs,*.ts,*.tsx,*.css,*.less,*.scss,*.json,*.graphql,*.md,*.vue,*.yaml,*.html PrettierAsync
75 |
76 |
77 | " ctrlp
78 | let g:ctrlp_user_command = ['.git/', 'git --git-dir=%s/.git ls-files -oc --exclude-standard']
79 |
80 | " j/k will move virtual lines (lines that wrap)
81 | noremap j (v:count == 0 ? 'gj' : 'j')
82 | noremap k (v:count == 0 ? 'gk' : 'k')
83 | nnoremap :w
84 | nnoremap :wq
85 |
86 | " shift+arrow selection
87 | nmap v
88 | nmap v
89 | nmap v
90 | nmap v
91 | vmap
92 | vmap
93 | vmap
94 | vmap
95 | imap v
96 | imap v
97 | imap v
98 | imap v
99 |
100 | vmap yi
101 | vmap di
102 | map pi
103 | imap pi
104 |
105 | set cindent
106 | colorscheme codedark
107 |
108 | " sync open file with NERDTree
109 | " " Check if NERDTree is open or active
110 | function! IsNERDTreeOpen()
111 | return exists("t:NERDTreeBufName") && (bufwinnr(t:NERDTreeBufName) != -1)
112 | endfunction
113 |
114 | " Call NERDTreeFind iff NERDTree is active, current window contains a modifiable
115 | " file, and we're not in vimdiff
116 | function! SyncTree()
117 | if &modifiable && IsNERDTreeOpen() && strlen(expand('%')) > 0 && !&diff
118 | NERDTreeFind
119 | wincmd p
120 | endif
121 | endfunction
122 |
123 | " Highlight currently open buffer in NERDTree
124 | autocmd BufEnter * call SyncTree()
125 |
126 | " coc config
127 | let g:coc_global_extensions = [
128 | \ 'coc-snippets',
129 | \ 'coc-pairs',
130 | \ 'coc-tsserver',
131 | \ 'coc-eslint',
132 | \ 'coc-prettier',
133 | \ 'coc-json',
134 | \ 'coc-python',
135 | \ ]
136 | " from readme
137 | " if hidden is not set, TextEdit might fail.
138 | set hidden " Some servers have issues with backup files, see #649 set nobackup set nowritebackup " Better display for messages set cmdheight=2 " You will have bad experience for diagnostic messages when it's default 4000.
139 | set updatetime=300
140 |
141 | " don't give |ins-completion-menu| messages.
142 | set shortmess+=c
143 |
144 | " always show signcolumns
145 | set signcolumn=yes
146 |
147 | " Use tab for trigger completion with characters ahead and navigate.
148 | " Use command ':verbose imap ' to make sure tab is not mapped by other plugin.
149 | inoremap
150 | \ pumvisible() ? "\" :
151 | \ check_back_space() ? "\" :
152 | \ coc#refresh()
153 | inoremap pumvisible() ? "\" : "\"
154 |
155 | function! s:check_back_space() abort
156 | let col = col('.') - 1
157 | return !col || getline('.')[col - 1] =~# '\s'
158 | endfunction
159 |
160 | " Use to trigger completion.
161 | inoremap coc#refresh()
162 |
163 | " Use to confirm completion, `u` means break undo chain at current position.
164 | " Coc only does snippet and additional edit on confirm.
165 | inoremap pumvisible() ? "\" : "\u\"
166 | " Or use `complete_info` if your vim support it, like:
167 | " inoremap complete_nfo()["selected"] != "-1" ? "\" : "\u\"
168 |
169 | " Use `[g` and `]g` to navigate diagnostics
170 | nmap [g (coc-diagnostic-prev)
171 | nmap ]g (coc-diagnostic-next)
172 |
173 | " Remap keys for gotos
174 | nmap gd (coc-definition)
175 | nmap gy (coc-type-definition)
176 | nmap gr (coc-references)
177 |
178 | " Use K to show documentation in preview window
179 | nnoremap K :call show_documentation()
180 |
181 | function! s:show_documentation()
182 | if (index(['vim','help'], &filetype) >= 0)
183 | execute 'h '.expand('')
184 | else
185 | call CocAction('doHover')
186 | endif
187 | endfunction
188 |
189 | " Highlight symbol under cursor on CursorHold
190 | autocmd CursorHold * silent call CocActionAsync('highlight')
191 |
192 | " Remap for rename current word
193 | nmap (coc-rename)
194 |
195 | " Remap for format selected region
196 | xmap f (coc-format-selected)
197 | nmap f (coc-format-selected)
198 |
199 | augroup mygroup
200 | autocmd!
201 | " Setup formatexpr specified filetype(s).
202 | autocmd FileType typescript,json setl formatexpr=CocAction('formatSelected')
203 | " Update signature help on jump placeholder
204 | autocmd User CocJumpPlaceholder call CocActionAsync('showSignatureHelp')
205 | augroup end
206 |
207 | " Remap for do codeAction of selected region, ex: `aap` for current paragraph
208 | xmap a (coc-codeaction-selected)
209 | nmap a (coc-codeaction-selected)
210 |
211 | " Remap for do codeAction of current line
212 | nmap ac (coc-codeaction)
213 | " Fix autofix problem of current line
214 | nmap qf (coc-fix-current)
215 |
216 | " Create mappings for function text object, requires document symbols feature of languageserver.
217 | xmap if (coc-funcobj-i)
218 | xmap af (coc-funcobj-a)
219 | omap if (coc-funcobj-i)
220 | omap af (coc-funcobj-a)
221 |
222 | " Use for select selections ranges, needs server support, like: coc-tsserver, coc-python
223 | nmap (coc-range-select)
224 | xmap (coc-range-select)
225 |
226 | " Use `:Format` to format current buffer
227 | command! -nargs=0 Format :call CocAction('format')
228 |
229 | " Use `:Fold` to fold current buffer
230 | command! -nargs=? Fold :call CocAction('fold', )
231 |
232 | " use `:OR` for organize import of current buffer
233 | command! -nargs=0 OR :call CocAction('runCommand', 'editor.action.organizeImport')
234 |
235 | " Add status line support, for integration with other plugin, checkout `:h coc-status`
236 | set statusline^=%{coc#status()}%{get(b:,'coc_current_function','')}
237 |
238 | " Using CocList
239 | " Show all diagnostics
240 | nnoremap a :CocList diagnostics
241 | " Manage extensions
242 | nnoremap e :CocList extensions
243 | " Show commands
244 | nnoremap c :CocList commands
245 | " Find symbol of current document
246 | nnoremap o :CocList outline
247 | " Search workspace symbols
248 | nnoremap s :CocList -I symbols
249 | " Do default action for next item.
250 | nnoremap j :CocNext
251 | " Do default action for previous item.
252 | nnoremap k :CocPrev
253 | " Resume latest coc list
254 | nnoremap p :CocListResumei
255 |
256 | set laststatus=2
257 | let g:airline#extensions#tabline#enabled = 1
258 | let g:airline_powerline_fonts = 1
259 | let g:airline_statusline_ontop=0
260 | let g:airline_theme='base16_twilight'
261 |
262 | let g:airline#extensions#tabline#formatter = 'default'
263 | " navegação entre os buffers
264 | nnoremap :bn
265 | nnoremap :bp
266 | nnoremap :bp \|bd #
267 |
268 | let g:ale_completion_enabled = 0
269 | let g:ale_linters = {'python': ['flake8', 'pylint'], 'javascript': ['eslint']}
270 |
--------------------------------------------------------------------------------