1
0
Fork 0
mirror of synced 2024-11-22 16:55:34 -05:00

Updated vim plugins

This commit is contained in:
amix 2017-04-01 13:22:06 +02:00
parent 50ae0a55f6
commit 75beb5f4ba
32 changed files with 704 additions and 238 deletions

View file

@ -1763,6 +1763,7 @@ fu! ctrlp#setpathmode(pmode, ...)
let spath = a:0 ? a:1 : s:crfpath let spath = a:0 ? a:1 : s:crfpath
let markers = ['.git', '.hg', '.svn', '.bzr', '_darcs'] let markers = ['.git', '.hg', '.svn', '.bzr', '_darcs']
if type(s:rmarkers) == 3 && !empty(s:rmarkers) if type(s:rmarkers) == 3 && !empty(s:rmarkers)
if s:findroot(spath, s:rmarkers, 0, 0) != [] | retu 1 | en
cal filter(markers, 'index(s:rmarkers, v:val) < 0') cal filter(markers, 'index(s:rmarkers, v:val) < 0')
let markers = s:rmarkers + markers let markers = s:rmarkers + markers
en en
@ -2384,7 +2385,7 @@ endf
fu! s:matchbuf(item, pat) fu! s:matchbuf(item, pat)
let bufnr = s:bufnrfilpath(a:item)[0] let bufnr = s:bufnrfilpath(a:item)[0]
let parts = s:bufparts(bufnr) let parts = s:bufparts(bufnr)
let item = bufnr.parts[0].parts[2].s:lash().parts[3] let item = s:byfname ? parts[2] : bufnr.parts[0].parts[2].s:lash().parts[3]
retu match(item, a:pat) retu match(item, a:pat)
endf endf

View file

@ -848,7 +848,7 @@ Example: >
When this is set to 1, the <bs> on empty prompt exit CtrlP. When this is set to 1, the <bs> on empty prompt exit CtrlP.
*ctrlp-default-value* *ctrlp-default-value*
Otherwize, you can use below to change default value. Otherwise, you can use below to change default value.
Example: > Example: >
let g:ctrlp_path_nolim = 1 let g:ctrlp_path_nolim = 1

View file

@ -0,0 +1,170 @@
goyo.txt goyo Last change: April 1 2017
GOYO - TABLE OF CONTENTS *goyo* *goyo-toc*
==============================================================================
goyo.vim (고요)
Installation
Usage
Dimension expression
Configuration
Callbacks
Inspiration
Pros.
License
GOYO.VIM (고요) *goyo*
==============================================================================
Distraction-free writing in Vim.
https://raw.github.com/junegunn/i/master/goyo.png
(Color scheme: {seoul256}{1})
Best served with {limelight.vim}{2}.
{1} https://github.com/junegunn/seoul256.vim
{2} https://github.com/junegunn/limelight.vim
INSTALLATION *goyo-installation*
==============================================================================
Use your favorite plugin manager.
*:PlugInstall*
- {vim-plug}{3}
1. Add `Plug'junegunn/goyo.vim'` to .vimrc
2. Run `:PlugInstall`
{3} https://github.com/junegunn/vim-plug
USAGE *goyo-usage*
==============================================================================
*:Goyo*
- `:Goyo`
- Toggle Goyo
- `:Goyo[dimension]`
- Turn on or resize Goyo
- `:Goyo!`
- Turn Goyo off
The window can be resized with the usual count]<CTRL-W + `>`, `<`, `+`, `-`
keys.
< Dimension expression >______________________________________________________~
*goyo-dimension-expression*
The expected format of a dimension expression is
`[WIDTH][XOFFSET][x[HEIGHT][YOFFSET]]`. `XOFFSET` and `YOFFSET` should be
prefixed by `+` or `-`. Each component can be given in percentage.
>
" Width
Goyo 120
" Height
Goyo x30
" Both
Goyo 120x30
" In percentage
Goyo 120x50%
" With offsets
Goyo 50%+25%x50%-25%
<
CONFIGURATION *goyo-configuration*
==============================================================================
*g:goyo_width* *g:goyo_height* *g:goyo_linenr*
- `g:goyo_width` (default: 80)
- `g:goyo_height` (default: 85%)
- `g:goyo_linenr` (default: 0)
< Callbacks >_________________________________________________________________~
*goyo-callbacks*
By default, {vim-airline}{4}, {vim-powerline}{5}, {powerline}{6},
{lightline.vim}{7}, {vim-signify}{8}, and {vim-gitgutter}{9} are temporarily
disabled while in Goyo mode.
If you have other plugins that you want to disable/enable, or if you want to
change the default settings of Goyo window, you can set up custom routines to
be triggered on `GoyoEnter` and `GoyoLeave` events.
>
function! s:goyo_enter()
silent !tmux set status off
silent !tmux list-panes -F '\#F' | grep -q Z || tmux resize-pane -Z
set noshowmode
set noshowcmd
set scrolloff=999
Limelight
" ...
endfunction
function! s:goyo_leave()
silent !tmux set status on
silent !tmux list-panes -F '\#F' | grep -q Z && tmux resize-pane -Z
set showmode
set showcmd
set scrolloff=5
Limelight!
" ...
endfunction
autocmd! User GoyoEnter nested call <SID>goyo_enter()
autocmd! User GoyoLeave nested call <SID>goyo_leave()
<
More examples can be found here: {Customization}{10}
{4} https://github.com/bling/vim-airline
{5} https://github.com/Lokaltog/vim-powerline
{6} https://github.com/Lokaltog/powerline
{7} https://github.com/itchyny/lightline.vim
{8} https://github.com/mhinz/vim-signify
{9} https://github.com/airblade/vim-gitgutter
{10} https://github.com/junegunn/goyo.vim/wiki/Customization
INSPIRATION *goyo-inspiration*
==============================================================================
- {LiteDFM}{11}
- {VimRoom}{12}
{11} https://github.com/bilalq/lite-dfm
{12} http://projects.mikewest.org/vimroom/
PROS. *goyo-pros*
==============================================================================
1. Works well with splits. Doesn't mess up with the current window arrangement
2. Works well with popular statusline plugins
3. Prevents accessing the empty windows around the central buffer
4. Can be closed with any of `:q[uit]`, `:clo[se]`, `:tabc[lose]`, or `:Goyo`
5. Can dynamically change the width of the window
6. Adjusts its colors when color scheme is changed
7. Realigns the window when the terminal (or window) is resized or when the size
of the font is changed
8. Correctly hides colorcolumns and Emojis in statusline
9. Highly customizable with callbacks
LICENSE *goyo-license*
==============================================================================
MIT
==============================================================================
vim:tw=78:sw=2:ts=2:ft=help:norl:nowrap:

View file

@ -0,0 +1,37 @@
_To assist in resolving your issue, provide as much information as possible, in place of the ellipses (`…`) below._
---
**Environment:** _Describe your Vim/NERDTree setup._
>* Operating System: …
>* Vim version `:version`: …
>* NERDTree version `git rev-parse --short HEAD`: …
>* NERDTree settings applied in your vimrc, if any:
>
> ```
> …
> ```
**Process:** _List the steps that will recreate the issue._
>1. …
**Current Result:** _Describe what you you currently experience from this process._
>…
**Expected Result:** _Describe what you would expect to have resulted from this process._
>…
---
**Optional**
**Screenshot(s):**
>…
**Possible Fix:** _(Have you poked around in the code?)_
>…

View file

