PageRenderTime 59ms CodeModel.GetById 33ms RepoModel.GetById 0ms app.codeStats 1ms

/shlomif-settings/vim-conf/vimrc.vim

https://bitbucket.org/shlomif/shlomif-computer-settings
Vim Script | 404 lines | 210 code | 101 blank | 93 comment | 12 complexity | a595935de7aa4f235a6460740508da0b MD5 | raw file
  1. " An example for a vimrc file.
  2. "
  3. " Maintainer: Bram Moolenaar <Bram@vim.org>
  4. " Last change: 1999 Jul 25
  5. "
  6. " To use it, copy it to
  7. " for Unix and OS/2: ~/.vimrc
  8. " for Amiga: s:.vimrc
  9. " for MS-DOS and Win32: $VIM\_vimrc
  10. filetype plugin indent on
  11. set nocompatible " Use Vim defaults (much better!)
  12. set bs=2 " allow backspacing over everything in insert mode
  13. set ai " always set autoindenting on
  14. set backup " keep a backup file
  15. set viminfo='20,\"50 " read/write a .viminfo file, don't store more
  16. " than 50 lines of registers
  17. " Changed by Shlomi Fish to a much bigger setting
  18. set history=5000 " keep 5,000 lines of command line history
  19. set ruler " show the cursor position all the time
  20. "Display an incomplete command in the lower right corner of the Vim window,
  21. " left of the ruler.
  22. set showcmd
  23. " For Win32 GUI: remove 't' flag from 'guioptions': no tearoff menu entries
  24. " let &guioptions = substitute(&guioptions, "t", "", "g")
  25. " Don't use Ex mode, use Q for formatting
  26. map Q gq
  27. " Switch syntax highlighting on, when the terminal has colors
  28. " Also switch on highlighting the last used search pattern.
  29. if &t_Co > 2 || has("gui_running")
  30. syntax on
  31. set hlsearch
  32. endif
  33. " Add Microsoft Windows-like behaviour
  34. " Old habits die hard.
  35. " - cancelled so old habits will die
  36. " source $VIMRUNTIME/mswin.vim
  37. " Make sure that indentation is 4 whitespace
  38. set shiftwidth=4
  39. " Cancelling because it causes problems in the file explorer (:E or whatever)
  40. " retab 4
  41. set tabstop=4
  42. " Expand tabs to whitespace.
  43. set expandtab
  44. set backupdir=.,~/tmp,~/
  45. function File_Is_Readable(fn)
  46. return filereadable(fnamemodify(a:fn, ":p"))
  47. endfunction
  48. " Set Incremental Search (I-Search)
  49. set incsearch
  50. " Make sure vim searches all the upper directories for the tags file.
  51. " See: http://www.vim.org/tips/tip.php?tip_id=94
  52. set tags=tags;/
  53. set runtimepath+=~/.vim/vim-addon-manager/
  54. set nomore
  55. let g:vim_addon_manager = {}
  56. let g:vim_addon_manager.auto_install = 1
  57. let g:vim_addon_manager.shell_commands_run_method = 'system'
  58. " Removed: unite
  59. " Removed: c%213
  60. call vam#ActivateAddons(['ack', 'Add_to_Word_Search', 'github:alessandroyorba/alduin', 'hg:https://shlomif@bitbucket.org/shlomif/vim-screenplay-text', 'closetag', 'Command-T', 'ctrlp', 'github:mattn/emmet-vim', 'FuzzyFinder', 'matchit.zip', 'parrot', 'github:nvie/vim-flake8', 'github:vim-perl/vim-perl', 'github:dleonard0/pony-vim-syntax', 'github:aaronbieber/quicktask', 'range-search', 'repeat', 'spec%98', 'surround', 'textobj-user', 'textobj-rubyblock', 'The_NERD_tree', 'UltiSnips', 'vcscommand', 'VimClojure', 'vim-addon-scala', 'github:fatih/vim-go', 'github:wlangstroth/vim-racket', 'github:honza/vim-snippets', 'github:wting/rust.vim', 'github:leafgarland/typescript-vim', 'github:ironcamel/vim-script-runner', 'xml'], {'auto_install': 1, 'shell_commands_run_method': "system",})
  61. set more
  62. " Create a new menu item to Convert to Website Meta Language
  63. an 50.740 &Syntax.Convert\ to\ &WML :so $VIMRUNTIME/syntax/2html.vim<CR>:%!wml_safe.pl<CR>
  64. " Expand the syntax menu automatically
  65. let do_syntax_sel_menu = 1
  66. runtime! synmenu.vim
  67. " aunmenu &Syntax.&Show\ individual\ choices
  68. " Make the To-HTML conversion use CSS styles
  69. let html_use_css = 1
  70. " This is so the indent inside the arguments/parameters of function calls will
  71. " be indented 4 spaces to the right instead of 8.
  72. set cinoptions+='(4,W4,b1,=0,m1'
  73. autocmd BufNewFile,BufRead ~/progs/svn/*.[ch] so ~/conf/Vim/svn-dev.vim
  74. function Dot_t_file_type()
  75. let fn = expand("<afile>")
  76. if (match(fn, "\\.arc\\.t$") >= 0)
  77. set filetype=arc
  78. elseif (match(fn, "\\.c\\(\\.t\\)\\?$") >= 0)
  79. set filetype=c
  80. elseif (match(fn, "\\.py\\(\\.t\\)\\?$") >= 0)
  81. set filetype=python
  82. else
  83. set filetype=perl
  84. compiler perlprove
  85. endif
  86. so ~/conf/Vim/perl-test-manage.vim
  87. map <F3> :call Perl_Tests_Count()<CR>
  88. endfunction
  89. " Clear the autocmd's from filetype.vim because it confuses t/*.t
  90. autocmd! filetypedetect BufNewFile,BufRead *.t
  91. autocmd BufNewFile,BufRead *.t call Dot_t_file_type()
  92. autocmd BufNewFile,BufRead ~/progs/freecell/*/t/*.py call Dot_t_file_type()
  93. autocmd BufNewFile,BufRead ~/progs/freecell/*/t/*.c call Dot_t_file_type()
  94. autocmd BufNewFile,BufRead ~/Download/unpack/graphics/*.pdb set filetype=perl
  95. set guifont=DejaVu\ Sans\ Mono\ 10
  96. " Cancelling so the Hebrew keyboard won't be so bad.
  97. " so ~/conf/Vim/hebrew.vim
  98. " Hebrew settings:
  99. map <F9> :set invrl<CR>
  100. imap <F9> <ESC>:set invrl<CR>a
  101. " To make sure Python file editing is tabbed according to 2 spaces
  102. " in the subversion Python files.
  103. autocmd BufNewFile,BufRead ~/progs/svn/*.py retab 2 | set shiftwidth=2
  104. " To make sure gimp code can be styled correctly.
  105. autocmd BufNewFile,BufRead ~/Download/unpack/graphics/Gimp/gimp-cvs/*.[ch] so ~/conf/Vim/gimp-dev.vim
  106. autocmd BufNewFile,BufRead ~/Download/unpack/graphics/Gimp/plug-ins/gimp-ace/*.[ch] so ~/conf/Vim/gimp-dev.vim
  107. " To make sure tabs in GIMP's change logs are really tabs as seems to be
  108. " the general convention
  109. autocmd BufNewFile,BufRead ~/Download/unpack/graphics/Gimp/gimp-cvs/*/ChangeLog set noexpandtab
  110. " Make the Sure the Print Icon in the toolbar does not do anything.
  111. " By default it prints the page without a prompt, which is annoying, because
  112. " it is sometimes pressed accidently.
  113. an 1.40 ToolBar.Print :echo "hello"<CR>
  114. vnoremenu ToolBar.Print :echo "hello"<CR>
  115. " This is to prevent gvim from creating backup files under the GIMP
  116. " directories which just confuses the GIMP.
  117. autocmd BufNewFile,BufRead ~/.gimp-*.scm set nobackup
  118. autocmd BufNewFile,BufRead ~/.gimp-*.py set nobackup
  119. " This is to import the range-search commands.
  120. " so ~/conf/Vim/range-search.vim
  121. " so ~/conf/Vim/ack.vim
  122. autocmd BufNewFile,BufRead */SConstruct set filetype=python
  123. " This is to set the Template Toolkit stuff.
  124. au BufNewFile,BufRead *.tt setf tt2
  125. au BufNewFile,BufRead *.tt2 setf tt2
  126. au BufNewFile,BufRead *.ttml setf tt2
  127. au BufNewFile,BufRead ~/Download/unpack/kernel/* so ~/conf/Vim/kernel.vim
  128. au BufNewFile,BufRead ~/progs/C/kernel/word-search/* so ~/conf/Vim/kernel.vim
  129. " Work-related directives - may be somewhat confidential.
  130. if File_Is_Readable("~/conf/Work/Vim/work.vim")
  131. so ~/conf/Work/Vim/work.vim
  132. endif
  133. " Personal details for perl-support
  134. let g:Perl_AuthorName = 'Shlomi Fish'
  135. let g:Perl_AuthorRef = 'SHLOMIF'
  136. let g:Perl_Email = 'shlomif@shlomifish.org'
  137. let g:Perl_Company = 'None'
  138. let g:Perl_BraceOnNewLine = "yes"
  139. au BufNewFile,BufRead *.p6 setlocal filetype=perl6
  140. au BufNewFile,BufRead *.io setlocal filetype=io
  141. function Docbook_Scripts()
  142. so ~/conf/Vim/docbook/linuxjournal/mfuncs.vim
  143. so ~/conf/Vim/docbook/linuxjournal/maps.vim
  144. so ~/conf/Vim/docbook/linuxjournal/tagtmps.vim
  145. so ~/conf/Vim/docbook/linuxjournal/tfuncs.vim
  146. endfunction
  147. au BufNewFile,BufRead ~/Docs/Svn/Docs/*.xml call Docbook_Scripts()
  148. au BufNewFile,BufRead ~/Docs/homepage/homepage/trunk/lib/docbook/xml/*.xml call Docbook_Scripts()
  149. au BufNewFile,BufRead ~/Docs/homepage/homepage/trunk/t2/art/recommendations/music/shlomi-fish-music-recommendations.xml so ~/conf/Vim/amazon-asin.vim
  150. function Homepage_Customisation()
  151. set path=~/Docs/homepage/homepage/trunk/lib,~/Docs/homepage/homepage/trunk
  152. " so ~/conf/Vim/homepage.vim
  153. " see http://vim.1045645.n5.nabble.com/How-do-one-open-files-for-editing-from-a-function-td1153531.html for why.
  154. if !exists("*Homepage_Grep_Results")
  155. function Homepage_Grep_Results()
  156. e ascii_quotes_results.txt | cbuf | cope
  157. endfunction
  158. endif
  159. if !exists("*Homepage_Grep")
  160. function Homepage_Grep()
  161. !bash bin/t2_find_ascii_quotes.bash
  162. call Homepage_Grep_Results()
  163. endfunction
  164. endif
  165. command! HGrep call Homepage_Grep()
  166. command! Hcope call Homepage_Grep_Results()
  167. endfunction
  168. au BufNewFile,BufRead ~/Docs/homepage/homepage/trunk/* call Homepage_Customisation()
  169. " Remming out because let @f causes too many problems with special escapes
  170. au BufNewFile,BufRead ~/Docs/homepage/homepage/trunk/t2/humour/fortunes/*.xml map <F4> /<fortune id="<CR>f"l"tyi":!perl convert-aphorism.pl '<C-R>t'<CR>
  171. au BufNewFile,BufRead ~/Docs/homepage/homepage/trunk/t2/humour/fortunes/*.xml map <F5> /<raw><CR>:s!raw!quote!<CR>/<text><CR>:s!<lt>text>!<lt>p>!<CR>:s#<!\[CDATA\[##<CR>/^\]\]><CR>:s#\]\]>##<CR>k/<lt>\/text><CR>:s#<lt>/text>#<lt>/p>#<CR>/<\/raw><CR>:s!raw!quote!<CR>
  172. au BufNewFile,BufRead ~/Docs/Diary/* so ~/conf/Vim/diary.vim
  173. " For VILisp - http://www.vim.org/scripts/script.php?script_id=221
  174. " autocmd BufRead *.lsp,*.lisp so ~/Download/unpack/file/editors/vim/VIlisp-2.3/VIlisp.vim
  175. let g:Perl_Shlomif_Settings_Loaded = 0
  176. " Prevent perl from highlighting POD inside which is annoying for
  177. " commented-out blocks and stuff like that. See /syntax/perl.vim
  178. let perl_include_pod = 0
  179. function Perl_Load_File()
  180. if g:Perl_Shlomif_Settings_Loaded == 0
  181. let g:Perl_Shlomif_Settings_Loaded = 1
  182. so ~/conf/Vim/shlomif-perl.vim
  183. endif
  184. endfunction
  185. autocmd FileType perl call Perl_Load_File()
  186. autocmd BufNewFile,BufRead ~/progs/prolog/*.pl set filetype=prolog
  187. autocmd BufNewFile,BufRead *.arc set filetype=arc
  188. " mapping to be able to move to the left and the right windows
  189. " without needing to leave the Ctrl key.
  190. map <C-W><C-Right> <C-W><Right>
  191. map <C-W><C-Left> <C-W><Left>
  192. " Cancel indentation on the Perl timeline's HTMLs.
  193. autocmd BufNewFile,BufRead ~/Docs/programming/Perl/Timeline/*.html set indentexpr=
  194. map <F8> :cn<CR>
  195. map <F7> :cp<CR>
  196. " Load the matchit it plugin which enhances the % for opening/closing
  197. " XML/HTML tags/elements and stuff.
  198. so $VIMRUNTIME/macros/matchit.vim
  199. au BufNewFile,BufRead */screenplay-xml/txt/*.txt setlocal filetype=screenplay-text
  200. au BufNewFile,BufRead *.screenplay-text.txt setlocal filetype=screenplay-text
  201. function Set_to_Bash()
  202. let g:is_bash = 1
  203. set ft=sh
  204. endfunction
  205. autocmd BufNewFile,BufRead ~/progs/bash/completion/trunk/bash_completion/bash_completion call Set_to_Bash()
  206. autocmd BufNewFile,BufRead ~/progs/bash/completion/trunk/bash_completion/cmds/* call Set_to_Bash()
  207. autocmd BufNewFile,BufRead ~/progs/games/kakuro/trunk/*.rb so ~/conf/Vim/kakuro-ruby.vim
  208. autocmd BufNewFile *.pl call Perl_Load_File() | :call Perl_New_Script()
  209. autocmd BufNewFile *.pm call Perl_Load_File() | :call Perl_New_Module()
  210. autocmd BufNewFile */t/*.t call Perl_Load_File() | :call Perl_New_Test_Program()
  211. let perl_no_extended_vars=1
  212. let g:surround_indent = 1
  213. autocmd BufRead ~/progs/freecell/trunk/fc-solve/source/* map <F4> :!echo '<C-R><C-W>' >> ~/progs/freecell/trunk/fc-solve/source/scripts/ids-whitelist.txt<CR>
  214. if has('multi_byte')
  215. " So C-k.. will generate an ellipsis.
  216. digraphs .. 8230
  217. " So C-k,, will generate a Hebrew opening double-quotes
  218. digraphs ,, 8222
  219. " So C-k`` will generate a Hebrew closing double-quotes
  220. digraphs `` 8220
  221. " So C-kab (abbreviation) will generate a Hebrew abbreviation sign
  222. digraphs ab 1524
  223. endif
  224. au FileType sass setlocal shiftwidth=4
  225. au BufNewFile ~/conf/svn/*.sh r ~/conf/svn/sample.sh | 1d
  226. function! SetXslt()
  227. let g:xml_tag_syntax_prefixes='xsl\|xhtml\|db5\|db\|docbook\|xml\|xlink'
  228. endfunction
  229. au BufNewFile,BufRead ~/*.xsl call SetXslt()
  230. au BufNewFile,BufRead ~/*.xslt call SetXslt()
  231. " Local customisations
  232. if File_Is_Readable("~/.local.vimrc.vim")
  233. so ~/.local.vimrc.vim
  234. endif
  235. function! CopyAll()
  236. normal ggVG"+y
  237. endfunction
  238. command CopyAll call CopyAll()
  239. function! StyledQuotes(start_line, end_line)
  240. let cmd = a:start_line . ',' . a:end_line . 's/"\([^"]\+\)"/“\1”/'
  241. exe cmd
  242. endfunction
  243. command -range StyledQuotes call StyledQuotes(<line1>,<line2>)
  244. " Remmed out because nuvola is a confusing color-scheme.
  245. " source ~/.vim/colors/nuvola_shlomif.vim
  246. let g:UltiSnipsSnippetDirectories = ["ExtraUltiSnips"]
  247. let g:UltiSnipsExpandTrigger="<tab>"
  248. let g:UltiSnipsJumpForwardTrigger="<tab>"
  249. let g:UltiSnipsJumpBackwardTrigger="<s-tab>"
  250. command -nargs=+ BufOut redir => bufout | silent <args> | redir END | new | call append(0, substitute(strtrans(bufout), '\^@', "\r", 'g'))
  251. function! Perl_FileType_Settings()
  252. noremap <buffer> <silent> <LocalLeader>rs :call Perl_SyntaxCheck()<CR>:redraw!<CR>:call Perl_SyntaxCheckMsg()<CR>
  253. " ---------- Add ':' to the keyword characters -----------
  254. " Tokens like 'File::Find' are recognized as
  255. " one keyword
  256. "
  257. setlocal iskeyword+=:
  258. endfunction
  259. autocmd FileType perl call Perl_FileType_Settings()
  260. autocmd BufRead,BufNewFile *.clay set filetype=clay
  261. set tabpagemax=200
  262. " Unobtrusive highlighting of trailing space.
  263. "
  264. " Taken from http://blog.kamil.dworakowski.name/2009/09/unobtrusive-highlighting-of-trailing.html
  265. highlight ExtraWhitespace ctermbg=red guibg=red
  266. au ColorScheme * highlight ExtraWhitespace guibg=red
  267. au BufEnter * match ExtraWhitespace /\s\+$/
  268. au InsertEnter * match ExtraWhitespace /\s\+\%#\@<!$/
  269. au InsertLeave * match ExtraWhiteSpace /\s\+$/
  270. command CancelExtWS highlight clear ExtraWhiteSpace
  271. map <F6> <ESC>:Ack -ai <C-R><C-W> t2 lib<CR>
  272. set t_Co=256
  273. " Spell freeform text inside XML tags.
  274. " See:
  275. " http://stackoverflow.com/questions/9234925/spell-check-with-vim-and-xml-automatically
  276. function Shlomif_XML_file_type()
  277. let fn = expand("<afile>:p")
  278. " Only for XML files under my homepage for now.
  279. if (match(fn, "Docs/homepage/") >= 0)
  280. syn spell toplevel
  281. end
  282. endfunction
  283. autocmd FileType xml call Shlomif_XML_file_type()
  284. autocmd BufRead,BufNewFile ~/Docs/programming/Vim/vim-begin/*.html set indentexpr=
  285. autocmd BufRead,BufNewFile ~/Docs/homepage/homepage/trunk/lib/pages/t2/philosophy/putting-all-cards-on-the-table.xhtml setlocal indentexpr=
  286. " For the Command-T plugin , because dest/t2-homepage in $homepage
  287. " has more than 30K files.
  288. let g:CommandTMaxFiles = 200000
  289. autocmd BufRead,BufNewFile ~/progs/perl/Quizzes/Golf/* setlocal noeol binary
  290. " Copy the current WORD (delimited by whitespace) into
  291. " both the * and + clipboards.
  292. map <Leader>cc viW""ygv"+ygv"*y
  293. set wildignore+=*.o,*.obj,.git,.svn,.hg,.bzr,*~
  294. " RPM spec - convert Url to metacpan.org
  295. autocmd BufRead,BufNewFile *.spec command MC %!perl ~/conf/trunk/shlomif-settings/home-bin-executables/bin/rpmspec-convert-to-metacpan.pl
  296. " For setting ack.vim's to ag if available - see ~/.vim/ack/README.md
  297. if executable('ag')
  298. let g:ackprg = 'ag --vimgrep'
  299. endif
  300. let no_flake8_maps = 1
  301. autocmd FileType python map <buffer> <F5> :call Flake8()<CR>
  302. autocmd BufRead,BufNewFile /home/shlomif/progs/freecell/git/*/ids-whitelist.txt map <F2> o<C-R>"<ESC> | map <F4> :%!LC_ALL=C sort<CR>
  303. set scrolloff=0