All of my important config files
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

381 lines
12 KiB

8 years ago
8 years ago
7 years ago
6 years ago
7 years ago
8 years ago
6 years ago
6 years ago
6 years ago
8 years ago
8 years ago
7 years ago
7 years ago
7 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
6 years ago
8 years ago
7 years ago
7 years ago
7 years ago
7 years ago
6 years ago
7 years ago
7 years ago
7 years ago
  1. set nocompatible " be iMproved, required
  2. filetype off " required
  3. " Section Plugins {{{
  4. " Load vim-plug
  5. if empty(glob("~/.config/nvim/autoload/plug.vim"))
  6. execute '!curl -fLo ~/.config/nvim/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim'
  7. endif
  8. call plug#begin()
  9. Plug 'tpope/vim-fugitive' " Git integration
  10. Plug 'tpope/vim-sensible' " Defaults everyone can agree on
  11. Plug 'tpope/vim-surround' " better handling of surrounding markers
  12. Plug 'tpope/vim-ragtag' " Enhancement of surround for html
  13. Plug 'tpope/vim-repeat' " repeat last command with .
  14. Plug 'tpope/vim-dadbod' " Modern database interface for Vim
  15. Plug 'tpope/vim-dispatch' " Needed for dadbod
  16. Plug 'scrooloose/nerdtree', { 'on': 'NERDTreeToggle' } " file tree
  17. Plug 'Xuyuanp/nerdtree-git-plugin', { 'on': 'NERDTreeToggle' }
  18. Plug 'scrooloose/nerdcommenter' " better commenting
  19. Plug 'neoclide/coc.nvim', {'branch': 'release'} " coc - completion
  20. Plug 'Shougo/neosnippet.vim' " snippet engine
  21. Plug 'Shougo/neosnippet-snippets' " snippets
  22. Plug 'easymotion/vim-easymotion' " better motion with leader
  23. Plug 'bling/vim-airline' " statusline
  24. Plug 'w0rp/ale' " asynchronous linting engine
  25. Plug 'godlygeek/tabular' " Align text on symbols
  26. Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' } " fuzzy file finder
  27. Plug 'junegunn/fzf.vim' " vim integration for fzf
  28. Plug 'airblade/vim-gitgutter' " git status in gutter column
  29. Plug 'radenling/vim-dispatch-neovim' " support for :Start command, needed in dadbod
  30. Plug 'lambdalisue/suda.vim' " As w!! did not work anymore in nvim
  31. Plug 'https://github.com/alok/notational-fzf-vim' " note taking
  32. Plug 'prettier/vim-prettier', { 'do': 'npm install' } " prettier integration
  33. " html / templates{{{
  34. Plug 'mattn/emmet-vim', { 'for': ['html', 'php', 'gohtmltmpl', 'vue', 'markdown'] } " emmet support for vim - easily create markdup wth CSS-like syntax
  35. Plug 'gregsexton/MatchTag', { 'for': ['html', 'php', 'gohtmltmpl', 'vue'] } " match tags in html, similar to paren support
  36. Plug 'othree/html5.vim', { 'for': ['html', 'php', 'gohtmltmpl', 'vue'] } " html5 support
  37. Plug 'lumiliet/vim-twig', { 'for': ['html'] } " twig syntax support
  38. Plug 'Glench/Vim-Jinja2-Syntax', { 'for': ['html'] }
  39. "}}}
  40. " JavaScript{{{
  41. Plug 'gavocanov/vim-js-indent', { 'for': [ 'javascript' ]} " JavaScript indent support
  42. Plug 'moll/vim-node', { 'for': [ 'javascript', 'vue' ]} " node support
  43. Plug 'https://github.com/othree/jspc.vim', { 'for': [ 'javascript', 'vue' ]} " Function parameter completion
  44. Plug 'heavenshell/vim-jsdoc', { 'for': [ 'javascript', 'vue' ]} " Generate JSDoc comments
  45. Plug 'posva/vim-vue', { 'for': [ 'javascript', 'html', 'vue' ] } " vue.js integration
  46. "}}}
  47. " Go {{{
  48. Plug 'fatih/vim-go', { 'for': [ 'go', 'html', 'gohtmltmpl' ], 'do': ':GoInstallBinaries' } " go support
  49. "}}}
  50. " LaTeX{{{
  51. Plug 'lervag/vimtex', { 'for': 'tex' }
  52. "}}}
  53. " Markdown{{{
  54. Plug 'suan/vim-instant-markdown', { 'for': 'markdown' }
  55. Plug 'tpope/vim-markdown', { 'for': 'markdown'}
  56. "}}}
  57. " Colorschemes{{{
  58. Plug 'altercation/vim-colors-solarized'
  59. "}}}
  60. " TOML{{{
  61. Plug 'cespare/vim-toml', { 'for': 'toml' }
  62. "}}}
  63. " Haskell{{{
  64. Plug 'bitc/vim-hdevtools', { 'for': 'haskell' }
  65. Plug 'nbouscal/vim-stylish-haskell', { 'for': 'haskell' }
  66. "}}}
  67. " C/C++{{{
  68. Plug 'Rip-Rip/clang_complete', { 'for': ['c', 'cpp'], 'do': 'make install' }
  69. let g:clang_library_path='/usr/lib/llvm-6.0/lib/libclang-6.0.so.1'
  70. Plug 'rhysd/vim-clang-format', { 'for' : ['c', 'cpp', 'java'] }
  71. "}}}
  72. " PHP{{{
  73. Plug 'captbaritone/better-indent-support-for-php-with-html', { 'for': 'php' }
  74. Plug 'lumiliet/vim-twig', { 'for': [ 'php', 'html' ] } " Twig templates
  75. Plug 'Rican7/php-doc-modded', { 'for': 'php' } " Automatic phpdoc comments
  76. "}}}
  77. " Python{{{
  78. Plug 'davidhalter/jedi-vim', { 'for': 'python', 'do': 'pip install jedi' }
  79. Plug 'zchee/deoplete-jedi', { 'for': 'python' }
  80. Plug 'python-mode/python-mode', { 'for': 'python', 'branch': 'develop' }
  81. "}}}
  82. " Java{{{
  83. Plug 'artur-shaik/vim-javacomplete2', { 'for': 'java' }
  84. "}}}
  85. " MIPS{{{
  86. Plug 'vim-scripts/mips.vim'
  87. "}}}
  88. " All of your Plugins must be added before the following line
  89. call plug#end() " required
  90. filetype plugin indent on " required
  91. " }}}
  92. " THEME{{{
  93. colorscheme solarized
  94. set background=dark
  95. " Use light theme if whole shell is in light mode
  96. let themeenv=$THEME_SWITCHER
  97. if themeenv=='light'
  98. set background=light
  99. endif
  100. " }}}
  101. " SETTINGS{{{
  102. set number " line numbers
  103. set autoread " reload file automatically
  104. set colorcolumn=100 " highlight column 99
  105. set textwidth=99
  106. set history=1000
  107. set wildignore+=node_modules " ignore node_modules folder from file search
  108. set inccommand=split " show interactive results of substiute command
  109. " make comments and HTML attributes italic
  110. highlight Comment cterm=italic
  111. highlight htmlArg cterm=italic
  112. set autoindent " automatically set indent of new line
  113. set smartindent
  114. set tabstop=4
  115. set shiftwidth=4
  116. set expandtab
  117. " toggle invisible characters
  118. set list
  119. set listchars=tab:→\ ,eol,trail:⋅,extends:❯,precedes:❮
  120. set showbreak=
  121. set ttyfast " faster redrawing
  122. set diffopt+=vertical
  123. set laststatus=2 " show the satus line all the time
  124. set so=7 " set 7 lines to the cursors - when moving vertical
  125. set wildmenu " enhanced command line completion
  126. set hidden " current buffer can be put into background
  127. set showcmd " show incomplete commands
  128. " set noshowmode " don't show which mode disabled for PowerLine
  129. set wildmode=list:longest " complete files like a shell
  130. set scrolloff=3 " lines of text around cursor
  131. set shell=$SHELL
  132. set cmdheight=1 " command bar height
  133. set title " set terminal title
  134. set foldmethod=marker" " folds are marked with {{{}}}
  135. " Uncomment the following to have Vim jump to the last position when
  136. " reopening a file
  137. if has("autocmd")
  138. au BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$")
  139. \| exe "normal! g'\"" | endif
  140. endif
  141. " Setting for correct mips syntax highlighting
  142. au BufReadPost *.mips set syntax=mips
  143. " Override default flavor to latex, so vimtex gets loaded always
  144. let g:tex_flavor = "latex"
  145. " }}}
  146. " MAPPINGS{{{
  147. let mapleader = ","
  148. " CtrlP for Tags
  149. nnoremap <leader><C-p> :CtrlPTag<cr>
  150. " fzf bindings
  151. nmap <C-p> :Files<CR>
  152. nmap <leader><C-p> :Tags<CR>
  153. nmap <leader>/ :Rg<CR>
  154. " Toggle NERDTree
  155. nmap <silent> <leader>k :NERDTreeToggle<cr>
  156. " expand to the path of the file in the current buffer
  157. nmap <silent> <leader>y :NERDTreeFind<cr>
  158. " Allow saving of files as sudo when I forgot to start vim using sudo.
  159. cmap w!! :w suda://%
  160. "Toggle set paste
  161. nmap <leader>tp :set paste!<cr>
  162. " scroll the viewport faster
  163. nnoremap <C-e> 3<C-e>
  164. nnoremap <C-y> 3<C-y>
  165. " ctrl-r in visual mode to replace selected text
  166. vnoremap <C-r> "hy:%s/<C-r>h//g<left><left>
  167. nmap <leader>an :ALENext<cr>
  168. nnoremap <leader>tn :tabnew<cr>
  169. nnoremap <F3> :Gstatus<cr>
  170. nnoremap <F4> :Gpush<cr>
  171. "}}}
  172. " P L U G I N S{{{
  173. let NERDTreeShowHidden=1
  174. let g:airline_powerline_fonts = 1
  175. " notational notes
  176. let g:nv_search_paths = ['~/notes']
  177. let g:nv_default_extension = '.md'
  178. let g:nv_main_directory = '~/notes'
  179. " ALE {{{
  180. let g:airline#extensions#ale#enabled = 1
  181. "}}}
  182. let vim_tags_ctags_binary='~/bin/phpctags'"
  183. " Java config
  184. autocmd FileType java setlocal omnifunc=javacomplete#Complete
  185. " Python-mode config
  186. let g:pymode_lint_on_write = 0
  187. " Vimtex{{{
  188. if !exists('g:neocomplete#sources#omni#input_patterns')
  189. let g:neocomplete#sources#omni#input_patterns = {}
  190. endif
  191. let g:neocomplete#sources#omni#input_patterns.tex =
  192. \ '\v\\%('
  193. \ . '\a*%(ref|cite)\a*%(\s*\[[^]]*\])?\s*\{[^{}]*'
  194. \ . '|includegraphics%(\s*\[[^]]*\])?\s*\{[^{}]*'
  195. \ . '|%(include|input)\s*\{[^{}]*'
  196. \ . ')'
  197. "}}}
  198. " C/C++ {{{
  199. autocmd FileType c,cpp,objc nnoremap <buffer><Leader>f :<C-u>ClangFormat<CR>
  200. autocmd FileType c,cpp,objc vnoremap <buffer><Leader>f :ClangFormat<CR>
  201. "}}}
  202. " Prettier
  203. let g:prettier#config#tab_width = 4
  204. let g:prettier#exec_cmd_async = 1
  205. " Completion {{{
  206. " if hidden is not set, TextEdit might fail.
  207. set hidden
  208. " Some servers have issues with backup files, see #649
  209. set nobackup
  210. set nowritebackup
  211. " Better display for messages
  212. set cmdheight=2
  213. " You will have bad experience for diagnostic messages when it's default 4000.
  214. set updatetime=300
  215. " don't give |ins-completion-menu| messages.
  216. set shortmess+=c
  217. " always show signcolumns
  218. set signcolumn=yes
  219. " Use tab for trigger completion with characters ahead and navigate.
  220. " Use command ':verbose imap <tab>' to make sure tab is not mapped by other plugin.
  221. inoremap <silent><expr> <TAB>
  222. \ pumvisible() ? "\<C-n>" :
  223. \ <SID>check_back_space() ? "\<TAB>" :
  224. \ coc#refresh()
  225. inoremap <expr><S-TAB> pumvisible() ? "\<C-p>" : "\<C-h>"
  226. function! s:check_back_space() abort
  227. let col = col('.') - 1
  228. return !col || getline('.')[col - 1] =~# '\s'
  229. endfunction
  230. " Use <c-space> to trigger completion.
  231. inoremap <silent><expr> <c-space> coc#refresh()
  232. " Use <cr> to confirm completion, `<C-g>u` means break undo chain at current position.
  233. " Coc only does snippet and additional edit on confirm.
  234. inoremap <expr> <cr> pumvisible() ? "\<C-y>" : "\<C-g>u\<CR>"
  235. " Use `[c` and `]c` to navigate diagnostics
  236. nmap <silent> [c <Plug>(coc-diagnostic-prev)
  237. nmap <silent> ]c <Plug>(coc-diagnostic-next)
  238. " Remap keys for gotos
  239. nmap <silent> gd <Plug>(coc-definition)
  240. nmap <silent> gy <Plug>(coc-type-definition)
  241. nmap <silent> gi <Plug>(coc-implementation)
  242. nmap <silent> gr <Plug>(coc-references)
  243. " Use K to show documentation in preview window
  244. nnoremap <silent> K :call <SID>show_documentation()<CR>
  245. function! s:show_documentation()
  246. if (index(['vim','help'], &filetype) >= 0)
  247. execute 'h '.expand('<cword>')
  248. else
  249. call CocAction('doHover')
  250. endif
  251. endfunction
  252. " Highlight symbol under cursor on CursorHold
  253. autocmd CursorHold * silent call CocActionAsync('highlight')
  254. " Remap for rename current word
  255. nmap <leader>rn <Plug>(coc-rename)
  256. " Remap for format selected region
  257. xmap <leader>f <Plug>(coc-format-selected)
  258. nmap <leader>f <Plug>(coc-format-selected)
  259. augroup mygroup
  260. autocmd!
  261. " Setup formatexpr specified filetype(s).
  262. autocmd FileType typescript,json setl formatexpr=CocAction('formatSelected')
  263. " Update signature help on jump placeholder
  264. autocmd User CocJumpPlaceholder call CocActionAsync('showSignatureHelp')
  265. augroup end
  266. " Remap for do codeAction of selected region, ex: `<leader>aap` for current paragraph
  267. xmap <leader>a <Plug>(coc-codeaction-selected)
  268. nmap <leader>a <Plug>(coc-codeaction-selected)
  269. " Remap for do codeAction of current line
  270. nmap <leader>ac <Plug>(coc-codeaction)
  271. " Fix autofix problem of current line
  272. nmap <leader>qf <Plug>(coc-fix-current)
  273. " Use <tab> for select selections ranges, needs server support, like: coc-tsserver, coc-python
  274. nmap <silent> <TAB> <Plug>(coc-range-select)
  275. xmap <silent> <TAB> <Plug>(coc-range-select)
  276. xmap <silent> <S-TAB> <Plug>(coc-range-select-backword)
  277. " Use `:Format` to format current buffer
  278. command! -nargs=0 Format :call CocAction('format')
  279. " Use `:Fold` to fold current buffer
  280. command! -nargs=? Fold :call CocAction('fold', <f-args>)
  281. " use `:OR` for organize import of current buffer
  282. command! -nargs=0 OR :call CocAction('runCommand', 'editor.action.organizeImport')
  283. " Add status line support, for integration with other plugin, checkout `:h coc-status`
  284. set statusline^=%{coc#status()}%{get(b:,'coc_current_function','')}
  285. " Using CocList
  286. " Show all diagnostics
  287. nnoremap <silent> <space>a :<C-u>CocList diagnostics<cr>
  288. " Manage extensions
  289. nnoremap <silent> <space>e :<C-u>CocList extensions<cr>
  290. " Show commands
  291. nnoremap <silent> <space>c :<C-u>CocList commands<cr>
  292. " Find symbol of current document
  293. nnoremap <silent> <space>o :<C-u>CocList outline<cr>
  294. " Search workspace symbols
  295. nnoremap <silent> <space>s :<C-u>CocList -I symbols<cr>
  296. " Do default action for next item.
  297. nnoremap <silent> <space>j :<C-u>CocNext<CR>
  298. " Do default action for previous item.
  299. nnoremap <silent> <space>k :<C-u>CocPrev<CR>
  300. " Resume latest coc list
  301. nnoremap <silent> <space>p :<C-u>CocListResume<CR>:
  302. " For conceal markers.
  303. if has('conceal')
  304. set conceallevel=2 concealcursor=niv
  305. endif
  306. let g:neosnippet#snippets_directory = '~/.dotfiles/vim/neosnippets'
  307. "}}}