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.

378 lines
12 KiB

8 years ago
8 years ago
7 years ago
5 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
5 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 '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. " html / templates{{{
  33. Plug 'mattn/emmet-vim', { 'for': ['html', 'php', 'gohtmltmpl', 'vue', 'markdown'] } " emmet support for vim - easily create markdup wth CSS-like syntax
  34. Plug 'gregsexton/MatchTag', { 'for': ['html', 'php', 'gohtmltmpl', 'vue'] } " match tags in html, similar to paren support
  35. Plug 'othree/html5.vim', { 'for': ['html', 'php', 'gohtmltmpl', 'vue'] } " html5 support
  36. Plug 'lumiliet/vim-twig', { 'for': ['html'] } " twig syntax support
  37. Plug 'Glench/Vim-Jinja2-Syntax', { 'for': ['html'] }
  38. "}}}
  39. " JavaScript{{{
  40. Plug 'gavocanov/vim-js-indent', { 'for': [ 'javascript' ]} " JavaScript indent support
  41. Plug 'heavenshell/vim-jsdoc', { 'for': [ 'javascript', 'vue' ]} " Generate JSDoc comments
  42. Plug 'posva/vim-vue', { 'for': [ 'javascript', 'html', 'vue' ] } " vue.js integration
  43. "}}}
  44. " Go {{{
  45. Plug 'fatih/vim-go', { 'for': [ 'go', 'html', 'gohtmltmpl' ], 'do': ':GoInstallBinaries' } " go support
  46. "}}}
  47. " LaTeX{{{
  48. Plug 'lervag/vimtex', { 'for': 'tex' }
  49. "}}}
  50. " Markdown{{{
  51. Plug 'suan/vim-instant-markdown', { 'for': 'markdown' }
  52. Plug 'tpope/vim-markdown', { 'for': 'markdown'}
  53. "}}}
  54. " Colorschemes{{{
  55. Plug 'altercation/vim-colors-solarized'
  56. "}}}
  57. " TOML{{{
  58. Plug 'cespare/vim-toml', { 'for': 'toml' }
  59. "}}}
  60. " Haskell{{{
  61. Plug 'bitc/vim-hdevtools', { 'for': 'haskell' }
  62. Plug 'nbouscal/vim-stylish-haskell', { 'for': 'haskell' }
  63. "}}}
  64. " C/C++{{{
  65. Plug 'Rip-Rip/clang_complete', { 'for': ['c', 'cpp'], 'do': 'make install' }
  66. let g:clang_library_path='/usr/lib/llvm-6.0/lib/libclang-6.0.so.1'
  67. Plug 'rhysd/vim-clang-format', { 'for' : ['c', 'cpp', 'java'] }
  68. "}}}
  69. " PHP{{{
  70. Plug 'captbaritone/better-indent-support-for-php-with-html', { 'for': 'php' }
  71. Plug 'lumiliet/vim-twig', { 'for': [ 'php', 'html' ] } " Twig templates
  72. Plug 'Rican7/php-doc-modded', { 'for': 'php' } " Automatic phpdoc comments
  73. "}}}
  74. " Python{{{
  75. Plug 'davidhalter/jedi-vim', { 'for': 'python', 'do': 'pip install jedi' }
  76. Plug 'zchee/deoplete-jedi', { 'for': 'python' }
  77. Plug 'python-mode/python-mode', { 'for': 'python', 'branch': 'develop' }
  78. "}}}
  79. " Java{{{
  80. Plug 'artur-shaik/vim-javacomplete2', { 'for': 'java' }
  81. "}}}
  82. " MIPS{{{
  83. Plug 'vim-scripts/mips.vim'
  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. " }}}
  143. " MAPPINGS{{{
  144. let mapleader = ","
  145. " CtrlP for Tags
  146. nnoremap <leader><C-p> :CtrlPTag<cr>
  147. " fzf bindings
  148. nmap <C-p> :Files<CR>
  149. nmap <leader><C-p> :Tags<CR>
  150. nmap <leader>/ :Rg<CR>
  151. " Toggle NERDTree
  152. nmap <silent> <leader>k :NERDTreeToggle<cr>
  153. " expand to the path of the file in the current buffer
  154. nmap <silent> <leader>y :NERDTreeFind<cr>
  155. " Allow saving of files as sudo when I forgot to start vim using sudo.
  156. cmap w!! :w suda://%
  157. "Toggle set paste
  158. nmap <leader>tp :set paste!<cr>
  159. " scroll the viewport faster
  160. nnoremap <C-e> 3<C-e>
  161. nnoremap <C-y> 3<C-y>
  162. " ctrl-r in visual mode to replace selected text
  163. vnoremap <C-r> "hy:%s/<C-r>h//g<left><left>
  164. nmap <leader>an :ALENext<cr>
  165. nnoremap <leader>tn :tabnew<cr>
  166. nnoremap <F3> :Gstatus<cr>
  167. nnoremap <F4> :Gpush<cr>
  168. "}}}
  169. " P L U G I N S{{{
  170. let NERDTreeShowHidden=1
  171. let g:airline_powerline_fonts = 1
  172. " notational notes
  173. let g:nv_search_paths = ['~/notes']
  174. let g:nv_default_extension = '.md'
  175. let g:nv_main_directory = '~/notes'
  176. " ALE {{{
  177. let g:airline#extensions#ale#enabled = 1
  178. "}}}
  179. let vim_tags_ctags_binary='~/bin/phpctags'"
  180. " Java config
  181. autocmd FileType java setlocal omnifunc=javacomplete#Complete
  182. " Python-mode config
  183. let g:pymode_lint_on_write = 0
  184. " Vimtex{{{
  185. if !exists('g:neocomplete#sources#omni#input_patterns')
  186. let g:neocomplete#sources#omni#input_patterns = {}
  187. endif
  188. let g:neocomplete#sources#omni#input_patterns.tex =
  189. \ '\v\\%('
  190. \ . '\a*%(ref|cite)\a*%(\s*\[[^]]*\])?\s*\{[^{}]*'
  191. \ . '|includegraphics%(\s*\[[^]]*\])?\s*\{[^{}]*'
  192. \ . '|%(include|input)\s*\{[^{}]*'
  193. \ . ')'
  194. "}}}
  195. " C/C++ {{{
  196. autocmd FileType c,cpp,objc nnoremap <buffer><Leader>f :<C-u>ClangFormat<CR>
  197. autocmd FileType c,cpp,objc vnoremap <buffer><Leader>f :ClangFormat<CR>
  198. "}}}
  199. " Prettier
  200. let g:prettier#config#tab_width = 4
  201. let g:prettier#exec_cmd_async = 1
  202. " Completion {{{
  203. " if hidden is not set, TextEdit might fail.
  204. set hidden
  205. " Some servers have issues with backup files, see #649
  206. set nobackup
  207. set nowritebackup
  208. " Better display for messages
  209. set cmdheight=2
  210. " You will have bad experience for diagnostic messages when it's default 4000.
  211. set updatetime=300
  212. " don't give |ins-completion-menu| messages.
  213. set shortmess+=c
  214. " always show signcolumns
  215. set signcolumn=yes
  216. " Use tab for trigger completion with characters ahead and navigate.
  217. " Use command ':verbose imap <tab>' to make sure tab is not mapped by other plugin.
  218. inoremap <silent><expr> <TAB>
  219. \ pumvisible() ? "\<C-n>" :
  220. \ <SID>check_back_space() ? "\<TAB>" :
  221. \ coc#refresh()
  222. inoremap <expr><S-TAB> pumvisible() ? "\<C-p>" : "\<C-h>"
  223. function! s:check_back_space() abort
  224. let col = col('.') - 1
  225. return !col || getline('.')[col - 1] =~# '\s'
  226. endfunction
  227. " Use <c-space> to trigger completion.
  228. inoremap <silent><expr> <c-space> coc#refresh()
  229. " Use <cr> to confirm completion, `<C-g>u` means break undo chain at current position.
  230. " Coc only does snippet and additional edit on confirm.
  231. inoremap <expr> <cr> pumvisible() ? "\<C-y>" : "\<C-g>u\<CR>"
  232. " Use `[c` and `]c` to navigate diagnostics
  233. nmap <silent> [c <Plug>(coc-diagnostic-prev)
  234. nmap <silent> ]c <Plug>(coc-diagnostic-next)
  235. " Remap keys for gotos
  236. nmap <silent> gd <Plug>(coc-definition)
  237. nmap <silent> gy <Plug>(coc-type-definition)
  238. nmap <silent> gi <Plug>(coc-implementation)
  239. nmap <silent> gr <Plug>(coc-references)
  240. " Use K to show documentation in preview window
  241. nnoremap <silent> K :call <SID>show_documentation()<CR>
  242. function! s:show_documentation()
  243. if (index(['vim','help'], &filetype) >= 0)
  244. execute 'h '.expand('<cword>')
  245. else
  246. call CocAction('doHover')
  247. endif
  248. endfunction
  249. " Highlight symbol under cursor on CursorHold
  250. autocmd CursorHold * silent call CocActionAsync('highlight')
  251. " Remap for rename current word
  252. nmap <leader>rn <Plug>(coc-rename)
  253. " Remap for format selected region
  254. xmap <leader>f <Plug>(coc-format-selected)
  255. nmap <leader>f <Plug>(coc-format-selected)
  256. augroup mygroup
  257. autocmd!
  258. " Setup formatexpr specified filetype(s).
  259. autocmd FileType typescript,json setl formatexpr=CocAction('formatSelected')
  260. " Update signature help on jump placeholder
  261. autocmd User CocJumpPlaceholder call CocActionAsync('showSignatureHelp')
  262. augroup end
  263. " Remap for do codeAction of selected region, ex: `<leader>aap` for current paragraph
  264. xmap <leader>a <Plug>(coc-codeaction-selected)
  265. nmap <leader>a <Plug>(coc-codeaction-selected)
  266. " Remap for do codeAction of current line
  267. nmap <leader>ac <Plug>(coc-codeaction)
  268. " Fix autofix problem of current line
  269. nmap <leader>qf <Plug>(coc-fix-current)
  270. " Use <tab> for select selections ranges, needs server support, like: coc-tsserver, coc-python
  271. nmap <silent> <TAB> <Plug>(coc-range-select)
  272. xmap <silent> <TAB> <Plug>(coc-range-select)
  273. xmap <silent> <S-TAB> <Plug>(coc-range-select-backword)
  274. " Use `:Format` to format current buffer
  275. command! -nargs=0 Format :call CocAction('format')
  276. " Use `:Fold` to fold current buffer
  277. command! -nargs=? Fold :call CocAction('fold', <f-args>)
  278. " use `:OR` for organize import of current buffer
  279. command! -nargs=0 OR :call CocAction('runCommand', 'editor.action.organizeImport')
  280. " Add status line support, for integration with other plugin, checkout `:h coc-status`
  281. set statusline^=%{coc#status()}%{get(b:,'coc_current_function','')}
  282. " Using CocList
  283. " Show all diagnostics
  284. nnoremap <silent> <space>a :<C-u>CocList diagnostics<cr>
  285. " Manage extensions
  286. nnoremap <silent> <space>e :<C-u>CocList extensions<cr>
  287. " Show commands
  288. nnoremap <silent> <space>c :<C-u>CocList commands<cr>
  289. " Find symbol of current document
  290. nnoremap <silent> <space>o :<C-u>CocList outline<cr>
  291. " Search workspace symbols
  292. nnoremap <silent> <space>s :<C-u>CocList -I symbols<cr>
  293. " Do default action for next item.
  294. nnoremap <silent> <space>j :<C-u>CocNext<CR>
  295. " Do default action for previous item.
  296. nnoremap <silent> <space>k :<C-u>CocPrev<CR>
  297. " Resume latest coc list
  298. nnoremap <silent> <space>p :<C-u>CocListResume<CR>:
  299. " For conceal markers.
  300. if has('conceal')
  301. set conceallevel=2 concealcursor=niv
  302. endif
  303. let g:neosnippet#snippets_directory = '~/.dotfiles/vim/neosnippets'
  304. "}}}