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.

420 lines
14 KiB

8 years ago
8 years ago
7 years ago
5 years ago
3 years ago
4 years ago
4 years ago
3 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
3 years ago
8 years ago
8 years ago
3 years ago
8 years ago
6 years ago
8 years ago
4 years ago
3 years ago
7 years ago
7 years ago
7 years ago
7 years ago
5 years ago
7 years ago
7 years ago
3 years ago
5 years ago
3 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 'scrooloose/nerdtree', { 'on': 'NERDTreeToggle' } " file tree
  15. Plug 'Xuyuanp/nerdtree-git-plugin', { 'on': 'NERDTreeToggle' }
  16. Plug 'scrooloose/nerdcommenter' " better commenting
  17. Plug 'neoclide/coc.nvim', {'branch': 'release'} " coc - completion
  18. Plug 'easymotion/vim-easymotion' " better motion with leader
  19. Plug 'bling/vim-airline' " statusline
  20. Plug 'w0rp/ale' " asynchronous linting engine
  21. Plug 'godlygeek/tabular' " Align text on symbols
  22. Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' } " fuzzy file finder
  23. Plug 'junegunn/fzf.vim' " vim integration for fzf
  24. Plug 'airblade/vim-gitgutter' " git status in gutter column
  25. Plug 'lambdalisue/suda.vim' " As w!! did not work anymore in nvim
  26. Plug 'https://github.com/alok/notational-fzf-vim' " note taking
  27. Plug 'prettier/vim-prettier', { 'do': 'npm install' } " prettier integration
  28. Plug 'honza/vim-snippets' " Collection of Snippets, used by coc-snippet
  29. "Plug 'ludovicchabant/vim-gutentags', { 'for': ['js', 'vue', 'php', 'python'] } " Keep tags in sync
  30. Plug 'dpelle/vim-LanguageTool', { 'for': ['markdown', 'tex', 'plaintext', 'mail']} " LanguageTool bindings
  31. Plug 'nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'} " We recommend updating the parsers on update
  32. " {{{ CocPlugins
  33. Plug 'neoclide/coc-json', { 'do': 'yarn install --frozen-lockfile' }
  34. Plug 'neoclide/coc-snippets', { 'do': 'yarn install --frozen-lockfile' }
  35. Plug 'neoclide/coc-tsserver', { 'do': 'yarn install --frozen-lockfile' }
  36. Plug 'neoclide/coc-eslint', { 'do': 'yarn install --frozen-lockfile' }
  37. Plug 'fannheyward/coc-rust-analyzer', { '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 'fannheyward/coc-texlab', { 'do': 'yarn install --frozen-lockfile' }
  42. Plug 'neoclide/coc-html', { 'do': 'yarn install --frozen-lockfile' }
  43. Plug 'neoclide/coc-yaml', { 'do': 'yarn install --frozen-lockfile' }
  44. "Plug 'neoclide/coc-python', { 'do': 'yarn install --frozen-lockfile' }
  45. Plug 'marlonfan/coc-phpls', { 'do': 'yarn install --frozen-lockfile' }
  46. Plug 'fannheyward/coc-sql', { 'do': 'yarn install --frozen-lockfile' }
  47. Plug 'fannheyward/coc-markdownlint', { 'do': 'yarn install --frozen-lockfile' }
  48. Plug 'josa42/coc-go', { 'do': 'yarn install --frozen-lockfile' }
  49. Plug 'fannheyward/coc-pyright', { 'for': 'python', 'do': 'yarn install --frozen-lockfile' }
  50. " }}}
  51. " html / templates{{{
  52. Plug 'mattn/emmet-vim', { 'for': ['jinja.html', 'html', 'php', 'gohtmltmpl', 'vue', 'markdown'] } " emmet support for vim - easily create markdup wth CSS-like syntax
  53. Plug 'gregsexton/MatchTag', { 'for': ['html', 'php', 'gohtmltmpl', 'vue'] } " match tags in html, similar to paren support
  54. Plug 'othree/html5.vim', { 'for': ['html', 'php', 'gohtmltmpl', 'vue'] } " html5 support
  55. Plug 'lumiliet/vim-twig', { 'for': ['html'] } " twig syntax support
  56. Plug 'Glench/Vim-Jinja2-Syntax', { 'for': ['html'] }
  57. Plug 'jvanja/vim-bootstrap4-snippets', { 'for': ['html', 'blade'] }
  58. "}}}
  59. " JavaScript{{{
  60. Plug 'gavocanov/vim-js-indent', { 'for': [ 'javascript' ]} " JavaScript indent support
  61. Plug 'heavenshell/vim-jsdoc', { 'for': [ 'javascript', 'typescript', 'vue' ], 'do': 'make install'} " Generate JSDoc comments
  62. Plug 'posva/vim-vue', { 'for': [ 'javascript', 'html', 'vue' ] } " vue.js integration
  63. "}}}
  64. " LaTeX{{{
  65. Plug 'lervag/vimtex', { 'for': 'tex' }
  66. "}}}
  67. " Markdown{{{
  68. Plug 'tpope/vim-markdown', { 'for': 'markdown'}
  69. Plug 'iamcco/markdown-preview.nvim', { 'do': 'cd app & yarn install', 'for': 'markdown' }
  70. "}}}
  71. " Colorschemes{{{
  72. Plug 'altercation/vim-colors-solarized'
  73. Plug 'vim-scripts/nginx.vim'
  74. "}}}
  75. " TOML{{{
  76. Plug 'cespare/vim-toml', { 'for': 'toml' }
  77. "}}}
  78. " C/C++{{{
  79. Plug 'Rip-Rip/clang_complete', { 'for': ['c', 'cpp'], 'do': 'make install' }
  80. let g:clang_library_path='/usr/lib/llvm-6.0/lib/libclang-6.0.so.1'
  81. Plug 'rhysd/vim-clang-format', { 'for' : ['c', 'cpp', 'java'] }
  82. Plug 'vim-scripts/DoxygenToolkit.vim', { 'for' : ['c', 'cpp'] }
  83. "}}}
  84. " PHP{{{
  85. Plug 'captbaritone/better-indent-support-for-php-with-html', { 'for': 'php' }
  86. Plug 'lumiliet/vim-twig', { 'for': [ 'php', 'html' ] } " Twig templates
  87. Plug 'Rican7/php-doc-modded', { 'for': 'php' } " Automatic phpdoc comments
  88. Plug 'jwalton512/vim-blade', { 'for': 'php' }
  89. "}}}
  90. " {{{ Python
  91. Plug 'jeetsukumaran/vim-pythonsense', { 'for': ['python'] } " text objects for python
  92. Plug 'heavenshell/vim-pydocstring', { 'for': ['python'], 'do': 'make install' }
  93. Plug 'anntzer/vim-cython', { 'for': ['python']}
  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 mouse=nv
  144. set foldmethod=marker" " folds are marked with {{{}}}
  145. " Uncomment the following to have Vim jump to the last position when
  146. " reopening a file
  147. if has("autocmd")
  148. if expand('%:t') != 'COMMIT_EDITMSG'
  149. au BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$")
  150. \| exe "normal! g'\"" | endif
  151. endif
  152. endif
  153. " Setting for correct mips syntax highlighting
  154. au BufReadPost *.mips set syntax=mips
  155. " Override default flavor to latex, so vimtex gets loaded always
  156. let g:tex_flavor = "latex"
  157. " use python 3 when in doubt
  158. set pyxversion=3
  159. " Disable ALEs LSP, as we're using coc
  160. let g:ale_disable_lsp = 1
  161. " }}}
  162. " MAPPINGS{{{
  163. let mapleader = ","
  164. " CtrlP for Tags
  165. nnoremap <leader><C-p> :CtrlPTag<cr>
  166. " fzf bindings
  167. nmap <C-p> :Files<CR>
  168. nmap <leader><C-p> :Tags<CR>
  169. nmap <leader>/ :Rg<CR>
  170. nmap <leader>b :Buffers<CR>
  171. " Toggle NERDTree
  172. nmap <silent> <leader>k :NERDTreeToggle<cr>
  173. " expand to the path of the file in the current buffer
  174. nmap <silent> <leader>y :NERDTreeFind<cr>
  175. " Allow saving of files as sudo when I forgot to start vim using sudo.
  176. cmap w!! :w suda://%
  177. "Toggle set paste
  178. nmap <leader>tp :set paste!<cr>
  179. " scroll the viewport faster
  180. nnoremap <C-e> 3<C-e>
  181. nnoremap <C-y> 3<C-y>
  182. " ctrl-r in visual mode to replace selected text
  183. vnoremap <C-r> "hy:%s/<C-r>h//g<left><left>
  184. nmap <leader>an :ALENext<cr>
  185. nnoremap <leader>tn :tabnew<cr>
  186. nnoremap <F3> :Git<cr>
  187. nnoremap <F4> :Git push<cr>
  188. "}}}
  189. " P L U G I N S{{{
  190. let g:languagetool_server="/opt/LanguageTool/LanguageTool-5.0/languagetool-server.jar"
  191. let g:languagetool_jar="/opt/LanguageTool/LanguageTool-5.0/languagetool-commandline.jar"
  192. let NERDTreeShowHidden=1
  193. if exists('g:started_by_firenvim')
  194. let g:airline_disable_statusline = 1
  195. else
  196. let g:airline_powerline_fonts = 1
  197. end
  198. " notational notes
  199. let g:nv_search_paths = ['~/notes']
  200. let g:nv_default_extension = '.md'
  201. let g:nv_main_directory = '~/notes'
  202. " ALE {{{
  203. let g:airline#extensions#ale#enabled = 1
  204. "}}}
  205. let vim_tags_ctags_binary='~/bin/phpctags'"
  206. " Java config
  207. autocmd FileType java setlocal omnifunc=javacomplete#Complete
  208. " Python-mode config
  209. let g:pymode_lint_on_write = 0
  210. " Vimtex{{{
  211. if !exists('g:neocomplete#sources#omni#input_patterns')
  212. let g:neocomplete#sources#omni#input_patterns = {}
  213. endif
  214. let g:neocomplete#sources#omni#input_patterns.tex =
  215. \ '\v\\%('
  216. \ . '\a*%(ref|cite)\a*%(\s*\[[^]]*\])?\s*\{[^{}]*'
  217. \ . '|includegraphics%(\s*\[[^]]*\])?\s*\{[^{}]*'
  218. \ . '|%(include|input)\s*\{[^{}]*'
  219. \ . ')'
  220. "}}}
  221. " C/C++ {{{
  222. autocmd FileType c,cpp,objc nnoremap <buffer><Leader>f :<C-u>ClangFormat<CR>
  223. autocmd FileType c,cpp,objc vnoremap <buffer><Leader>f :ClangFormat<CR>
  224. "}}}
  225. " Prettier
  226. let g:prettier#config#tab_width = 2
  227. let g:prettier#exec_cmd_async = 1
  228. " Completion {{{
  229. " if hidden is not set, TextEdit might fail.
  230. set hidden
  231. " Some servers have issues with backup files, see #649
  232. set nobackup
  233. set nowritebackup
  234. " Better display for messages
  235. set cmdheight=2
  236. " You will have bad experience for diagnostic messages when it's default 4000.
  237. set updatetime=300
  238. " don't give |ins-completion-menu| messages.
  239. set shortmess+=c
  240. " always show signcolumns
  241. set signcolumn=yes
  242. " Use tab for trigger completion with characters ahead and navigate.
  243. " Use command ':verbose imap <tab>' to make sure tab is not mapped by other plugin.
  244. inoremap <silent><expr> <TAB>
  245. \ pumvisible() ? "\<C-n>" :
  246. \ <SID>check_back_space() ? "\<TAB>" :
  247. \ coc#refresh()
  248. inoremap <expr><S-TAB> pumvisible() ? "\<C-p>" : "\<C-h>"
  249. function! s:check_back_space() abort
  250. let col = col('.') - 1
  251. return !col || getline('.')[col - 1] =~# '\s'
  252. endfunction
  253. " Use <c-space> to trigger completion.
  254. inoremap <silent><expr> <c-space> coc#refresh()
  255. " Use <cr> to confirm completion, `<C-g>u` means break undo chain at current position.
  256. " Coc only does snippet and additional edit on confirm.
  257. inoremap <expr> <cr> pumvisible() ? "\<C-y>" : "\<C-g>u\<CR>"
  258. " Use `[c` and `]c` to navigate diagnostics
  259. nmap <silent> [c <Plug>(coc-diagnostic-prev)
  260. nmap <silent> ]c <Plug>(coc-diagnostic-next)
  261. " Remap keys for gotos
  262. nmap <silent> gd <Plug>(coc-definition)
  263. nmap <silent> gy <Plug>(coc-type-definition)
  264. nmap <silent> gi <Plug>(coc-implementation)
  265. nmap <silent> gr <Plug>(coc-references)
  266. " Use K to show documentation in preview window
  267. nnoremap <silent> H :call <SID>show_documentation()<CR>
  268. function! s:show_documentation()
  269. if (index(['vim','help'], &filetype) >= 0)
  270. execute 'h '.expand('<cword>')
  271. else
  272. call CocAction('doHover')
  273. endif
  274. endfunction
  275. " Highlight symbol under cursor on CursorHold
  276. autocmd CursorHold * silent call CocActionAsync('highlight')
  277. " Remap for rename current word
  278. nmap <leader>rn <Plug>(coc-rename)
  279. " Remap for format selected region
  280. xmap <leader>f <Plug>(coc-format-selected)
  281. nmap <leader>f <Plug>(coc-format-selected)
  282. augroup mygroup
  283. autocmd!
  284. " Setup formatexpr specified filetype(s).
  285. autocmd FileType typescript,json setl formatexpr=CocAction('formatSelected')
  286. " Update signature help on jump placeholder
  287. autocmd User CocJumpPlaceholder call CocActionAsync('showSignatureHelp')
  288. augroup end
  289. " Remap for do codeAction of selected region, ex: `<leader>aap` for current paragraph
  290. xmap <leader>a <Plug>(coc-codeaction-selected)
  291. nmap <leader>a <Plug>(coc-codeaction-selected)
  292. " Remap for do codeAction of current line
  293. nmap <leader>ac <Plug>(coc-codeaction)
  294. " Fix autofix problem of current line
  295. nmap <leader>qf <Plug>(coc-fix-current)
  296. " Use <tab> for select selections ranges, needs server support, like: coc-tsserver, coc-python
  297. "nmap <silent> <TAB> <Plug>(coc-range-select)
  298. "xmap <silent> <TAB> <Plug>(coc-range-select)
  299. "xmap <silent> <S-TAB> <Plug>(coc-range-select-backward)
  300. " Use `:Format` to format current buffer
  301. command! -nargs=0 Format :call CocAction('format')
  302. " Use `:Fold` to fold current buffer
  303. command! -nargs=? Fold :call CocAction('fold', <f-args>)
  304. " use `:OR` for organize import of current buffer
  305. command! -nargs=0 OR :call CocAction('runCommand', 'editor.action.organizeImport')
  306. " Add status line support, for integration with other plugin, checkout `:h coc-status`
  307. set statusline^=%{coc#status()}%{get(b:,'coc_current_function','')}
  308. " Using CocList
  309. " Show all diagnostics
  310. nnoremap <silent> <space>a :<C-u>CocList diagnostics<cr>
  311. " Manage extensions
  312. nnoremap <silent> <space>e :<C-u>CocList extensions<cr>
  313. " Show commands
  314. nnoremap <silent> <space>c :<C-u>CocList commands<cr>
  315. " Find symbol of current document
  316. nnoremap <silent> <space>o :<C-u>CocList outline<cr>
  317. " Search workspace symbols
  318. nnoremap <silent> <space>s :<C-u>CocList -I symbols<cr>
  319. " Do default action for next item.
  320. nnoremap <silent> <space>j :<C-u>CocNext<CR>
  321. " Do default action for previous item.
  322. nnoremap <silent> <space>k :<C-u>CocPrev<CR>
  323. " Resume latest coc list
  324. nnoremap <silent> <space>p :<C-u>CocListResume<CR>:
  325. " snippets
  326. imap <C-k> <Plug>(coc-snippets-expand-jump)
  327. " For conceal markers.
  328. if has('conceal')
  329. set conceallevel=2 concealcursor=niv
  330. endif
  331. let g:neosnippet#snippets_directory = '~/.dotfiles/vim/neosnippets'
  332. "}}}
  333. " Treesitter {{{
  334. lua <<EOF
  335. require'nvim-treesitter.configs'.setup {
  336. ensure_installed = {"typescript", "javascript", "python", "json", "yaml"}, -- one of "all", "maintained" (parsers with maintainers), or a list of languages
  337. highlight = {
  338. enable = true, -- false will disable the whole extension
  339. disable = {}, -- list of language that will be disabled
  340. },
  341. }
  342. EOF
  343. " }}}
  344. "}}}