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.

382 lines
13 KiB

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