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.

432 lines
14 KiB

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