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.

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