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.

423 lines
14 KiB

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