Pārlūkot izejas kodu

Add .vimrc and Readme

Daniel Sheffield 5 dienas atpakaļ
revīzija
3a5852589b
2 mainītis faili ar 389 papildinājumiem un 0 dzēšanām
  1. 74 0
      Readme.md
  2. 315 0
      vim/.vimrc

+ 74 - 0
Readme.md

@@ -0,0 +1,74 @@
+# Personal dotfiles (eg .config)
+
+The files here are structured for compatibility with stow.
+
+# Targets
+
+Each package may have files that target the system or the user file heirarchy.
+Therefore, each package may have a subdirectory containing any of:
+
+   * system
+   * user
+
+*Example*:
+
+```plain
+dotfiles
+├── Readme.md
+├── ssh
+│   ├── system
+│   │   └── etc
+│   │       └── ssh
+│   │           ├── ssh_config
+│   │           └── sshd_config
+│   └── user
+│       └── .ssh
+│           └── config
+└── vim
+    └── .vimrc
+```
+
+
+In the case no target subdirectories are present for a given package, then the target is assumed to be the `user` target.
+
+More targets may be added in the future:
+
+   * user-config (`/home/acme/.config`)
+   * user-local (`/home/acme/.local`)
+   * system-opt (`/opt`)
+   * system-local (`/usr/local`)
+   * system-lib (`/usr/local/lib`)
+
+For now, to ensure maximum compatibility, it's more flexable to require each package to supply the specific heirarchy.
+
+## User
+
+All directories under the user target are relative to `$HOME`.
+
+*Example* Stow all `vim` config at `/home/acme/`:
+```bash
+./dot apply vim
+```
+
+On GNU compatible system this is equivalent to:
+
+```bash
+stow -d $DOTFILES_DIR/vim -t /home/acme
+```
+
+## System
+
+All directories under the system targt are relative to `/`.
+
+*Example* Stow system/user `ssh` config at `/home/acme/` and `/` respectively:
+```bash
+./dot apply ssh
+```
+
+On GNU compatible system this is equivalent to:
+
+```bash
+stow -d $DOTFILES_DIR/ssh/user -t /home/acme
+sudo stow -d $DOTFILES_DIR/ssh/system -t /
+```
+

+ 315 - 0
vim/.vimrc

@@ -0,0 +1,315 @@
+" To make 3rd party includes
+set foldmethod=marker
+
+" Enable syntax and plugins
+syntax enable
+filetype indent plugin on
+
+" Plugins {{{
+call plug#begin()
+
+Plug 'OmniSharp/omnisharp-vim'
+" After :PlugInstall do :OmnisharpInstall
+
+Plug 'dense-analysis/ale'
+
+call plug#end()
+" }}}
+
+" Personal {{{
+
+" Looks {{{
+" Window title reflects document title
+set title
+
+" Ye olde faithful
+set textwidth=80
+
+
+" HUD {{{
+set hlsearch incsearch
+set number relativenumber
+set ruler
+" }}}
+
+" Spaces instead of TABs :( {{{
+set expandtab
+set shiftround
+set shiftwidth=4
+set softtabstop=-1 " When 'sts' is negative, the value of 'shiftwidth' is used.
+set tabstop=6      " Make TAB char more obvious
+" }}}
+
+" }}}
+
+" Feels {{{
+
+" 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
+
+
+" Formatting {{{
+
+" Title Case
+vnoremap gt :s/\%V\v<(.)(\w*)/\u\1\L\2/g<CR>:noh<CR>
+vnoremap gT :s/\v<(.)(\w*)/\u\1\L\2/g<CR>:noh<CR>
+vnoremap gi" c"<C-r>""<Esc>
+vnoremap gi' c'<C-r>"'<Esc>
+vnoremap gi` c`<C-r>"`<Esc>
+vnoremap gi( c(<C-r>")<Esc>
+vnoremap gi) c(<C-r>")<Esc>
+vnoremap gi[ c[<C-r>"]<Esc>
+vnoremap gi] c[<C-r>"]<Esc>
+vnoremap gi{ c{<C-r>"{<Esc>
+vnoremap gi} c}<C-r>"}<Esc>
+
+"}}}
+
+" Autoformatting (to be tested) {{{
+"set formatoptions+=c
+"set formatoptions+=n
+"set formatoptions+=q
+"set formatoptions+=r
+" }}}
+
+" }}}
+
+" }}}
+
+" 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
+" - <CR>/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.html<CR>3jwf>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 = 1
+" }}}
+
+" C#/.NET specific settings {{{
+" Enable OmniSharp for C# files
+autocmd FileType cs setlocal omnifunc=OmniSharp#Complete
+
+" Optional: Key mappings
+autocmd FileType cs nnoremap <buffer> gd :OmniSharpGotoDefinition<CR>
+autocmd FileType cs nnoremap <buffer> <leader>fi :OmniSharpFindImplementations<CR>
+autocmd FileType cs nnoremap <buffer> <leader>us :OmniSharpFindUsages<CR>
+autocmd FileType cs nnoremap <buffer> K :OmniSharpDocumentation<CR>
+
+" 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
+" }}}
+
+" 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': [0],
+  "\ 'winblend': 30,
+  "\ 'winhl': 'Normal:Normal,FloatBorder:ModeMsg',
+  "\ 'border': [1],
+  "\ 'borderchars': ['─', '│', '─', '│', '┌', '┐', '┘', '└'],
+  "\ 'borderhighlight': ['ModeMsg']
+  "\ }
+  let g:OmniSharp_popup_options = {
+  \ 'highlight': 'Normal',
+  \ 'padding': [1],
+  \ 'border': [1],
+  \ 'borderchars': ['─', '│', '─', '│', '╭', '╮', '╯', '╰'],
+  \ 'borderhighlight': ['Special']
+  \}
+  "\ 'highlight': 'Normal',
+  "\ 'winblend': 30,
+  "\ 'winhl': 'Normal:Normal,FloatBorder:Special',
+endif
+let g:OmniSharp_popup_mappings = {
+\ 'sigNext': '<C-n>',
+\ 'sigPrev': '<C-p>',
+\ 'pageDown': ['<C-f>', '<PageDown>'],
+\ 'pageUp': ['<C-b>', '<PageUp>']
+\}
+
+let g:OmniSharp_highlight_groups = {
+\ 'ExcludedCode': 'NonText'
+\}
+
+" }}}
+" }}}
+
+" }}}
+
+" Restore some things Max Cantor changed
+unlet g:netrw_banner
+
+" Clear search highlight after sourcing
+silent! call feedkeys(":nohlsearch\<CR>")
+