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.

365 lines
12 KiB

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