summaryrefslogtreecommitdiff
path: root/misc/vim
diff options
context:
space:
mode:
Diffstat (limited to 'misc/vim')
-rw-r--r--misc/vim/autoload/go/complete.vim2
-rw-r--r--misc/vim/ftplugin/go.vim4
-rw-r--r--misc/vim/ftplugin/go/fmt.vim2
-rw-r--r--misc/vim/indent/go.vim20
-rw-r--r--misc/vim/readme.txt8
5 files changed, 26 insertions, 10 deletions
diff --git a/misc/vim/autoload/go/complete.vim b/misc/vim/autoload/go/complete.vim
index 8dd43de4a..a4fa6b668 100644
--- a/misc/vim/autoload/go/complete.vim
+++ b/misc/vim/autoload/go/complete.vim
@@ -58,7 +58,7 @@ function! go#complete#Package(ArgLead, CmdLine, CursorPos)
if executable('go')
let goroot = substitute(system('go env GOROOT'), '\n', '', 'g')
if v:shell_error
- echomsg '\'go env GOROOT\' failed'
+ echomsg '''go env GOROOT'' failed'
endif
else
let goroot = $GOROOT
diff --git a/misc/vim/ftplugin/go.vim b/misc/vim/ftplugin/go.vim
index 8066733cf..532fb1723 100644
--- a/misc/vim/ftplugin/go.vim
+++ b/misc/vim/ftplugin/go.vim
@@ -9,9 +9,11 @@ if exists("b:did_ftplugin")
endif
let b:did_ftplugin = 1
+setlocal formatoptions-=t
+
setlocal comments=s1:/*,mb:*,ex:*/,://
setlocal commentstring=//\ %s
-let b:undo_ftplugin = "setl com< cms<"
+let b:undo_ftplugin = "setl fo< com< cms<"
" vim:ts=4:sw=4:et
diff --git a/misc/vim/ftplugin/go/fmt.vim b/misc/vim/ftplugin/go/fmt.vim
index 5f7976f5f..359545bd4 100644
--- a/misc/vim/ftplugin/go/fmt.vim
+++ b/misc/vim/ftplugin/go/fmt.vim
@@ -57,7 +57,7 @@ function! s:GoFormat()
endif
undo
if !empty(errors)
- call setloclist(0, errors, 'r')
+ call setqflist(errors, 'r')
endif
echohl Error | echomsg "Gofmt returned error" | echohl None
endif
diff --git a/misc/vim/indent/go.vim b/misc/vim/indent/go.vim
index faf4d79e2..e3d6e8416 100644
--- a/misc/vim/indent/go.vim
+++ b/misc/vim/indent/go.vim
@@ -24,6 +24,18 @@ if exists("*GoIndent")
finish
endif
+" The shiftwidth() function is relatively new.
+" Don't require it to exist.
+if exists('*shiftwidth')
+ func s:sw()
+ return shiftwidth()
+ endfunc
+else
+ func s:sw()
+ return &shiftwidth
+ endfunc
+endif
+
function! GoIndent(lnum)
let prevlnum = prevnonblank(a:lnum-1)
if prevlnum == 0
@@ -40,17 +52,17 @@ function! GoIndent(lnum)
if prevl =~ '[({]\s*$'
" previous line opened a block
- let ind += &sw
+ let ind += s:sw()
endif
if prevl =~# '^\s*\(case .*\|default\):$'
" previous line is part of a switch statement
- let ind += &sw
+ let ind += s:sw()
endif
" TODO: handle if the previous line is a label.
if thisl =~ '^\s*[)}]'
" this line closed a block
- let ind -= &sw
+ let ind -= s:sw()
endif
" Colons are tricky.
@@ -58,7 +70,7 @@ function! GoIndent(lnum)
" 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
+ let ind -= s:sw()
endif
return ind
diff --git a/misc/vim/readme.txt b/misc/vim/readme.txt
index b8469f927..9a9e22870 100644
--- a/misc/vim/readme.txt
+++ b/misc/vim/readme.txt
@@ -5,9 +5,11 @@ To use all the Vim plugins, add these lines to your $HOME/.vimrc.
" Some Linux distributions set filetype in /etc/vimrc.
" Clear filetype flags before changing runtimepath to force Vim to reload them.
- filetype off
- filetype plugin indent off
- set runtimepath+=$GOROOT/misc/vim
+ if exists("g:did_load_filetypes")
+ filetype off
+ filetype plugin indent off
+ endif
+ set runtimepath+=$GOROOT/misc/vim " replace $GOROOT with the output of: go env GOROOT
filetype plugin indent on
syntax on