vimrc 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615
  1. " Use pathogen to load other plugins
  2. execute pathogen#infect()
  3. Helptags
  4. filetype plugin indent on
  5. set encoding=utf-8
  6. set spelllang=en_us
  7. " Search settings
  8. set incsearch
  9. set ignorecase
  10. set smartcase
  11. set hlsearch
  12. " Indentation and tab functionality
  13. set tabstop=2
  14. set shiftwidth=2
  15. set softtabstop=2
  16. set expandtab
  17. set autoindent
  18. set smarttab
  19. set smartindent
  20. " Code Folding
  21. set foldopen-=block
  22. set nofoldenable
  23. set foldmethod=indent
  24. set foldnestmax=10
  25. set viewoptions=cursor,folds,slash,unix
  26. set noshowmode
  27. " Command expiration
  28. set timeout
  29. set ttimeoutlen=15
  30. " Set font for (m|g)vim
  31. set guifont=Meslo\ LG\ S\ for\ Powerline:h11
  32. set guioptions=ce
  33. set number " Line numbers
  34. set nowrap " Line Wrapping
  35. set hidden " Just hide buffer when :bd'ing
  36. set autoread " Automatically update externally updated files
  37. set cc=80 " Which line is the 80th column?
  38. set splitright " New window split settings
  39. set splitbelow " New window split settings
  40. set viminfo^=% " Remember buffer info on close
  41. set completeopt=menu
  42. set maxmempattern=8171906 " Because some files are big
  43. """"""""""""""""""""""""""""
  44. " Keybinds
  45. """"""""""""""""""""""""""""
  46. com! W w
  47. com! Q q
  48. let mapleader="\<space>"
  49. " Wrapped lines treated like normal ones
  50. nnoremap j gj
  51. nnoremap k gk
  52. nnoremap <leader>S :call ToggleSpellCheck()<cr>
  53. function! ToggleSpellCheck()
  54. if &spell ==# "nospell"
  55. set spell
  56. else
  57. set nospell
  58. endif
  59. endfunction
  60. " Set CTRL+S to save becuase I smack that every 10 seconds on whatever application I use
  61. command! -nargs=0 Save if &modified | confirm write | endif
  62. nnoremap <silent> <C-s> :Save<CR>
  63. inoremap <C-s> <C-o>:Save<CR>
  64. vnoremap <C-s> <C-o>:Save<CR>
  65. " CTRL+w to close the current buffer
  66. nnoremap <silent> <C-w> :Sayonara<CR>
  67. nnoremap <silent> <S-w> :hide<CR>
  68. " Buffer magic
  69. nnoremap <leader>l :ls<CR>:b<space>
  70. nnoremap <leader>; :tabs<CR>:tabn<space>
  71. " Switch indentation settings
  72. nnoremap <leader>y :set expandtab tabstop=4 shiftwidth=4 softtabstop=4<CR>
  73. nnoremap <leader>Y :set expandtab tabstop=8 shiftwidth=8 softtabstop=4<CR>
  74. nnoremap <leader>m :set expandtab tabstop=2 shiftwidth=2 softtabstop=2<CR>
  75. nnoremap <leader>M :set noexpandtab tabstop=8 softtabstop=4 shiftwidth=4<CR>
  76. " To wrap or not to wrap
  77. nnoremap <leader>w :setlocal wrap!<CR>:setlocal wrap?<CR>
  78. " Window Switching and Resizing
  79. nnoremap <silent> <C-k> :wincmd k<CR>
  80. nnoremap <silent> <C-j> :wincmd j<CR>
  81. nnoremap <silent> <C-h> :wincmd h<CR>
  82. nnoremap <silent> <C-l> :wincmd l<CR>
  83. nnoremap <silent> <A-K> :wincmd K<CR>
  84. nnoremap <silent> <A-J> :wincmd J<CR>
  85. nnoremap <silent> <A-H> :wincmd H<CR>
  86. nnoremap <silent> <A-L> :wincmd L<CR>
  87. nnoremap <silent> <A-T> :wincmd T<CR>
  88. nnoremap <silent> + :wincmd +<CR>
  89. nnoremap <silent> _ :wincmd -<CR>
  90. nnoremap <silent> ) :wincmd ><CR>
  91. nnoremap <silent> ( :wincmd <<CR>
  92. nnoremap <silent> <leader>r :wincmd r<CR>
  93. nnoremap <silent> <leader>R :wincmd R<CR>
  94. " Navigate tag stack
  95. nmap <A-]> <C-]>
  96. nmap <A-[> <C-T>
  97. " ALt+d to duplicate a line, vmode version is best for SHIFT+V, not the others
  98. nmap Y y$
  99. nnoremap <A-d> yyp
  100. vnoremap <A-d> y<C-o>p
  101. inoremap <A-d> <C-o>:yank<CR><C-o>:put<CR>
  102. nnoremap <A-p> "+p
  103. vnoremap <A-p> "+p
  104. nnoremap <expr> <silent> <A-y> '"+' . (v:count ? v:count : '') . 'y'
  105. vnoremap <A-y> "+y
  106. " Move lines of text via Cmd+[jk]
  107. nnoremap <silent> <A-j> :m+1<CR>==
  108. nnoremap <silent> <A-k> :m-2<CR>==
  109. vnoremap <silent> <A-j> :m '>+1<CR>gv=gv
  110. vnoremap <silent> <A-k> :m '<-2<CR>gv=gv
  111. " Move text left/right via alt+[hl]
  112. nnoremap <silent> <A-l> "mx"mp
  113. nnoremap <silent> <A-h> "mxhh"mp
  114. " TODO: Maintain selection
  115. vnoremap <silent> <A-l> "mx"mp
  116. vnoremap <silent> <A-h> "mxhh"mp
  117. " Clear searches so there aren't underlined words.
  118. nnoremap <silent> <C-i> :nohlsearch<CR>
  119. " Formatting
  120. nmap <silent> =j :FormatJSON<CR>
  121. nmap <silent> =x :FormatXML<CR>
  122. "au FileType javascript setlocal formatprg=prettier
  123. "au FileType javascript.jsx setlocal formatprg=prettier
  124. "au FileType typescript setlocal formatprg=prettier\ --parser\ typescript
  125. "au FileType html setlocal formatprg=js-beautify\ --type\ html
  126. "au FileType scss setlocal formatprg=prettier\ --parser\ css
  127. "au FileType css setlocal formatprg=prettier\ --parser\ css
  128. nmap <silent> =, :s/$/,/<CR><C-i>
  129. " Set specific directories for swap, undo, and backups.
  130. set backupdir=~/.vim/tmp/backup//
  131. set directory=~/.vim/tmp/swap//
  132. set undodir=~/.vim/tmp/undo//
  133. set viewdir=~/.vim/tmp/view//
  134. set undofile
  135. if has('gui_macvim')
  136. macmenu File.Print key=<nop>
  137. endif
  138. map <S-k> <nop>
  139. map <S-q> <nop>
  140. """"""""""""""""""""""""""""
  141. " vim-rspec
  142. """"""""""""""""""""""""""""
  143. map <silent> <leader>t :call RunCurrentSpecFile()<CR>
  144. map <silent> <leader>a :call RunAllSpecs()<CR>
  145. map <silent> <leader>s :call RunNearestSpec()<CR>
  146. map <silent> <leader>k :call RunLastSpec()<CR>
  147. let g:rspec_command = "if command -v rspec >/dev/null 2>&1; then rspec {spec}; else bundle exec spec {spec}; fi"
  148. """"""""""""""""""""""""""""
  149. " Ctrl-P Settings
  150. """"""""""""""""""""""""""""
  151. " Keybinding and functionality
  152. let g:ctrlp_map = "<leader>o"
  153. " Move Ctrl-P to top of the screen
  154. let g:ctrlp_match_window_bottom = 0
  155. let g:ctrlp_match_window_reversed = 0
  156. " Ignore some filetypes
  157. let g:ctrlp_custom_ignore = 'node_modules\|DS_Store\|\v\~$|\.(o|swp|pyc|wav|mp3|ogg|blend)$|(^|[/\\])\.(hg|git|bzr)($|[/\\])|__init__\.py'
  158. let g:ctrlp_by_filename = 1
  159. let g:ctrlp_clear_cache_on_exit = 0
  160. " Uncomment to show hidden directories.
  161. "let g:ctrlp_show_hidden = 1
  162. """"""""""""""""""""""""""""
  163. " Airline (Powerline replacement)
  164. """"""""""""""""""""""""""""
  165. let g:airline_theme = 'powerlineish'
  166. let g:airline_powerline_fonts = 1
  167. let g:airline_section_b = ''
  168. let g:airline_section_y = ''
  169. let g:airline_section_z = ''
  170. """"""""""""""""""""""""""""
  171. " NerdTree
  172. """"""""""""""""""""""""""""
  173. " Directory tree toggle
  174. nnoremap <leader>e :NERDTreeToggle<CR>
  175. """"""""""""""""""""""""""""
  176. " NerdCommenter
  177. """"""""""""""""""""""""""""
  178. map <leader>cc <plug>NERDCommenterToggle
  179. " For some reason, CommentToggle doesn't work unless this is
  180. " remapped, so remapping it to something I won't ever use.
  181. map <leader><A-/><space> <plug>NERDCommenterComment
  182. """"""""""""""""""""""""""""
  183. " TeX Settings
  184. """"""""""""""""""""""""""""
  185. let g:tex_flavor = "latex"
  186. let g:LatexBox_latexmk_options = "-pvc -pdfps"
  187. """"""""""""""""""""""""""""
  188. " Rails.vim
  189. """"""""""""""""""""""""""""
  190. let g:rails_gem_projections = {
  191. \ "fabrication": {
  192. \ "spec/fabricators/*_fabricator.rb": {
  193. \ "command": "fabricator",
  194. \ "affinity": "model",
  195. \ "alternate": "app/models/{}.rb",
  196. \ "related": "db/schema.rb#{plural}",
  197. \ "test": "spec/models/{}_spec.rb",
  198. \ "template": "Fabricator :{} do\nend",
  199. \ "keywords": "Fabricate Fabricator sequence"
  200. \ }
  201. \ },
  202. \ "webpacker": {
  203. \ "app/javascript/packs/*.js": {
  204. \ "command": "pack",
  205. \ "test": "spec/javascript/{}.test.js"
  206. \ },
  207. \ "app/javascript/packs/*.jsx": {
  208. \ "command": "pack",
  209. \ "test": "spec/javascript/{}.test.jsx"
  210. \ },
  211. \ "app/javascript/packs/*.ts": {
  212. \ "command": "pack",
  213. \ "test": "spec/javascript/{}.test.ts"
  214. \ },
  215. \ "app/javascript/packs/*.tsx": {
  216. \ "command": "pack",
  217. \ "test": "spec/javascript/{}.test.tsx"
  218. \ },
  219. \ },
  220. \ "factory_bot_rails": {
  221. \ "spec/factories/*_factory.rb": {
  222. \ "command": "factory",
  223. \ "affinity": "collection",
  224. \ "alternate": "app/models/{singular}.rb",
  225. \ "related": "db/schema.rb#{plural}",
  226. \ "test": "spec/models/{singular}_spec.rb",
  227. \ "template": "FactoryBot.define do\n factory :{singular} do\n end\nend",
  228. \ "keywords": "factory sequence"
  229. \ }
  230. \ },
  231. \ "factory_bot": {
  232. \ "spec/factories/*_factory.rb": {
  233. \ "command": "factory",
  234. \ "affinity": "collection",
  235. \ "alternate": "app/models/{singular}.rb",
  236. \ "related": "db/schema.rb#{plural}",
  237. \ "test": "spec/models/{singular}_spec.rb",
  238. \ "template": "FactoryBot.define do\n factory :{singular} do\n end\nend",
  239. \ "keywords": "factory sequence"
  240. \ }
  241. \ },
  242. \ "jasmine": {
  243. \ "spec/javascripts/*_spec.coffee": {
  244. \ "command": "rice",
  245. \ "template": "describe {camelcase|capitalize}, ->\n ",
  246. \ "keywords": "describe it beforeEach expect loadFixtures xit"
  247. \ },
  248. \ "spec/javascripts/*_spec.js": {
  249. \ "command": "rice",
  250. \ "template": "describe({camelcase|capitalize}, function() {\n \n})",
  251. \ "keywords": "describe it beforeEach expect loadFixtures xit"
  252. \ }
  253. \ },
  254. \ "interactor-rails": {
  255. \ "app/interactors/*.rb": {
  256. \ "command": "interactor",
  257. \ "template": "class {camelcase|capitalize|colons}\n\nend"
  258. \ },
  259. \ },
  260. \ "cucumber-rails": {
  261. \ "features/*.feature": {
  262. \ "command": "feature",
  263. \ "template": "Feature: {capitalize}\n\n Scenario: " ,
  264. \ },
  265. \ "features/step_definitions/*_steps.rb": {
  266. \ "command": "steps",
  267. \ "affinity": "collection"
  268. \ }
  269. \ },
  270. \ "draper": {
  271. \ "app/decorators/*.rb": {
  272. \ "command": "decorator",
  273. \ "affinity": "model",
  274. \ "alternate": "app/models/{}.rb",
  275. \ "related": "db/schema.rb#{plural}",
  276. \ "test": "spec/decorators/{}_decorator_spec.rb",
  277. \ "template": "class {camelcase|capitalize|colons}Decorator < Draper::Decorator\n\nend",
  278. \ "keywords": "delegate_all"
  279. \ }
  280. \ },
  281. \ "graphql": {
  282. \ "app/graphql/types/*.rb": {
  283. \ "command": "type",
  284. \ "affinity": "model",
  285. \ "alternate": "app/models/{}.rb",
  286. \ "related": "app/graphql/*_schema.rb#{plural}",
  287. \ "test": "spec/graphql/type/{}_type_spec.rb",
  288. \ "template": "module Types\n class {camelcase|capitalize|colons}Type < Types::BaseObject\n graphql_name '{capitalize}'\n end\nend",
  289. \ },
  290. \ "app/graphql/resolvers/*.rb": {
  291. \ "command": "resolver",
  292. \ "affinity": "model",
  293. \ "alternate": "app/models/{}.rb",
  294. \ "related": "app/graphql/*_schema.rb#{}",
  295. \ "test": "spec/graphql/resolvers/{}_resolver_spec.rb",
  296. \ "template": "module Resolvers\n class {camelcase|capitalize|colons}Resolver < BaseResolver\n end\nend",
  297. \ },
  298. \ "app/graphql/mutations/*.rb": {
  299. \ "command": "mutation",
  300. \ "affinity": "model",
  301. \ "alternate": "app/models/{}.rb",
  302. \ "test": "spec/graphql/mutations/{}_spec.rb",
  303. \ "template": "module Mutations\n class {camelcase|capitalize|colons} < Mutations::BaseMutation\n end\nend",
  304. \ },
  305. \ "app/graphql/subscriptions/*.rb": {
  306. \ "command": "subscription",
  307. \ "affinity": "model",
  308. \ "alternate": "app/models/{}.rb",
  309. \ "test": "spec/graphql/subscriptions/{}_spec.rb",
  310. \ "template": "module Subscriptions\n class {camelcase|capitalize|colons} < Subscriptions::BaseSubscription\n end\nend",
  311. \ }
  312. \ }
  313. \ }
  314. let g:rails_projections = {
  315. \ "app/services/*_service.rb": {"command": "service"},
  316. \ "app/extras/*.rb": {"command": "extra"}
  317. \ }
  318. """"""""""""""""""""""""""""
  319. " delimitMate
  320. """"""""""""""""""""""""""""
  321. exec "set <BS>=\<C-H>"
  322. let g:delimitMate_expand_space = 1
  323. let g:delimitMate_expand_cr = 1
  324. """"""""""""""""""""""""""""
  325. " YCM Settings
  326. """"""""""""""""""""""""""""
  327. "let g:ycm_autoclose_preview_window_after_completion = 1
  328. "let g:ycm_server_log_level = 'error'
  329. """"""""""""""""""""""""""""
  330. " Colors and Themes
  331. """"""""""""""""""""""""""""
  332. syntax enable
  333. "Set 256 color mode (not always needed).
  334. if $TERM == "xterm-256color" || $TERM == "screen-256color" || $COLORTERM == "xfce4-terminal"
  335. set t_Co=256
  336. endif
  337. " Use a nice color scheme
  338. colors monokai
  339. " but override matchparen color
  340. hi MatchParen ctermfg=160 ctermbg=NONE cterm=underline guifg=#df0000 guibg=NONE gui=underline
  341. """"""""""""""""""""""""""""""""""""""""
  342. " Useful Stuff
  343. """"""""""""""""""""""""""""""""""""""""
  344. " Delete trailing whitespaces on saving.
  345. function! DeleteTrailingWS()
  346. if !exists('b:noStrip')
  347. exe "normal mz"
  348. keepp %s/\s\+$//ge
  349. exe "normal `z"
  350. endif
  351. endfunction
  352. au BufWritePre * :call DeleteTrailingWS()
  353. au FileType go let b:noStrip=1
  354. " Allow the use of ALT as a function key.
  355. if !has('nvim')
  356. let c='a'
  357. while c <= 'z'
  358. exec "set <A-".c.">=\e".c
  359. exec "imap \e".c." <A-".c.">"
  360. let c = nr2char(1+char2nr(c))
  361. endw
  362. endif
  363. " Smart indent when entering insert mode with i on empty lines
  364. function! IndentWithI()
  365. if len(getline('.')) == 0
  366. return "\"_cc"
  367. else
  368. return "i"
  369. endif
  370. endfunction
  371. nnoremap <expr> i IndentWithI()
  372. " Smart indent when entering insert mode with i on empty lines
  373. function! IndentWithI()
  374. if len(getline('.')) == 0
  375. return "\"_cc"
  376. else
  377. return "i"
  378. endif
  379. endfunction
  380. nnoremap <expr> i IndentWithI()
  381. " For auto-aligning '|' delimited tables
  382. inoremap <silent> <Bar> <Bar><Esc>:call <SID>align()<CR>a
  383. function! s:align()
  384. let p = '^\s*|\s.*\s|\s*$'
  385. if exists(':Tabularize') && getline('.') =~# '^\s*|' && (getline(line('.')-1) =~# p || getline(line('.')+1) =~# p)
  386. let column = strlen(substitute(getline('.')[0:col('.')],'[^|]','','g'))
  387. let position = strlen(matchstr(getline('.')[0:col('.')],'.*|\s*\zs.*'))
  388. Tabularize/|/l1
  389. normal! 0
  390. call search(repeat('[^|]*|',column).'\s\{-\}'.repeat('.',position),'ce',line('.'))
  391. endif
  392. endfunction
  393. " Set tabline at the top
  394. function! Tabline()
  395. let s = ''
  396. for i in range(tabpagenr('$'))
  397. let tab = i + 1
  398. let bufnr = tabpagebuflist(tab)[tabpagewinnr(tab) - 1]
  399. let bufname = bufname(bufnr)
  400. let bufmodified = getbufvar(bufnr, "&mod")
  401. let s .= '%' . tab . 'T'
  402. let s .= (tab == tabpagenr() ? '%#TabLineSel#' : '%#TabLine#')
  403. let s .= ' ' . tab . (bufmodified ? '+' : '') . ': '
  404. let s .= (bufname != '' ? pathshorten(fnamemodify(bufname, ':.')) . ' ' : '--- ')
  405. endfor
  406. let s .= '%#TabLineFill#'
  407. return s
  408. endfunction
  409. set tabline=%!Tabline()
  410. " Go settings
  411. au BufRead,BufNewFile *.go set filetype=go
  412. au BufWritePre *.go :GoImports
  413. au FileType go map <buffer> <silent> <leader>t :GoTest<CR>
  414. au FileType go map <buffer> <silent> <leader>i :GoInfo<CR>
  415. let g:go_highlight_functions = 1
  416. let g:go_highlight_methods = 1
  417. let g:go_highlight_fields = 1
  418. let g:go_highlight_types = 1
  419. let g:go_highlight_operators = 0
  420. let g:go_highlight_extra_types = 1
  421. let g:go_highlight_format_strings = 1
  422. let g:go_highlight_generate_tags = 1
  423. let g:go_fmt_autosave = 0 " Let syntastic do this
  424. let g:go_fmt_experimental = 1 " Maintain folds after GoFmt + write
  425. set rtp+=$GOPATH/src/github.com/golang/lint/misc/vim
  426. au BufRead,BufNewFile *.go map <leader>d :GoDeclsDir<cr>
  427. " JSON things
  428. let g:vim_json_syntax_conceal = 1
  429. com! FormatJSON %!python -m json.tool
  430. com! FormatXML %!xmllint --format -
  431. " Operator highlighting
  432. let g:ophigh_highlight_link_group = "Operator"
  433. let g:ophigh_container_color = "208"
  434. let g:ophigh_container_color_gui = "#fd971f"
  435. " Filetypes
  436. au BufRead,BufNewFile *.Dockerfile set filetype=dockerfile
  437. au BufRead,BufNewFile *.xsd set filetype=xml
  438. au BufRead,BufNewFile *.wsdl set filetype=xml
  439. " F10 to print syntax highlighting for selection under cursor
  440. map <F10> :echo "hi<" . synIDattr(synID(line("."),col("."),1),"name") . '> trans<'
  441. \ . synIDattr(synID(line("."),col("."),0),"name") . "> lo<"
  442. \ . synIDattr(synIDtrans(synID(line("."),col("."),1)),"name") . ">"<CR>
  443. let g:rustfmt_autosave = 1
  444. let g:ycm_rust_src_path = $RUST_SRC_PATH
  445. let g:rust_src_path = $RUST_SRC_PATH
  446. "let g:coc_global_extensions = ['coc-rust-analyzer']
  447. inoremap <silent><expr> <TAB>
  448. \ coc#pum#visible() ? coc#pum#next(1) :
  449. \ CheckBackspace() ? "\<Tab>" :
  450. \ coc#refresh()
  451. inoremap <expr><S-TAB> coc#pum#visible() ? coc#pum#prev(1) : "\<C-h>"
  452. " Use `[g` and `]g` to navigate diagnostics
  453. " Use `:CocDiagnostics` to get all diagnostics of current buffer in location list
  454. nmap <silent> [g <Plug>(coc-diagnostic-prev)
  455. nmap <silent> ]g <Plug>(coc-diagnostic-next)
  456. " GoTo code navigation
  457. nmap <silent> gd <Plug>(coc-definition)
  458. nmap <silent> gy <Plug>(coc-type-definition)
  459. nmap <silent> gi <Plug>(coc-implementation)
  460. nmap <silent> gr <Plug>(coc-references)
  461. autocmd BufRead *.rs :setlocal tags=./rusty-tags.vi;/,$RUST_SRC_PATH/rusty-tags.vi
  462. autocmd BufWrite *.rs :silent! exec "!rusty-tags vi --quiet --start-dir=" . expand('%:p:h') . "&" <bar> redraw!
  463. " Fix backspace
  464. "imap <silent> <BS> <C-R>=YcmOnDeleteChar()<CR><Plug>delimitMateBS
  465. "function! YcmOnDeleteChar()
  466. " if pumvisible()
  467. " return "\<C-y>"
  468. " endif
  469. " return ""
  470. "endfunction
  471. let g:LatexBox_latexmk_async = 1
  472. let g:LatexBox_latexmk_preview_continuously = 1
  473. " OmniSharp settings are disabled because YCM does it better
  474. let g:Omnisharp_start_server = 0
  475. "let g:ycm_auto_start_csharp_server = 1
  476. "let g:ycm_auto_stop_csharp_server = 1
  477. " Source project specific settings from .git/project.vim if the file exists
  478. " this kinda sucks because
  479. " a) depends on fugutive
  480. " b) will only source one .git/project.vim ever, per vim instance
  481. " c) can potentially source something you don't want
  482. autocmd BufEnter,VimEnter * call s:MaybeRunProjectSettings(expand("<amatch>"))
  483. let g:custom_project_settings_loaded = 0
  484. function! s:MaybeRunProjectSettings(file)
  485. if g:custom_project_settings_loaded == 1
  486. return
  487. endif
  488. let git_dir = FugitiveExtractGitDir(@%)
  489. if git_dir != ""
  490. if filereadable(git_dir.'/project.vim')
  491. exec "source ".(git_dir.'/project.vim')
  492. endif
  493. endif
  494. let g:custom_project_settings_loaded = 1
  495. endfunction
  496. if has('nvim')
  497. let g:python3_host_prog = "/usr/local/bin/python3"
  498. let g:loaded_perl_provider = 0 "disable perl
  499. endif
  500. "let g:ycm_key_list_select_completion = ['<C-n>', '<Down>']
  501. "let g:ycm_key_list_previous_completion = ['<C-p>', '<Up>']
  502. "let g:SuperTabDefaultCompletionType = '<C-n>'
  503. let g:UltiSnipsSnippetsDir="$HOME/.vim/snippets"
  504. "let g:UltiSnipsExpandTrigger="<tab>"
  505. let g:UltiSnipsJumpForwardTrigger="<c-b>"
  506. let g:UltiSnipsJumpBackwardTrigger="<c-z>"
  507. let g:ale_completion_enabled = 0
  508. let g:airline#extensions#ale#enabled = 1
  509. let g:ale_linters = {
  510. \ 'ruby': ['standardrb'],
  511. \}
  512. " \ 'javascript': ['eslint'],
  513. let g:ale_fixers = {
  514. \ 'javascript': ['eslint', 'prettier'],
  515. \ 'typescript': ['eslint', 'prettier'],
  516. \ 'scss': ['prettier'],
  517. \ 'html': ['prettier'],
  518. \ 'ruby': ['standardrb'],
  519. \}
  520. let g:ale_fix_on_save = 1
  521. let g:ale_lint_delay = 1000
  522. " ts/tsx highlighting sucks a lot and I'm not inclined to fix it right now.
  523. " Should be able to get by with using javascript{,.jsx} highlighting for now
  524. au BufRead,BufNewFile *.ts set filetype=javascript
  525. au BufRead,BufNewFile *.tsx set filetype=javascript.jsx
  526. au BufRead,BufNewFile *_spec.rb set filetype=rspec