Last active
May 1, 2021 06:37
-
-
Save krehwell/e495652fdbf83562afb396c1c482445e to your computer and use it in GitHub Desktop.
Unity C# - Vim (windows)
This file contains hidden or 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
filetype plugin indent on | |
syntax on | |
" ----- NOAUTOCOMMENT TO ALL FILES ----- | |
augroup AutoCommetDisable | |
autocmd! | |
" autocmd BufEnter * silent! lcd %:p:h | |
autocmd FileType * set formatoptions-=cro | |
augroup END | |
" ----- TRIM ANY TRAILING WHITESPACES ----- | |
fun! TrimWhitespace() | |
let l:save = winsaveview() | |
keeppatterns %s/\s\+$//e | |
call winrestview(l:save) | |
endfun | |
augroup TrimWhitespaceOnSave | |
autocmd! | |
autocmd BufWritePre * :call TrimWhitespace() | |
augroup END | |
" ----- CONVERT 4 SPACES TO 2 SPACES ----- | |
fun! Four2Two() range | |
set expandtab | |
set shiftwidth=4 | |
retab | |
'<,'>normal! == | |
'<,'>s;^\(\s\+\);\=repeat(' ', len(submatch(0))/2);g | |
norm!gv | |
endfun | |
" ----- MY VAR ------ | |
nnoremap <localleader>i :vsplit $INIT<cr> | |
let $INIT="~/AppData/local/nvim/init.vim" | |
" ----- ALL SETs ----- | |
" set cursorlineopt=number | |
" set autochdir " set the curr dir to opened buf | |
set backspace=2 | |
set backspace=indent,eol,start | |
set colorcolumn=80 | |
set hidden " coc ask me to do this | |
set ignorecase | |
set incsearch | |
if exists('$TMUX') | |
set laststatus=0 | |
endif | |
set nobackup " no backup file | |
set nowritebackup | |
set nobuflisted | |
set nocompatible " should be good for vim to act normal | |
set noswapfile " no swp file | |
set nowrap | |
set nu " number shows | |
" set relativenumber | |
set path+=** " dir path search | |
" set signcolumn=yes:1 | |
set smartcase | |
set tabstop=4 softtabstop=4 shiftwidth=4 expandtab autoindent smartindent " own indenting | |
set title | |
set ttimeoutlen=0 | |
set updatetime=100 | |
set undodir=~/.vim/undodir " undotree dir | |
set undofile " to be able to save history of undo tree | |
set wildmenu " shows suggestion in tab : | |
set noshowmode | |
set splitright | |
set splitbelow | |
autocmd ColorScheme * highlight! link SignColumn LineNr | |
nnoremap <F3> :set invpaste paste?<CR> | |
set pastetoggle=<F3> | |
set showmode | |
set scrolloff=5 | |
" ------ FOLDING ------ | |
" Folding | |
set foldmethod=indent | |
" Don't fold anything by default - I'll close the folds myself | |
set foldlevel=99 | |
" Don't bother folding small blocks | |
set foldminlines=5 | |
" Autoclose folds when moving out of them | |
" set foldclose=all | |
" Fold column | |
set foldcolumn=0 | |
" ----- VIM PLUG ----- | |
call plug#begin('~/vim/plugged') | |
" ----- | |
Plug 'neoclide/coc.nvim', {'branch': 'release'} | |
" ----- FUZZY SEARCH PLUG ----- | |
Plug 'junegunn/fzf', { 'do': { -> fzf#install() } } | |
Plug 'junegunn/fzf.vim' | |
Plug 'jremmen/vim-ripgrep' | |
Plug 'ctrlpvim/ctrlp.vim' | |
" ----- GIT PLUG ----- | |
Plug 'tpope/vim-fugitive' | |
" Plug 'airblade/vim-gitgutter' | |
Plug 'rbong/vim-flog' | |
Plug 'OmniSharp/omnisharp-vim' | |
" ----- STATUS/HELPER ----- | |
" Plug 'narajaon/onestatus' | |
Plug 'itchyny/lightline.vim' | |
Plug 'mbbill/undotree' | |
Plug 'vimpostor/vim-tpipeline' | |
Plug 'dmerejkowsky/vim-ale' | |
" ----- DIR TREE ----- | |
" Plug 'lambdalisue/fern-git-status.vim' | |
Plug 'lambdalisue/fern.vim' | |
Plug 'ryanoasis/vim-devicons' | |
" Plug 'lambdalisue/fern-renderer-nerdfont.vim.vim' | |
Plug 'lambdalisue/fern-hijack.vim' | |
" ----- MOVEMENT/NAVIGATION PLUG ----- | |
" Plug 'Yggdroot/indentLine' | |
Plug 'mg979/vim-visual-multi' | |
Plug 'tpope/vim-repeat' | |
Plug 'tpope/vim-surround' | |
Plug 'alvan/vim-closetag' | |
" ----- COLORSCHEME PLUG ----- | |
Plug 'sheerun/vim-polyglot' | |
Plug 'morhetz/gruvbox' | |
Plug 'senran101604/neotrix.vim', {'branch': 'main'} | |
Plug 'ayu-theme/ayu-vim' | |
call plug#end() | |
" -_-_-_-_-_- NEOVIDE THINGS HELPLER -_-_-_-_-_- | |
set guifont=Consolas\ NF:h17 | |
" system clipboard | |
nmap <c-c> "+y | |
vmap <c-c> "+y | |
nmap <c-v> "+p | |
inoremap <c-v> <c-r>+ | |
cnoremap <c-v> <c-r>+ | |
" use <c-r> to insert original character without triggering things like auto-pairs | |
inoremap <c-r> <c-v> | |
" -_-_-_-_-_- START OF COC -_-_-_-_-_- | |
let g:ale_linters = { | |
\ 'cs': ['OmniSharp'] | |
\} | |
" ----- TAB TO SCROLL THRU COMPLETION ----- | |
inoremap <silent><expr> <TAB> | |
\ pumvisible() ? "\<C-n>" : | |
\ <SID>check_back_space() ? "\<TAB>" : | |
\ coc#refresh() | |
inoremap <expr><S-TAB> pumvisible() ? "\<C-p>" : "\<C-h>" | |
function! s:check_back_space() abort | |
let col = col('.') - 1 | |
return !col || getline('.')[col - 1] =~# '\s' | |
endfunction | |
" ----- CODE PRETTIER ----- | |
command! -nargs=0 Prettier :CocCommand prettier.formatFile | |
vmap <leader>f <Plug>(coc-format-selected) | |
nmap <leader>f <Plug>(coc-format-selected) | |
" ----- FORMATTING SELECTED CODE ----- | |
xmap <leader>f <Plug>(coc-format-selected) | |
nmap <leader>f <Plug>(coc-format-selected) | |
augroup mygroup | |
autocmd! | |
" Setup formatexpr specified filetype(s). | |
autocmd FileType typescript,json setl formatexpr=CocAction('formatSelected') | |
" Update signature help on jump placeholder. | |
autocmd User CocJumpPlaceholder call CocActionAsync('showSignatureHelp') | |
augroup end | |
" ----- <C-space> TO TRIGGER COMPLETION ----- | |
if has('nvim') | |
inoremap <silent><expr> <c-space> coc#refresh() | |
else | |
inoremap <silent><expr> <c-@> coc#refresh() | |
endif | |
" ----- HIGHLIGHT SYMBOL-REFERENCES ON HOLDING CURSOR ----- | |
autocmd CursorHold * silent call CocActionAsync('highlight') | |
" ----- SHOW DOCUMENTATION ON <SHIFT-k> ----- | |
nnoremap <silent> K :call <SID>show_documentation()<CR> | |
function! s:show_documentation() | |
if (index(['vim','help'], &filetype) >= 0) | |
execute 'h '.expand('<cword>') | |
else | |
call CocAction('doHover') | |
endif | |
endfunction | |
" REMAP <C-j> AND <C-k> FOR SCROLL FLOAT WINDOWS/POPUPS. | |
if has('nvim-0.4.0') || has('patch-8.2.0750') | |
inoremap <silent><nowait><expr> <C-j> coc#float#has_scroll() ? "\<c-r>=coc#float#scroll(1)\<cr>" : "\<Right>" | |
inoremap <silent><nowait><expr> <C-k> coc#float#has_scroll() ? "\<c-r>=coc#float#scroll(0)\<cr>" : "\<Left>" | |
endif | |
" ----- CHANGE INSIDE/AROUND FUNCTION/CLASS ----- | |
" NOTE: Requires 'textDocument.documentSymbol' support from the language server. | |
xmap if <Plug>(coc-funcobj-i) | |
omap if <Plug>(coc-funcobj-i) | |
xmap af <Plug>(coc-funcobj-a) | |
omap af <Plug>(coc-funcobj-a) | |
xmap ic <Plug>(coc-classobj-i) | |
omap ic <Plug>(coc-classobj-i) | |
xmap ac <Plug>(coc-classobj-a) | |
omap ac <Plug>(coc-classobj-a) | |
" ----- RENAMING <F2> ----- | |
nmap <f2> <Plug>(coc-rename) | |
" ----- CODE NAVIGATION ----- | |
nmap <silent> gd <Plug>(coc-definition) | |
nmap <silent> gy <Plug>(coc-type-definition) | |
nmap <silent> gi <Plug>(coc-implementation) | |
nmap <silent> gr <Plug>(coc-references) | |
" ----- JUMP TO ERROR ----- | |
nnoremap <leader>e :call CocAction('diagnosticNext')<CR> | |
nnoremap <leader>E :call CocAction('diagnosticPrevious')<CR> | |
" -_-_-_-_-_- END OF COC -_-_-_-_-_- | |
" -_-_-_-_-_- C# THIGNS -_-_-_-_-_- | |
let g:OmniSharp_highlighting = 3 | |
" -_-_-_-_-_- C# THIGNS -_-_-_-_-_- | |
" ----- FIX CURSOR HOLD ---- | |
let g:cursorhold_updatetime = 100 | |
" ----- LET CLOSETAG ON REACT FILE ----- | |
let g:closetag_filenames = '*.js, *.jsx, *.tsx' | |
" ----- `<Link>` will be closed while `<link>` won't ----- | |
let g:closetag_emptyTags_caseSensitive = 1 | |
" ----- LIGHTLINE SETTTINGS ----- | |
" let g:lightline = {'colorscheme': 'argonaut'} | |
" 'right': [ [ 'lineinfo' ], ['percent'], ['filetype']] | |
let g:lightline = { | |
\ 'colorscheme': 'gruvbox', | |
\ 'active': { | |
\ 'left': [ [ 'mode', 'paste' ], | |
\ [ 'gitbranch', 'filename', 'modified' ] ], | |
\ 'right': [] | |
\ }, | |
\ 'component_function': { | |
\ 'gitbranch': 'FugitiveHead' | |
\ } | |
\ } | |
" ----- FERN CONFIG ----- | |
let g:fern#renderer = "devicons" | |
augroup fern-custom | |
autocmd! * | |
autocmd FileType fern setlocal nonu | |
augroup END | |
" ----- THEME SETUP ----- | |
" let g:gruvbox_termcolors='256' | |
let g:gruvbox_contrast_dark='hard' | |
let g:gruvbox_bold= '0' | |
set background=dark | |
" let ayucolor="mirage" | |
set termguicolors | |
colorscheme gruvbox | |
" ----- LEADER KEY ----- | |
let mapleader = " " | |
let maplocalleader = "\\" | |
" ----- SHORTCUT BASIC ----- | |
nnoremap <leader>h :wincmd h<CR> | |
nnoremap <leader>j :wincmd j<CR> | |
nnoremap <leader>k :wincmd k<CR> | |
nnoremap <leader>l :wincmd l<CR> | |
nnoremap <leader>u :UndotreeToggle<CR>:UndotreeFocus<CR> | |
nnoremap <silent> <Leader>pv :Fern . -drawer -reveal=% -width=27 -toggle<CR> | |
nnoremap <silent> <Leader>- :vertical resize -10<CR> | |
nnoremap <silent> <Leader>= :vertical resize +10<CR> | |
nnoremap <silent> <Leader>0 :resize -3<CR> | |
nnoremap <silent> <Leader>9 :resize +3<CR> | |
nnoremap <Leader>n :noh<CR> | |
" CONTROLLING VIM-TAB || C-CONTROL | |
nnoremap <C-k> :tabprevious<CR> | |
nnoremap <C-j> :tabnext<CR> | |
" MAPPING EDITING | |
inoremap <M-;> <esc>v$<esc>`>a;<esc>`<a | |
inoremap <c-b> <esc><right>dwi | |
inoremap <silent> jj <c-o>:call search('}\\|)\\|]\\|>\\|"', 'cW')<cr><Right> | |
inoremap {<CR> {<CR>}<Esc>O<BS><Tab> | |
nnoremap <M-j> ddp | |
nnoremap <M-k> ddkP | |
vnoremap w e | |
" SESSION BUFFER CONTROLLER | |
nnoremap <localleader>s :mksession! ~\vim_session<cr> | |
nnoremap <localleader>o :source ~\vim_session<cr> | |
nnoremap <localleader>a ggVG | |
" CD TO CURRENT BUFFER's DIR | lcd -> for cding the current buffer only to the current dir | |
nnoremap <localleader>cd :cd %:p:h | |
nnoremap <localleader>lcd :lcd %:p:h | |
iabbrev /* /* */<esc>bhhi<del> | |
" ----- BOILERPLATES ----- | |
nnoremap <leader>,html :-1read $HOME/boilerplates/skeleton.html<CR>3j2wf>a | |
" ----- LINE HIGHLIGHT ----- | |
" define line highlight color | |
highlight LineHighlight ctermbg=darkgray guibg=black | |
" highlight the current line | |
nnoremap <silent> <localleader>h :call matchadd('LineHighlight', '\%'.line('.').'l')<CR> | |
" clear all the highlighted lines | |
nnoremap <silent> <localleader>H :call clearmatches()<CR> | |
" GLOBAL BUFFER COPY/PASTE | |
vnoremap <localleader>c :w! ~/.vimbufferz<CR> | |
vnoremap <localleader>c :.w! ~/.vimbufferz<CR> | |
nnoremap <localleader>v :r ~/.vimbufferz<CR> | |
" copy line without linebreak | |
nnoremap Y 0vg_y |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment