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.

516 lines
17 KiB

7 years ago
7 years ago
3 years ago
7 years ago
5 years ago
3 years ago
3 years ago
3 years ago
2 years ago
2 years ago
3 years ago
2 years ago
3 years ago
4 years ago
3 years ago
7 years ago
7 years ago
6 years ago
2 years ago
2 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
2 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
3 years ago
7 years ago
7 years ago
3 years ago
7 years ago
6 years ago
7 years ago
4 years ago
2 years ago
4 years ago
3 years ago
2 years ago
3 years ago
7 years ago
2 years ago
2 years ago
7 years ago
7 years ago
2 years ago
7 years ago
2 years ago
2 years ago
2 years ago
7 years ago
5 years ago
3 years ago
2 years ago
3 years ago
7 years ago
7 years ago
3 years ago
5 years ago
3 years ago
7 years ago
2 years ago
2 years ago
2 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-rhubarb' " Github integration
  11. Plug 'tpope/vim-sensible' " Defaults everyone can agree on
  12. Plug 'tpope/vim-surround' " better handling of surrounding markers
  13. Plug 'tpope/vim-ragtag' " Enhancement of surround for html
  14. Plug 'tpope/vim-repeat' " repeat last command with .
  15. Plug 'scrooloose/nerdtree', { 'on': ['NERDTreeToggle', 'NERDTreeFind'] } " file tree
  16. Plug 'Xuyuanp/nerdtree-git-plugin', { 'on': ['NERDTreeToggle', 'NERDTreeFind'] }
  17. Plug 'scrooloose/nerdcommenter' " better commenting
  18. Plug 'neoclide/coc.nvim', {'branch': 'release'} " coc - completion
  19. Plug 'easymotion/vim-easymotion' " better motion with leader
  20. Plug 'bling/vim-airline' " statusline
  21. Plug 'w0rp/ale' " asynchronous linting engine
  22. Plug 'godlygeek/tabular' " Align text on symbols
  23. Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' } " fuzzy file finder
  24. Plug 'junegunn/fzf.vim' " vim integration for fzf
  25. Plug 'airblade/vim-gitgutter' " git status in gutter column
  26. Plug 'lambdalisue/suda.vim' " As w!! did not work anymore in nvim
  27. Plug 'https://github.com/alok/notational-fzf-vim' " note taking
  28. Plug 'prettier/vim-prettier', { 'do': 'npm install' } " prettier integration
  29. Plug 'honza/vim-snippets' " Collection of Snippets, used by coc-snippet
  30. "Plug 'ludovicchabant/vim-gutentags', { 'for': ['js', 'vue', 'php', 'python'] } " Keep tags in sync
  31. Plug 'dpelle/vim-LanguageTool', { 'for': ['markdown', 'tex', 'plaintext', 'mail']} " LanguageTool bindings
  32. Plug 'nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'} " We recommend updating the parsers on update
  33. Plug 'nvim-treesitter/nvim-treesitter-textobjects'
  34. Plug 'kyazdani42/nvim-web-devicons' " Icons...
  35. Plug 'mfussenegger/nvim-dap', { 'for': ['typescript', 'javascript', 'python', 'rust'] }
  36. Plug 'lbrayner/vim-rzip' " recursive zip support, needed for yarn pnp
  37. Plug 'kkoomen/vim-doge', { 'do': { -> doge#install() } }
  38. Plug 'taybart/b64.nvim' " en/decode base64 strings
  39. " telescope. Needed for octo.nvim, might replace fzf
  40. Plug 'nvim-lua/popup.nvim'
  41. Plug 'nvim-lua/plenary.nvim'
  42. Plug 'nvim-telescope/telescope.nvim'
  43. Plug 'nvim-telescope/telescope-fzf-native.nvim', { 'do': 'make' } " improve sort performance
  44. Plug 'pwntester/octo.nvim'
  45. "Plug 'github/copilot.vim'
  46. " {{{ CocPlugins
  47. Plug 'neoclide/coc-json', { 'do': 'yarn install --frozen-lockfile' }
  48. Plug 'neoclide/coc-snippets', { 'do': 'yarn install --frozen-lockfile' }
  49. Plug 'neoclide/coc-tsserver', { 'do': 'yarn install --frozen-lockfile' }
  50. Plug 'neoclide/coc-eslint', { 'do': 'yarn install --frozen-lockfile' }
  51. Plug 'fannheyward/coc-rust-analyzer', { 'do': 'yarn install --frozen-lockfile' }
  52. Plug 'neoclide/coc-css', { 'do': 'yarn install --frozen-lockfile' }
  53. Plug 'neoclide/coc-vimtex', { 'do': 'yarn install --frozen-lockfile' }
  54. Plug 'fannheyward/coc-texlab', { 'do': 'yarn install --frozen-lockfile' }
  55. Plug 'neoclide/coc-html', { 'do': 'yarn install --frozen-lockfile' }
  56. Plug 'neoclide/coc-yaml', { 'do': 'yarn install --frozen-lockfile' }
  57. "Plug 'neoclide/coc-python', { 'do': 'yarn install --frozen-lockfile' }
  58. Plug 'fannheyward/coc-sql', { 'do': 'yarn install --frozen-lockfile' }
  59. Plug 'fannheyward/coc-markdownlint', { 'do': 'yarn install --frozen-lockfile' }
  60. Plug 'fannheyward/coc-pyright', { 'for': 'python', 'do': 'yarn install --frozen-lockfile' }
  61. Plug 'josa42/coc-sh', { 'do': 'yarn install --frozen-lockfile' }
  62. " }}}
  63. " html / templates{{{
  64. Plug 'mattn/emmet-vim', { 'for': ['jinja.html', 'html', 'php', 'gohtmltmpl', 'vue', 'markdown'] } " emmet support for vim - easily create markdup wth CSS-like syntax
  65. Plug 'gregsexton/MatchTag', { 'for': ['html', 'php', 'gohtmltmpl', 'vue'] } " match tags in html, similar to paren support
  66. Plug 'othree/html5.vim', { 'for': ['html', 'php', 'gohtmltmpl', 'vue'] } " html5 support
  67. Plug 'lumiliet/vim-twig', { 'for': ['html'] } " twig syntax support
  68. Plug 'Glench/Vim-Jinja2-Syntax', { 'for': ['html'] }
  69. Plug 'jvanja/vim-bootstrap4-snippets', { 'for': ['html', 'blade'] }
  70. "}}}
  71. " JavaScript{{{
  72. Plug 'gavocanov/vim-js-indent', { 'for': [ 'javascript' ]} " JavaScript indent support
  73. Plug 'posva/vim-vue', { 'for': [ 'javascript', 'html', 'vue' ] } " vue.js integration
  74. Plug 'kevinoid/vim-jsonc'
  75. "}}}
  76. " LaTeX{{{
  77. Plug 'lervag/vimtex', { 'for': 'tex' }
  78. "}}}
  79. " Markdown{{{
  80. Plug 'tpope/vim-markdown', { 'for': 'markdown'}
  81. Plug 'iamcco/markdown-preview.nvim', { 'do': 'cd app & yarn install', 'for': 'markdown' }
  82. "}}}
  83. " Colorschemes{{{
  84. Plug 'altercation/vim-colors-solarized'
  85. Plug 'vim-scripts/nginx.vim'
  86. "}}}
  87. " TOML{{{
  88. Plug 'cespare/vim-toml', { 'for': 'toml' }
  89. "}}}
  90. " C/C++{{{
  91. Plug 'Rip-Rip/clang_complete', { 'for': ['c', 'cpp'], 'do': 'make install' }
  92. let g:clang_library_path='/usr/lib/llvm-6.0/lib/libclang-6.0.so.1'
  93. Plug 'rhysd/vim-clang-format', { 'for' : ['c', 'cpp', 'java'] }
  94. Plug 'vim-scripts/DoxygenToolkit.vim', { 'for' : ['c', 'cpp'] }
  95. "}}}
  96. " PHP{{{
  97. Plug 'captbaritone/better-indent-support-for-php-with-html', { 'for': 'php' }
  98. Plug 'lumiliet/vim-twig', { 'for': [ 'php', 'html' ] } " Twig templates
  99. Plug 'Rican7/php-doc-modded', { 'for': 'php' } " Automatic phpdoc comments
  100. Plug 'jwalton512/vim-blade', { 'for': 'php' }
  101. "}}}
  102. " {{{ Python
  103. Plug 'jeetsukumaran/vim-pythonsense', { 'for': ['python'] } " text objects for python
  104. Plug 'heavenshell/vim-pydocstring', { 'for': ['python'], 'do': 'make install' }
  105. Plug 'anntzer/vim-cython', { 'for': ['python']}
  106. Plug 'python-rope/ropevim'
  107. "}}}
  108. "{{{ CSV
  109. Plug 'chrisbra/csv.vim', { 'for': 'csv' }
  110. "}}}
  111. " All of your Plugins must be added before the following line
  112. call plug#end() " required
  113. filetype plugin indent on " required
  114. " }}}
  115. " THEME{{{
  116. colorscheme solarized
  117. set background=dark
  118. " Use light theme if whole shell is in light mode
  119. let themeenv=$THEME_SWITCHER
  120. if themeenv=='light'
  121. set background=light
  122. endif
  123. " }}}
  124. " SETTINGS{{{
  125. " disable Ex mode, who needs this anyway?
  126. noremap Q <Nop>
  127. set number " line numbers
  128. set autoread " reload file automatically
  129. set colorcolumn=100 " highlight column 99
  130. set textwidth=99
  131. set smartcase "use smart case like in ripgrep (case insensitive until capital letters are used)
  132. set history=1000
  133. set wildignore+=node_modules " ignore node_modules folder from file search
  134. set inccommand=split " show interactive results of substiute command
  135. " make comments and HTML attributes italic
  136. highlight Comment cterm=italic
  137. highlight htmlArg cterm=italic
  138. set autoindent " automatically set indent of new line
  139. set smartindent
  140. set tabstop=4
  141. set shiftwidth=4
  142. set expandtab
  143. " toggle invisible characters
  144. set list
  145. set listchars=tab:→\ ,trail:⋅,extends:❯,precedes:❮
  146. set showbreak=
  147. set ttyfast " faster redrawing
  148. set diffopt+=vertical
  149. set laststatus=2 " show the satus line all the time
  150. set so=7 " set 7 lines to the cursors - when moving vertical
  151. set wildmenu " enhanced command line completion
  152. set hidden " current buffer can be put into background
  153. set showcmd " show incomplete commands
  154. " set noshowmode " don't show which mode disabled for PowerLine
  155. set wildmode=list:longest " complete files like a shell
  156. set scrolloff=3 " lines of text around cursor
  157. set shell=$SHELL
  158. set cmdheight=1 " command bar height
  159. set title " set terminal title
  160. set mouse=nv
  161. set foldmethod=marker" " folds are marked with {{{}}}
  162. " Uncomment the following to have Vim jump to the last position when
  163. " reopening a file
  164. if has("autocmd")
  165. if expand('%:t') != 'COMMIT_EDITMSG'
  166. au BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$")
  167. \| exe "normal! g'\"" | endif
  168. endif
  169. endif
  170. " Setting for correct mips syntax highlighting
  171. au BufReadPost *.mips set syntax=mips
  172. " Override default flavor to latex, so vimtex gets loaded always
  173. let g:tex_flavor = "latex"
  174. " use python 3 when in doubt
  175. let g:python3_host_prog="/home/schneider/.pyenv/versions/neovim3/bin/python"
  176. set pyxversion=3
  177. " nodejs settings
  178. "let g:node_host_prog="/usr/bin/node"
  179. " Disable ALEs LSP, as we're using coc
  180. let g:ale_disable_lsp = 1
  181. " }}}
  182. " MAPPINGS{{{
  183. let mapleader = ","
  184. " CtrlP for Tags
  185. nnoremap <leader><C-p> :CtrlPTag<cr>
  186. " fzf bindings
  187. "nmap <C-p> :Files<CR>
  188. nmap <leader><C-p> :Tags<CR>
  189. nmap <leader>/ :Rg<CR>
  190. "nmap <leader>b :Buffers<CR>
  191. " Telescope Bindings
  192. nmap <C-p> :lua require("telescope.builtin").find_files({find_command={"fd","--type=f","-H", "-E=.git", "-E=.yalc", "-E=node_modules"}})<CR>
  193. "nmap <C-p> :Telescope fd<CR>
  194. nmap <leader>b :lua require('telescope.builtin').buffers({ sort_mru = true, ignore_current_buffer = true })<CR>
  195. nmap <leader>/ :Telescope live_grep<CR>
  196. " Toggle NERDTree
  197. nmap <silent> <leader>k :NERDTreeToggle<cr>
  198. " expand to the path of the file in the current buffer
  199. nmap <silent> <leader>y :NERDTreeFind<cr>
  200. " Allow saving of files as sudo when I forgot to start vim using sudo.
  201. cmap w!! :w suda://%
  202. "Toggle set paste
  203. nmap <leader>tp :set paste!<cr>
  204. " scroll the viewport faster
  205. nnoremap <C-e> 3<C-e>
  206. nnoremap <C-y> 3<C-y>
  207. " ctrl-r in visual mode to replace selected text
  208. vnoremap <C-r> "hy:%s/<C-r>h//g<left><left>
  209. nmap <leader>an :ALENext<cr>
  210. nnoremap <leader>tn :tabnew<cr>
  211. nnoremap <F3> :Git<cr>
  212. nnoremap <F4> :Git push<cr>
  213. vnoremap <silent> <leader>be :<c-u>lua require("b64").encode()<cr>
  214. vnoremap <silent> <leader>bd :<c-u>lua require("b64").decode()<cr>
  215. "}}}
  216. " {{{ Textobjects
  217. lua <<EOF
  218. require'nvim-treesitter.configs'.setup {
  219. textobjects = {
  220. select = {
  221. enable = true,
  222. -- Automatically jump forward to textobj, similar to targets.vim
  223. lookahead = true,
  224. keymaps = {
  225. -- You can use the capture groups defined in textobjects.scm
  226. ["af"] = "@function.outer",
  227. ["if"] = "@function.inner",
  228. ["ac"] = "@class.outer",
  229. ["ic"] = "@class.inner",
  230. -- Or you can define your own textobjects like this
  231. -- ["iF"] = {
  232. -- python = "(function_definition) @function",
  233. -- cpp = "(function_definition) @function",
  234. -- c = "(function_definition) @function",
  235. -- java = "(method_declaration) @function",
  236. -- },
  237. },
  238. },
  239. },
  240. }
  241. EOF
  242. " }}}
  243. " P L U G I N S{{{
  244. let g:languagetool_server="/opt/LanguageTool/LanguageTool-5.0/languagetool-server.jar"
  245. let g:languagetool_jar="/opt/LanguageTool/LanguageTool-5.0/languagetool-commandline.jar"
  246. let NERDTreeShowHidden=1
  247. if exists('g:started_by_firenvim')
  248. let g:airline_disable_statusline = 1
  249. else
  250. let g:airline_powerline_fonts = 1
  251. end
  252. " notational notes
  253. let g:nv_search_paths = ['~/notes']
  254. let g:nv_default_extension = '.md'
  255. let g:nv_main_directory = '~/notes'
  256. " Octo.nvim
  257. "lua require('octo')
  258. " ALE {{{
  259. let g:airline#extensions#ale#enabled = 1
  260. "}}}
  261. let vim_tags_ctags_binary='~/bin/phpctags'"
  262. " Java config
  263. autocmd FileType java setlocal omnifunc=javacomplete#Complete
  264. " Vimtex{{{
  265. if !exists('g:neocomplete#sources#omni#input_patterns')
  266. let g:neocomplete#sources#omni#input_patterns = {}
  267. endif
  268. let g:neocomplete#sources#omni#input_patterns.tex =
  269. \ '\v\\%('
  270. \ . '\a*%(ref|cite)\a*%(\s*\[[^]]*\])?\s*\{[^{}]*'
  271. \ . '|includegraphics%(\s*\[[^]]*\])?\s*\{[^{}]*'
  272. \ . '|%(include|input)\s*\{[^{}]*'
  273. \ . ')'
  274. "}}}
  275. " C/C++ {{{
  276. autocmd FileType c,cpp,objc nnoremap <buffer><Leader>f :<C-u>ClangFormat<CR>
  277. autocmd FileType c,cpp,objc vnoremap <buffer><Leader>f :ClangFormat<CR>
  278. "}}}
  279. " Prettier
  280. let g:prettier#config#tab_width = 4
  281. let g:prettier#exec_cmd_async = 1
  282. " Completion {{{
  283. " if hidden is not set, TextEdit might fail.
  284. set hidden
  285. " Some servers have issues with backup files, see #649
  286. set nobackup
  287. set nowritebackup
  288. " Better display for messages
  289. set cmdheight=2
  290. " You will have bad experience for diagnostic messages when it's default 4000.
  291. set updatetime=300
  292. " don't give |ins-completion-menu| messages.
  293. set shortmess+=c
  294. " always show signcolumns
  295. set signcolumn=yes
  296. " {{{ coc completion
  297. "Use <tab> and <S-tab> to navigate completion list:
  298. function! CheckBackSpace() abort
  299. let col = col('.') - 1
  300. return !col || getline('.')[col - 1] =~ '\s'
  301. endfunction
  302. inoremap <silent><expr> <CR> coc#pum#visible() ? coc#_select_confirm()
  303. \: "\<C-g>u\<CR>\<c-r>=coc#on_enter()\<CR>"
  304. " Insert <tab> when previous text is space, refresh completion if not.
  305. inoremap <silent><expr> <TAB>
  306. \ coc#pum#visible() ? coc#pum#next(1):
  307. \ CheckBackSpace() ? "\<Tab>" :
  308. \ coc#refresh()
  309. inoremap <expr><S-TAB> coc#pum#visible() ? coc#pum#prev(1) : "\<C-h>"
  310. "}}}
  311. function! s:check_back_space() abort
  312. let col = col('.') - 1
  313. return !col || getline('.')[col - 1] =~# '\s'
  314. endfunction
  315. " Use <c-space> to trigger completion.
  316. inoremap <silent><expr> <c-space> coc#refresh()
  317. " Use `[c` and `]c` to navigate diagnostics
  318. nmap <silent> [c <Plug>(coc-diagnostic-prev)
  319. nmap <silent> ]c <Plug>(coc-diagnostic-next)
  320. " Remap keys for gotos
  321. nmap <silent> gd <Plug>(coc-definition)
  322. nmap <silent> gy <Plug>(coc-type-definition)
  323. nmap <silent> gi <Plug>(coc-implementation)
  324. nmap <silent> gr <Plug>(coc-references)
  325. " Use K to show documentation in preview window
  326. nnoremap <silent> H :call <SID>show_documentation()<CR>
  327. function! s:show_documentation()
  328. if (index(['vim','help'], &filetype) >= 0)
  329. execute 'h '.expand('<cword>')
  330. else
  331. call CocAction('doHover')
  332. endif
  333. endfunction
  334. " Highlight symbol under cursor on CursorHold
  335. autocmd CursorHold * silent call CocActionAsync('highlight')
  336. " Remap for rename current word
  337. nmap <leader>rn <Plug>(coc-rename)
  338. " Remap for format selected region
  339. xmap <leader>f <Plug>(coc-format-selected)
  340. nmap <leader>f <Plug>(coc-format-selected)
  341. augroup mygroup
  342. autocmd!
  343. " Setup formatexpr specified filetype(s).
  344. autocmd FileType typescript,json setl formatexpr=CocAction('formatSelected')
  345. " Update signature help on jump placeholder
  346. autocmd User CocJumpPlaceholder call CocActionAsync('showSignatureHelp')
  347. augroup end
  348. " Remap for do codeAction of selected region, ex: `<leader>aap` for current paragraph
  349. xmap <leader>a <Plug>(coc-codeaction-selected)
  350. nmap <leader>a <Plug>(coc-codeaction-selected)
  351. " Remap for do codeAction of current line
  352. nmap <leader>ac <Plug>(coc-codeaction)
  353. " Fix autofix problem of current line
  354. nmap <leader>qf <Plug>(coc-fix-current)
  355. " Use <tab> for select selections ranges, needs server support, like: coc-tsserver, coc-python
  356. "nmap <silent> <TAB> <Plug>(coc-range-select)
  357. "xmap <silent> <TAB> <Plug>(coc-range-select)
  358. "xmap <silent> <S-TAB> <Plug>(coc-range-select-backward)
  359. " Use `:Format` to format current buffer
  360. command! -nargs=0 Format :call CocAction('format')
  361. " Use `:Fold` to fold current buffer
  362. command! -nargs=? Fold :call CocAction('fold', <f-args>)
  363. " use `:OR` for organize import of current buffer
  364. command! -nargs=0 OR :call CocAction('runCommand', 'editor.action.organizeImport')
  365. " Add status line support, for integration with other plugin, checkout `:h coc-status`
  366. set statusline^=%{coc#status()}%{get(b:,'coc_current_function','')}
  367. " Using CocList
  368. " Show all diagnostics
  369. nnoremap <silent> <space>a :<C-u>CocList diagnostics<cr>
  370. " Manage extensions
  371. nnoremap <silent> <space>e :<C-u>CocList extensions<cr>
  372. " Show commands
  373. nnoremap <silent> <space>c :<C-u>CocList commands<cr>
  374. " Find symbol of current document
  375. nnoremap <silent> <space>o :<C-u>CocList outline<cr>
  376. " Search workspace symbols
  377. nnoremap <silent> <space>s :<C-u>CocList -I symbols<cr>
  378. " Do default action for next item.
  379. nnoremap <silent> <space>j :<C-u>CocNext<CR>
  380. " Do default action for previous item.
  381. nnoremap <silent> <space>k :<C-u>CocPrev<CR>
  382. " Resume latest coc list
  383. nnoremap <silent> <space>p :<C-u>CocListResume<CR>:
  384. " snippets
  385. imap <C-k> <Plug>(coc-snippets-expand-jump)
  386. let g:neosnippet#snippets_directory = '~/.dotfiles/vim/neosnippets'
  387. "}}}
  388. " Treesitter {{{
  389. lua <<EOF
  390. require'nvim-treesitter.configs'.setup {
  391. ensure_installed = {"typescript", "javascript", "python", "json", "yaml"}, -- one of "all", "maintained" (parsers with maintainers), or a list of languages
  392. highlight = {
  393. enable = true, -- false will disable the whole extension
  394. disable = {}, -- list of language that will be disabled
  395. },
  396. }
  397. EOF
  398. " }}}
  399. " Telescope {{{
  400. lua <<EOF
  401. -- You dont need to set any of these options. These are the default ones. Only
  402. -- the loading is important
  403. require('telescope').setup {
  404. extensions = {
  405. fzf = {
  406. fuzzy = true, -- false will only do exact matching
  407. override_generic_sorter = true, -- override the generic sorter
  408. override_file_sorter = true, -- override the file sorter
  409. case_mode = "smart_case", -- or "ignore_case" or "respect_case"
  410. -- the default case_mode is "smart_case"
  411. }
  412. }
  413. }
  414. -- To get fzf loaded and working with telescope, you need to call
  415. -- load_extension, somewhere after setup function:
  416. require('telescope').load_extension('fzf')
  417. EOF
  418. "}}}
  419. " doge settings
  420. let g:doge_javascript_settings = {
  421. \ 'omit_redundant_param_types': 1,
  422. \}
  423. let g:doge_doc_standard_python = 'google'
  424. let g:doge_mapping_comment_jump_forward = '<c-k>'
  425. "}}}