unlet! skip_defaults_vim runtime defaults.vim " To make 3rd party includes set foldmethod=marker " Enable syntax and plugins syntax enable filetype indent plugin on nnoremap gid :read !date +\%Y-\%m-\%dkJ " Plugins {{{ call plug#begin() Plug 'OmniSharp/omnisharp-vim' " After :PlugInstall do :OmnisharpInstall Plug 'dense-analysis/ale' call plug#end() " }}} " Personal {{{ " Looks {{{ function! ConfigPresent() " Settings for presentation mode set nonumber norelativenumber endfunction function! ConfigNoPresent() " Settings for non-presentation mode set number relativenumber endfunction nnoremap gp :call ConfigPresent() nnoremap gP :call ConfigNoPresent() " Window title reflects document title set title " Ye olde faithful set textwidth=80 " HUD {{{ set hlsearch incsearch call ConfigNoPresent() set ruler set showcmd " }}} " Spaces instead of TABs :( {{{ set expandtab " Use spaces instead of tab characters set shiftround set shiftwidth=4 " Number of spaces to use for each step of (auto)indent set softtabstop=4 " Number of spaces that a Tab key press is equivalent to set softtabstop=-1 " When 'sts' is negative, the value of 'shiftwidth' is used. set tabstop=6 " Make TAB char more obvious set tabstop=6 " Number of spaces that a tab character represents " }}} " }}} " Feels {{{ set iskeyword-=_ " Don't skip over _ " Search subdirectories " Provides tab-complete for all file-related tasks set path+=** " Display all matching files when we tab complete " instead of cycling through completions set wildmenu " UTF-8 everywhere set encoding=utf-8 scriptencoding utf-8 " Copy Pasta {{{ " Registers " function! RegisterSwapDefaultWith() " Swap the default register with the contents of another let l = nr2char(getchar()) execute 'let @x=@' . l . '| let @' . l . '=@" | let @"=@x' endfunction nnoremap c :call RegisterSwapDefaultWith() nnoremap C :call RegisterSwapDefaultWith()+ " " (visual) ca := swap contents of default register (") with register a " (visual) C := swap contents of default register with clipboard (+) " }}} " Case {{{ " Uppercase/Lowercase " " (visual) gu := lowercase selection " (normal) guu := lowercase line " (visual) gU := uppercase selection " (normal) gUU := uppercase line " Title Case " vnoremap gt :s/\%V\v<(.)(\w*)/\u\1\L\2/g:noh nnoremap gtt V:s/\v<(.)(\w*)/\u\1\L\2/g:noh " " (visual) gt := titlecase selection " (normal) gtt := titlecase line " }}} " Quote {{{ function! SelectionSurroundWith() " Surround selected text with a single char let open = nr2char(getchar()) let pairs = {'(': ')', '[': ']', '{': '}', '<': '>'} let close = get(pairs, open, open) execute "normal! gvc" . open . "\\"" . close . "\" endfunction vnoremap gi :call SelectionSurroundWith() " " (visual) gi" := surround selection with quotes (") " (visual) gi{ := surround selection with braces ({}) " }}} " Autoformatting (to be tested) {{{ "set formatoptions+=c "set formatoptions+=n "set formatoptions+=q "set formatoptions+=r " }}} " }}} " C#/.NET specific settings {{{ " Enable OmniSharp for C# files autocmd FileType cs setlocal omnifunc=OmniSharp#Complete " Optional: Key mappings {{{ augroup omnisharp_commands autocmd! " Show type information automatically when the cursor stops moving. " Note that the type is echoed to the Vim command line, and will overwrite " any other messages in this space including e.g. ALE linting messages. autocmd CursorHold *.cs OmniSharpTypeLookup " The following commands are contextual, based on the cursor position. autocmd FileType cs nmap gd (omnisharp_go_to_definition) autocmd FileType cs nmap U (omnisharp_find_usages) autocmd FileType cs nmap osfi (omnisharp_find_implementations) autocmd FileType cs nmap ospd (omnisharp_preview_definition) autocmd FileType cs nmap ospi (omnisharp_preview_implementations) " autocmd FileType cs nmap ost (omnisharp_type_lookup) autocmd FileType cs nmap K (omnisharp_documentation) " autocmd FileType cs nmap osfs (omnisharp_find_symbol) autocmd FileType cs nmap F (omnisharp_fix_usings) " autocmd FileType cs nmap (omnisharp_signature_help) " autocmd FileType cs imap (omnisharp_signature_help) " " " Navigate up and down by method/property/field " autocmd FileType cs nmap [[ (omnisharp_navigate_up) " autocmd FileType cs nmap ]] (omnisharp_navigate_down) " " Find all code errors/warnings for the current solution and populate the quickfix window " autocmd FileType cs nmap osgcc (omnisharp_global_code_check) " " Contextual code actions (uses fzf, vim-clap, CtrlP or unite.vim selector when available) " autocmd FileType cs nmap osca (omnisharp_code_actions) " autocmd FileType cs xmap osca (omnisharp_code_actions) " " Repeat the last code action performed (does not use a selector) " autocmd FileType cs nmap os. (omnisharp_code_action_repeat) " autocmd FileType cs xmap os. (omnisharp_code_action_repeat) " " autocmd FileType cs nmap os= (omnisharp_code_format) " autocmd FileType cs nmap R (omnisharp_rename) " " autocmd FileType cs nmap osre (omnisharp_restart_server) " autocmd FileType cs nmap osst (omnisharp_start_server) " autocmd FileType cs nmap ossp (omnisharp_stop_server) autocmd FileType cs nmap T (omnisharp_run_tests_in_file) autocmd FileType cs nmap t (omnisharp_run_test) augroup END " }}} " Settings: {{{ set completeopt=menuone,noinsert,noselect,popuphidden set completepopup=highlight:Pmenu,border:off set backspace=indent,eol,start set hidden set nofixendofline set nostartofline set splitbelow set splitright set laststatus=2 set showmode set signcolumn=yes set mouse=a set updatetime=1000 " }}} " }}} " }}} " 3rd Party {{{ " Max Cantor {{{ " " Copied from https://github.com/changemewtf/no_plugins/blob/master/no_plugins.vim " " HOW TO DO 90% OF WHAT PLUGINS DO (WITH JUST VIM) " Max Cantor " NYC Vim Meetup -- August 3, 2016 " FEATURES TO COVER: " - Fuzzy File Search " - Tag jumping " - Autocomplete " - File Browsing " - Snippets " - Build Integration (if we have time) " GOALS OF THIS TALK: " - Increase Vim understanding " - Offer powerful options " NOT GOALS OF THIS TALK: " - Hate on plugins " - Get people to stop using plugins " {{{ BASIC SETUP " BASIC SETUP: " enter the current millenium set nocompatible " enable syntax and plugins (for netrw) syntax enable filetype plugin on " }}} " FINDING FILES: {{{ " Search down into subfolders " Provides tab-completion for all file-related tasks set path+=** " Display all matching files when we tab complete set wildmenu " NOW WE CAN: " - Hit tab to :find by partial match " - Use * to make it fuzzy " THINGS TO CONSIDER: " - :b lets you autocomplete any open buffer " }}} " TAG JUMPING: {{{ " Create the `tags` file (may need to install ctags first) command! MakeTags !ctags -R . " NOW WE CAN: " - Use ^] to jump to tag under cursor " - Use g^] for ambiguous tags " - Use ^t to jump back up the tag stack " THINGS TO CONSIDER: " - This doesn't help if you want a visual list of tags " }}} " AUTOCOMPLETE: {{{ " The good stuff is documented in |ins-completion| " HIGHLIGHTS: " - ^x^n for JUST this file " - ^x^f for filenames (works with our path trick!) " - ^x^] for tags only " - ^n for anything specified by the 'complete' option " NOW WE CAN: " - Use ^n and ^p to go back and forth in the suggestion list " }}} " FILE BROWSING: {{{ " Tweaks for browsing let g:netrw_banner=0 " disable annoying banner let g:netrw_browse_split=4 " open in prior window let g:netrw_altv=1 " open splits to the right let g:netrw_liststyle=3 " tree view let g:netrw_list_hide=netrw_gitignore#Hide() let g:netrw_list_hide.=',\(^\|\s\s\)\zs\.\S\+' " NOW WE CAN: " - :edit a folder to open a file browser " - /v/t to open in an h-split/v-split/tab " - check |netrw-browse-maps| for more mappings " }}} " SNIPPETS: {{{ " Read an empty HTML template and move cursor to title nnoremap ,html :-1read $HOME/.vim/.skeleton.html3jwf>a " NOW WE CAN: " - Take over the world! " (with much fewer keystrokes) " }}} " BUILD INTEGRATION: {{{ " Steal Mr. Bradley's formatter & add it to our spec_helper " http://philipbradley.net/rspec-into-vim-with-quickfix " Configure the `make` command to run RSpec set makeprg=bundle\ exec\ rspec\ -f\ QuickfixFormatter " NOW WE CAN: " - Run :make to run RSpec " - :cl to list errors " - :cc# to jump to error by number " - :cn and :cp to navigate forward and back " }}} " THANK YOU! " Download this file at: " github.com/mcantor/no_plugins " Follow me for kitten pictures: " twitter.com/mcantor " Contact me at `max at maxcantor dot net` for: " - Consulting (Dev and PM) " - Tutoring " - Classroom Teaching " - Internal Training " - Encouragement " }}} " ALE {{{ let g:ale_linters = { \ 'cs': ['OmniSharp'] \} let g:ale_fixers = { 'cs': [ 'dotnet-format' ] } let g:ale_set_quickfix = 0 let g:ale_set_loclist = 1 " }}} " OmniSharp: {{{ let g:OmniSharp_popup_position = 'peek' if has('nvim') let g:OmniSharp_popup_options = { \ 'winblend': 30, \ 'winhl': 'Normal:Normal,FloatBorder:ModeMsg', \ 'border': 'rounded' \} else let g:OmniSharp_popup_options = { \ 'highlight': 'Normal', \ 'padding': [1], \ 'border': [1], \ 'borderchars': ['─', '│', '─', '│', '╭', '╮', '╯', '╰'], \ 'borderhighlight': ['Special'] \} endif let g:OmniSharp_popup_mappings = { \ 'sigNext': '', \ 'sigPrev': '', \ 'pageDown': ['', ''], \ 'pageUp': ['', ''] \} let g:OmniSharp_highlight_groups = { \ 'ExcludedCode': 'NonText' \} " }}} " }}} " Restore some things Max Cantor changed unlet g:netrw_banner " Restore some other defaults that got disabled set showcmd " Clear search highlight after sourcing silent! call feedkeys(":nohlsearch\") " Fix CTRL-] suppressed on Alacritty for Windows nnoremap " Make navigation a bit easier on Colemak set langmap=jk,kj