@ -98,6 +98,35 @@ function! syntastic#preprocess#dockerfile_lint(errors) abort " {{{2
return out return out
endfunction " }}}2 endfunction " }}}2
function! syntastic#preprocess#dscanner(errors) abort " {{{2
let idx = 0
while idx < len(a:errors) && a:errors[idx][0] !=# '{'
let idx += 1
endwhile
let errs = s:_decode_JSON(join(a:errors[idx :], ''))
let out = []
if type(errs) == type({}) && has_key(errs, 'issues') && type(errs['issues']) == type([])
for issue in errs['issues']
try
call add(out,
\ issue['fileName'] . ':' .
\ issue['line'] . ':' .
\ issue['column'] . ':' .
\ issue['message'] . ' [' . issue['key'] . ']')
catch /\m^Vim\%((\a\+)\)\=:E716/
call syntastic#log#warn('checker d/dscanner: unrecognized error item ' . string(issue))
let out = []
break
endtry
endfor
else
call syntastic#log#warn('checker d/dscanner: unrecognized error format (crashed checker?)')
endif
return out
endfunction " }}}2
function! syntastic#preprocess#flow(errors) abort " {{{2 function! syntastic#preprocess#flow(errors) abort " {{{2
let idx = 0 let idx = 0
while idx < len(a:errors) && a:errors[idx][0] !=# '{' while idx < len(a:errors) && a:errors[idx][0] !=# '{'

View file

@ -1755,6 +1755,7 @@ SYNTAX CHECKERS FOR D *syntastic-checkers-d*
The following checkers are available for D (filetype "d"): The following checkers are available for D (filetype "d"):
1. DMD......................|syntastic-d-dmd| 1. DMD......................|syntastic-d-dmd|
2. D-Scanner................|syntastic-d-dscanner|
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
1. DMD *syntastic-d-dmd* 1. DMD *syntastic-d-dmd*
@ -1834,6 +1835,22 @@ the usual 'g:syntastic_d_dmd_<option>' variables. The only exception is
'g:syntastic_d_dmd_exec', which can still be used to override the checker's 'g:syntastic_d_dmd_exec', which can still be used to override the checker's
executable. executable.
------------------------------------------------------------------------------
2. D-Scanner *syntastic-d-dscanner*
Name: dscanner
Maintainer: ANtlord
"D-Scanner" is a tool for analyzing D source code (https://dlang.org/). See
the project's page at GitHub for more information:
https://github.com/Hackerpilot/Dscanner
Checker options~
This checker is initialised using the "makeprgBuild()" function and thus it
accepts the standard options described at |syntastic-config-makeprg|.
============================================================================== ==============================================================================
SYNTAX CHECKERS FOR DART *syntastic-checkers-dart* SYNTAX CHECKERS FOR DART *syntastic-checkers-dart*
@ -1934,6 +1951,7 @@ SYNTAX CHECKERS FOR DOCKERFILE *syntastic-checkers-dockerfile*
The following checkers are available for Dockerfile (filetype "dockerfile"): The following checkers are available for Dockerfile (filetype "dockerfile"):
1. dockerfile-lint..........|syntastic-dockerfile-dockerfile_lint| 1. dockerfile-lint..........|syntastic-dockerfile-dockerfile_lint|
2. Hadolint.................|syntastic-dockerfile-hadolint|
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
1. dockerfile-lint *syntastic-dockerfile-dockerfile_lint* 1. dockerfile-lint *syntastic-dockerfile-dockerfile_lint*
@ -1957,6 +1975,22 @@ Checker options~
This checker is initialised using the "makeprgBuild()" function and thus it This checker is initialised using the "makeprgBuild()" function and thus it
accepts the standard options described at |syntastic-config-makeprg|. accepts the standard options described at |syntastic-config-makeprg|.
------------------------------------------------------------------------------
2. Hadolint *syntastic-dockerfile-hadolint*
Name: hadolint
Maintainer: Jesper B. Rosenkilde <jbr@humppa.dk>
"Hadolint" is a dockerfile linter written in Haskell. See the project's page
at GitHub for details:
https://github.com/lukasmartinelli/hadolint
Checker options~
This checker is initialised using the "makeprgBuild()" function and thus it
accepts the standard options described at |syntastic-config-makeprg|.
============================================================================== ==============================================================================
SYNTAX CHECKERS FOR DUST *syntastic-checkers-dustjs* SYNTAX CHECKERS FOR DUST *syntastic-checkers-dustjs*
@ -4884,59 +4918,11 @@ SYNTAX CHECKERS FOR R *syntastic-checkers-r*
The following checkers are available for R (filetype "r"): The following checkers are available for R (filetype "r"):
1. lint.....................|syntastic-r-lint| 1. lintr....................|syntastic-r-lintr|
2. lintr....................|syntastic-r-lintr| 2. svtools..................|syntastic-r-svtools|
3. svtools..................|syntastic-r-svtools|
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
1. lint *syntastic-r-lint* 1. lintr *syntastic-r-lintr*
Name: lint
Maintainer: LCD 47 <lcd047@gmail.com>
This is a style checker for R files, using the R package "lint":
http://cran.r-project.org/web/packages/lint/
Checker option~
*'g:syntastic_r_lint_styles'*
Type: string
Default: "lint.style"
R list of style tests to apply.
Set 'g:syntastic_r_lint_styles' to something like this: >
let g:syntastic_r_lint_styles =
\ 'list(spacing.indentation.notabs, spacing.indentation.evenindent)'
<
See "lint"'s manual for possible values:
http://cran.r-project.org/web/packages/lint/lint.pdf
Note~
This checker doesn't call the "makeprgBuild()" function, and thus it ignores
the usual 'g:syntastic_r_lint_<option>' variables. The only exception is
'g:syntastic_r_lint_exec', which can still be used to override the "R"
executable.
Limitations~
The checker uses column numbers only when running into syntax errors. If
you're checking files containing tab characters, then Vim's 'tabstop' must
match R's idea of tabstop, otherwise column numbers will be shifted. At the
time of this writing R's tabstop is hardcoded to 8, so you should probably
add something like this to your vimrc: >
set tabstop=8
<
The "lint" package will only show at most 5 messages of a kind. At the time of
this writing this is not configurable.
Beware also that the checker is pretty slow when using the default style
setting of "lint.style".
------------------------------------------------------------------------------
2. lintr *syntastic-r-lintr*
Name: lintr Name: lintr
Maintainer: Jim Hester <james.f.hester@gmail.com> Maintainer: Jim Hester <james.f.hester@gmail.com>
@ -4984,7 +4970,7 @@ executable.
See also: |syntastic-rmd-lintr|. See also: |syntastic-rmd-lintr|.
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
3. svtools *syntastic-r-svtools* 2. svtools *syntastic-r-svtools*
Name: svtools Name: svtools
Maintainer: LCD 47 <lcd047@gmail.com> Maintainer: LCD 47 <lcd047@gmail.com>
@ -5953,6 +5939,7 @@ SYNTAX CHECKERS FOR SOLIDITY *syntastic-checkers-solidity*
The following checkers are available for Solidity (filetype "solidity"): The following checkers are available for Solidity (filetype "solidity"):
1. solc.....................|syntastic-solidity-solc| 1. solc.....................|syntastic-solidity-solc|
2. Solium...................|syntastic-solidity-solium|
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
1. solc *syntastic-solidity-solc* 1. solc *syntastic-solidity-solc*
@ -5977,6 +5964,27 @@ You probably also need a plugin to set |filetype| for Solidity files, such as
https://github.com/tomlion/vim-solidity https://github.com/tomlion/vim-solidity
------------------------------------------------------------------------------
2. Solium *syntastic-solidity-solium*
Name: solium
Maintainer: Matthijs van den Bos <matthijs@vandenbos.org>
"Solium" is a linter for "Solidity" files. See the project's page for details:
https://github.com/duaraghav8/Solium
Checker options~
This checker is initialised using the "makeprgBuild()" function and thus it
accepts the standard options described at |syntastic-config-makeprg|.
Note~
You probably also need a plugin to set |filetype| for Solidity files, such as
"vim-solidity":
https://github.com/tomlion/vim-solidity
============================================================================== ==============================================================================
SYNTAX CHECKERS FOR SQL *syntastic-checkers-sql* SYNTAX CHECKERS FOR SQL *syntastic-checkers-sql*

View file

@ -19,7 +19,7 @@ if has('reltime')
lockvar! g:_SYNTASTIC_START lockvar! g:_SYNTASTIC_START
endif endif
let g:_SYNTASTIC_VERSION = '3.8.0-26' let g:_SYNTASTIC_VERSION = '3.8.0-35'
lockvar g:_SYNTASTIC_VERSION lockvar g:_SYNTASTIC_VERSION
" Sanity checks {{{1 " Sanity checks {{{1

View file

@ -0,0 +1,48 @@
"============================================================================
"File: dscanner.vim
"Description: Syntax checking plugin for syntastic
"Maintainer: ANtlord
"License: This program is free software. It comes without any warranty,
" to the extent permitted by applicable law. You can redistribute
" it and/or modify it under the terms of the Do What The Fuck You
" Want To Public License, Version 2, as published by Sam Hocevar.
" See http://sam.zoy.org/wtfpl/COPYING for more details.
"
"============================================================================
if exists('g:loaded_syntastic_d_dscanner_checker')
finish
endif
let g:loaded_syntastic_d_dscanner_checker = 1
let s:save_cpo = &cpo
set cpo&vim
function! SyntaxCheckers_d_dscanner_GetHighlightRegex(i)
let term = matchstr(a:i['text'], '\m^.\{-}''\zs\S\+\ze''')
return term !=# '' ? '\V\<' . escape(term, '\') . '\>' : ''
endfunction
function! SyntaxCheckers_d_dscanner_GetLocList() dict
let makeprg = self.makeprgBuild({
\ 'args_after': '--report',
\ 'tail': '2>' . syntastic#util#DevNull() })
let errorformat = '%f:%l:%c:%m'
return SyntasticMake({
\ 'makeprg': makeprg,
\ 'errorformat': errorformat,
\ 'preprocess': 'dscanner',
\ 'subtype': 'Style',
\ 'returns': [0] })
endfunction
call g:SyntasticRegistry.CreateAndRegisterChecker({
\ 'filetype': 'd',
\ 'name': 'dscanner' })
let &cpo = s:save_cpo
unlet s:save_cpo
" vim: set sw=4 sts=4 et fdm=marker:

View file

@ -0,0 +1,41 @@
"============================================================================
"File: hadolint.vim
"Description: Dockerfile linter written in Haskell
" (http://hadolint.lukasmartinelli.ch/).
"Maintainer: Jesper B. Rosenkilde <jbr at humppa dot dk>
"License: This program is free software. It comes without any warranty,
" to the extent permitted by applicable law. You can redistribute
" it and/or modify it under the terms of the Do What The Fuck You
" Want To Public License, Version 2, as published by Sam Hocevar.
" See http://sam.zoy.org/wtfpl/COPYING for more details.
"
"============================================================================
if exists('g:loaded_syntastic_dockerfile_hadolint_checker')
finish
endif
let g:loaded_syntastic_dockerfile_hadolint_checker = 1
let s:save_cpo = &cpo
set cpo&vim
function! SyntaxCheckers_dockerfile_hadolint_GetLocList() dict
let makeprg = self.makeprgBuild({})
let errorformat = '%W%f:%l %m'
return SyntasticMake({
\ 'makeprg': makeprg,
\ 'errorformat': errorformat,
\ 'subtype': 'Style',
\ 'returns': [0, 1] })
endfunction
call g:SyntasticRegistry.CreateAndRegisterChecker({
\ 'filetype': 'dockerfile',
\ 'name': 'hadolint'})
let &cpo = s:save_cpo
unlet s:save_cpo
" vim: set sw=4 sts=4 et fdm=marker:

View file

@ -0,0 +1,43 @@
"============================================================================
"File: solium.vim
"Description: Solidity syntax checker - using solium
"Maintainer: Matthijs van den Bos <matthijs@vandenbos.org>
"License: This program is free software. It comes without any warranty,
" to the extent permitted by applicable law. You can redistribute
" it and/or modify it under the terms of the Do What The Fuck You
" Want To Public License, Version 2, as published by Sam Hocevar.
" See http://sam.zoy.org/wtfpl/COPYING for more details.
"
"============================================================================
if exists('g:loaded_syntastic_solidity_solium_checker')
finish
endif
let g:loaded_syntastic_solidity_solium_checker = 1
let s:save_cpo = &cpo
set cpo&vim
function! SyntaxCheckers_solidity_solium_GetLocList() dict
let makeprg = self.makeprgBuild({
\ 'args_after': '-R gcc',
\ 'fname_before': '--file'})
let errorformat =
\ '%f:%l:%c: %trror: %m,' .
\ '%f:%l:%c: %tarning: %m'
return SyntasticMake({
\ 'makeprg': makeprg,
\ 'errorformat': errorformat,
\ 'returns': [0, 1] })
endfunction
call g:SyntasticRegistry.CreateAndRegisterChecker({
\ 'filetype': 'solidity',
\ 'name': 'solium'})
let &cpo = s:save_cpo
unlet s:save_cpo
" vim: set sw=4 sts=4 et fdm=marker:

View file

@ -427,6 +427,58 @@ Let's say, for example, you want to remove trailing whitespace from all changed
``` ```
#### Cycle through hunks in all buffers
`]c` and `[c` jump from one hunk to the next in the current buffer. You can use this code to jump to the next hunk no matter which buffer it's in.
```viml
function! NextHunkAllBuffers()
let line = line('.')
GitGutterNextHunk
if line('.') != line
return
endif
let bufnr = bufnr('')
while 1
bnext
if bufnr('') == bufnr
return
endif
if !empty(GitGutterGetHunks())
normal! 1G
GitGutterNextHunk
return
endif
endwhile
endfunction
function! PrevHunkAllBuffers()
let line = line('.')
GitGutterPrevHunk
if line('.') != line
return
endif
let bufnr = bufnr('')
while 1
bprevious
if bufnr('') == bufnr
return
endif
if !empty(GitGutterGetHunks())
normal! G
GitGutterPrevHunk
return
endif
endwhile
endfunction
nmap <silent> ]c :call NextHunkAllBuffers()<CR>
nmap <silent> [c :call PrevHunkAllBuffers()<CR>
```
### FAQ ### FAQ
> Why can't I unstage staged changes? > Why can't I unstage staged changes?

View file

@ -44,7 +44,7 @@ endfunction
function! gitgutter#handle_diff(diff) abort function! gitgutter#handle_diff(diff) abort
call gitgutter#debug#log(a:diff) call gitgutter#debug#log(a:diff)
call setbufvar(gitgutter#utility#bufnr(), 'gitgutter_tracked', 1) call gitgutter#utility#setbufvar(gitgutter#utility#bufnr(), 'tracked', 1)
call gitgutter#hunk#set_hunks(gitgutter#diff#parse_diff(a:diff)) call gitgutter#hunk#set_hunks(gitgutter#diff#parse_diff(a:diff))
let modified_lines = gitgutter#diff#process_hunks(gitgutter#hunk#hunks()) let modified_lines = gitgutter#diff#process_hunks(gitgutter#hunk#hunks())
@ -209,10 +209,16 @@ function! gitgutter#undo_hunk() abort
call gitgutter#utility#system(gitgutter#utility#command_in_directory_of_file(g:gitgutter_git_executable.' apply --reverse --unidiff-zero - '), diff_for_hunk) call gitgutter#utility#system(gitgutter#utility#command_in_directory_of_file(g:gitgutter_git_executable.' apply --reverse --unidiff-zero - '), diff_for_hunk)
" reload file preserving screen line position " reload file preserving screen line position
let wl = winline() " CTRL-Y and CTRL-E treat negative counts as positive counts.
let x = line('w0')
silent edit silent edit
let offset = wl - winline() let y = line('w0')
execute "normal! ".offset."\<C-Y>" let z = x - y
if z > 0
execute "normal! ".z."\<C-E>"
else
execute "normal! ".z."\<C-Y>"
endif
endif endif
silent! call repeat#set("\<Plug>GitGutterUndoHunk", -1)<CR> silent! call repeat#set("\<Plug>GitGutterUndoHunk", -1)<CR>

View file

@ -59,11 +59,7 @@ function! gitgutter#async#execute(cmd) abort
if has('unix') if has('unix')
let command = ["sh", "-c", a:cmd] let command = ["sh", "-c", a:cmd]
elseif has('win32') elseif has('win32')
" Help docs recommend {command} be a string on Windows. But I think let command = "cmd.exe /c ".a:cmd
" they also say that will run the command directly, which I believe would
" mean the redirection and pipe stuff wouldn't work.
" let command = "cmd.exe /c ".a:cmd
let command = ["cmd.exe", "/c", a:cmd]
else else
throw 'unknown os' throw 'unknown os'
endif endif
@ -79,7 +75,7 @@ function! gitgutter#async#execute(cmd) abort
endfunction endfunction
function! gitgutter#async#handle_diff_job_nvim(job_id, data, event) abort function! gitgutter#async#handle_diff_job_nvim(job_id, data, event) dict abort
call gitgutter#debug#log('job_id: '.a:job_id.', event: '.a:event.', buffer: '.self.buffer) call gitgutter#debug#log('job_id: '.a:job_id.', event: '.a:event.', buffer: '.self.buffer)
let job_bufnr = self.buffer let job_bufnr = self.buffer

View file

@ -56,7 +56,7 @@ function! gitgutter#diff#run_diff(realtime, preserve_full_diff) abort
let cmd = '(' let cmd = '('
let bufnr = gitgutter#utility#bufnr() let bufnr = gitgutter#utility#bufnr()
let tracked = getbufvar(bufnr, 'gitgutter_tracked') " i.e. tracked by git let tracked = gitgutter#utility#getbufvar(bufnr, 'tracked', 0) " i.e. tracked by git
if !tracked if !tracked
" Don't bother trying to realtime-diff an untracked file. " Don't bother trying to realtime-diff an untracked file.
" NOTE: perhaps we should pull this guard up to the caller? " NOTE: perhaps we should pull this guard up to the caller?
@ -95,6 +95,7 @@ function! gitgutter#diff#run_diff(realtime, preserve_full_diff) abort
let cmd .= g:gitgutter_git_executable let cmd .= g:gitgutter_git_executable
if s:c_flag if s:c_flag
let cmd .= ' -c "diff.autorefreshindex=0"' let cmd .= ' -c "diff.autorefreshindex=0"'
let cmd .= ' -c "diff.noprefix=false"'
endif endif
let cmd .= ' diff --no-ext-diff --no-color -U0 '.g:gitgutter_diff_args.' ' let cmd .= ' diff --no-ext-diff --no-color -U0 '.g:gitgutter_diff_args.' '
@ -165,7 +166,6 @@ function! gitgutter#diff#parse_hunk(line) abort
endfunction endfunction
function! gitgutter#diff#process_hunks(hunks) abort function! gitgutter#diff#process_hunks(hunks) abort
call gitgutter#hunk#reset()
let modified_lines = [] let modified_lines = []
for hunk in a:hunks for hunk in a:hunks
call extend(modified_lines, gitgutter#diff#process_hunk(hunk)) call extend(modified_lines, gitgutter#diff#process_hunk(hunk))

View file

@ -1,47 +1,53 @@
let s:hunks = []
function! gitgutter#hunk#set_hunks(hunks) abort function! gitgutter#hunk#set_hunks(hunks) abort
let s:hunks = a:hunks call gitgutter#utility#setbufvar(gitgutter#utility#bufnr(), 'hunks', a:hunks)
call s:reset_summary()
endfunction endfunction
function! gitgutter#hunk#hunks() abort function! gitgutter#hunk#hunks() abort
return s:hunks return gitgutter#utility#getbufvar(gitgutter#utility#bufnr(), 'hunks', [])
endfunction
function! gitgutter#hunk#summary(bufnr) abort
return get(getbufvar(a:bufnr,''), 'gitgutter_summary', [0,0,0])
endfunction endfunction
function! gitgutter#hunk#reset() abort function! gitgutter#hunk#reset() abort
call setbufvar(gitgutter#utility#bufnr(), 'gitgutter_summary', [0,0,0]) call gitgutter#utility#setbufvar(gitgutter#utility#bufnr(), 'hunks', [])
call s:reset_summary()
endfunction
function! gitgutter#hunk#summary(bufnr) abort
return gitgutter#utility#getbufvar(a:bufnr, 'summary', [0,0,0])
endfunction
function! s:reset_summary() abort
call gitgutter#utility#setbufvar(gitgutter#utility#bufnr(), 'summary', [0,0,0])
endfunction endfunction
function! gitgutter#hunk#increment_lines_added(count) abort function! gitgutter#hunk#increment_lines_added(count) abort
let bufnr = gitgutter#utility#bufnr() let bufnr = gitgutter#utility#bufnr()
let summary = gitgutter#hunk#summary(bufnr) let summary = gitgutter#hunk#summary(bufnr)
let summary[0] += a:count let summary[0] += a:count
call setbufvar(bufnr, 'gitgutter_summary', summary) call gitgutter#utility#setbufvar(bufnr, 'summary', summary)
endfunction endfunction
function! gitgutter#hunk#increment_lines_modified(count) abort function! gitgutter#hunk#increment_lines_modified(count) abort
let bufnr = gitgutter#utility#bufnr() let bufnr = gitgutter#utility#bufnr()
let summary = gitgutter#hunk#summary(bufnr) let summary = gitgutter#hunk#summary(bufnr)
let summary[1] += a:count let summary[1] += a:count
call setbufvar(bufnr, 'gitgutter_summary', summary) call gitgutter#utility#setbufvar(bufnr, 'summary', summary)
endfunction endfunction
function! gitgutter#hunk#increment_lines_removed(count) abort function! gitgutter#hunk#increment_lines_removed(count) abort
let bufnr = gitgutter#utility#bufnr() let bufnr = gitgutter#utility#bufnr()
let summary = gitgutter#hunk#summary(bufnr) let summary = gitgutter#hunk#summary(bufnr)
let summary[2] += a:count let summary[2] += a:count
call setbufvar(bufnr, 'gitgutter_summary', summary) call gitgutter#utility#setbufvar(bufnr, 'summary', summary)
endfunction endfunction
function! gitgutter#hunk#next_hunk(count) abort function! gitgutter#hunk#next_hunk(count) abort
if gitgutter#utility#is_active() if gitgutter#utility#is_active()
let current_line = line('.') let current_line = line('.')
let hunk_count = 0 let hunk_count = 0
for hunk in s:hunks for hunk in gitgutter#hunk#hunks()
if hunk[2] > current_line if hunk[2] > current_line
let hunk_count += 1 let hunk_count += 1
if hunk_count == a:count if hunk_count == a:count
@ -58,7 +64,7 @@ function! gitgutter#hunk#prev_hunk(count) abort
if gitgutter#utility#is_active() if gitgutter#utility#is_active()
let current_line = line('.') let current_line = line('.')
let hunk_count = 0 let hunk_count = 0
for hunk in reverse(copy(s:hunks)) for hunk in reverse(copy(gitgutter#hunk#hunks()))
if hunk[2] < current_line if hunk[2] < current_line
let hunk_count += 1 let hunk_count += 1
if hunk_count == a:count if hunk_count == a:count
@ -77,7 +83,7 @@ endfunction
function! gitgutter#hunk#current_hunk() abort function! gitgutter#hunk#current_hunk() abort
let current_hunk = [] let current_hunk = []
for hunk in s:hunks for hunk in gitgutter#hunk#hunks()
if gitgutter#hunk#cursor_in_hunk(hunk) if gitgutter#hunk#cursor_in_hunk(hunk)
let current_hunk = hunk let current_hunk = hunk
break break
@ -105,7 +111,7 @@ endfunction
" be if any changes above it in the file didn't exist. " be if any changes above it in the file didn't exist.
function! gitgutter#hunk#line_adjustment_for_current_hunk() abort function! gitgutter#hunk#line_adjustment_for_current_hunk() abort
let adj = 0 let adj = 0
for hunk in s:hunks for hunk in gitgutter#hunk#hunks()
if gitgutter#hunk#cursor_in_hunk(hunk) if gitgutter#hunk#cursor_in_hunk(hunk)
break break
else else

View file

@ -15,9 +15,9 @@ function! gitgutter#sign#clear_signs() abort
let bufnr = gitgutter#utility#bufnr() let bufnr = gitgutter#utility#bufnr()
call gitgutter#sign#find_current_signs() call gitgutter#sign#find_current_signs()
let sign_ids = map(values(getbufvar(bufnr, 'gitgutter_gitgutter_signs')), 'v:val.id') let sign_ids = map(values(gitgutter#utility#getbufvar(bufnr, 'gitgutter_signs')), 'v:val.id')
call gitgutter#sign#remove_signs(sign_ids, 1) call gitgutter#sign#remove_signs(sign_ids, 1)
call setbufvar(bufnr, 'gitgutter_gitgutter_signs', {}) call gitgutter#utility#setbufvar(bufnr, 'gitgutter_signs', {})
endfunction endfunction
@ -47,17 +47,17 @@ endfunction
function! gitgutter#sign#add_dummy_sign() abort function! gitgutter#sign#add_dummy_sign() abort
let bufnr = gitgutter#utility#bufnr() let bufnr = gitgutter#utility#bufnr()
if !getbufvar(bufnr, 'gitgutter_dummy_sign') if !gitgutter#utility#getbufvar(bufnr, 'dummy_sign')
execute "sign place" s:dummy_sign_id "line=" . 9999 "name=GitGutterDummy buffer=" . bufnr execute "sign place" s:dummy_sign_id "line=" . 9999 "name=GitGutterDummy buffer=" . bufnr
call setbufvar(bufnr, 'gitgutter_dummy_sign', 1) call gitgutter#utility#setbufvar(bufnr, 'dummy_sign', 1)
endif endif
endfunction endfunction
function! gitgutter#sign#remove_dummy_sign(force) abort function! gitgutter#sign#remove_dummy_sign(force) abort
let bufnr = gitgutter#utility#bufnr() let bufnr = gitgutter#utility#bufnr()
if getbufvar(bufnr, 'gitgutter_dummy_sign') && (a:force || !g:gitgutter_sign_column_always) if gitgutter#utility#getbufvar(bufnr, 'dummy_sign') && (a:force || !g:gitgutter_sign_column_always)
execute "sign unplace" s:dummy_sign_id "buffer=" . bufnr execute "sign unplace" s:dummy_sign_id "buffer=" . bufnr
call setbufvar(bufnr, 'gitgutter_dummy_sign', 0) call gitgutter#utility#setbufvar(bufnr, 'dummy_sign', 0)
endif endif
endfunction endfunction
@ -101,9 +101,9 @@ function! gitgutter#sign#find_current_signs() abort
end end
endfor endfor
call setbufvar(bufnr, 'gitgutter_dummy_sign', dummy_sign_placed) call gitgutter#utility#setbufvar(bufnr, 'dummy_sign', dummy_sign_placed)
call setbufvar(bufnr, 'gitgutter_gitgutter_signs', gitgutter_signs) call gitgutter#utility#setbufvar(bufnr, 'gitgutter_signs', gitgutter_signs)
call setbufvar(bufnr, 'gitgutter_other_signs', other_signs) call gitgutter#utility#setbufvar(bufnr, 'other_signs', other_signs)
endfunction endfunction
@ -113,7 +113,7 @@ function! gitgutter#sign#obsolete_gitgutter_signs_to_remove(new_gitgutter_signs_
let bufnr = gitgutter#utility#bufnr() let bufnr = gitgutter#utility#bufnr()
let signs_to_remove = [] " list of [<id (number)>, ...] let signs_to_remove = [] " list of [<id (number)>, ...]
let remove_all_signs = 1 let remove_all_signs = 1
let old_gitgutter_signs = getbufvar(bufnr, 'gitgutter_gitgutter_signs') let old_gitgutter_signs = gitgutter#utility#getbufvar(bufnr, 'gitgutter_signs')
for line_number in keys(old_gitgutter_signs) for line_number in keys(old_gitgutter_signs)
if index(a:new_gitgutter_signs_line_numbers, str2nr(line_number)) == -1 if index(a:new_gitgutter_signs_line_numbers, str2nr(line_number)) == -1
call add(signs_to_remove, old_gitgutter_signs[line_number].id) call add(signs_to_remove, old_gitgutter_signs[line_number].id)
@ -128,8 +128,8 @@ endfunction
function! gitgutter#sign#remove_signs(sign_ids, all_signs) abort function! gitgutter#sign#remove_signs(sign_ids, all_signs) abort
let bufnr = gitgutter#utility#bufnr() let bufnr = gitgutter#utility#bufnr()
if a:all_signs && s:supports_star && empty(getbufvar(bufnr, 'gitgutter_other_signs')) if a:all_signs && s:supports_star && empty(gitgutter#utility#getbufvar(bufnr, 'other_signs'))
let dummy_sign_present = getbufvar(bufnr, 'gitgutter_dummy_sign') let dummy_sign_present = gitgutter#utility#getbufvar(bufnr, 'dummy_sign')
execute "sign unplace * buffer=" . bufnr execute "sign unplace * buffer=" . bufnr
if dummy_sign_present if dummy_sign_present
execute "sign place" s:dummy_sign_id "line=" . 9999 "name=GitGutterDummy buffer=" . bufnr execute "sign place" s:dummy_sign_id "line=" . 9999 "name=GitGutterDummy buffer=" . bufnr
@ -144,8 +144,8 @@ endfunction
function! gitgutter#sign#upsert_new_gitgutter_signs(modified_lines) abort function! gitgutter#sign#upsert_new_gitgutter_signs(modified_lines) abort
let bufnr = gitgutter#utility#bufnr() let bufnr = gitgutter#utility#bufnr()
let other_signs = getbufvar(bufnr, 'gitgutter_other_signs') let other_signs = gitgutter#utility#getbufvar(bufnr, 'other_signs')
let old_gitgutter_signs = getbufvar(bufnr, 'gitgutter_gitgutter_signs') let old_gitgutter_signs = gitgutter#utility#getbufvar(bufnr, 'gitgutter_signs')
for line in a:modified_lines for line in a:modified_lines
let line_number = line[0] " <number> let line_number = line[0] " <number>

View file

@ -2,6 +2,23 @@ let s:file = ''
let s:using_xolox_shell = -1 let s:using_xolox_shell = -1
let s:exit_code = 0 let s:exit_code = 0
function! gitgutter#utility#setbufvar(buffer, varname, val)
let dict = get(getbufvar(a:buffer, ''), 'gitgutter', {})
let dict[a:varname] = a:val
call setbufvar(a:buffer, 'gitgutter', dict)
endfunction
function! gitgutter#utility#getbufvar(buffer, varname, ...)
let dict = get(getbufvar(a:buffer, ''), 'gitgutter', {})
if has_key(dict, a:varname)
return dict[a:varname]
else
if a:0
return a:1
endif
endif
endfunction
function! gitgutter#utility#warn(message) abort function! gitgutter#utility#warn(message) abort
echohl WarningMsg echohl WarningMsg
echo 'vim-gitgutter: ' . a:message echo 'vim-gitgutter: ' . a:message
@ -10,8 +27,8 @@ function! gitgutter#utility#warn(message) abort
endfunction endfunction
function! gitgutter#utility#warn_once(message, key) abort function! gitgutter#utility#warn_once(message, key) abort
if empty(getbufvar(s:bufnr, a:key)) if empty(gitgutter#utility#getbufvar(s:bufnr, a:key))
call setbufvar(s:bufnr, a:key, '1') call gitgutter#utility#setbufvar(s:bufnr, a:key, '1')
echohl WarningMsg echohl WarningMsg
redraw | echo 'vim-gitgutter: ' . a:message redraw | echo 'vim-gitgutter: ' . a:message
echohl None echohl None
@ -92,11 +109,11 @@ function! gitgutter#utility#has_unsaved_changes() abort
endfunction endfunction
function! gitgutter#utility#has_fresh_changes() abort function! gitgutter#utility#has_fresh_changes() abort
return getbufvar(s:bufnr, 'changedtick') != getbufvar(s:bufnr, 'gitgutter_last_tick') return getbufvar(s:bufnr, 'changedtick') != gitgutter#utility#getbufvar(s:bufnr, 'last_tick')
endfunction endfunction
function! gitgutter#utility#save_last_seen_change() abort function! gitgutter#utility#save_last_seen_change() abort
call setbufvar(s:bufnr, 'gitgutter_last_tick', getbufvar(s:bufnr, 'changedtick')) call gitgutter#utility#setbufvar(s:bufnr, 'last_tick', getbufvar(s:bufnr, 'changedtick'))
endfunction endfunction
function! gitgutter#utility#shell_error() abort function! gitgutter#utility#shell_error() abort
@ -136,12 +153,12 @@ function! gitgutter#utility#system(cmd, ...) abort
endfunction endfunction
function! gitgutter#utility#file_relative_to_repo_root() abort function! gitgutter#utility#file_relative_to_repo_root() abort
let file_path_relative_to_repo_root = getbufvar(s:bufnr, 'gitgutter_repo_relative_path') let file_path_relative_to_repo_root = gitgutter#utility#getbufvar(s:bufnr, 'repo_relative_path')
if empty(file_path_relative_to_repo_root) if empty(file_path_relative_to_repo_root)
let dir_path_relative_to_repo_root = gitgutter#utility#system(gitgutter#utility#command_in_directory_of_file(g:gitgutter_git_executable.' rev-parse --show-prefix')) let dir_path_relative_to_repo_root = gitgutter#utility#system(gitgutter#utility#command_in_directory_of_file(g:gitgutter_git_executable.' rev-parse --show-prefix'))
let dir_path_relative_to_repo_root = gitgutter#utility#strip_trailing_new_line(dir_path_relative_to_repo_root) let dir_path_relative_to_repo_root = gitgutter#utility#strip_trailing_new_line(dir_path_relative_to_repo_root)
let file_path_relative_to_repo_root = dir_path_relative_to_repo_root . gitgutter#utility#filename() let file_path_relative_to_repo_root = dir_path_relative_to_repo_root . gitgutter#utility#filename()
call setbufvar(s:bufnr, 'gitgutter_repo_relative_path', file_path_relative_to_repo_root) call gitgutter#utility#setbufvar(s:bufnr, 'repo_relative_path', file_path_relative_to_repo_root)
endif endif
return file_path_relative_to_repo_root return file_path_relative_to_repo_root
endfunction endfunction
@ -174,14 +191,10 @@ function! gitgutter#utility#strip_trailing_new_line(line) abort
return substitute(a:line, '\n$', '', '') return substitute(a:line, '\n$', '', '')
endfunction endfunction
function! gitgutter#utility#git_version() abort
return matchstr(system(g:gitgutter_git_executable.' --version'), '[0-9.]\+')
endfunction
" True for git v1.7.2+. " True for git v1.7.2+.
function! gitgutter#utility#git_supports_command_line_config_override() abort function! gitgutter#utility#git_supports_command_line_config_override() abort
let [major, minor, patch; _] = split(gitgutter#utility#git_version(), '\.') call system(g:gitgutter_git_executable.' -c foo.bar=baz --version')
return major > 1 || (major == 1 && minor > 7) || (minor == 7 && patch > 1) return !v:shell_error
endfunction endfunction
function! gitgutter#utility#stringify(list) abort function! gitgutter#utility#stringify(list) abort

View file

@ -138,6 +138,7 @@ Commands for staging or undoing individual hunks:
:GitGutterPreviewHunk *:GitGutterPreviewHunk* :GitGutterPreviewHunk *:GitGutterPreviewHunk*
Preview the hunk the cursor is in. Preview the hunk the cursor is in.
Use |:pclose| or |CTRL-W_CTRL-Z| to close the preview window.
=============================================================================== ===============================================================================
5. AUTOCOMMAND *GitGutterAutocmd* 5. AUTOCOMMAND *GitGutterAutocmd*

View file

@ -1,5 +1,7 @@
## unplanned ## unplanned
## 1.12 - (March 29, 2017)
FEATURES: FEATURES:
* New `:GoAddTags` and `:GoRemoveTags` command based on the tool * New `:GoAddTags` and `:GoRemoveTags` command based on the tool
@ -20,6 +22,7 @@ if err != nil {
IMPROVEMENTS: IMPROVEMENTS:
* vim-go works now even if GOPATH is not set (starting with Go 1.8) [gh-1248]
* Lowercase `<Leader>` in mappings examples for consistent documentation across the README [gh-1192] * Lowercase `<Leader>` in mappings examples for consistent documentation across the README [gh-1192]
* All of files should be written in utf-8 if the file will be passed to external command. [gh-1184] * All of files should be written in utf-8 if the file will be passed to external command. [gh-1184]
* `:GoAddTags` is now able to add options to existing tags with the syntax * `:GoAddTags` is now able to add options to existing tags with the syntax
@ -27,6 +30,8 @@ IMPROVEMENTS:
* Document 'noshowmode' requirement for echo_go_info [gh-1197] * Document 'noshowmode' requirement for echo_go_info [gh-1197]
* Improve godoc view for vertical splits [gh-1195] * Improve godoc view for vertical splits [gh-1195]
* Set GOPATH for both possible go guru execution paths (sync and async) [gh-1193] * Set GOPATH for both possible go guru execution paths (sync and async) [gh-1193]
* Improve docs for :GoDef usage [gh-1242]
* Highlight trimming syntax for Go templates [gh-1235]
BUG FIXES: BUG FIXES:
@ -44,12 +49,13 @@ BUG FIXES:
* Fix `:GoAddTags` not working if any field comment would contain `{}` [gh-1189] * Fix `:GoAddTags` not working if any field comment would contain `{}` [gh-1189]
* Respect go_fmt_options when running goimports [gh-1211] * Respect go_fmt_options when running goimports [gh-1211]
* Set the filename in the location-list when there is an error with :GoFmt [gh-1199] * Set the filename in the location-list when there is an error with :GoFmt [gh-1199]
* Fix `:GoInstall` to accept additional arguments if async mode was enabled [gh-1246]
BACKWARDS INCOMPATIBILITIES: BACKWARDS INCOMPATIBILITIES:
* The command `:GoGuruTags` is removed in favour of the new command * The command `:GoGuruTags` is removed in favour of the new command
`:GoBuildTags`. This command will be used now not just for `guru`, also for `:GoBuildTags`. This command will be used now not just for `guru`, also for
all new commands such as `guru` [gh-1232] all new commands such as `gorename` [gh-1232]
* The setting `g:go_guru_tags` is removed in favour of the new setting * The setting `g:go_guru_tags` is removed in favour of the new setting
`g:go_build_tags` [gh-1232] `g:go_build_tags` [gh-1232]

View file

@ -177,9 +177,6 @@ function! go#cmd#Install(bang, ...) abort
" expand all wildcards(i.e: '%' to the current file name) " expand all wildcards(i.e: '%' to the current file name)
let goargs = map(copy(a:000), "expand(v:val)") let goargs = map(copy(a:000), "expand(v:val)")
" escape all shell arguments before we pass it to make
let goargs = go#util#Shelllist(goargs, 1)
if get(g:, 'go_echo_command_info', 1) if get(g:, 'go_echo_command_info', 1)
call go#util#EchoProgress("installing dispatched ...") call go#util#EchoProgress("installing dispatched ...")
endif endif
@ -221,7 +218,7 @@ function! go#cmd#Install(bang, ...) abort
if !empty(errors) && !a:bang if !empty(errors) && !a:bang
call go#list#JumpToFirst(l:listtype) call go#list#JumpToFirst(l:listtype)
else else
call go#util#EchoSuccess("installed to ". $GOPATH) call go#util#EchoSuccess("installed to ". go#path#Detect())
endif endif
let $GOPATH = old_gopath let $GOPATH = old_gopath
@ -407,7 +404,6 @@ function! go#cmd#Generate(bang, ...) abort
let $GOPATH = old_gopath let $GOPATH = old_gopath
endfunction endfunction
" --------------------- " ---------------------
" | Vim job callbacks | " | Vim job callbacks |
" --------------------- " ---------------------

View file

@ -136,6 +136,10 @@ endfunction
" formated. " formated.
function! go#fmt#run(bin_name, source, target) function! go#fmt#run(bin_name, source, target)
let cmd = s:fmt_cmd(a:bin_name, a:source, a:target) let cmd = s:fmt_cmd(a:bin_name, a:source, a:target)
if empty(cmd)
return
endif
if cmd[0] == "goimports" if cmd[0] == "goimports"
" change GOPATH too, so goimports can pick up the correct library " change GOPATH too, so goimports can pick up the correct library
let old_gopath = $GOPATH let old_gopath = $GOPATH
@ -162,7 +166,7 @@ function! s:fmt_cmd(bin_name, source, target)
" if not the user get's a warning via go#path#CheckBinPath() " if not the user get's a warning via go#path#CheckBinPath()
let bin_path = go#path#CheckBinPath(a:bin_name) let bin_path = go#path#CheckBinPath(a:bin_name)
if empty(bin_path) if empty(bin_path)
return return []
endif endif
" start constructing the command " start constructing the command
@ -176,7 +180,7 @@ function! s:fmt_cmd(bin_name, source, target)
if !exists('b:goimports_vendor_compatible') if !exists('b:goimports_vendor_compatible')
let out = go#util#System(bin_path . " --help") let out = go#util#System(bin_path . " --help")
if out !~ "-srcdir" if out !~ "-srcdir"
call go#util#EchoWarning(printf("vim-go: goimports (%s) does not support srcdir. Update with: :GoUpdateBinaries", bin_path)) call go#util#EchoWarning(printf("vim-go: goimports (%s) does not support srcdir. Update with: :GoUpdateBinaries", , bin_path))
else else
let b:goimports_vendor_compatible = 1 let b:goimports_vendor_compatible = 1
endif endif

View file

@ -9,8 +9,13 @@ let s:initial_go_path = ""
" GOPATH with it. If two double quotes are passed (the empty string in go), " GOPATH with it. If two double quotes are passed (the empty string in go),
" it'll clear the GOPATH and will restore to the initial GOPATH. " it'll clear the GOPATH and will restore to the initial GOPATH.
function! go#path#GoPath(...) abort function! go#path#GoPath(...) abort
" no argument, show GOPATH
if len(a:000) == 0
echo go#path#Detect()
return
endif
" we have an argument, replace GOPATH " we have an argument, replace GOPATH
if len(a:000)
" clears the current manually set GOPATH and restores it to the " clears the current manually set GOPATH and restores it to the
" initial GOPATH, which was set when Vim was started. " initial GOPATH, which was set when Vim was started.
if len(a:000) == 1 && a:1 == '""' if len(a:000) == 1 && a:1 == '""'
@ -26,18 +31,19 @@ function! go#path#GoPath(...) abort
echon "vim-go: " | echohl Function | echon "GOPATH changed to ". a:1 | echohl None echon "vim-go: " | echohl Function | echon "GOPATH changed to ". a:1 | echohl None
let s:initial_go_path = $GOPATH let s:initial_go_path = $GOPATH
let $GOPATH = a:1 let $GOPATH = a:1
return
endif
echo go#path#Detect()
endfunction endfunction
" Default returns the default GOPATH. If there is a single GOPATH it returns " Default returns the default GOPATH. If there is a single GOPATH it returns
" it. For multiple GOPATHS separated with a the OS specific separator, only " it. For multiple GOPATHS separated with a the OS specific separator, only
" the first one is returned " the first one is returned. If GOPATH is not set, it uses the default GOPATH
" set starting with GO 1.8. This GOPATH can be retrieved via 'go env GOPATH'
function! go#path#Default() abort function! go#path#Default() abort
let go_paths = split($GOPATH, go#util#PathListSep()) if $GOPATH == ""
" use default GOPATH via go env
return go#util#gopath()
endif
let go_paths = split($GOPATH, go#util#PathListSep())
if len(go_paths) == 1 if len(go_paths) == 1
return $GOPATH return $GOPATH
endif endif
@ -48,7 +54,7 @@ endfunction
" HasPath checks whether the given path exists in GOPATH environment variable " HasPath checks whether the given path exists in GOPATH environment variable
" or not " or not
function! go#path#HasPath(path) abort function! go#path#HasPath(path) abort
let go_paths = split($GOPATH, go#util#PathListSep()) let go_paths = split(go#path#Default(), go#util#PathListSep())
let last_char = strlen(a:path) - 1 let last_char = strlen(a:path) - 1
" check cases of '/foo/bar/' and '/foo/bar' " check cases of '/foo/bar/' and '/foo/bar'
@ -70,7 +76,7 @@ endfunction
" over the current GOPATH. It also detects diretories whose are outside " over the current GOPATH. It also detects diretories whose are outside
" GOPATH. " GOPATH.
function! go#path#Detect() abort function! go#path#Detect() abort
let gopath = $GOPATH let gopath = go#path#Default()
" don't lookup for godeps if autodetect is disabled. " don't lookup for godeps if autodetect is disabled.
if !get(g:, "go_autodetect_gopath", 1) if !get(g:, "go_autodetect_gopath", 1)
@ -122,15 +128,14 @@ function! go#path#BinPath() abort
let bin_path = "" let bin_path = ""
" check if our global custom path is set, if not check if $GOBIN is set so " check if our global custom path is set, if not check if $GOBIN is set so
" we can use it, otherwise use $GOPATH + '/bin' " we can use it, otherwise use default GOPATH
if exists("g:go_bin_path") if exists("g:go_bin_path")
let bin_path = g:go_bin_path let bin_path = g:go_bin_path
elseif $GOBIN != "" elseif $GOBIN != ""
let bin_path = $GOBIN let bin_path = $GOBIN
elseif $GOPATH != ""
let bin_path = expand(go#path#Default() . "/bin/")
else else
" could not find anything " GOPATH (user set or default GO)
let bin_path = expand(go#path#Default() . "/bin/")
endif endif
return bin_path return bin_path
@ -164,7 +169,9 @@ function! go#path#CheckBinPath(binpath) abort
" just get the basename " just get the basename
let basename = fnamemodify(binpath, ":t") let basename = fnamemodify(binpath, ":t")
if !executable(basename) if !executable(basename)
echom "vim-go: could not find '" . basename . "'. Run :GoInstallBinaries to fix it."
call go#util#EchoError(printf("could not find '%s'. Run :GoInstallBinaries to fix it", basename))
" restore back! " restore back!
let $PATH = old_path let $PATH = old_path
return "" return ""

View file

@ -217,15 +217,14 @@ COMMANDS *go-commands*
If [!] is not given the first error is jumped to. If [!] is not given the first error is jumped to.
*:GoDef* *:GoDef*
:GoDef [identifier] :GoDef
gd gd
CTRL-] CTRL-]
Goto declaration/definition for the given [identifier]. If no argument is Goto declaration/definition for the declaration under the cursor. By default
given, it will jump to the declaration under the cursor. By default the the CTRL-] key and the mapping `gd` are enabled to invoke :GoDef for the
CTRL-] key and the mapping `gd` are enabled to invoke :GoDef for the
identifier under the cursor. See |'g:go_def_mapping_enabled'| to disable identifier under the cursor. See |'g:go_def_mapping_enabled'| to disable
them. them. No explicit arguments are supported.
vim-go also keeps a per-window location stack, roughly analogous to how vim-go also keeps a per-window location stack, roughly analogous to how
Vim's internal |tags| functionality works. This is pushed to every time a Vim's internal |tags| functionality works. This is pushed to every time a

View file

@ -33,15 +33,15 @@ command! -nargs=? -complete=dir GoPath call go#path#GoPath(<f-args>)
" target install directory. GoInstallBinaries doesn't install binaries if they " target install directory. GoInstallBinaries doesn't install binaries if they
" exist, to update current binaries pass 1 to the argument. " exist, to update current binaries pass 1 to the argument.
function! s:GoInstallBinaries(updateBinaries) function! s:GoInstallBinaries(updateBinaries)
if $GOPATH == "" && go#util#gopath() == "" let err = s:CheckBinaries()
echohl Error if err != 0
echomsg "vim.go: $GOPATH is not set"
echohl None
return return
endif endif
let err = s:CheckBinaries() if go#path#Default() == ""
if err != 0 echohl Error
echomsg "vim.go: $GOPATH is not set and 'go env GOPATH' returns empty"
echohl None
return return
endif endif

View file

@ -74,8 +74,8 @@ hi def link goTplVariable Special
syn region gotplAction start="{{" end="}}" contains=@gotplLiteral,gotplControl,gotplFunctions,gotplVariable,goTplIdentifier display syn region gotplAction start="{{" end="}}" contains=@gotplLiteral,gotplControl,gotplFunctions,gotplVariable,goTplIdentifier display
syn region gotplAction start="\[\[" end="\]\]" contains=@gotplLiteral,gotplControl,gotplFunctions,gotplVariable display syn region gotplAction start="\[\[" end="\]\]" contains=@gotplLiteral,gotplControl,gotplFunctions,gotplVariable display
syn region goTplComment start="{{/\*" end="\*/}}" display syn region goTplComment start="{{\(- \)\?/\*" end="\*/\( -\)\?}}" display
syn region goTplComment start="\[\[/\*" end="\*/\]\]" display syn region goTplComment start="\[\[\(- \)\?/\*" end="\*/\( -\)\?\]\]" display
hi def link gotplAction PreProc hi def link gotplAction PreProc
hi def link goTplComment Comment hi def link goTplComment Comment

View file

@ -4,14 +4,14 @@
Indent Text Objects Indent Text Objects
INTRODUCTION |idntobj-introduction| INTRODUCTION |indtobj-introduction|
TEXT OBJECTS |idntobj-objects| TEXT OBJECTS |indtobj-objects|
BLANK LINES |idntobj-blanklines| BLANK LINES |indtobj-blanklines|
ABOUT |idntobj-about| ABOUT |indtobj-about|
============================================================================== ==============================================================================
INTRODUCTION *idntobj-introduction* INTRODUCTION *indtobj-introduction*
Vim text objects provide a convenient way to select and operate on various Vim text objects provide a convenient way to select and operate on various
types of objects. These objects include regions surrounded by various types of types of objects. These objects include regions surrounded by various types of
@ -24,7 +24,7 @@ structure can be quickly selected, for example.
============================================================================== ==============================================================================
TEXT OBJECTS *ai* *ii* *aI* *iI* *idntobj-objects* TEXT OBJECTS *ai* *ii* *aI* *iI* *indtobj-objects*
This plugin defines two new text objects. These are very similar - they differ This plugin defines two new text objects. These are very similar - they differ
only in whether they include the line below the block or not. only in whether they include the line below the block or not.
@ -78,7 +78,7 @@ structure.
============================================================================== ==============================================================================
BLANK LINES *idntobj-blanklines* BLANK LINES *indtobj-blanklines*
When scanning code blocks, the plugin usually ignores blank lines. There is an When scanning code blocks, the plugin usually ignores blank lines. There is an
exception to this, however, when the block being selected is not indented. In exception to this, however, when the block being selected is not indented. In
@ -94,7 +94,7 @@ This exceptional behaviour can be disabled by executing the following line
============================================================================== ==============================================================================
ABOUT *idntobj-about* ABOUT *indtobj-about*
vim-indent-object was written by Michael Smith <msmith@msmith.id.au>. The vim-indent-object was written by Michael Smith <msmith@msmith.id.au>. The
project repository is kept at: project repository is kept at:

View file

@ -355,18 +355,18 @@ snippet /// "XML summary comment" b
/// </summary> /// </summary>
endsnippet endsnippet
snippet <p "XML pramameter comment" b snippet <p "XML pramameter comment" w
<param name="${1}">${2}</param> <param name="${1}">${2}</param>
endsnippet endsnippet
snippet <ex "XML exception comment" b snippet <ex "XML exception comment" w
<exception cref="${1:System.Exception}">${2}</exception> <exception cref="${1:System.Exception}">${2}</exception>
endsnippet endsnippet
snippet <r "XML returns comment" b snippet <r "XML returns comment" w
<returns>$0</returns> <returns>$0</returns>
endsnippet endsnippet
snippet <c "XML code comment" b snippet <c "XML code comment" w
<code>$0</code> <code>$0</code>
endsnippet endsnippet

View file

@ -0,0 +1 @@
extends html, javascript, css

View file

@ -1,7 +1,9 @@
# module and export all # module
snippet mod snippet mod
-module(${1:`vim_snippets#Filename('', 'my')`}). -module(${1:`vim_snippets#Filename()`}).
# module and export all
snippet modall
-module(${1:`vim_snippets#Filename()`}).
-compile([export_all]). -compile([export_all]).
start() -> start() ->
@ -73,7 +75,7 @@ snippet %p
%% @private %% @private
# OTP application # OTP application
snippet application snippet application
-module(${1:`vim_snippets#Filename('', 'my')`}). -module(${1:`vim_snippets#Filename()`}).
-behaviour(application). -behaviour(application).
@ -91,7 +93,7 @@ snippet application
ok. ok.
# OTP supervisor # OTP supervisor
snippet supervisor snippet supervisor
-module(${1:`vim_snippets#Filename('', 'my')`}). -module(${1:`vim_snippets#Filename()`}).
-behaviour(supervisor). -behaviour(supervisor).
@ -114,7 +116,7 @@ snippet supervisor
{ok, {RestartStrategy, Children}}. {ok, {RestartStrategy, Children}}.
# OTP gen_server # OTP gen_server
snippet gen_server snippet gen_server
-module(${0:`vim_snippets#Filename('', 'my')`}). -module(${0:`vim_snippets#Filename()`}).
-behaviour(gen_server). -behaviour(gen_server).
@ -170,7 +172,7 @@ snippet gen_server
%%%=================================================================== %%%===================================================================
# OTP gen_fsm # OTP gen_fsm
snippet gen_fsm snippet gen_fsm
-module(${0:`vim_snippets#Filename('', 'my')`}). -module(${0:`vim_snippets#Filename()`}).
-behaviour(gen_fsm). -behaviour(gen_fsm).
@ -348,7 +350,7 @@ snippet gen_fsm
%%%=================================================================== %%%===================================================================
# OTP gen_event # OTP gen_event
snippet gen_event snippet gen_event
-module(${0:`vim_snippets#Filename('', 'my')`}). -module(${0:`vim_snippets#Filename()`}).
-behaviour(gen_event). -behaviour(gen_event).
@ -484,7 +486,7 @@ snippet gen_event
%%%=================================================================== %%%===================================================================
# EUnit snippets # EUnit snippets
snippet eunit snippet eunit
-module(${1:`vim_snippets#Filename('', 'my')`}). -module(${1:`vim_snippets#Filename()`}).
-include_lib("eunit/include/eunit.hrl"). -include_lib("eunit/include/eunit.hrl").
${0} ${0}
@ -515,7 +517,7 @@ snippet asexc
?assertException(${1:Class}, ${2:Pattern}, ${0:Expression}) ?assertException(${1:Class}, ${2:Pattern}, ${0:Expression})
# common_test test_SUITE # common_test test_SUITE
snippet testsuite snippet testsuite
-module(${0:`vim_snippets#Filename('', 'my')`}). -module(${0:`vim_snippets#Filename()`}).
-include_lib("common_test/include/ct.hrl"). -include_lib("common_test/include/ct.hrl").