Last active
October 20, 2018 15:18
-
-
Save andreav/0efc52e202eb3ac662fb677e89130cfb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" When started as "evim", evim.vim will already have done these settings. | |
if v:progname =~? "evim" | |
finish | |
endif | |
" Use Vim settings, rather then Vi settings (much better!). | |
" This must be first, because it changes other options as a side effect. | |
set nocompatible | |
" | |
" VUNDLE | |
""""""""""""""""""""""""" | |
" setup vundle: git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim | |
" setup ycm: sudo apt-get install cmake && cd ~/.vim/bundle/youcompleteme && ./install.py --clang-completer | |
filetype off | |
" set the runtime path to include Vundle and initialize | |
set rtp+=~/.vim/bundle/Vundle.vim | |
call vundle#begin() | |
" let Vundle manage Vundle, required | |
Plugin 'VundleVim/Vundle.vim' | |
Plugin 'ZoomWin' | |
Plugin 'tpope/vim-fugitive' | |
Plugin 'kien/ctrlp.vim' | |
Plugin 'scrooloose/nerdcommenter' | |
Plugin 'highlight.vim' | |
Plugin 'mattn/emmet-vim' | |
Plugin 'tmhedberg/matchit' | |
Plugin 'valloric/youcompleteme' | |
"sudo apt-get install build-essential cmake | |
"sudo apt-get install python-dev python3-dev | |
"sudo npm install -g typescript | |
"cd ~/.vim/bundle/youcompleteme && ./install.py --clang-completer | |
"pip install jedi | |
Plugin 'SirVer/ultisnips' | |
Plugin 'honza/vim-snippets' | |
Plugin 'tpope/vim-surround' | |
Plugin 'scrooloose/syntastic' | |
Plugin 'Chiel92/vim-autoformat' "running eslint --fix | |
Plugin 'sekel/vim-vue-syntastic' | |
Plugin 'leafgarland/typescript-vim' | |
"pip install flake8 | |
"npm install eslint eslint-plugin-vue "it's enought local thanks to syntastic-local-eslint.vim | |
"Create jsconfig.json and tsconfig.json (see below) | |
Plugin 'brookhong/cscope.vim' | |
"Plugin 'marijnh/tern_for_vim' | |
"cd ~/.vim/bundle/tern_for_vim && npm install | |
"Create .tern-project (see below) | |
Plugin 'pangloss/vim-javascript' | |
Plugin 'Vimjas/vim-python-pep8-indent' | |
Plugin 'moll/vim-node' | |
Plugin 'posva/vim-vue' | |
" Typescript autocompletion: should be enought ycm, but not working in .vue files | |
" also needs npm install ts-vue-plugin + tsconfig configuration: plugins: [{ name: ts-vue-plugin }] | |
Plugin 'quramy/tsuquyomi' | |
Plugin 'Quramy/tsuquyomi-vue' | |
Plugin 'dbext.vim' | |
call vundle#end() | |
filetype plugin indent on | |
" allow backspacing over everything in insert mode | |
set backspace=indent,eol,start | |
if has("vms") | |
set nobackup " do not keep a backup file, use versions instead | |
else | |
set backup " keep a backup file | |
endif | |
set history=2000 " keep 50 lines of command line history | |
set ruler " show the cursor position all the time | |
set showcmd " display incomplete commands | |
set incsearch " do incremental searching | |
set shiftwidth=2 | |
" set cino={.4s | |
set cino={.4s,(0 | |
" For Win32 GUI: remove 't' flag from 'guioptions': no tearoff menu entries | |
" let &guioptions = substitute(&guioptions, "t", "", "g") | |
" Don't use Ex mode, use Q for formatting | |
map Q gq | |
" This is an alternative that also works in block mode, but the deleted | |
" text is lost and it only works for putting the current register. | |
"vnoremap p "_dp | |
" Switch syntax highlighting on, when the terminal has colors | |
" Also switch on highlighting the last used search pattern. | |
if &t_Co > 2 || has("gui_running") | |
syntax on | |
" set guifont=-misc-fixed-medium-r-normal--14-110-100-100-c-70-iso8859-1 | |
set hlsearch | |
endif | |
" Only do this part when compiled with support for autocommands. | |
if has("autocmd") | |
" Enable file type detection. | |
" Use the default filetype settings, so that mail gets 'tw' set to 72, | |
" 'cindent' is on in C files, etc. | |
" Also load indent files, to automatically do language-dependent indenting. | |
filetype plugin indent on | |
" Put these in an autocmd group, so that we can delete them easily. | |
augroup vimrcEx | |
au! | |
" For all text files set 'textwidth' to 78 characters. | |
autocmd FileType text setlocal textwidth=78 | |
" When editing a file, always jump to the last known cursor position. | |
" Don't do it when the position is invalid or when inside an event handler | |
" (happens when dropping a file on gvim). | |
autocmd BufReadPost * | |
\ if line("'\"") > 0 && line("'\"") <= line("$") | | |
\ exe "normal g`\"" | | |
\ endif | |
augroup END | |
" reading Ms-Word documents, requires antiword | |
autocmd BufReadPost *.doc %!antiword "%" | |
inoremap <expr> <cr> pumvisible() ? "\<c-y>" : "\<c-g>u\<cr>" | |
inoremap <expr> <c-n> pumvisible() ? "\<lt>c-n>" : "\<lt>c-n>\<lt>c-r>=pumvisible() ? \"\\<lt>down>\" : \"\"\<lt>cr>" | |
inoremap <expr> j pumvisible()?"\<C-N>":"j" | |
inoremap <expr> k pumvisible()?"\<C-P>":"k" | |
autocmd BufReadPost *.cc runtime after/**/*.vim | |
let OmniCpp_MayCompleteDot = 0 | |
let OmniCpp_MayCompleteArrow = 0 | |
"let OmniCpp_ShowPrototypeInAbbr = 1 | |
else | |
set autoindent " always set autoindenting on | |
endif " has("autocmd") | |
let g:cppcomplete_placeholders = 1 | |
set history=1000 | |
filetype on | |
set nocompatible | |
set wildmenu | |
set wildmode=longest,list | |
set noerrorbells | |
set mat=5 " how many tenths of a second to blink matching brackets for | |
set wildignore=*.o,*.obj,*.bak,*.exe,*~ | |
set tabstop=4 | |
set expandtab | |
set softtabstop=4 | |
set switchbuf=usetab,newtab | |
"if has("cscope") | |
" set csprg=/users/vallea/CSCOPE/cscope-15.5/bin/cscope | |
" nmap <C-\> :cs find c <C-R>=expand("<cword>")<CR><CR> | |
" | |
" "ab css cs find s | |
" ab csg cs find g | |
" ab csd cs find d | |
" ab csc cs find c | |
" "ab cst cs find t | |
" ab cse cs find e | |
" ab csf cs find f | |
" ab csi cs find i | |
" | |
"endif | |
set noerrorbells | |
set mat=5 " how many tenths of a second to blink matching brackets for | |
set wildignore=*.o,*.obj,*.bak,*.exe,*~ | |
colorscheme desert | |
" python | |
set ai ts=4 sts=4 et sw=4 | |
ab ipdb import ipdb; ipdb.set_trace() | |
map <F4> :execute "vimgrep /" . expand("<cword>") . "/j ##" <Bar> cw<CR> | |
map <F5> :execute "vimgrep /<C-R><C-/>/j ##" <Bar> cw<CR> | |
" fugitive config | |
""""""""""""""""" | |
"Gdiff vertical | |
set diffopt+=vertical | |
" emmet config | |
"""""""""""""" | |
"emmet leader C-Z instead on C-Y | |
let g:user_emmet_leader_key='<C-Z>' | |
" ycm config | |
"""""""""""" | |
let g:ycm_key_list_select_completion = ['<C-n', '<Down>'] | |
let g:ycm_key_list_select_previous_completion = ['<C-p>', '<Up>'] | |
let g:ycm_python_binary_path = 'python' " for python 2 or 3 from venv | |
" If you prefer the Omni-Completion tip window to close when a selection is | |
" made, these lines close it on movement in insert mode or when leaving | |
" insert mode | |
autocmd CursorMovedI * if pumvisible() == 0|pclose|endif | |
autocmd InsertLeave * if pumvisible() == 0|pclose|endif | |
nnoremap <leader>gl :YcmCompleter GoToDeclaration<CR> | |
nnoremap <leader>gf :YcmCompleter GoToDefinition<CR> | |
nnoremap <leader>gg :YcmCompleter GoToDefinitionElseDeclaration<CR> | |
"Turn off preview window - to show current status :set completeopt? or :h completeopt | |
" set completeopt-=preview | |
let g:ycm_add_preview_to_completeopt = 1 | |
let g:ycm_autoclose_preview_window_after_insertion = 1 | |
" cscope config | |
""""""""""""""" | |
nnoremap <leader>fa :call CscopeFindInteractive(expand('<cword>'))<CR> | |
nnoremap <leader>l :call ToggleLocationList()<CR> | |
" s: Find this C symbol | |
nnoremap <leader>fs :call CscopeFind('s', expand('<cword>'))<CR> | |
" g: Find this definition | |
nnoremap <leader>fg :call CscopeFind('g', expand('<cword>'))<CR> | |
" d: Find functions called by this function | |
nnoremap <leader>fd :call CscopeFind('d', expand('<cword>'))<CR> | |
" c: Find functions calling this function | |
nnoremap <leader>fc :call CscopeFind('c', expand('<cword>'))<CR> | |
" t: Find this text string | |
nnoremap <leader>ft :call CscopeFind('t', expand('<cword>'))<CR> | |
" e: Find this egrep pattern | |
nnoremap <leader>fe :call CscopeFind('e', expand('<cword>'))<CR> | |
" f: Find this file | |
nnoremap <leader>ff :call CscopeFind('f', expand('<cword>'))<CR> | |
" i: Find files #including this file | |
nnoremap <leader>fi :call CscopeFind('i', expand('<cword>'))<CR> | |
" ultisnips config | |
"""""""""""""""""" | |
let g:UltiSnipsExpandTrigger="<c-tab>" " use c-tab an not tab when with ycm | |
let g:UltiSnipsListSnippets="<c-l>" | |
let g:UltiSnipsJumpForwardTrigger="<c-j>" | |
let g:UltiSnipsJumpBackwardTrigger="<c-k>" | |
" If you want :UltiSnipsEdit to split your window. | |
"let g:UltiSnipsEditSplit="vertical" | |
" syntastic config | |
"""""""""""""""""" | |
"Debug - :SyntasticInfo | |
"Debug - :let g:syntastic_debug = 3 | |
" :SyntaticCheck eslint or flake8 | |
let g:syntastic_python_checkers = ['flake8'] " pip install flake8 | |
let g:syntastic_python_flake8_args = '--ignore=E501,E265' " comma separed codes | |
let g:syntastic_javascript_checkers = ['eslint'] " remember npm install -g eslint eslint-plugin-vue | |
" let g:syntastic_javascript_eslint_exe='./node_modules/.bin/eslint' | |
let local_eslint = finddir('node_modules', '.;') . '/.bin/eslint' | |
if matchstr(local_eslint, "^\/\\w") == '' | |
let local_eslint = getcwd() . "/" . local_eslint | |
endif | |
if executable(local_eslint) | |
let g:syntastic_javascript_eslint_exec = local_eslint | |
let g:syntastic_vue_eslint_exec = local_eslint | |
endif | |
let g:syntastic_typescript_checks=['tsc', 'tslint'] | |
"let g:syntastic_typescript_tsc_fname = '' | |
let g:tsuquyomi_disable_quickfix = 1 | |
let g:syntastic_vue_checkers = ['eslint'] | |
"let g:syntastic_typescript_checkers = ['tsuquyomi'] | |
"set statusline+=%#warningmsg# | |
"set statusline+=%{SyntasticStatuslineFlag()} | |
"set statusline+=%* | |
let g:syntastic_always_populate_loc_list = 1 | |
let g:syntastic_auto_loc_list = 1 | |
let g:syntastic_check_on_open = 0 | |
let g:syntastic_check_on_wq = 0 " do not check on save, invoke with :SyntasticCheck | |
let g:syntastic_debug=0 | |
" set statusline+=%#warningmsg# | |
" set statusline+=%{SyntasticStatuslineFlag()} | |
" set statusline+=%* | |
" file: jsconfig.json - needed for ycm autocompletion with TSServer and Javascript | |
"{ | |
" \"compilerOptions": { | |
" \"checkJs": true | |
" }, | |
" \"exclude": [ | |
" \"node_modules", | |
" \"**/node_modules/*" | |
" ] | |
"} | |
" autoformat | |
"""""""""""" | |
noremap <F3> :Autoformat<CR> | |
" surround config | |
""""""""""""""""" | |
let g:surround_{char2nr("v")} = "{{ \r }}" | |
let g:surround_{char2nr("{")} = "{{ \r }}" | |
let g:surround_{char2nr("%")} = "{% \r %}" | |
let g:surround_{char2nr("b")} = "{% block \1block name: \1 %}\r{% endblock \1\1 %}" | |
let g:surround_{char2nr("i")} = "{% if \1condition: \1 %}\r{% endif %}" | |
let g:surround_{char2nr("w")} = "{% with \1with: \1 %}\r{% endwith %}" | |
let g:surround_{char2nr("f")} = "{% for \1for loop: \1 %}\r{% endfor %}" | |
let g:surround_{char2nr("c")} = "{% comment %}\r{% endcomment %}" | |
let g:surround_{char2nr("t")} = "{% trans \"\r\" %}" | |
" Examples | |
" ysiw" - add " before and after inner word | |
" ys$" - add " from before to end of line | |
" cs"' - replace " by ' | |
" Tern for vim | |
"""""""""""""" | |
"enable keyboard shortcuts | |
let g:tern_map_keys=1 | |
"show argument hints | |
let g:tern_show_argument_hints='on_hold' | |
"Create file .tern-project file: | |
"{ | |
" \"libs": [ | |
" \"lodash", | |
" \"moment" | |
" ], | |
" \"plugins": { | |
" \"node": {} | |
" } | |
"} | |
"CTRLP | |
"""""" | |
"ref - http://ctrlpvim.github.io/ctrlp.vim/ | |
"Press <F5> to purge the cache for the current directory to get new files, remove deleted files and apply new ignore options. | |
"Press <c-f> and <c-b> to cycle between modes. | |
"Press <c-d> to switch to filename search instead of full path. | |
"Press <c-r> to switch to regexp mode. | |
"Use <c-j>, <c-k> or the arrow keys to navigate the result list. | |
"Use <c-t> or <c-v>, <c-x> to open the selected entry in a new tab or in a new split. | |
"Use <c-n>, <c-p> to select the next/previous string in the prompt's history. | |
"Use <c-y> to create a new file and its parent directories. | |
"Use <c-z> to mark/unmark multiple files and <c-o> to open them. | |
let g:ctrlp_custom_ignore = 'node_modules\|DS_Store\|git' | |
"Shift lines | |
"ref - http://vim.wikia.com/wiki/Moving_lines_up_or_down | |
""""""""""" | |
nnoremap <A-j> :m .+1<CR>== | |
nnoremap <A-k> :m .-2<CR>== | |
inoremap <A-j> <Esc>:m .+1<CR>==gi | |
inoremap <A-k> <Esc>:m .-2<CR>==gi | |
vnoremap <A-j> :m '>+1<CR>gv=gv | |
vnoremap <A-k> :m '<-2<CR>gv=gv | |
"dbext | |
"""""" | |
" Each profile has the form: | |
" g:dbext_default_profile_'profilename' = 'var=value:var=value:...' | |
" for pposgres create a file containing 1 line: | |
" hostname:port:database:username:password | |
" Or First export PGPASSWORD=edmusr and then launch vim | |
let g:dbext_default_profile_edm = 'type=PGSQL:host=localhost:port=5434:dbname=edm:user=edmusr' | |
let g:dbext_default_profile = 'edm' | |
" let dbext_default_PGSQL_cmd_terminator = ";" | |
" per project config | |
"""""""""""""""""""" | |
ab ttemp trips/templates/trips | |
" WebConfig conventions | |
""""""""""""""""""""""" | |
" @/ --> ./src | |
"test: :echo substitute('@/aaa,'^@\/','./src/','') | |
"set includeexpr=substitute(v:fname,'^@\/','./src/','') | |
set suffixesadd=.js,.jsx,.vue,.json,.ts,.tsx,.scss |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment