Skip to content

Instantly share code, notes, and snippets.

@jenikm
Created July 7, 2017 18:10
Show Gist options
  • Save jenikm/ca9f5736addd325d642e0044fb44730d to your computer and use it in GitHub Desktop.
Save jenikm/ca9f5736addd325d642e0044fb44730d to your computer and use it in GitHub Desktop.
.vimrc
"call dein#add(Scripts-----------------------------)
if &compatible
set nocompatible " Be iMproved
endif
" Required:
set runtimepath+=~/.vim/dein/repos/github.com/Shougo/dein.vim
" Required:
call dein#begin(expand('~/.vim/dein')) " plugins' root path
call dein#add('Shougo/dein.vim')
call dein#add('Shougo/vimproc.vim', {
\ 'build': {
\ 'windows': 'tools\\update-dll-mingw',
\ 'cygwin': 'make -f make_cygwin.mak',
\ 'mac': 'make -f make_mac.mak',
\ 'linux': 'make',
\ 'unix': 'gmake',
\ },
\ })
call dein#add('Shougo/unite.vim')
" Add or remove your Bundles here:
call dein#add('Shougo/neosnippet.vim')
call dein#add('Shougo/neosnippet-snippets')
call dein#add('scrooloose/nerdtree')
"call dein#add('ctrlpvim/ctrlp.vim')
if has("gui_running")
set mouse=a
call dein#add('flazz/vim-colorschemes')
else
set mouse=""
endif
" You can specify revision/branch/tag.
"NeoBundleLazy 'Valloric/YouCompleteMe', { 'augroup': 'youcompletemeStart', 'autoload': { 'insert': 1 } }
"call dein#add('derekwyatt/vim-scala')
if has('nvim')
call dein#add('Shougo/deoplete.nvim')
else
call dein#add('Shougo/neocomplete.vim')
"call dein#add('Valloric/YouCompleteMe')
endif
call dein#add('vim-scripts/ctrlp.vim')
call dein#add('mustache/vim-mustache-handlebars')
call dein#add('tpope/vim-fugitive')
"call dein#add('fugitive.vim')
"call dein#add('tpope/vim-rails')
call dein#add('vim-scripts/dbext.vim')
"call dein#add('vim-ruby/vim-ruby')
"call dein#add('kana/vim-textobj-user')
"call dein#add('nelstrom/vim-textobj-rubyblock')
call dein#add("pangloss/vim-javascript")
call dein#add("taylor/vim-zoomwin")
call dein#add('mxw/vim-jsx')
call dein#add('digitaltoad/vim-jade')
call dein#add('smerrill/vcl-vim-plugin.git')
"call dein#add('venantius/vim-cljfmt')
runtime macros/matchit.vim
call dein#add('vim-scripts/Align')
" THIS CRASHES VIM, fast way to run spec
call dein#add('tpope/vim-endwise')
"call dein#add('rking/ag.vim')
call dein#add('jmcomets/vim-pony')
call dein#add('ignatov/kotlin-vim')
call dein#add('kchmck/vim-coffee-script')
call dein#add('Lokaltog/vim-easymotion')
call dein#add('tomtom/tcomment_vim')
call dein#add('tpope/vim-fireplace')
" Required:
call dein#end()
" Required:
filetype plugin indent on
"set rtp+=~/.fzf
au BufRead,BufNewFile *.kt set filetype=kotlin
au BufRead,BufNewFile *.jet set filetype=kotlin
au Syntax kotlin source ~/.vim/syntax/kotlin.vim
set laststatus=2
"set statusline=%<%f\ %h%m%r%{fugitive#statusline()}%=%-14.(%l,%c%V%)\ %P
"map q :
let g:EasyMotion_leader_key = ','
let g:ctrlp_prompt_mappings = {
\ 'AcceptSelection("e")': [],
\ 'AcceptSelection("t")': ['<cr>', '<c-m>'],
\ }
map <D-r> :RunItermSpecLine<cr>
set cursorline
let g:ctrlp_custom_ignore = {'dir': 'bundle\|node_modules\|bower_components'}
"let g:ctrlp_max_files = 100000
"let g:ctrlp_follow_symlinks = 1
" Uncomment the next line to make Vim more Vi-compatible
" NOTE: debian.vim sets 'nocompatible'. Setting 'compatible' changes numerous
" options, so any other options should be set AFTER setting 'compatible'.
"set compatible
" Vim5 and later versions support syntax highlighting. Uncommenting the next
" line enables syntax highlighting by default.
if has("syntax")
syntax on
endif
if has("gui_running")
colorscheme slate
endif
" If using a dark background within the editing area and syntax highlighting
" turn on this option as well
"set background=dark
" Uncomment the following to have Vim jump to the last position when
" reopening a file
"if has("autocmd")
" au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif
"endif
au FileType python set sw=2 ts=2 expandtab softtabstop=2
set softtabstop=2
set sw=2
set ts=2
set background=dark
set expandtab
set nu
set hlsearch
set autoindent
set tabpagemax=100
set incsearch
"set pastetoggle=<F3>
set colorcolumn=100
set nocp
set wildignore+=*tmp/*,*.so,*.swp,*.zip,*doc/*
filetype on " Enable filetype detection
filetype indent on " Enable filetype-specific indenting
filetype plugin on " Enable filetype-specific plugins
"Highlights stuff in red
"nnoremap , :mat Error "<C-R><C-W>"<CR>
" Ag mapping
"au BufRead *.rb nnoremap K :Ag "\b<C-R><C-W>\b"<CR>:cw<CR> app spec lib db config
"au BufRead *.erb nnoremap K :Ag "\b<C-R><C-W>\b"<CR>:cw<CR> app spec lib db config
"au BufRead *.haml nnoremap K :Ag "\b<C-R><C-W>\b"<CR>:cw<CR> app spec lib db config
"au BufRead *.js nnoremap K :Ag "\b<C-R><C-W>\b"<CR>:cw<CR> app spec lib db config
"nnoremap \ :Ag -l <SPACE>
"Postgres
au BufRead */psql.edit.* set syntax=sql
au BufRead *.pss set syntax=vb
au BufRead *.ru set syntax=ruby
au BufRead *.csv set syntax=nothing
au BufRead *.gradle set syntax=groovy
"au BufRead *.pde set syntax=java
" Uncomment the following to have Vim load indentation rules and plugins
" according to the detected filetype.
"if has("autocmd")
" filetype plugin indent on
"endif
"iab pry require 'pry';binding.pry
iab pryr require 'pry-remote';binding.pry_remote
iab pry require 'pry';binding.pry
iab pdb pdb.set_trace()
autocmd FileType javascript,html iab fu function
autocmd FileType javascript,html iab cl console.log(
autocmd FileType javascript,html iab cldb console.log('!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!')
autocmd FileType clojure iab cldb (println "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!")
autocmd FileType clojure iab cl (println
" The following are commented out as they cause vim to behave a lot
" differently from regular Vi. They are highly recommended though.
"set showcmd " Show (partial) command in status line.
set showmatch " Show matching brackets.
"set ignorecase " Do case insensitive matching
"set smartcase " Do smart case matching
"set incsearch " Incremental search
"set autowrite " Automatically save before commands like :next and :make
"set hidden " Hide buffers when they are abandoned
"OLD
"au BufRead *.c nmap <c-k> :w <bar> clear <bar> make <CR>
"au BufRead *.h nmap <c-k> :w <bar> clear <bar> make <CR>
"Map commands to save and make c file quickly
au BufRead *.c nmap <c-k> :w <CR>:!clear && make <CR>
au BufRead *.h nmap <c-k> :w <CR>:!clear && make <CR>
map te :tabedit<Space>
set backspace=indent,eol,start
map tr :call ResolveTask() <CR>
function! ResolveTask()
let task = expand("<cword>")
let cmd = 'resolve_task ' . task
let result = substitute(system(cmd), '[\]\|[[:cntrl:]]', '', 'g')
" Append space + result to current line without moving cursor.
call setline(line('.'), getline('.') . ' ' . result)
endfunction
map <F2> :.w !pbcopy<CR><CR>
map <F3> :r !pbpaste<CR>
autocmd FileType ruby map <F9> :w<CR>:!ruby -c %<CR>
" Source a global configuration file if available
if filereadable("/etc/vim/vimrc.local")
source /etc/vim/vimrc.local
endif
set spelllang=en
" Open tag in new tab
nmap <C-\> <C-w><C-]><C-w>T
map <leader>gf :e <cfile><cr>
" Close window
":nmap <C-Q> :q<CR>
" Write
":nmap <C-Q> :q<CR>
function! TrimWhiteSpace()
%s/\s\+$//e
endfunction
function! MoveToPrevTab()
"there is only one window
if tabpagenr('$') == 1 && winnr('$') == 1
return
endif
"preparing new window
let l:tab_nr = tabpagenr('$')
let l:cur_buf = bufnr('%')
if tabpagenr() != 1
close!
if l:tab_nr == tabpagenr('$')
tabprev
endif
sp
else
close!
exe "0tabnew"
endif
"opening current buffer in new window
exe "b".l:cur_buf
endfunc
function! MoveToNextTab()
"there is only one window
if tabpagenr('$') == 1 && winnr('$') == 1
return
endif
"preparing new window
let l:tab_nr = tabpagenr('$')
let l:cur_buf = bufnr('%')
if tabpagenr() < tab_nr
close!
if l:tab_nr == tabpagenr('$')
tabnext
endif
sp
else
close!
tabnew
endif
"opening current buffer in new window
exe "b".l:cur_buf
endfunc
map tF :call MoveToNextTab()<CR><C-w>H
map tB :call MoveToPrevTab()<CR><C-w>H
autocmd BufWritePre *.rb :call TrimWhiteSpace()
autocmd BufWritePre *.js :call TrimWhiteSpace()
autocmd BufWritePre *.haml :call TrimWhiteSpace()
autocmd BufWritePre *.html :call TrimWhiteSpace()
autocmd BufWritePre *.erb :call TrimWhiteSpace()
autocmd BufWritePre *.rjs :call TrimWhiteSpace()
autocmd BufWritePre *.java :call TrimWhiteSpace()
autocmd BufWritePre *.php :call TrimWhiteSpace()
autocmd BufWritePre *.phtml :call TrimWhiteSpace()
autocmd BufWritePre *.jsx :call TrimWhiteSpace()
autocmd BufWritePre *.clj :call TrimWhiteSpace()
autocmd BufWritePre *.mustache :call TrimWhiteSpace()
autocmd BufWritePre *.scss :call TrimWhiteSpace()
autocmd BufWritePre *.sql :call TrimWhiteSpace()
autocmd BufWritePre *.c :call TrimWhiteSpace()
autocmd BufWritePre *.jade :call TrimWhiteSpace()
autocmd BufWritePre Makefile :call TrimWhiteSpace()
autocmd BufWritePre *.yaml :call TrimWhiteSpace()
if has('nvim')
let g:deoplete#enable_at_startup = 1
else
let g:neocomplete#enable_at_startup = 1
let g:ycm_server_keep_logfiles = 1
"Youcompleteme configs
let g:ycm_collect_identifiers_from_tags_files = 0
let g:ycm_min_num_of_chars_for_completion = 2
let g:ycm_min_num_identifier_candidate_chars = 2
let g:ycm_complete_in_comments_and_strings=1
let g:ycm_filetype_specific_completion_to_disable = { 'ruby': ['.'] }
let g:ycm_filetype_blacklist = {
\ 'notes' : 1,
\ 'markdown' : 1,
\ 'text' : 1,
\ 'yaml' : 1,
\ 'unite' : 1,
\}
endif
" PostgreSQL
let g:dbext_default_profile_dev = 'type=PGSQL:user=apollo:passwd=:dbname=apollo_dev:host=localhost'
"let g:dbext_default_profile_slave = 'type=PGSQL'
let g:dbext_default_profile = 'dev'
" For SQL formatting SQLUFormatter
let g:sqlutil_keyword_case = '\U'
let g:sqlutil_align_comma = 1
function! JscsFix()
"Save current cursor position"
let l:winview = winsaveview()
"Pipe the current buffer (%) through the jscs -x command"
% ! jscs -x
"Restore cursor position - this is needed as piping the file"
"through jscs jumps the cursor to the top"
call winrestview(l:winview)
endfunction
command! JscsFix :call JscsFix()
map <F4> :JscsFix<CR><CR>
set ruler
"Run the JscsFix command just before the buffer is written for *.js files"
"autocmd BufWritePre *.js JscsFix
"syntax off
"au VimEnter * syntax on
"1) Find hexa value of that non-printable character. Move your cursor to that character and press 'ga'.
"2) In escape mode, execute this ':%s/\%x85/\r/g'. In my case, hexadecimal value of that non-printable character is 85. I replaced that with '\r'.
"autocmd BufRead *.clj silent :Connect nrepl://127.0.0.1:54434 .
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment