Created
April 3, 2020 10:12
-
-
Save mrtank/9c8affb7e92b53851aa1b128d7ddfc35 to your computer and use it in GitHub Desktop.
my vimrc
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
set encoding=utf-8 | |
scriptencoding utf-8 | |
source $VIMRUNTIME/vimrc_example.vim | |
source $VIMRUNTIME/mswin.vim | |
behave mswin | |
set diffexpr=MyDiff() | |
function MyDiff() | |
let opt = '-a --binary ' | |
if &diffopt =~ 'icase' | let opt = opt . '-i ' | endif | |
if &diffopt =~ 'iwhite' | let opt = opt . '-b ' | endif | |
let arg1 = v:fname_in | |
if arg1 =~ ' ' | let arg1 = '"' . arg1 . '"' | endif | |
let arg2 = v:fname_new | |
if arg2 =~ ' ' | let arg2 = '"' . arg2 . '"' | endif | |
let arg3 = v:fname_out | |
if arg3 =~ ' ' | let arg3 = '"' . arg3 . '"' | endif | |
let eq = '' | |
if $VIMRUNTIME =~ ' ' | |
if &sh =~ '\<cmd' | |
let cmd = '""' . $VIMRUNTIME . '\diff"' | |
let eq = '"' | |
else | |
let cmd = substitute($VIMRUNTIME, ' ', '" ', '') . '\diff"' | |
endif | |
else | |
let cmd = $VIMRUNTIME . '\diff' | |
endif | |
silent execute '!' . cmd . ' ' . opt . arg1 . ' ' . arg2 . ' > ' . arg3 . eq | |
endfunction | |
" Vim5 and later versions support syntax highlighting. Uncommenting the | |
" following enables syntax highlighting by default. | |
if has('syntax') | |
syntax on | |
endif | |
let mapleader=' ' | |
map <Space><Space> <Leader><Leader> | |
" plug stuff | |
call plug#begin('c:\\Program Files (x86)\\Vim\\vim82\\plug\\') | |
Plug 'vim-syntastic/syntastic' | |
Plug 'junegunn/vader.vim' | |
if has('nvim') | |
Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' } | |
else | |
Plug 'Shougo/deoplete.nvim' | |
Plug 'roxma/nvim-yarp' | |
Plug 'roxma/vim-hug-neovim-rpc' | |
endif | |
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' } | |
Plug 'junegunn/fzf.vim' | |
Plug 'Shougo/echodoc.vim' | |
Plug 'autozimu/LanguageClient-neovim', { | |
\ 'branch': 'next', | |
\ 'tag': '0.1.155', | |
\ 'do': 'powershell -executionpolicy bypass -File install.ps1', | |
\ } | |
Plug 'ionide/Ionide-vim', { | |
\ 'do': 'make fsautocomplete', | |
\} | |
call plug#end() | |
let $NVIM_PYTHON_LOG_FILE = 'e:/temp/nvimlog/nvim_log' | |
let $NVIM_PYTHON_LOG_LEVEL = 'DEBUG' | |
let g:LanguageClient_loggingFile = expand('e:/temp/nvimlog/LanguageClient.log') | |
let g:LanguageClient_serverStderr = expand('e:/temp/nvimlog/LanguageClient.stderr.log') | |
"call deoplete#custom#option('sources', { | |
" \ '_': ['ale'], | |
" \}) | |
call deoplete#custom#option({ | |
\ 'auto_complete_delay': 100, | |
\ }) | |
let g:python3_host_prog = 'G:\Python3.8.1\python.exe' | |
let g:fsharp#unused_opens_analyzer = 1 | |
let g:fsharp#unused_declarations_analyzer = 1 | |
"let g:ale_completion_enabled = 1 | |
let g:deoplete#enable_at_startup = 1 | |
set cmdheight=2 | |
let g:echodoc#enable_at_startup = 1 | |
let g:echodoc#type = 'signature' | |
set updatetime=100 | |
" Always draw the signcolumn. | |
set signcolumn=yes | |
let g:fsharp#fsi_focus_on_send = 1 | |
"autocmd CursorHold *.fs,*.fsi,*.fsx call fsharp#showTooltip() | |
let g:fsharp#fsi_keymap = "vim-fsharp" | |
" 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 | |
set mouse=a " Enable mouse usage (all modes) | |
colorscheme ron " Mild dark background. Strong colors | |
set ts=2 " short 2 space tabs | |
set sw=2 | |
set expandtab " force tabs to be spaces | |
retab | |
function! s:exercism_tests() | |
if expand('%:e') ==? 'vim' | |
let testfile = printf('%s/%s.vader', expand('%:p:h'), | |
\ tr(expand('%:p:h:t'), '-', '_')) | |
if !filereadable(testfile) | |
echoerr 'File does not exist: '. testfile | |
return | |
endif | |
source % | |
execute 'Vader' testfile | |
else | |
let sourcefile = printf('%s/%s.vim', expand('%:p:h'), | |
\ tr(expand('%:p:h:t'), '-', '_')) | |
if !filereadable(sourcefile) | |
echoerr 'File does not exist: '. sourcefile | |
return | |
endif | |
execute 'source' sourcefile | |
Vader | |
endif | |
endfunction | |
augroup my_group | |
au! | |
autocmd BufRead *.{vader,vim} | |
\ command! -buffer Test call s:exercism_tests() | |
" 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 | |
" Uncomment the following to have Vim load indentation rules and plugins | |
" according to the detected filetype. | |
if has('autocmd') | |
filetype plugin indent on | |
endif | |
autocmd Filetype make setlocal noexpandtab " in case of Makefile the tab stays | |
au FileType python,c,fsharp setl ts=4 sw=4 sts=4 " these files have longer tabs | |
au GUIEnter * simalt ~M " fullscreen | |
au BufNewFile,BufRead *.tmp setf php " temp files are php like | |
au BufNewFile,BufRead *.test set filetype=xml | |
augroup END | |
" If using a dark background within the editing area and syntax highlighting | |
" turn on this option as well | |
set background=dark | |
set foldmethod=syntax " using syntax rules for generating fold tabs when opening a file | |
set number " showing numbering on the left | |
set breakindent " wrap will play nicely with indent | |
" typo safety | |
ab hgoy hogy | |
" sql command generation faster | |
ab todo TODO | |
ab Se SELECT | |
ab Fr FROM | |
ab Wh WHERE | |
ab Or ORDER BY | |
ab Gr GROUP BY | |
ab Be BETWEEN | |
" in input mode I can go to the end/beginning of line/new line. No need for | |
" enter | |
map <Leader>M :%s/\r//g<CR> | |
map <Leader>u :if mapcheck("<lt>Leader>", "n") != "" \| echo "yes" \| else \| echo "no" \| endif<left><left><left><left><left><left><left><left><left><left><left><left><left><left><left><left><left><left><left><left><left><left><left><left><left><left><left><left><left><left><left><left><left><left><left><left><left><left><left><left><left><left><left><left><left><left><left><left><left><left><left><left><left> | |
inoremap II <Esc>I | |
inoremap AA <Esc>A | |
inoremap OO <Esc>O | |
nmap <Leader>/ :vimgrep<Space>/ | |
nmap <Leader>? :vimgrep<Space>/<c-r>=expand("<lt>cword>")<cr>/<Space>*<cr>:cw<cr> | |
function SetLSPShortcuts() | |
nnoremap <leader>ld :call LanguageClient#textDocument_definition()<CR> | |
nnoremap <leader>lr :call LanguageClient#textDocument_rename()<CR> | |
nnoremap <leader>lf :call LanguageClient#textDocument_formatting()<CR> | |
nnoremap <leader>lt :call LanguageClient#textDocument_typeDefinition()<CR> | |
nnoremap <leader>lx :call LanguageClient#textDocument_references()<CR> | |
nnoremap <leader>la :call LanguageClient_workspace_applyEdit()<CR> | |
nnoremap <leader>lc :call LanguageClient#textDocument_completion()<CR> | |
nnoremap <leader>lh :call LanguageClient#textDocument_hover()<CR> | |
nnoremap <leader>ls :call LanguageClient_textDocument_documentSymbol()<CR> | |
nnoremap <leader>lm :call LanguageClient_contextMenu()<CR> | |
endfunction() | |
augroup LSP | |
autocmd! | |
autocmd FileType cpp,c,fsharp call SetLSPShortcuts() | |
augroup END | |
function! Get_visual_selection() | |
" Why is this not a built-in Vim script function?! | |
let [lnum1, col1] = getpos("'<")[1:2] | |
let [lnum2, col2] = getpos("'>")[1:2] | |
let lines = getline(lnum1, lnum2) | |
let lines[-1] = lines[-1][: col2 - (&selection ==? 'inclusive' ? 1 : 2)] | |
let lines[0] = lines[0][col1 - 1:] | |
return join(lines, "\n") | |
endfunction | |
vmap <Leader>? :<c-u>vimgrep<Space>/<c-r>=Get_visual_selection()<cr>/<Space>*<cr>:cw<cr> | |
map <F3> :cn<cr> | |
map <F4> :cp<cr> | |
nmap <Leader>n :tabnew<cr> | |
nmap <Leader>o :tabedit <c-r>=expand("%:p:h")<cr>/ | |
nmap <Leader>p :cd %:p:h<cr>:pwd<cr> | |
" Pressing <space>ss will toggle and untoggle spell checking | |
map <Leader>ss :setlocal spell!<cr> | |
" Shortcuts using <Leader> | |
map <Leader>sn ]s | |
map <Leader>sp [s | |
map <Leader>sa zg | |
map <Leader>s? z= | |
map <Leader>x !xmllint.exe "%" --format --encode utf-8 | |
set ruler " bottom line showing the position | |
"set tags+=~/.vim/systags | |
" ctrl-a calculates the expression like 12+4= -> 12+4=16 | |
ino <C-A> <C-O>yiW<End>=<C-R>=<C-R>0<CR> | |
" source C:\Users\mgarai\tabcustomize.vim " adding tab number for the tabs. | |
set lz " performance lazy redraw. Don't redraw while executing macros. | |
set lines=122 | |
set columns=202 | |
set scrolloff=5 | |
" no beep section | |
set noerrorbells | |
set novisualbell | |
set vb t_vb= | |
set tm=500 | |
set wildmenu " : commands completion for tab is verbose. | |
set wildmode=list:longest | |
" use backup, but not in the current dir. | |
set backupdir=$TEMP | |
set directory=$TEMP | |
set noswapfile | |
set shellslash " intelligent slashing of the directory path | |
" used for vim-latex | |
set grepprg=grep\ -nH\ $* | |
let g:tex_flavor='latex' | |
set iskeyword+=: | |
"set nows " n doesn't iterate through the file again at the end | |
"if has("cscope") | |
" set csprg=/usr/local/bin/cscope | |
" set csto=0 | |
" set cst | |
" set nocsverb | |
" " add any database in current directory | |
" if filereadable("cscope.out") | |
" cs add cscope.out | |
" " else add database pointed to by environment | |
" elseif $CSCOPE_DB != "" | |
" cs add $CSCOPE_DB | |
" endif | |
" set csverb | |
"endif | |
"if has("cscope") | |
" set cscopeprg=c:\apps\ | |
" set cscopetagorder=0 | |
" set cscopetag | |
" set cscopepathcomp=3 | |
" set nocscopeverbose | |
" cs add .cscope.out | |
" set csverb | |
" | |
" " cscope find | |
" " | |
" " 0 or s: Find this C symbol | |
" " 1 or d: Find this definition | |
" " 2 or g: Find functions called by this function | |
" " 3 or c: Find functions calling this function | |
" " 4 or t: Find assignments to | |
" " 6 or e: Find this egrep pattern | |
" " 7 or f: Find this file | |
" " 8 or i: Find files #including this file | |
" | |
" map ^Ks :cs find 0 <C-R>=expand("<cword>")<CR><CR> | |
" map ^Kd :cs find 1 <C-R>=expand("<cword>")<CR><CR> | |
" map ^Kg :cs find 2 <C-R>=expand("<cword>")<CR><CR> | |
" map ^Kc :cs find 3 <C-R>=expand("<cword>")<CR><CR> | |
" map ^Kt :cs find 4 <C-R>=expand("<cword>")<CR><CR> | |
" map ^Ke :cs find 6 <C-R>=expand("<cword>")<CR><CR> | |
" map ^Kf :cs find 7 <C-R>=expand("<cfile>")<CR><CR> | |
" map ^Ki :cs find 8 <C-R>=expand("%")<CR><CR> | |
"endif | |
" Search for selected text, forwards or backwards. | |
vnoremap <silent> * :<C-U> | |
\let old_reg=getreg('"')<Bar>let old_regtype=getregtype('"')<CR> | |
\gvy/<C-R><C-R>=substitute( | |
\escape(@", '/\.*$^~['), '\_s\+', '\\_s\\+', 'g')<CR><CR> | |
\gV:call setreg('"', old_reg, old_regtype)<CR> | |
vnoremap <silent> # :<C-U> | |
\let old_reg=getreg('"')<Bar>let old_regtype=getregtype('"')<CR> | |
\gvy?<C-R><C-R>=substitute( | |
\escape(@", '?\.*$^~['), '\_s\+', '\\_s\\+', 'g')<CR><CR> | |
\gV:call setreg('"', old_reg, old_regtype)<CR> | |
" help: | |
" edit vimscript file: | |
" :e $MYVIMRC | |
" http://www.zzapper.co.uk/vimtips.html | |
function! OnlineDoc() | |
let s:browser = "\"c:\\Program Files (x86)\\Opera\\launcher.exe\"" " TODO!! : change to full path of opera. | |
let s:wordUnderCursor = expand('<cword>') | |
if &ft ==? 'php' | |
let s:url = 'http://www.php.net/'.s:wordUnderCursor | |
elseif &ft !=? '' | |
let s:url = 'http://www.google.com/search?q='.s:wordUnderCursor.'+lang:'.&ft | |
else | |
let s:url = 'http://www.google.com/search?q='.s:wordUnderCursor | |
endif | |
let s:cmd = '!start ' . s:browser . ' ' . s:url | |
"echo s:cmd | |
execute s:cmd | |
redraw! | |
endfunction | |
" online doc search | |
map <Leader>k :call OnlineDoc()<CR> | |
set renderoptions=type:directx | |
set guifont=JetBrains\ Mono:h11 | |
set statusline+=%#warningmsg# | |
set statusline+=%{SyntasticStatuslineFlag()} | |
set statusline+=%* | |
let g:syntastic_python_python_exec = 'python3' | |
let g:syntastic_always_populate_loc_list = 1 | |
let g:syntastic_auto_loc_list = 1 | |
let g:syntastic_check_on_open = 1 | |
let g:syntastic_check_on_wq = 0 | |
let g:syntastic_vim_checkers = ['vint'] | |
let g:syntastic_python_checkers = ['pylint'] | |
" let g:fsharpbinding_debug = 1 | |
" let g:fsharp_interactive_bin = 'c:\\Mono\\bin\\fsharpiAnyCpu.bat' | |
" let g:fsharp_xbuild_path = 'c:\\Mono\\bin\\xbuild.bat' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment