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.

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