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
5 years ago
5 years ago
5 years ago
7 years ago
8 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
5 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 'easymotion/vim-easymotion' " better motion with leader
  21. Plug 'bling/vim-airline' " statusline
  22. Plug 'w0rp/ale' " asynchronous linting engine
  23. Plug 'godlygeek/tabular' " Align text on symbols
  24. Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' } " fuzzy file finder
  25. Plug 'junegunn/fzf.vim' " vim integration for fzf
  26. Plug 'airblade/vim-gitgutter' " git status in gutter column
  27. Plug 'radenling/vim-dispatch-neovim' " support for :Start command, needed in dadbod
  28. Plug 'lambdalisue/suda.vim' " As w!! did not work anymore in nvim
  29. Plug 'https://github.com/alok/notational-fzf-vim' " note taking
  30. Plug 'prettier/vim-prettier', { 'do': 'npm install' } " prettier integration
  31. Plug 'honza/vim-snippets' " Collection of Snippets, used by coc-snippet
  32. Plug 'ludovicchabant/vim-gutentags' " Keep tags in sync
  33. " {{{ CocPlugins
  34. Plug 'neoclide/coc-json', { 'do': 'yarn install --frozen-lockfile' }
  35. Plug 'neoclide/coc-snippets', { 'do': 'yarn install --frozen-lockfile' }
  36. Plug 'neoclide/coc-tsserver', { 'do': 'yarn install --frozen-lockfile' }
  37. Plug 'neoclide/coc-rls', { 'do': 'yarn install --frozen-lockfile' }
  38. Plug 'neoclide/coc-vetur', { 'do': 'yarn install --frozen-lockfile' }
  39. Plug 'neoclide/coc-css', { 'do': 'yarn install --frozen-lockfile' }
  40. Plug 'neoclide/coc-vimtex', { 'do': 'yarn install --frozen-lockfile' }
  41. Plug 'neoclide/coc-html', { 'do': 'yarn install --frozen-lockfile' }
  42. Plug 'neoclide/coc-yaml', { 'do': 'yarn install --frozen-lockfile' }
  43. Plug 'neoclide/coc-python', { 'do': 'yarn install --frozen-lockfile' }
  44. Plug 'marlonfan/coc-phpls', { 'do': 'yarn install --frozen-lockfile' }
  45. Plug 'fannheyward/coc-sql', { 'do': 'yarn install --frozen-lockfile' }
  46. " }}}
  47. " html / templates{{{
  48. Plug 'mattn/emmet-vim', { 'for': ['html', 'php', 'gohtmltmpl', 'vue', 'markdown'] } " emmet support for vim - easily create markdup wth CSS-like syntax
  49. Plug 'gregsexton/MatchTag', { 'for': ['html', 'php', 'gohtmltmpl', 'vue'] } " match tags in html, similar to paren support
  50. Plug 'othree/html5.vim', { 'for': ['html', 'php', 'gohtmltmpl', 'vue'] } " html5 support
  51. Plug 'lumiliet/vim-twig', { 'for': ['html'] } " twig syntax support
  52. Plug 'Glench/Vim-Jinja2-Syntax', { 'for': ['html'] }
  53. "}}}
  54. " JavaScript{{{
  55. Plug 'gavocanov/vim-js-indent', { 'for': [ 'javascript' ]} " JavaScript indent support
  56. Plug 'heavenshell/vim-jsdoc', { 'for': [ 'javascript', 'vue' ]} " Generate JSDoc comments
  57. Plug 'posva/vim-vue', { 'for': [ 'javascript', 'html', 'vue' ] } " vue.js integration
  58. "}}}
  59. " Go {{{
  60. Plug 'fatih/vim-go', { 'for': [ 'go', 'html', 'gohtmltmpl' ], 'do': ':GoInstallBinaries' } " go support
  61. "}}}
  62. " LaTeX{{{
  63. Plug 'lervag/vimtex', { 'for': 'tex' }
  64. "}}}
  65. " Markdown{{{
  66. Plug 'suan/vim-instant-markdown', { 'for': 'markdown' }
  67. Plug 'tpope/vim-markdown', { 'for': 'markdown'}
  68. "}}}
  69. " Colorschemes{{{
  70. Plug 'altercation/vim-colors-solarized'
  71. Plug 'vim-scripts/nginx.vim'
  72. "}}}
  73. " TOML{{{
  74. Plug 'cespare/vim-toml', { 'for': 'toml' }
  75. "}}}
  76. " C/C++{{{
  77. Plug 'Rip-Rip/clang_complete', { 'for': ['c', 'cpp'], 'do': 'make install' }
  78. let g:clang_library_path='/usr/lib/llvm-6.0/lib/libclang-6.0.so.1'
  79. Plug 'rhysd/vim-clang-format', { 'for' : ['c', 'cpp', 'java'] }
  80. Plug 'vim-scripts/DoxygenToolkit.vim', { 'for' : ['c', 'cpp'] }
  81. "}}}
  82. " PHP{{{
  83. Plug 'captbaritone/better-indent-support-for-php-with-html', { 'for': 'php' }
  84. Plug 'lumiliet/vim-twig', { 'for': [ 'php', 'html' ] } " Twig templates
  85. Plug 'Rican7/php-doc-modded', { 'for': 'php' } " Automatic phpdoc comments
  86. "}}}
  87. " All of your Plugins must be added before the following line
  88. call plug#end() " required
  89. filetype plugin indent on " required
  90. " }}}
  91. " THEME{{{
  92. colorscheme solarized
  93. set background=dark
  94. " Use light theme if whole shell is in light mode
  95. let themeenv=$THEME_SWITCHER
  96. if themeenv=='light'
  97. set background=light
  98. endif
  99. " }}}
  100. " SETTINGS{{{
  101. set number " line numbers
  102. set autoread " reload file automatically
  103. set colorcolumn=100 " highlight column 99
  104. set textwidth=99
  105. set history=1000
  106. set wildignore+=node_modules " ignore node_modules folder from file search
  107. set inccommand=split " show interactive results of substiute command
  108. " make comments and HTML attributes italic
  109. highlight Comment cterm=italic
  110. highlight htmlArg cterm=italic
  111. set autoindent " automatically set indent of new line
  112. set smartindent
  113. set tabstop=4
  114. set shiftwidth=4
  115. set expandtab
  116. " toggle invisible characters
  117. set list
  118. set listchars=tab:→\ ,eol,trail:⋅,extends:❯,precedes:❮
  119. set showbreak=
  120. set ttyfast " faster redrawing
  121. set diffopt+=vertical
  122. set laststatus=2 " show the satus line all the time
  123. set so=7 " set 7 lines to the cursors - when moving vertical
  124. set wildmenu " enhanced command line completion
  125. set hidden " current buffer can be put into background
  126. set showcmd " show incomplete commands
  127. " set noshowmode " don't show which mode disabled for PowerLine
  128. set wildmode=list:longest " complete files like a shell
  129. set scrolloff=3 " lines of text around cursor
  130. set shell=$SHELL
  131. set cmdheight=1 " command bar height
  132. set title " set terminal title
  133. set foldmethod=marker" " folds are marked with {{{}}}
  134. " Uncomment the following to have Vim jump to the last position when
  135. " reopening a file
  136. if has("autocmd")
  137. au BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$")
  138. \| exe "normal! g'\"" | endif
  139. endif
  140. " Setting for correct mips syntax highlighting
  141. au BufReadPost *.mips set syntax=mips
  142. " Override default flavor to latex, so vimtex gets loaded always
  143. let g:tex_flavor = "latex"
  144. " }}}
  145. " MAPPINGS{{{
  146. let mapleader = ","
  147. " CtrlP for Tags
  148. nnoremap <leader><C-p> :CtrlPTag<cr>
  149. " fzf bindings
  150. nmap <C-p> :Files<CR>
  151. nmap <leader><C-p> :Tags<CR>
  152. nmap <leader>/ :Rg<CR>
  153. nmap <leader>b :Buffers<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> H :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. " snippets
  303. imap <C-k> <Plug>(coc-snippets-expand-jump)
  304. " For conceal markers.
  305. if has('conceal')
  306. set conceallevel=2 concealcursor=niv
  307. endif
  308. let g:neosnippet#snippets_directory = '~/.dotfiles/vim/neosnippets'
  309. "}}}