.vimrc 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315
  1. " To make 3rd party includes
  2. set foldmethod=marker
  3. " Enable syntax and plugins
  4. syntax enable
  5. filetype indent plugin on
  6. " Plugins {{{
  7. call plug#begin()
  8. Plug 'OmniSharp/omnisharp-vim'
  9. " After :PlugInstall do :OmnisharpInstall
  10. Plug 'dense-analysis/ale'
  11. call plug#end()
  12. " }}}
  13. " Personal {{{
  14. " Looks {{{
  15. " Window title reflects document title
  16. set title
  17. " Ye olde faithful
  18. set textwidth=80
  19. " HUD {{{
  20. set hlsearch incsearch
  21. set number relativenumber
  22. set ruler
  23. " }}}
  24. " Spaces instead of TABs :( {{{
  25. set expandtab
  26. set shiftround
  27. set shiftwidth=4
  28. set softtabstop=-1 " When 'sts' is negative, the value of 'shiftwidth' is used.
  29. set tabstop=6 " Make TAB char more obvious
  30. " }}}
  31. " }}}
  32. " Feels {{{
  33. " Search subdirectories
  34. " Provides tab-complete for all file-related tasks
  35. set path+=**
  36. " Display all matching files when we tab complete
  37. " instead of cycling through completions
  38. set wildmenu
  39. " UTF-8 everywhere
  40. set encoding=utf-8
  41. scriptencoding utf-8
  42. " Formatting {{{
  43. " Title Case
  44. vnoremap gt :s/\%V\v<(.)(\w*)/\u\1\L\2/g<CR>:noh<CR>
  45. vnoremap gT :s/\v<(.)(\w*)/\u\1\L\2/g<CR>:noh<CR>
  46. vnoremap gi" c"<C-r>""<Esc>
  47. vnoremap gi' c'<C-r>"'<Esc>
  48. vnoremap gi` c`<C-r>"`<Esc>
  49. vnoremap gi( c(<C-r>")<Esc>
  50. vnoremap gi) c(<C-r>")<Esc>
  51. vnoremap gi[ c[<C-r>"]<Esc>
  52. vnoremap gi] c[<C-r>"]<Esc>
  53. vnoremap gi{ c{<C-r>"{<Esc>
  54. vnoremap gi} c}<C-r>"}<Esc>
  55. "}}}
  56. " Autoformatting (to be tested) {{{
  57. "set formatoptions+=c
  58. "set formatoptions+=n
  59. "set formatoptions+=q
  60. "set formatoptions+=r
  61. " }}}
  62. " }}}
  63. " }}}
  64. " 3rd Party {{{
  65. " Max Cantor {{{
  66. "
  67. " Copied from https://github.com/changemewtf/no_plugins/blob/master/no_plugins.vim
  68. "
  69. " HOW TO DO 90% OF WHAT PLUGINS DO (WITH JUST VIM)
  70. " Max Cantor
  71. " NYC Vim Meetup -- August 3, 2016
  72. " FEATURES TO COVER:
  73. " - Fuzzy File Search
  74. " - Tag jumping
  75. " - Autocomplete
  76. " - File Browsing
  77. " - Snippets
  78. " - Build Integration (if we have time)
  79. " GOALS OF THIS TALK:
  80. " - Increase Vim understanding
  81. " - Offer powerful options
  82. " NOT GOALS OF THIS TALK:
  83. " - Hate on plugins
  84. " - Get people to stop using plugins
  85. " {{{ BASIC SETUP
  86. " BASIC SETUP:
  87. " enter the current millenium
  88. set nocompatible
  89. " enable syntax and plugins (for netrw)
  90. syntax enable
  91. filetype plugin on
  92. " }}}
  93. " FINDING FILES: {{{
  94. " Search down into subfolders
  95. " Provides tab-completion for all file-related tasks
  96. set path+=**
  97. " Display all matching files when we tab complete
  98. set wildmenu
  99. " NOW WE CAN:
  100. " - Hit tab to :find by partial match
  101. " - Use * to make it fuzzy
  102. " THINGS TO CONSIDER:
  103. " - :b lets you autocomplete any open buffer
  104. " }}}
  105. " TAG JUMPING: {{{
  106. " Create the `tags` file (may need to install ctags first)
  107. command! MakeTags !ctags -R .
  108. " NOW WE CAN:
  109. " - Use ^] to jump to tag under cursor
  110. " - Use g^] for ambiguous tags
  111. " - Use ^t to jump back up the tag stack
  112. " THINGS TO CONSIDER:
  113. " - This doesn't help if you want a visual list of tags
  114. " }}}
  115. " AUTOCOMPLETE: {{{
  116. " The good stuff is documented in |ins-completion|
  117. " HIGHLIGHTS:
  118. " - ^x^n for JUST this file
  119. " - ^x^f for filenames (works with our path trick!)
  120. " - ^x^] for tags only
  121. " - ^n for anything specified by the 'complete' option
  122. " NOW WE CAN:
  123. " - Use ^n and ^p to go back and forth in the suggestion list
  124. " }}}
  125. " FILE BROWSING: {{{
  126. " Tweaks for browsing
  127. let g:netrw_banner=0 " disable annoying banner
  128. let g:netrw_browse_split=4 " open in prior window
  129. let g:netrw_altv=1 " open splits to the right
  130. let g:netrw_liststyle=3 " tree view
  131. let g:netrw_list_hide=netrw_gitignore#Hide()
  132. let g:netrw_list_hide.=',\(^\|\s\s\)\zs\.\S\+'
  133. " NOW WE CAN:
  134. " - :edit a folder to open a file browser
  135. " - <CR>/v/t to open in an h-split/v-split/tab
  136. " - check |netrw-browse-maps| for more mappings
  137. " }}}
  138. " SNIPPETS: {{{
  139. " Read an empty HTML template and move cursor to title
  140. nnoremap ,html :-1read $HOME/.vim/.skeleton.html<CR>3jwf>a
  141. " NOW WE CAN:
  142. " - Take over the world!
  143. " (with much fewer keystrokes)
  144. " }}}
  145. " BUILD INTEGRATION: {{{
  146. " Steal Mr. Bradley's formatter & add it to our spec_helper
  147. " http://philipbradley.net/rspec-into-vim-with-quickfix
  148. " Configure the `make` command to run RSpec
  149. set makeprg=bundle\ exec\ rspec\ -f\ QuickfixFormatter
  150. " NOW WE CAN:
  151. " - Run :make to run RSpec
  152. " - :cl to list errors
  153. " - :cc# to jump to error by number
  154. " - :cn and :cp to navigate forward and back
  155. " }}}
  156. " THANK YOU!
  157. " Download this file at:
  158. " github.com/mcantor/no_plugins
  159. " Follow me for kitten pictures:
  160. " twitter.com/mcantor
  161. " Contact me at `max at maxcantor dot net` for:
  162. " - Consulting (Dev and PM)
  163. " - Tutoring
  164. " - Classroom Teaching
  165. " - Internal Training
  166. " - Encouragement
  167. " }}}
  168. " ALE {{{
  169. let g:ale_linters = {
  170. \ 'cs': ['OmniSharp']
  171. \}
  172. let g:ale_fixers = { 'cs': [ 'dotnet-format' ] }
  173. let g:ale_set_quickfix = 1
  174. " }}}
  175. " C#/.NET specific settings {{{
  176. " Enable OmniSharp for C# files
  177. autocmd FileType cs setlocal omnifunc=OmniSharp#Complete
  178. " Optional: Key mappings
  179. autocmd FileType cs nnoremap <buffer> gd :OmniSharpGotoDefinition<CR>
  180. autocmd FileType cs nnoremap <buffer> <leader>fi :OmniSharpFindImplementations<CR>
  181. autocmd FileType cs nnoremap <buffer> <leader>us :OmniSharpFindUsages<CR>
  182. autocmd FileType cs nnoremap <buffer> K :OmniSharpDocumentation<CR>
  183. " Settings: {{{
  184. set completeopt=menuone,noinsert,noselect,popuphidden
  185. set completepopup=highlight:Pmenu,border:off
  186. set backspace=indent,eol,start
  187. set hidden
  188. set nofixendofline
  189. set nostartofline
  190. set splitbelow
  191. set splitright
  192. set laststatus=2
  193. set showmode
  194. set signcolumn=yes
  195. set mouse=a
  196. set updatetime=1000
  197. " }}}
  198. " OmniSharp: {{{
  199. let g:OmniSharp_popup_position = 'peek'
  200. if has('nvim')
  201. let g:OmniSharp_popup_options = {
  202. \ 'winblend': 30,
  203. \ 'winhl': 'Normal:Normal,FloatBorder:ModeMsg',
  204. \ 'border': 'rounded'
  205. \}
  206. else
  207. "let g:OmniSharp_popup_options = {
  208. "\ 'highlight': 'Normal',
  209. "\ 'padding': [0],
  210. "\ 'winblend': 30,
  211. "\ 'winhl': 'Normal:Normal,FloatBorder:ModeMsg',
  212. "\ 'border': [1],
  213. "\ 'borderchars': ['─', '│', '─', '│', '┌', '┐', '┘', '└'],
  214. "\ 'borderhighlight': ['ModeMsg']
  215. "\ }
  216. let g:OmniSharp_popup_options = {
  217. \ 'highlight': 'Normal',
  218. \ 'padding': [1],
  219. \ 'border': [1],
  220. \ 'borderchars': ['─', '│', '─', '│', '╭', '╮', '╯', '╰'],
  221. \ 'borderhighlight': ['Special']
  222. \}
  223. "\ 'highlight': 'Normal',
  224. "\ 'winblend': 30,
  225. "\ 'winhl': 'Normal:Normal,FloatBorder:Special',
  226. endif
  227. let g:OmniSharp_popup_mappings = {
  228. \ 'sigNext': '<C-n>',
  229. \ 'sigPrev': '<C-p>',
  230. \ 'pageDown': ['<C-f>', '<PageDown>'],
  231. \ 'pageUp': ['<C-b>', '<PageUp>']
  232. \}
  233. let g:OmniSharp_highlight_groups = {
  234. \ 'ExcludedCode': 'NonText'
  235. \}
  236. " }}}
  237. " }}}
  238. " }}}
  239. " Restore some things Max Cantor changed
  240. unlet g:netrw_banner
  241. " Clear search highlight after sourcing
  242. silent! call feedkeys(":nohlsearch\<CR>")