Advertisement
Guest User

Untitled

a guest
Feb 28th, 2017
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VIM 4.73 KB | None | 0 0
  1. " let g:livepreview_previewer = 'evince'
  2. " YCM {
  3. set nocompatible
  4. filetype off
  5. set rtp+=~/.vim/bundle/Vundle.vim
  6. call vundle#begin()
  7. Plugin 'VundleVim/Vundle.vim'
  8. Plugin 'Valloric/YouCompleteMe'
  9. call vundle#end()
  10. set omnifunc=syntaxcomplete#Complete
  11. autocmd BufEnter * sign define dummy
  12. autocmd BufEnter * execute 'sign place 9999 line=1 name=dummy buffer=' . bufnr('')
  13. set splitbelow
  14. let g:ycm_global_ycm_extra_conf = '~/.vim/ycm_extra_conf.py'
  15. let g:ycm_autoclose_preview_window_after_completion = 1
  16. let g:jedi#popup_on_dot = 1
  17. let g:EclimCompletionMethod = 'omnifunc'
  18. filetype plugin indent on
  19. " }
  20.  
  21. " Main configuration {
  22. syntax on
  23. set ai "autoindent
  24. set si "smartindent
  25. set nu "number
  26. set et "expandtab
  27. set ts=2 "tabstop
  28. set sts=2 "softtabstop
  29. set sw=2 "shiftwidth
  30. set cinw+=forn,forab,ford "cinwords
  31. au FileType c,cpp,h,hpp set cin
  32. set tm=300 "timeoutlen
  33. set spr "splitright
  34. " }
  35.  
  36. autocmd BufRead,BufNewFile *.in setfiletype text
  37.  
  38. " Mappings {
  39. " map <f4> :!geany %<cr>
  40. map <f4> :w<Enter>:!xclip -i -sel clip < %<Enter><Enter>
  41. map <c-j> 5j
  42. map <c-k> 5k
  43. imap jj <esc>
  44. imap jk <esc>:w<cr>
  45. " imap kj <esc>:w<cr>
  46. map H ^
  47. map L $
  48. imap {<cr> {<cr>}<esc>O
  49. " map gc I//<esc>
  50. " map gu ^xx
  51. " }
  52.  
  53. " Compile & run {
  54. let $CXXFLAGS = "-O2 -std=c++14 -DLOCAL -Wall -Wextra -Wno-char-subscripts -Wno-unused-result"
  55. map <F9> :w<Enter>:make! %:r<Enter>
  56. imap <F9> <Esc>:w<Enter>:make! %:r<Enter>
  57. " au BufEnter *.c,*.cpp,*.h,*.hpp map <f5> :!./%<<cr>
  58. " au BufEnter *.py map <f5> :w<Enter>:!python3 %<Enter>
  59. " au BufEnter *.java map <f5> :Java %<cr>
  60. " au BufEnter *.lua map <f5> :!lua %<cr>
  61. "
  62.  
  63. " func! Compile()
  64.     " :w<Enter>
  65.     " if &filetype == "java"
  66.         " :!javac %
  67.     " else
  68.         " :make! %:r
  69.     " endif
  70. " endf
  71.  
  72. " map <F9> :call Compile()<Enter>
  73.  
  74.  
  75. func! Run()
  76.     :w
  77.     if &filetype == "python"
  78.         :!python3 %
  79.     elseif &filetype == "text"
  80.         write
  81.         wincmd w
  82.         call Run()
  83.         wincmd w
  84.     elseif &filetype == "java"
  85.         :!java %<
  86.     else
  87.         :!./%<
  88.     endif
  89. endf
  90.  
  91. map <F5> :call Run()<Enter>
  92. imap <F5> <Esc>:call Run()<Enter>
  93. " }
  94.  
  95. " Modern comments {
  96. func! GetCommentString()
  97.     if &filetype == "cpp" || &filetype == "c" || &filetype == "h" || &filetype == "hpp" || &filetype == "java"
  98.         return "//"
  99.     elseif &filetype == "vim"
  100.         return "\" "
  101.     elseif &filetype == "tex"
  102.         return "% "
  103.     elseif &filetype == "lua"
  104.         return "--"
  105.     endif
  106.     return "# "
  107. endf
  108. func! Comment()
  109.     let s = getline(".")
  110.     let pos = 0
  111.     while pos < len(s) && (s[pos] == ' ' || s[pos] == '\t')
  112.         let pos += 1
  113.     endwhile
  114.     if pos < len(s)
  115.         call setline(".", strpart(s, 0, pos) . GetCommentString() . strpart(s, pos))
  116.         let shift = 0
  117.         normal l
  118.         normal l
  119.     endif
  120. endf
  121. func! Uncomment()
  122.     let s = getline(".")
  123.     let comment = GetCommentString()
  124.     let pos = 0
  125.     while pos < len(s) && (s[pos] == ' ' || s[pos] == '\t')
  126.         let pos += 1
  127.     endwhile
  128.     if pos + len(comment) <= len(s)
  129.         if strpart(s, pos, len(comment)) == comment
  130.             call setline(".", strpart(s, 0, pos) . strpart(s, pos + len(comment)))
  131.             normal h
  132.             normal h
  133.         endif
  134.     endif
  135. endf
  136. map gc :call Comment()<cr>
  137. map gu :call Uncomment()<cr>
  138. " }
  139.  
  140. " Abbreviations {
  141. ia templ #include <bits/stdc++.h>
  142. \<cr>using namespace std;
  143. \<cr>#define forn(i,n) for (int i = 0; i < int(n); ++i)
  144. \<cr>#define sz(x) ((int) (x).size())
  145. \<cr>typedef long long ll;
  146. \<cr>typedef long double ld;
  147. \<cr>
  148. " }
  149.  
  150. " Extra menu {
  151. func! Switch()
  152.     echo "h: highlight"
  153.     echo "p: paste"
  154.     echo "c: copy"
  155.     echo ""
  156.     let c = nr2char(getchar())
  157.     if c == 'h'
  158.         set hlsearch!
  159.     elseif c == 'p'
  160.         set paste!
  161.     elseif c == 'c'
  162.         if &nu
  163.             sign unplace 9999
  164.         else
  165.             execute 'sign place 9999 line=1 name=dummy buffer=' . bufnr('')
  166.         endif
  167.         set nu!
  168.     else
  169.         echo "fail"
  170.     endif
  171. endf
  172. map <f8> :call Switch()<cr>
  173. " }
  174.  
  175. " Default template
  176. func! Template()
  177.     " 0r ~/disk/src/templates/jinotega.cpp
  178.     0r ~/disk/src/templates/bufnewfile.cpp
  179.     normal 14j
  180. endf
  181. au BufNewFile *.cpp call Template()
  182.  
  183. " Non-C++ features {
  184. " let g:livepreview_previewer = 'zathura'
  185. au Filetype make setlocal noet
  186. set keymap=russian-jcukenwin
  187. set iminsert=0
  188. set imsearch=0
  189. " map <f4> :!xclip i < %<cr><cr>
  190. " }
  191.  
  192. " let $CPPFLAGS .= " -Wno-misleading-indentation"
  193.  
  194. map <F6> :!xinput set-prop "SynPS/2 Synaptics TouchPad" "Device Enabled" 0<Enter>
  195. map <F7> :!xinput set-prop "SynPS/2 Synaptics TouchPad" "Device Enabled" 1<Enter>
  196.  
  197. set keymap=russian-jcukenwin
  198. set iminsert=0
  199. set imsearch=0
  200. highlight lCursor guifg=NONE guibg=Cyan
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement