Commits

Dan Callahan committed 4208a68

Update dotfiles (mostly golang, rst related)

  • Participants
  • Parent commits 8d06602

Comments (0)

Files changed (8)

File files/.ackrc

 --type-set=haml=.haml
 --type-set=less=.less
 --type-set=coffee=.coffee
+--type-set=rst=.rst

File files/.vim/bundle/go/ftdetect/gofiletype.vim

-au BufRead,BufNewFile *.go set filetype=go
+au BufReadPre,BufNewFile *.go set filetype=go fileencoding=utf-8 fileencodings=utf-8

File files/.vim/bundle/go/ftplugin/go/fmt.vim

 "       replacing the buffer with stderr output.
 "
 
-command! Fmt call s:GoFormat()
+command! -buffer Fmt call s:GoFormat()
 
 function! s:GoFormat()
     let view = winsaveview()

File files/.vim/bundle/go/ftplugin/go/import.vim

     finish
 endif
 
-command! -buffer -nargs=? Drop call s:SwitchImport(0, '', <f-args>)
-command! -buffer -nargs=1 Import call s:SwitchImport(1, '', <f-args>)
-command! -buffer -nargs=* ImportAs call s:SwitchImport(1, <f-args>)
+command! -buffer -nargs=? -complete=customlist,go#complete#Package Drop call s:SwitchImport(0, '', <f-args>)
+command! -buffer -nargs=1 -complete=customlist,go#complete#Package Import call s:SwitchImport(1, '', <f-args>)
+command! -buffer -nargs=* -complete=customlist,go#complete#Package ImportAs call s:SwitchImport(1, <f-args>)
 " map <buffer> <LocalLeader>f :Import fmt<CR>
 " map <buffer> <LocalLeader>F :Drop fmt<CR>
 

File files/.vim/bundle/go/indent/go.vim

 "
 " indent/go.vim: Vim indent file for Go.
 "
+" TODO:
+" - function invocations split across lines
+" - general line splits (line ends in an operator)
 
 if exists("b:did_indent")
     finish
 endif
 let b:did_indent = 1
 
-" C indentation is mostly correct
-setlocal cindent
+" C indentation is too far off useful, mainly due to Go's := operator.
+" Let's just define our own.
+setlocal nolisp
+setlocal autoindent
+setlocal indentexpr=GoIndent(v:lnum)
+setlocal indentkeys+=<:>,0=},0=)
 
-" Options set:
-" +0 -- Don't indent continuation lines (because Go doesn't use semicolons
-"       much)
-" L0 -- Don't move jump labels (NOTE: this isn't correct when working with
-"       gofmt, but it does keep struct literals properly indented.)
-" :0 -- Align case labels with switch statement
-" l1 -- Always align case body relative to case labels
-" J1 -- Indent JSON-style objects (properly indents struct-literals)
-" (0, Ws -- Indent lines inside of unclosed parentheses by one shiftwidth
-" m1 -- Align closing parenthesis line with first non-blank of matching
-"       parenthesis line
-"
-" Known issue: Trying to do a multi-line struct literal in a short variable
-"              declaration will not indent properly.
-setlocal cinoptions+=+0,L0,:0,l1,J1,(0,Ws,m1
+if exists("*GoIndent")
+  finish
+endif
+
+function! GoIndent(lnum)
+  let prevlnum = prevnonblank(a:lnum-1)
+  if prevlnum == 0
+    " top of file
+    return 0
+  endif
+
+  " grab the previous and current line, stripping comments.
+  let prevl = substitute(getline(prevlnum), '//.*$', '', '')
+  let thisl = substitute(getline(a:lnum), '//.*$', '', '')
+  let previ = indent(prevlnum)
+
+  let ind = previ
+
+  if prevl =~ '[({]\s*$'
+    " previous line opened a block
+    let ind += &sw
+  endif
+  if prevl =~# '^\s*\(case .*\|default\):$'
+    " previous line is part of a switch statement
+    let ind += &sw
+  endif
+  " TODO: handle if the previous line is a label.
+
+  if thisl =~ '^\s*[)}]'
+    " this line closed a block
+    let ind -= &sw
+  endif
+
+  " Colons are tricky.
+  " We want to outdent if it's part of a switch ("case foo:" or "default:").
+  " We ignore trying to deal with jump labels because (a) they're rare, and
+  " (b) they're hard to disambiguate from a composite literal key.
+  if thisl =~# '^\s*\(case .*\|default\):$'
+    let ind -= &sw
+  endif
+
+  return ind
+endfunction

File files/.vim/bundle/go/readme.txt

-Vim syntax highlighting for Go (http://golang.org)
-==================================================
+Vim plugins for Go (http://golang.org)
+======================================
+
+To use all the Vim plugins, add these lines to your vimrc.
+
+  set rtp+=$GOROOT/misc/vim
+  filetype plugin indent on
+  syntax on
+
+If you want to select fewer plugins, use the instructions in the rest of
+this file.
+
+Vim syntax highlighting
+-----------------------
 
 To install automatic syntax highlighting for GO programs:
 
 
   mkdir -p $HOME/.vim/ftdetect
   mkdir -p $HOME/.vim/syntax
+  mkdir -p $HOME/.vim/autoload/go
   ln -s $GOROOT/misc/vim/ftdetect/gofiletype.vim $HOME/.vim/ftdetect/
   ln -s $GOROOT/misc/vim/syntax/go.vim $HOME/.vim/syntax
+  ln -s $GOROOT/misc/vim/autoload/go/complete.vim $HOME/.vim/autoload/go
   echo "syntax on" >> $HOME/.vimrc
 
 
-Vim filetype plugins for Go
-===========================
+Vim filetype plugins
+--------------------
 
-To install one of the available filetype plugins for Go:
+To install one of the available filetype plugins:
 
   1. Same as 1 above.
   2. Copy or link one or more plugins from ftplugin/go/*.vim to the
      filetype plugin on
 
 
-Vim indentation plugin for Go
-=============================
+Vim indentation plugin
+----------------------
 
-To install automatic indentation for Go:
+To install automatic indentation:
 
   1. Same as 1 above.
   2. Copy or link indent/go.vim to the indent directory underneath your vim
   3. Add the following line to your .vimrc file (normally $HOME/.vimrc):
 
      filetype indent on
+
+
+Godoc plugin
+------------
+
+To install godoc plugin:
+
+  1. Same as 1 above.
+  2. Copy or link plugin/godoc.vim to $HOME/.vim/plugin/godoc,
+     syntax/godoc.vim to $HOME/.vim/syntax/godoc.vim,
+     ftplugin/go/godoc.vim to $HOME/.vim/ftplugin/go/godoc.vim.
+     and autoload/go/complete.vim to $HOME/.vim/autoload/go/complete.vim.

File files/.vimrc

 set ttyfast
 set background=dark
 colorscheme peaksea
-set listchars=tab:→\\,trail:·,precedes:«,extends:»,nbsp:_
+set listchars=trail:·,precedes:«,extends:»,nbsp:_,tab:→\\
 set list
 
 " Searching
 set wildignore+=*.sw[po]
 set wildignore+=.DS_Store
 set wildignore+=[Tt]humbs.db
+set wildignore+=*.6
 
 " Plugin Configuration
 map <leader>f :NERDTreeToggle<CR>

File files/.zshenv

 # Go Lang
 if [[ -d "${HOME}/.local/src/go" ]]; then
     export GOROOT="${HOME}/.local/src/go"
+    export GOMAXPROCS=4
     path=($path "${GOROOT}/bin")
 fi