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.

204 lines
7.8 KiB

  1. let mapleader =","
  2. if ! filereadable(expand('~/.config/nvim/autoload/plug.vim'))
  3. echo "Downloading junegunn/vim-plug to manage plugins..."
  4. silent !mkdir -p ~/.config/nvim/autoload/
  5. silent !curl "https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim" > ~/.config/nvim/autoload/plug.vim
  6. autocmd VimEnter * PlugInstall
  7. endif
  8. call plug#begin('~/.config/nvim/plugged')
  9. Plug 'morhetz/gruvbox'
  10. Plug 'neoclide/coc.nvim', {'branch': 'release'}
  11. Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
  12. Plug 'junegunn/fzf.vim'
  13. "Plug 'vim-scripts/jcommenter.vim'
  14. "Plug 'SirVer/ultisnips'
  15. "Plug 'phux/vim-snippets'
  16. "Plug 'tobyS/vmustache'
  17. "Plug 'tobyS/pdv'
  18. Plug 'Rican7/php-doc-modded'
  19. Plug 'jreybert/vimagit'
  20. Plug 'bling/vim-airline'
  21. Plug 'tpope/vim-commentary'
  22. Plug 'tpope/vim-fugitive'
  23. Plug 'rbong/vim-flog'
  24. Plug 'ap/vim-css-color'
  25. call plug#end()
  26. " Some basics:
  27. set go=a
  28. set mouse=a
  29. set nohlsearch
  30. set clipboard+=unnamedplus
  31. set incsearch
  32. set smartcase
  33. set noswapfile
  34. set nobackup
  35. set undodir=~/.config/nvim/undodir
  36. set undofile
  37. colorscheme gruvbox
  38. set background=dark
  39. nnoremap c "_c
  40. set nocompatible
  41. filetype plugin on
  42. syntax on
  43. set encoding=utf-8
  44. set number relativenumber
  45. " Indent marks
  46. "set listchars=tab:\|_
  47. "set list
  48. " Tab 2 spaces
  49. filetype plugin indent on
  50. set tabstop=2 softtabstop=2 expandtab shiftwidth=2 smarttab
  51. " Disables automatic commenting on newline:
  52. autocmd FileType * setlocal formatoptions-=c formatoptions-=r formatoptions-=o
  53. " coc
  54. inoremap <silent><expr> <TAB>
  55. \ pumvisible() ? "\<C-n>" :
  56. \ <SID>check_back_space() ? "\<TAB>" :
  57. \ coc#refresh()
  58. inoremap <expr><S-TAB> pumvisible() ? "\<C-p>" : "\<C-h>"
  59. function! s:check_back_space() abort
  60. let col = col('.') - 1
  61. return !col || getline('.')[col - 1] =~# '\s'
  62. endfunction
  63. nmap <leader>gd <Plug>(coc-definition)
  64. nmap <leader>gr <Plug>(coc-references)
  65. inoremap <expr> <C-j> pumvisible() ? "\<Down>" : "\<C-j>"
  66. inoremap <expr> <C-k> pumvisible() ? "\<Up>" : "\<C-k>"
  67. " fzf remaps
  68. "nnoremap <C-p> :GFiles<CR>
  69. nnoremap <C-q> :GFiles<CR>
  70. nnoremap <C-a> :Files<CR>
  71. " php-doc-modded
  72. nnoremap <C-c> :call PhpDocSingle()<CR>i
  73. "nnoremap <C-P> :call PhpDocSingle()<CR>
  74. "vnoremap <C-P> :call PhpDocRange()<CR>
  75. let g:pdv_cfg_autoEndClass = 0
  76. let g:pdv_cfg_autoEndFunction = 0
  77. " Spell-check set to <leader>o, 'o' for 'orthography':
  78. map <leader>o :setlocal spell! spelllang=en_au<CR>
  79. " Splits open at the bottom and right, which is non-retarded, unlike vim defaults.
  80. set splitbelow splitright
  81. " Shortcutting split navigation, saving a keypress:
  82. " nnoremap <C-h> <C-w>h
  83. " nnoremap <C-j> <C-w>j
  84. " nnoremap <C-k> <C-w>k
  85. " nnoremap <C-l> <C-w>l
  86. " Check file in shellcheck:
  87. map <leader>s :!clear && shellcheck %<CR>
  88. " Replace all is aliased to S.
  89. nnoremap S :%s//g<Left><Left>
  90. " Ensure files are read as what I want:
  91. let g:vimwiki_ext2syntax = {'.Rmd': 'markdown', '.rmd': 'markdown','.md': 'markdown', '.markdown': 'markdown', '.mdown': 'markdown'}
  92. let g:vimwiki_list = [{'path': '~/vimwiki', 'syntax': 'markdown', 'ext': '.md'}]
  93. autocmd BufRead,BufNewFile *.ms,*.me,*.mom,*.man set filetype=groff
  94. autocmd BufRead,BufNewFile *.tex set filetype=tex
  95. " Automatically deletes all trailing whitespace on save.
  96. autocmd BufWritePre * %s/\s\+$//e
  97. " Rebind $ to <leader>d
  98. nnoremap <leader>d $
  99. " Navigating with guides
  100. inoremap <leader><leader> <Esc>/<++><Enter>"_c4l
  101. vnoremap <leader><leader> <Esc>/<++><Enter>"_c4l
  102. map <leader><leader> <Esc>/<++><Enter>"_c4l
  103. " Remember last cursor position
  104. autocmd BufReadPost * if @% !~# '\.git[\/\\]COMMIT_EDITMSG$' && line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g`\"" | endif
  105. " Update CHANGELOG message
  106. inoremap <leader>C Update CHANGELOG<esc>:wq<cr>
  107. """HTML
  108. autocmd FileType html inoremap <leader>b <b></b><Space><++><Esc>FbT>i
  109. autocmd FileType html inoremap <leader>it <em></em><Space><++><Esc>FeT>i
  110. autocmd FileType html inoremap <leader>1 <h1></h1><Enter><Enter><++><Esc>2kf<i
  111. autocmd FileType html inoremap <leader>2 <h2></h2><Enter><Enter><++><Esc>2kf<i
  112. autocmd FileType html inoremap <leader>3 <h3></h3><Enter><Enter><++><Esc>2kf<i
  113. autocmd FileType html inoremap <leader>p <p></p><Enter><Enter><++><Esc>02kf>a
  114. autocmd FileType html inoremap <leader>a <a<Space>href=""><++></a><Space><++><Esc>14hi
  115. autocmd FileType html inoremap <leader>e <a<Space>target="_blank"<Space>href=""><++></a><Space><++><Esc>14hi
  116. autocmd FileType html inoremap <leader>ul <ul><Enter><li></li><Enter></ul><Enter><Enter><++><Esc>03kf<i
  117. autocmd FileType html inoremap <leader>li <Esc>o<li></li><Esc>F>a
  118. autocmd FileType html inoremap <leader>ol <ol><Enter><li></li><Enter></ol><Enter><Enter><++><Esc>03kf<i
  119. autocmd FileType html inoremap <leader>im <img src="" alt="<++>"><++><esc>Fcf"a
  120. autocmd FileType html inoremap <leader>td <td></td><++><Esc>Fdcit
  121. autocmd FileType html inoremap <leader>tr <tr></tr><Enter><++><Esc>kf<i
  122. autocmd FileType html inoremap <leader>th <th></th><++><Esc>Fhcit
  123. autocmd FileType html inoremap <leader>tab <table><Enter></table><Esc>O
  124. autocmd FileType html inoremap <leader>gr <font color="green"></font><Esc>F>a
  125. autocmd FileType html inoremap <leader>rd <font color="red"></font><Esc>F>a
  126. autocmd FileType html inoremap <leader>yl <font color="yellow"></font><Esc>F>a
  127. autocmd FileType html inoremap <leader>dt <dt></dt><Enter><dd><++></dd><Enter><++><esc>2kcit
  128. autocmd FileType html inoremap <leader>dl <dl><Enter><Enter></dl><enter><enter><++><esc>3kcc
  129. autocmd FileType html inoremap &<space> &amp;<space>
  130. autocmd FileType html inoremap á &aacute;
  131. autocmd FileType html inoremap é &eacute;
  132. autocmd FileType html inoremap í &iacute;
  133. autocmd FileType html inoremap ó &oacute;
  134. autocmd FileType html inoremap ú &uacute;
  135. autocmd FileType html inoremap ä &auml;
  136. autocmd FileType html inoremap ë &euml;
  137. autocmd FileType html inoremap ï &iuml;
  138. autocmd FileType html inoremap ö &ouml;
  139. autocmd FileType html inoremap ü &uuml;
  140. autocmd FileType html inoremap ã &atilde;
  141. autocmd FileType html inoremap &etilde;
  142. autocmd FileType html inoremap ĩ &itilde;
  143. autocmd FileType html inoremap õ &otilde;
  144. autocmd FileType html inoremap ũ &utilde;
  145. autocmd FileType html inoremap ñ &ntilde;
  146. autocmd FileType html inoremap à &agrave;
  147. autocmd FileType html inoremap è &egrave;
  148. autocmd FileType html inoremap ì &igrave;
  149. autocmd FileType html inoremap ò &ograve;
  150. autocmd FileType html inoremap ù &ugrave;
  151. ""MARKDOWN
  152. " autocmd Filetype markdown,rmd map <leader>w yiWi[<esc>Ea](<esc>pa)
  153. " autocmd Filetype markdown,rmd inoremap <leader>n ---<Enter><Enter>
  154. " autocmd Filetype markdown,rmd inoremap <leader>b ****<++><Esc>F*hi
  155. " autocmd Filetype markdown,rmd inoremap <leader>s ~~~~<++><Esc>F~hi
  156. " autocmd Filetype markdown,rmd inoremap <leader>e **<++><Esc>F*i
  157. " autocmd Filetype markdown,rmd inoremap <leader>h ====<Space><++><Esc>F=hi
  158. " autocmd Filetype markdown,rmd inoremap <leader>i ![](<++>)<++><Esc>F[a
  159. " autocmd Filetype markdown,rmd inoremap <leader>a [](<++>)<++><Esc>F[a
  160. " autocmd Filetype markdown,rmd inoremap <leader>1 #<Space><Enter><++><Esc>kA
  161. " autocmd Filetype markdown,rmd inoremap <leader>2 ##<Space><Enter><++><Esc>kA
  162. " autocmd Filetype markdown,rmd inoremap <leader>3 ###<Space><Enter><++><Esc>kA
  163. " autocmd Filetype markdown,rmd inoremap <leader>l --------<Enter>
  164. " autocmd Filetype rmd inoremap <leader>r ```{r}<CR>```<CR><CR><esc>2kO
  165. " autocmd Filetype rmd inoremap <leader>p ```{python}<CR>```<CR><CR><esc>2kO
  166. " autocmd Filetype rmd inoremap <leader>c ```<cr>```<cr><cr><esc>2kO
  167. """.php
  168. autocmd FileType php inoremap <leader>f public function <Enter>{<Enter><Tab><++><Enter>}<Esc>kkk$i
  169. autocmd FileType php inoremap <leader>t $this
  170. autocmd FileType php inoremap <leader>u use Thirty4\Theme\Form\\<++>;<Esc>5hi
  171. autocmd FileType php inoremap <leader>s 'url' => [ 'select', [ 'name' => '' ]],<Esc>4hi
  172. autocmd FileType php inoremap <leader>v var_dump();<CR>die();<Esc>k$hi