medmond919

VIM Example #2

Mar 27th, 2018
6,597
0
Never
2
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. " -----------------------------------------------------------------------------
  2. " Standard Vim settings
  3. " -----------------------------------------------------------------------------
  4.  
  5. "
  6. " General settings
  7. " -----------------------------------------------------------------------------
  8. set nocompatible
  9. set ttyfast
  10. set lazyredraw
  11. " Write files on make/GoBuild etc
  12. set autowrite
  13.  
  14. " Accept ^? as backspace char (allows remapping of C-h for moving to a left
  15. " split) - NOTE: Must set up terminal emulator to emit ^? when backspace is
  16. " pressed
  17. set t_kb=
  18.  
  19. " vim-plug - handle required plugins
  20. call plug#begin('~/.config/nvim/plugged')
  21. " Ui & theming
  22. Plug 'altercation/vim-colors-solarized'
  23. Plug 'itchyny/lightline.vim'
  24. " Development
  25. Plug 'airblade/vim-gitgutter'
  26. Plug 'fatih/vim-go'
  27. Plug 'elzr/vim-json'
  28. Plug 'tpope/vim-fugitive'
  29. "Plug 'ekalinin/Dockerfile.vim'
  30. Plug 'majutsushi/tagbar'
  31. Plug 'tpope/vim-dispatch'
  32. Plug 'radenling/vim-dispatch-neovim'
  33. Plug 'w0rp/ale'
  34. " Filetypes
  35. Plug 'elzr/vim-json'
  36. " Misc
  37. Plug 'SirVer/ultisnips'
  38. Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' }
  39. Plug 'zchee/deoplete-go', { 'do': 'make' }
  40. Plug 'ervandew/supertab'
  41. Plug 'junegunn/fzf', { 'dir': '~/.config/.fzf', 'do': './install --all' }
  42. Plug 'junegunn/fzf.vim'
  43. Plug 'jiangmiao/auto-pairs'
  44. call plug#end()
  45.  
  46. " Speed up update interval
  47. set updatetime=100
  48.  
  49. " Set new leader
  50. let mapleader=","
  51.  
  52. " Allow backspacing over everything in insert mode
  53. set backspace=indent,eol,start
  54.  
  55. " Highlight searches & set incremental searching
  56. set hlsearch incsearch
  57.  
  58. " Disable backups & swaps
  59. set nobackup
  60. set noswapfile
  61.  
  62. " indent by multiples of tabstop
  63. set shiftround
  64.  
  65. " Tree-style listing in netrw
  66. let g:netrw_liststyle=3
  67.  
  68. "
  69. " Key (re)mappings
  70. " -----------------------------------------------------------------------------
  71.  
  72. " Move up/down per terminal line, not file line (for wrapped lines)
  73. noremap <silent> <expr> j (v:count == 0 ? 'gj' : 'j')
  74. noremap <silent> <expr> k (v:count == 0 ? 'gk' : 'k')
  75. " Disable cursor keys in normal & insert mode
  76. "noremap <up> <nop>
  77. "noremap <down> <nop>
  78. "noremap <left> <nop>
  79. "noremap <right> <nop>
  80. "inoremap <up> <nop>
  81. "inoremap <down> <nop>
  82. "inoremap <left> <nop>
  83. "inoremap <right> <nop>
  84.  
  85. " Change window movement keys slightly
  86. map <C-H> <C-W><C-H>
  87. map <C-J> <C-W><C-J>
  88. map <C-K> <C-W><C-K>
  89. map <C-L> <C-W><C-L>
  90. tnoremap <C-h> <C-\><C-N><C-w>h
  91. tnoremap <C-j> <C-\><C-N><C-w>j
  92. tnoremap <C-k> <C-\><C-N><C-w>k
  93. tnoremap <C-l> <C-\><C-N><C-w>l
  94.  
  95. " Highlight terminal cursor differently to editing cursor
  96. highlight TermCursor ctermfg=red guifg=red
  97. set splitbelow
  98. set splitright
  99.  
  100. " jj to ESC back to Normal mode; quicker than reaching for ESC
  101. inoremap jj <ESC>
  102.  
  103. " Alt-[jk] for move current line up/down (also in visual block mode)
  104. nnoremap <A-j> :m+<CR>==
  105. nnoremap <A-k> :m-2<CR>==
  106. vnoremap <A-j> :m'>+<CR>gv=gv
  107. vnoremap <A-k> :m-2<CR>gv=gv
  108.  
  109. " Alt-[hl] for indenting in and back (also in visual block mode)
  110. nnoremap <A-h> <<
  111. nnoremap <A-l> >>
  112. vnoremap <A-h> <gv
  113. vnoremap <A-l> >gv
  114.  
  115. "
  116. " General UI settings
  117. " -----------------------------------------------------------------------------
  118. set number
  119. "set relativenumber
  120. "autocmd InsertEnter * :set number
  121. "autocmd InsertLeave * :set relativenumber
  122. set laststatus=2
  123. set ruler
  124. set tabstop=2
  125. set shiftwidth=2
  126. set expandtab
  127. set cursorline
  128. set fillchars+=vert:\
  129.  
  130. " Highlight all chars past col 100 to encourage line breaks; "Float" defaults
  131. " to red in neodark theme
  132. "call matchadd('Float', '\%101v.\+', 100)
  133.  
  134. "
  135. " Theme settings
  136. " -----------------------------------------------------------------------------
  137. "set background=dark
  138. colorscheme solarized
  139. syntax on
  140.  
  141. "
  142. " Vim-go
  143. " -----------------------------------------------------------------------------
  144. let g:go_highlight_functions=1  
  145. let g:go_highlight_methods=0  
  146. let g:go_highlight_structs=1  
  147. let g:go_highlight_operators=0
  148. let g:go_highlight_interfaces=1
  149. let g:go_highlight_build_constraints=1
  150. let g:go_fmt_command="goimports"
  151. let g:go_auto_sameids=1
  152. let g:go_metalinter_autosave=1
  153. let g:go_auto_type_info=1
  154. "let g:go_snippet_engine='neosnippet'
  155. let g:go_list_height=10
  156. "let g:go_list_type="quickfix"
  157. "let g:go_fmt_fail_silently=1
  158.  
  159. " Map <leader>t to GoTest
  160. autocmd FileType go nmap <leader>t  <Plug>(go-test)
  161. " Map <leader>c to GoCoverageToggle
  162. autocmd FileType go nmap <leader>c  <Plug>(go-coverage-toggle)
  163. " Map <leader>a to GoAlternate
  164. autocmd FileType go nmap <leader>a  <Plug>(go-alternate)
  165.  
  166. let g:go_metalinter_enabled = ['vet', 'golint', 'gosimple', 'errcheck']
  167.  
  168. "
  169. " lightline
  170. " -----------------------------------------------------------------------------
  171. let g:lightline = {
  172.  \ 'colorscheme': 'solarized',
  173.  \ 'active': {
  174.  \   'left': [ ['mode', 'paste'],
  175.  \             ['gitbranch', 'readonly', 'filename', 'modified'] ]
  176.  \ },
  177.  \ 'component_function': {
  178.  \   'gitbranch': 'fugitive#head'
  179.  \ },
  180.  \ }
  181.  
  182. " Disable mode display, as it's part of the status bar in standard themes
  183. set noshowmode
  184.  
  185. "
  186. " Tagbar
  187. " -----------------------------------------------------------------------------
  188. "nmap <leader>b :TagbarToggle<CR>
  189.  
  190. " General UI config
  191. let g:tagbar_left=1
  192. let g:tagbar_width = 35
  193.  
  194. " Configuration for Golang, using gotags
  195. let g:tagbar_type_go = {
  196.     \ 'ctagstype' : 'go',
  197.     \ 'kinds'     : [
  198.         \ 'p:package',
  199.         \ 'i:imports:1',
  200.         \ 'c:constants',
  201.         \ 'v:variables',
  202.         \ 't:types',
  203.         \ 'n:interfaces',
  204.         \ 'w:fields',
  205.         \ 'e:embedded',
  206.         \ 'm:methods',
  207.         \ 'r:constructor',
  208.         \ 'f:functions'
  209.     \ ],
  210.     \ 'sro' : '.',
  211.     \ 'kind2scope' : {
  212.         \ 't' : 'ctype',
  213.         \ 'n' : 'ntype'
  214.     \ },
  215.     \ 'scope2kind' : {
  216.         \ 'ctype' : 't',
  217.         \ 'ntype' : 'n'
  218.     \ },
  219.     \ 'ctagsbin'  : 'gotags',
  220.     \ 'ctagsargs' : '-sort -silent'
  221. \ }
  222.  
  223. autocmd VimEnter * nested :call tagbar#autoopen(1)
  224. autocmd FileType * nested :call tagbar#autoopen(0)
  225.  
  226. "
  227. " Deoplete
  228. " -----------------------------------------------------------------------------
  229. let g:deoplete#enable_at_startup = 1
  230. let g:deoplete#max_list = 10
  231. let g:deoplete#max_menu_width = 20
  232.  
  233. " Switch tab ordering, so from top of completion list down; map to tab/shift-tab
  234.  
  235. "
  236. " Deoplete-go
  237. " -----------------------------------------------------------------------------
  238. let g:deoplete#sources#go#gocode_binary=$GOPATH.'/bin/gocode'
  239.  
  240. "
  241. " Neosnippets
  242. " -----------------------------------------------------------------------------
  243. " Use Tab to jump between placehoders
  244. "imap <Tab> <Plug>(neosnippet_expand_or_jump)
  245. "smap <Tab> <Plug>(neosnippet_expand_or_jump)
  246. "xmap <Tab> <Plug>(neosnippet_expand_target)
  247.  
  248. "
  249. " ale
  250. " -----------------------------------------------------------------------------
  251. " Error and warning signs.
  252. let g:ale_sign_error = '▶▶'
  253. let g:ale_sign_warning = '▶▶'
  254. let g:ale_sign_column_always = 1
  255. let g:ale_lint_on_text_changed = 'always'
  256. "
  257. " fzf-vim
  258. " -----------------------------------------------------------------------------
  259. imap <c-x><c-o> <plug>(fzf-complete-line)
  260. map <leader>b :Buffers<cr>
  261. map <leader>f :Files<cr>
  262. map <leader>g :GFiles<cr>
  263. "map <leader>t :Tags<cr>
  264.  
  265. let g:fzf_layout = { 'down': '~20%' }
  266.  
  267. " Customize fzf colors to match theme
  268. let g:fzf_colors = {
  269.     \ 'bg':          ['bg', 'CursorLine'],
  270.     \ 'bg+':         ['bg', 'CursorLine'],
  271.     \ 'info':        ['fg', 'Keyword'],
  272.     \ 'prompt':      ['fg', 'Function', 'Bold'],
  273.     \ 'marker':      ['fg', 'Float', 'Bold'],
  274.     \ 'hl':          ['fg', 'Float', 'Bold'],
  275.     \ 'hl+':         ['fg', 'Float', 'Bold'],
  276.     \ 'header':      ['bg', 'CursorLine']
  277. \ }
  278.  
  279. "
  280. " gitgutter
  281. " -----------------------------------------------------------------------------
  282. let g:gitgutter_sign_added = '┃'
  283. let g:gitgutter_sign_modified = '┃'
  284. let g:gitgutter_sign_removed = '┃'
Advertisement