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
13 KiB

8 years ago
8 years ago
7 years ago
5 years ago
4 years ago
4 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
4 years ago
7 years ago
7 years ago
7 years ago
7 years ago
5 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', { 'for': ['js', 'vue', 'php'] } " 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. Plug 'fannheyward/coc-markdownlint', { 'do': 'yarn install --frozen-lockfile' }
  47. " }}}
  48. " html / templates{{{
  49. Plug 'mattn/emmet-vim', { 'for': ['html', 'php', 'gohtmltmpl', 'vue', 'markdown'] } " emmet support for vim - easily create markdup wth CSS-like syntax
  50. Plug 'gregsexton/MatchTag', { 'for': ['html', 'php', 'gohtmltmpl', 'vue'] } " match tags in html, similar to paren support
  51. Plug 'othree/html5.vim', { 'for': ['html', 'php', 'gohtmltmpl', 'vue'] } " html5 support
  52. Plug 'lumiliet/vim-twig', { 'for': ['html'] } " twig syntax support
  53. Plug 'Glench/Vim-Jinja2-Syntax', { 'for': ['html'] }
  54. "}}}
  55. " JavaScript{{{
  56. Plug 'gavocanov/vim-js-indent', { 'for': [ 'javascript' ]} " JavaScript indent support
  57. Plug 'heavenshell/vim-jsdoc', { 'for': [ 'javascript', 'vue' ]} " Generate JSDoc comments
  58. Plug 'posva/vim-vue', { 'for': [ 'javascript', 'html', 'vue' ] } " vue.js integration
  59. "}}}
  60. " LaTeX{{{
  61. Plug 'lervag/vimtex', { 'for': 'tex' }
  62. "}}}
  63. " Markdown{{{
  64. Plug 'tpope/vim-markdown', { 'for': 'markdown'}
  65. Plug 'iamcco/markdown-preview.nvim', { 'do': 'cd app & yarn install', 'for': 'markdown' }
  66. "}}}
  67. " Colorschemes{{{
  68. Plug 'altercation/vim-colors-solarized'
  69. Plug 'vim-scripts/nginx.vim'
  70. "}}}
  71. " TOML{{{
  72. Plug 'cespare/vim-toml', { 'for': 'toml' }
  73. "}}}
  74. " C/C++{{{
  75. Plug 'Rip-Rip/clang_complete', { 'for': ['c', 'cpp'], 'do': 'make install' }
  76. let g:clang_library_path='/usr/lib/llvm-6.0/lib/libclang-6.0.so.1'
  77. Plug 'rhysd/vim-clang-format', { 'for' : ['c', 'cpp', 'java'] }
  78. Plug 'vim-scripts/DoxygenToolkit.vim', { 'for' : ['c', 'cpp'] }
  79. "}}}
  80. " PHP{{{
  81. Plug 'captbaritone/better-indent-support-for-php-with-html', { 'for': 'php' }
  82. Plug 'lumiliet/vim-twig', { 'for': [ 'php', 'html' ] } " Twig templates
  83. Plug 'Rican7/php-doc-modded', { 'for': 'php' } " Automatic phpdoc comments
  84. "}}}
  85. " All of your Plugins must be added before the following line
  86. call plug#end() " required
  87. filetype plugin indent on " required
  88. " }}}
  89. " THEME{{{
  90. colorscheme solarized
  91. set background=dark
  92. " Use light theme if whole shell is in light mode
  93. let themeenv=$THEME_SWITCHER
  94. if themeenv=='light'
  95. set background=light
  96. endif
  97. " }}}
  98. " SETTINGS{{{
  99. set number " line numbers
  100. set autoread " reload file automatically
  101. set colorcolumn=100 " highlight column 99
  102. set textwidth=99
  103. set history=1000
  104. set wildignore+=node_modules " ignore node_modules folder from file search
  105. set inccommand=split " show interactive results of substiute command
  106. " make comments and HTML attributes italic
  107. highlight Comment cterm=italic
  108. highlight htmlArg cterm=italic
  109. set autoindent " automatically set indent of new line
  110. set smartindent
  111. set tabstop=4
  112. set shiftwidth=4
  113. set expandtab
  114. " toggle invisible characters
  115. set list
  116. set listchars=tab:→\ ,eol,trail:⋅,extends:❯,precedes:❮
  117. set showbreak=
  118. set ttyfast " faster redrawing
  119. set diffopt+=vertical
  120. set laststatus=2 " show the satus line all the time
  121. set so=7 " set 7 lines to the cursors - when moving vertical
  122. set wildmenu " enhanced command line completion
  123. set hidden " current buffer can be put into background
  124. set showcmd " show incomplete commands
  125. " set noshowmode " don't show which mode disabled for PowerLine
  126. set wildmode=list:longest " complete files like a shell
  127. set scrolloff=3 " lines of text around cursor
  128. set shell=$SHELL
  129. set cmdheight=1 " command bar height
  130. set title " set terminal title
  131. set foldmethod=marker" " folds are marked with {{{}}}
  132. " Uncomment the following to have Vim jump to the last position when
  133. " reopening a file
  134. if has("autocmd")
  135. au BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$")
  136. \| exe "normal! g'\"" | endif
  137. endif
  138. " Setting for correct mips syntax highlighting
  139. au BufReadPost *.mips set syntax=mips
  140. " Override default flavor to latex, so vimtex gets loaded always
  141. let g:tex_flavor = "latex"
  142. " use python 3 when in doubt
  143. set pyxversion=3
  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. "}}}