Advertisement
Guest User

Untitled

a guest
Mar 28th, 2020
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VIM 8.33 KB | None | 0 0
  1. "
  2. "     ██▒   █▓ ██▓ ███▄ ▄███▓ ██▀███   ▄████▄
  3. "    ▓██░   █▒▓██▒▓██▒▀█▀ ██▒▓██ ▒ ██▒▒██▀ ▀█
  4. "     ▓██  █▒░▒██▒▓██    ▓██░▓██ ░▄█ ▒▒▓█    ▄
  5. "      ▒██ █░░░██░▒██    ▒██ ▒██▀▀█▄  ▒▓▓▄ ▄██▒
  6. "       ▒▀█░  ░██░▒██▒   ░██▒░██▓ ▒██▒▒ ▓███▀ ░
  7. "       ░ ▐░  ░▓  ░ ▒░   ░  ░░ ▒▓ ░▒▓░░ ░▒ ▒  ░
  8. "       ░ ░░   ▒ ░░  ░      ░  ░▒ ░ ▒░  ░  ▒
  9. "         ░░   ▒ ░░      ░     ░░   ░ ░
  10. "          ░   ░         ░      ░     ░ ░
  11. "         ░                           ░
  12.  
  13. "#####################"
  14. "###### PLUGINS ######"
  15. "#####################"
  16.  
  17. " Automatic vim-plug installation
  18. if empty(glob('~/.local/share/nvim/site/autoload/plug.vim'))
  19.     silent !curl -fLo ~/.local/share/nvim/site/autoload/plug.vim --create-dirs
  20.     \ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
  21.     autocmd VimEnter * PlugInstall --sync | source ~/.config/nvim/init.vim
  22. endif
  23.  
  24. " Specify plugin directory
  25. call plug#begin('~/.local/share/nvim/plugged')
  26.  
  27. Plug 'scrooloose/nerdtree'
  28. Plug 'w0rp/ale'
  29. Plug 'sheerun/vim-polyglot'
  30. Plug 'neoclide/coc.nvim', {'branch':'release'}
  31. Plug 'davidyorr/vim-es6-unused-imports'
  32. Plug 'tpope/vim-commentary'
  33. Plug 'suy/vim-context-commentstring'
  34. Plug 'tpope/vim-surround'
  35. Plug 'iamcco/markdown-preview.nvim', { 'do': { -> mkdp#util#install() } }
  36. Plug 'junegunn/fzf'
  37. Plug 'tpope/vim-fugitive'
  38. Plug 'rust-lang/rust.vim'
  39.  
  40. " Initialize plugin system
  41. call plug#end()
  42.  
  43. "#######################"
  44. "###### BRAIN LAG ######"
  45. "#######################"
  46.  
  47. " Common spelling errors
  48. iab teh the
  49. iab Teh The
  50. iab improt import
  51. iab cont const
  52. iab retrun return
  53.  
  54. "#############################"
  55. "###### GENERAL CONFIGS ######"
  56. "#############################"
  57.  
  58. " CoC config
  59. let g:coc_global_extension = [
  60.     \ 'coc-snippets',
  61.     \ 'coc-pairs',
  62.     \ 'coc-tsserver',
  63.     \ 'coc-eslint',
  64.     \ 'coc-prettier',
  65.     \ 'coc-json',
  66.     \ ]
  67. command! -nargs=0 Prettier :CocCommand prettier.formatFile
  68.  
  69. " Enable syntax and plugins
  70. syntax enable
  71. filetype on
  72. filetype plugin on
  73. filetype indent on
  74.  
  75. " Disable vi mode
  76. set nocompatible
  77.  
  78. " Better splits
  79. set splitbelow
  80. set splitright
  81.  
  82. " Set encoding
  83. set encoding=utf8
  84.  
  85. " If hidden is not set, textEdit might fail
  86. set hidden
  87.  
  88. " Better display for messages
  89. set cmdheight=2
  90.  
  91. " Better diagnostic messages
  92. set updatetime=300
  93.  
  94. " Remove |ins-completion-menu| messages
  95. set shortmess+=c
  96.  
  97. " Hide mode (shown in status line)
  98. set noshowmode
  99.  
  100. " When a file has been changed outside of Vim, automatically read it again
  101. set autoread
  102.  
  103. " Always show current position
  104. set ruler
  105.  
  106. " When a bracket is inserted, briefly jump to the matching one
  107. set showmatch
  108.  
  109. " Tenths of a second to show the matching paren
  110. set mat=2
  111.  
  112. " Switching this option off most likely breaks plugins, someone told me...
  113. set magic
  114.  
  115. " Don't show signcolumn
  116. set signcolumn=no
  117.  
  118. " Highlight search results
  119. set hlsearch
  120.  
  121. " Number of columns occupied by a tab character
  122. set tabstop=2
  123.  
  124. " See multiple spaces as tabstops so <BS> does the right thing
  125. set softtabstop=2
  126.  
  127. " Softtabstop == tabstop, noexpandtab && always force use of tabs
  128. set noexpandtab
  129.  
  130. " Width for autoindents
  131. set shiftwidth=2
  132.  
  133. " Indent a new line the same amount as the line just typed
  134. set autoindent
  135.  
  136. " Add relative line numbers
  137. "set relativenumber number
  138.  
  139. " Add just line numbers
  140. set number
  141.  
  142. " Prevent cursor jumping
  143. set lazyredraw
  144.  
  145. " Enable cursor line, disable cursor column
  146. set cursorline
  147. set nocursorcolumn
  148.  
  149. " Sets unix as standard filetype
  150. set ffs=unix,dos,mac
  151.  
  152. " Wrap lines
  153. set wrap
  154.  
  155. " Maximum items in completion suggest popup menu
  156. set pumheight=10
  157.  
  158. " Don't make a any backups before overwriting a file
  159. set nobackup
  160. set nowritebackup
  161.  
  162. " Don't use a swapfile for the buffer
  163. set noswapfile
  164.  
  165. " Increase max memory to show syntax highlighting for large files
  166. set maxmempattern=20000
  167.  
  168. " Don't show preview [sratch] window
  169. set completeopt-=preview
  170.  
  171. "############################"
  172. "###### AUTOCMDS, ETC #######"
  173. "############################"
  174.  
  175. " Syntax highlighting for TS/TSX
  176. au BufNewFile,BufRead *.ts setlocal filetype=typescript
  177. au BufNewFile,BufRead *.tsx setlocal filetype=typescript.tsx
  178.  
  179. " Auto resize panes
  180. autocmd VimResized * wincmd =
  181.  
  182. " Remove trailing whitespace on save
  183. autocmd BufWritePre * %s/\s\+$//e
  184.  
  185. " Open NERDTree if no file specified
  186. autocmd StdinReadPre * let s:std_in=1
  187. autocmd VimEnter * if argc() == 0 && !exists("s:std_in") | NERDTree | endif
  188.  
  189. " Check for unused es6 imports
  190. autocmd BufWinEnter *.ts,*.tsx,*.js,*.jsx execute "ES6ImportsHighlight"
  191. autocmd BufWritePost *.ts,*.tsx,*.js,*.jsx execute "ES6ImportsHighlight"
  192.  
  193. " Set es6 unused import plugin colors
  194. let g:es6_imports_gui_fg_color="#475763"
  195. let g:es6_imports_gui_bg_color="#192C3B"
  196.  
  197. " File specific rules
  198. augroup filespecific
  199.     autocmd!
  200.     au BufRead,BufNewFile *.ts set ft=typescript
  201.     au BufNewFile,BufRead *.prisma setfiletype graphql
  202.     au FileType go set noet nolist
  203.     au FileType python setl ts=4
  204. augroup END
  205.  
  206. "#####################################"
  207. "###### THEME & PLUGIN SETTINGS ######"
  208. "#####################################"
  209.  
  210. " Set colors to gui
  211. set termguicolors
  212.  
  213. " Set theme
  214. colorscheme debris
  215.  
  216. " Source NERDTree filetype highlighting
  217. source ~/.config/nvim/plugin/nerdtree.vim
  218.  
  219. " Set list characters
  220. set list
  221. set listchars=
  222. set listchars+=tab:›\ ,
  223. set listchars+=trail:•,
  224.  
  225. " Set end of buffer and vertsplit to empty
  226. set fillchars+=eob:\ ,
  227. set fillchars+=vert:\ ,
  228.  
  229. " Disable nvim-typescript diagnostics as they override ALE signs
  230. let g:nvim_typescript#diagnostics_enable = 0
  231.  
  232. " ALE settings
  233. let g:ale_sign_info= "•"
  234. let g:ale_sign_error = "•"
  235. let g:ale_sign_warning = "•"
  236. let g:ale_sign_style_error = "•"
  237. let g:ale_sign_style_warning = "•"
  238. let g:ale_fixers = {
  239.     \ 'javascript': ['eslint'],
  240.     \ 'css': ['prettier'],
  241.     \ 'scss': ['prettier']
  242.     \}
  243. let g:ale_fix_on_save = 1
  244.  
  245. " Rust auto-format
  246. let g:rustfmt_autosave = 1
  247.  
  248. " NERDTree settings
  249. let g:NERDTreeMinimalUI = 1
  250. let g:NERDTreeShowHidden = 1
  251. let g:NERDTreeShowLineNumbers = 0
  252. let g:NERDTreeCascadeSingleChildDir = 0
  253. let g:NERDTreeDirArrowExpandable = "•"
  254. let g:NERDTreeDirArrowCollapsible = "•"
  255. let g:NERDTreeWinSize = 31
  256.  
  257. "#########################"
  258. "###### KEYBINDINGS ######"
  259. "#########################"
  260.  
  261. " Go to definition
  262. nmap <silent> gd <Plug>(coc-definition)
  263.  
  264. " Go to type defintion
  265. nmap <silent> gy <Plug>(coc-type-definition)
  266.  
  267. " Go to implementation
  268. nmap <silent> gi <Plug>(coc-implementation)
  269.  
  270. " Go to reference
  271. nmap <silent> gr <Plug>(coc-references)
  272.  
  273. " Quick fix current line
  274. nmap <leader>qf <Plug>(coc-fix-current)
  275.  
  276. " Bind JK to normal mode
  277. inoremap jk <ESC>
  278.  
  279. " Tab to to jump
  280. inoremap <expr><TAB> pumvisible() ? "\<C-n>" : "\<TAB>"
  281.  
  282. " Enter to complete
  283. inoremap <expr> <CR> pumvisible() ? "\<C-y>" : "\<CR>"
  284.  
  285. " Map nerdtreetoggle to ctrl-n
  286. map <C-n> :NERDTreeToggle<CR>
  287.  
  288. " Navigate between linter errors
  289. nmap <silent> <C-k> <Plug>(ale_previous_wrap)
  290. nmap <silent> <C-j> <Plug>(ale_next_wrap)
  291. nmap <silent> <C-h> :ALEHover<CR>
  292.  
  293. " Map Esc to exit Terminal
  294. tnoremap <Esc> <C-\><C-n>
  295.  
  296. " Move line up
  297. nmap <M-j> :m+<CR>==
  298. imap <M-j> <Esc>:m+<CR>==gi=gi
  299. vmap <M-j> :m'>+<CR>gv=gv
  300.  
  301. " Move line down
  302. nmap <M-k> :m-2<CR>==
  303. imap <M-k> <Esc>:m-2<CR>==gi=gi
  304. vmap <M-k> :m-2<CR>gv=gv
  305.  
  306. " Add uppercase variants to save/write
  307. :command W w
  308. :command Q q
  309. :command Wq wq
  310. :command WQ wq
  311.  
  312. " Fzf
  313. nnoremap <C-p> :FZF<CR>
  314.  
  315. " Splits
  316. nnoremap <C-J> <C-W><C-J>
  317. nnoremap <C-K> <C-W><C-K>
  318. nnoremap <C-L> <C-W><C-L>
  319. nnoremap <C-H> <C-W><C-H>
  320.  
  321. nnoremap ; :
  322.  
  323. " Fugitive lifehack
  324. nnoremap <leader>gvd :Gvdiffsplit!<CR>
  325. nnoremap gdh :diffget //2<CR>
  326. nnoremap gdl :diffget //3<CR>
  327.  
  328. " Disable arrow keys to prevent cowardice
  329. map <Up> <Nop>
  330. map! <Up> <Nop>
  331. map <Down> <Nop>
  332. map! <Down> <Nop>
  333. map <Left> <Nop>
  334. map! <Left> <Nop>
  335. map <Right> <Nop>
  336. map! <Right> <Nop>
  337.  
  338. " Clipboard
  339. set clipboard+=unnamedplus
  340.  
  341. " Vimdiff colors
  342. hi DiffAdd guibg=#12181d
  343. hi DiffChange guibg=#12181d
  344. hi DiffText guibg=#12181d
  345. hi DiffDelete guibg=#12181d
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement