mirror of
1
0
Fork 0

Updated plugins

This commit is contained in:
Amir Salihefendic 2019-01-08 11:11:54 +01:00
parent 96b46f56ae
commit 1d42b63013
55 changed files with 1669 additions and 675 deletions

View File

@ -137,9 +137,7 @@ function! ale_linters#elm#make#ParseMessageItem(item) abort
endif endif
endfunction endfunction
" Return the command to execute the linter in the projects directory. function! ale_linters#elm#make#GetPackageFile(buffer) abort
" If it doesn't, then this will fail when imports are needed.
function! ale_linters#elm#make#GetCommand(buffer) abort
let l:elm_json = ale#path#FindNearestFile(a:buffer, 'elm.json') let l:elm_json = ale#path#FindNearestFile(a:buffer, 'elm.json')
if empty(l:elm_json) if empty(l:elm_json)
@ -147,10 +145,55 @@ function! ale_linters#elm#make#GetCommand(buffer) abort
let l:elm_json = ale#path#FindNearestFile(a:buffer, 'elm-package.json') let l:elm_json = ale#path#FindNearestFile(a:buffer, 'elm-package.json')
endif endif
return l:elm_json
endfunction
function! ale_linters#elm#make#IsVersionGte19(buffer) abort
let l:elm_json = ale_linters#elm#make#GetPackageFile(a:buffer)
if l:elm_json =~# '-package'
return 0
else
return 1
endif
endfunction
function! ale_linters#elm#make#GetRootDir(buffer) abort
let l:elm_json = ale_linters#elm#make#GetPackageFile(a:buffer)
if empty(l:elm_json) if empty(l:elm_json)
return ''
else
return fnamemodify(l:elm_json, ':p:h')
endif
endfunction
function! ale_linters#elm#make#IsTest(buffer) abort
let l:root_dir = ale_linters#elm#make#GetRootDir(a:buffer)
if empty(l:root_dir)
return 0
endif
let l:tests_dir = join([l:root_dir, 'tests', ''], has('win32') ? '\' : '/')
let l:buffer_path = fnamemodify(bufname(a:buffer), ':p')
if stridx(l:buffer_path, l:tests_dir) == 0
return 1
else
return 0
endif
endfunction
" Return the command to execute the linter in the projects directory.
" If it doesn't, then this will fail when imports are needed.
function! ale_linters#elm#make#GetCommand(buffer) abort
let l:root_dir = ale_linters#elm#make#GetRootDir(a:buffer)
if empty(l:root_dir)
let l:dir_set_cmd = '' let l:dir_set_cmd = ''
else else
let l:root_dir = fnamemodify(l:elm_json, ':p:h')
let l:dir_set_cmd = 'cd ' . ale#Escape(l:root_dir) . ' && ' let l:dir_set_cmd = 'cd ' . ale#Escape(l:root_dir) . ' && '
endif endif
@ -161,11 +204,24 @@ function! ale_linters#elm#make#GetCommand(buffer) abort
return l:dir_set_cmd . '%e make --report=json --output=/dev/null %t' return l:dir_set_cmd . '%e make --report=json --output=/dev/null %t'
endfunction endfunction
function! ale_linters#elm#make#GetExecutable(buffer) abort
let l:is_test = ale_linters#elm#make#IsTest(a:buffer)
let l:is_v19 = ale_linters#elm#make#IsVersionGte19(a:buffer)
if l:is_test && l:is_v19
return ale#node#FindExecutable(
\ a:buffer,
\ 'elm_make',
\ ['node_modules/.bin/elm-test', 'node_modules/.bin/elm']
\ )
else
return ale#node#FindExecutable(a:buffer, 'elm_make', ['node_modules/.bin/elm'])
endif
endfunction
call ale#linter#Define('elm', { call ale#linter#Define('elm', {
\ 'name': 'make', \ 'name': 'make',
\ 'executable_callback': ale#node#FindExecutableFunc('elm_make', [ \ 'executable_callback': 'ale_linters#elm#make#GetExecutable',
\ 'node_modules/.bin/elm',
\ ]),
\ 'output_stream': 'both', \ 'output_stream': 'both',
\ 'command_callback': 'ale_linters#elm#make#GetCommand', \ 'command_callback': 'ale_linters#elm#make#GetCommand',
\ 'callback': 'ale_linters#elm#make#Handle' \ 'callback': 'ale_linters#elm#make#Handle'

View File

@ -0,0 +1,29 @@
" Author: Jerko Steiner <https://github.com/jeremija>
" Description: https://github.com/saibing/bingo
call ale#Set('go_bingo_executable', 'bingo')
call ale#Set('go_bingo_options', '--mode stdio')
function! ale_linters#go#bingo#GetCommand(buffer) abort
return '%e' . ale#Pad(ale#Var(a:buffer, 'go_bingo_options'))
endfunction
function! ale_linters#go#bingo#FindProjectRoot(buffer) abort
let l:project_root = ale#path#FindNearestFile(a:buffer, 'go.mod')
let l:mods = ':h'
if empty(l:project_root)
let l:project_root = ale#path#FindNearestDirectory(a:buffer, '.git')
let l:mods = ':h:h'
endif
return !empty(l:project_root) ? fnamemodify(l:project_root, l:mods) : ''
endfunction
call ale#linter#Define('go', {
\ 'name': 'bingo',
\ 'lsp': 'stdio',
\ 'executable_callback': ale#VarFunc('go_bingo_executable'),
\ 'command_callback': 'ale_linters#go#bingo#GetCommand',
\ 'project_root_callback': 'ale_linters#go#bingo#FindProjectRoot',
\})

View File

@ -1,9 +1,15 @@
" Author: Michiel Westerbeek <happylinks@gmail.com> " Author: Michiel Westerbeek <happylinks@gmail.com>
" Description: Linter for GraphQL Schemas " Description: Linter for GraphQL Schemas
function! ale_linters#graphql#gqlint#GetCommand(buffer) abort
return ale#path#BufferCdString(a:buffer)
\ . 'gqlint'
\ . ' --reporter=simple %t'
endfunction
call ale#linter#Define('graphql', { call ale#linter#Define('graphql', {
\ 'name': 'gqlint', \ 'name': 'gqlint',
\ 'executable': 'gqlint', \ 'executable': 'gqlint',
\ 'command': 'gqlint --reporter=simple %t', \ 'command_callback': 'ale_linters#graphql#gqlint#GetCommand',
\ 'callback': 'ale#handlers#unix#HandleAsWarning', \ 'callback': 'ale#handlers#unix#HandleAsWarning',
\}) \})

View File

@ -18,7 +18,7 @@ function! ale_linters#perl#perl#Handle(buffer, lines) abort
return [] return []
endif endif
let l:pattern = '\(.\+\) at \(.\+\) line \(\d\+\)' let l:pattern = '\(..\{-}\) at \(..\{-}\) line \(\d\+\)'
let l:output = [] let l:output = []
let l:basename = expand('#' . a:buffer . ':t') let l:basename = expand('#' . a:buffer . ':t')

View File

@ -48,26 +48,38 @@ endfunction
function! ale#c#ParseCFlags(path_prefix, cflag_line) abort function! ale#c#ParseCFlags(path_prefix, cflag_line) abort
let l:cflags_list = [] let l:cflags_list = []
let l:previous_options = [] let l:previous_options = ''
let l:split_lines = split(a:cflag_line, '-') let l:split_lines = split(a:cflag_line, ' ')
let l:option_index = 0 let l:option_index = 0
while l:option_index < len(l:split_lines) while l:option_index < len(l:split_lines)
let l:option = l:split_lines[l:option_index] let l:option = l:previous_options . l:split_lines[l:option_index]
let l:option_index = l:option_index + 1 let l:option_index = l:option_index + 1
call add(l:previous_options, l:option)
" Check if cflag contained a '-' and should not have been splitted
let l:option_list = split(l:option, '\zs')
if len(l:option_list) > 0 && l:option_list[-1] isnot# ' ' && l:option_index < len(l:split_lines) " Check if cflag contained an unmatched characters and should not have been splitted
let l:option_special = substitute(l:option, '\\"', '', 'g')
let l:option_special = substitute(l:option_special, '[^"''()`]', '', 'g')
let l:option_special = substitute(l:option_special, '""', '', 'g')
let l:option_special = substitute(l:option_special, '''''', '', 'g')
let l:option_special = substitute(l:option_special, '``', '', 'g')
let l:option_special = substitute(l:option_special, '((', '(', 'g')
let l:option_special = substitute(l:option_special, '))', ')', 'g')
let l:option_special = substitute(l:option_special, '()', '', 'g')
if len(l:option_special) > 0 && l:option_index < len(l:split_lines)
let l:previous_options = l:option . ' '
continue continue
endif endif
let l:option = join(l:previous_options, '-') " Check if there was spaces after -D/-I and the flag should not have been splitted
let l:previous_options = [] if l:option is# '-D' || l:option is# '-I'
let l:previous_options = l:option
continue
endif
let l:previous_options = ''
let l:option = '-' . substitute(l:option, '^\s*\(.\{-}\)\s*$', '\1', '')
" Fix relative paths if needed " Fix relative paths if needed
if stridx(l:option, '-I') >= 0 && if stridx(l:option, '-I') >= 0 &&
@ -145,15 +157,17 @@ if !exists('s:compile_commands_cache')
let s:compile_commands_cache = {} let s:compile_commands_cache = {}
endif endif
function! s:GetListFromCompileCommandsFile(compile_commands_file) abort function! s:GetLookupFromCompileCommandsFile(compile_commands_file) abort
let l:empty = [{}, {}]
if empty(a:compile_commands_file) if empty(a:compile_commands_file)
return [] return l:empty
endif endif
let l:time = getftime(a:compile_commands_file) let l:time = getftime(a:compile_commands_file)
if l:time < 0 if l:time < 0
return [] return l:empty
endif endif
let l:key = a:compile_commands_file . ':' . l:time let l:key = a:compile_commands_file . ':' . l:time
@ -162,21 +176,36 @@ function! s:GetListFromCompileCommandsFile(compile_commands_file) abort
return s:compile_commands_cache[l:key] return s:compile_commands_cache[l:key]
endif endif
let l:data = [] let l:raw_data = []
silent! let l:data = json_decode(join(readfile(a:compile_commands_file), '')) silent! let l:raw_data = json_decode(join(readfile(a:compile_commands_file), ''))
if !empty(l:data) let l:file_lookup = {}
let s:compile_commands_cache[l:key] = l:data let l:dir_lookup = {}
return l:data for l:entry in l:raw_data
let l:basename = tolower(fnamemodify(l:entry.file, ':t'))
let l:file_lookup[l:basename] = get(l:file_lookup, l:basename, []) + [l:entry]
let l:dirbasename = tolower(fnamemodify(l:entry.directory, ':p:h:t'))
let l:dir_lookup[l:dirbasename] = get(l:dir_lookup, l:basename, []) + [l:entry]
endfor
if !empty(l:file_lookup) && !empty(l:dir_lookup)
let l:result = [l:file_lookup, l:dir_lookup]
let s:compile_commands_cache[l:key] = l:result
return l:result
endif endif
return [] return l:empty
endfunction endfunction
function! ale#c#ParseCompileCommandsFlags(buffer, dir, json_list) abort function! ale#c#ParseCompileCommandsFlags(buffer, dir, file_lookup, dir_lookup) abort
" Search for an exact file match first. " Search for an exact file match first.
for l:item in a:json_list let l:basename = tolower(expand('#' . a:buffer . ':t'))
let l:file_list = get(a:file_lookup, l:basename, [])
for l:item in l:file_list
if bufnr(l:item.file) is a:buffer if bufnr(l:item.file) is a:buffer
return ale#c#ParseCFlags(a:dir, l:item.command) return ale#c#ParseCFlags(a:dir, l:item.command)
endif endif
@ -185,7 +214,10 @@ function! ale#c#ParseCompileCommandsFlags(buffer, dir, json_list) abort
" Look for any file in the same directory if we can't find an exact match. " Look for any file in the same directory if we can't find an exact match.
let l:dir = ale#path#Simplify(expand('#' . a:buffer . ':p:h')) let l:dir = ale#path#Simplify(expand('#' . a:buffer . ':p:h'))
for l:item in a:json_list let l:dirbasename = tolower(expand('#' . a:buffer . ':p:h:t'))
let l:dir_list = get(a:dir_lookup, l:dirbasename, [])
for l:item in l:dir_list
if ale#path#Simplify(fnamemodify(l:item.file, ':h')) is? l:dir if ale#path#Simplify(fnamemodify(l:item.file, ':h')) is? l:dir
return ale#c#ParseCFlags(a:dir, l:item.command) return ale#c#ParseCFlags(a:dir, l:item.command)
endif endif
@ -196,9 +228,11 @@ endfunction
function! ale#c#FlagsFromCompileCommands(buffer, compile_commands_file) abort function! ale#c#FlagsFromCompileCommands(buffer, compile_commands_file) abort
let l:dir = ale#path#Dirname(a:compile_commands_file) let l:dir = ale#path#Dirname(a:compile_commands_file)
let l:json_list = s:GetListFromCompileCommandsFile(a:compile_commands_file) let l:lookups = s:GetLookupFromCompileCommandsFile(a:compile_commands_file)
let l:file_lookup = l:lookups[0]
let l:dir_lookup = l:lookups[1]
return ale#c#ParseCompileCommandsFlags(a:buffer, l:dir, l:json_list) return ale#c#ParseCompileCommandsFlags(a:buffer, l:dir, l:file_lookup, l:dir_lookup)
endfunction endfunction
function! ale#c#GetCFlags(buffer, output) abort function! ale#c#GetCFlags(buffer, output) abort

View File

@ -509,6 +509,12 @@ function! ale#completion#GetCompletions() abort
return return
endif endif
call ale#completion#AlwaysGetCompletions()
endfunction
" This function can be used to manually trigger autocomplete, even when
" g:ale_completion_enabled is set to false
function! ale#completion#AlwaysGetCompletions() abort
let [l:line, l:column] = getcurpos()[1:2] let [l:line, l:column] = getcurpos()[1:2]
let l:prefix = ale#completion#GetPrefix(&filetype, l:line, l:column) let l:prefix = ale#completion#GetPrefix(&filetype, l:line, l:column)

View File

@ -86,7 +86,7 @@ function! s:OnReady(linter, lsp_details, line, column, options, ...) abort
let l:request_id = ale#lsp#Send(l:id, l:message) let l:request_id = ale#lsp#Send(l:id, l:message)
let s:go_to_definition_map[l:request_id] = { let s:go_to_definition_map[l:request_id] = {
\ 'open_in_tab': get(a:options, 'open_in_tab', 0), \ 'open_in': get(a:options, 'open_in', 'current-buffer'),
\} \}
endfunction endfunction

View File

@ -315,10 +315,10 @@ function! s:RunFixer(options) abort
\ ? call(l:Function, [l:buffer, a:options.output]) \ ? call(l:Function, [l:buffer, a:options.output])
\ : call(l:Function, [l:buffer, a:options.output, copy(l:input)]) \ : call(l:Function, [l:buffer, a:options.output, copy(l:input)])
else else
" Chained commands accept (buffer, [input]) " Chained commands accept (buffer, [done, input])
let l:result = ale#util#FunctionArgCount(l:Function) == 1 let l:result = ale#util#FunctionArgCount(l:Function) == 1
\ ? call(l:Function, [l:buffer]) \ ? call(l:Function, [l:buffer])
\ : call(l:Function, [l:buffer, copy(l:input)]) \ : call(l:Function, [l:buffer, v:null, copy(l:input)])
endif endif
if type(l:result) is v:t_number && l:result == 0 if type(l:result) is v:t_number && l:result == 0

View File

@ -4,22 +4,28 @@
call ale#Set('python_black_executable', 'black') call ale#Set('python_black_executable', 'black')
call ale#Set('python_black_use_global', get(g:, 'ale_use_global_executables', 0)) call ale#Set('python_black_use_global', get(g:, 'ale_use_global_executables', 0))
call ale#Set('python_black_options', '') call ale#Set('python_black_options', '')
call ale#Set('python_black_auto_pipenv', 0)
function! ale#fixers#black#GetExecutable(buffer) abort
if (ale#Var(a:buffer, 'python_auto_pipenv') || ale#Var(a:buffer, 'python_black_auto_pipenv'))
\ && ale#python#PipenvPresent(a:buffer)
return 'pipenv'
endif
return ale#python#FindExecutable(a:buffer, 'python_black', ['black'])
endfunction
function! ale#fixers#black#Fix(buffer) abort function! ale#fixers#black#Fix(buffer) abort
let l:executable = ale#python#FindExecutable( let l:executable = ale#fixers#black#GetExecutable(a:buffer)
\ a:buffer,
\ 'python_black',
\ ['black'],
\)
if !executable(l:executable) let l:exec_args = l:executable =~? 'pipenv$'
return 0 \ ? ' run black'
endif \ : ''
let l:options = ale#Var(a:buffer, 'python_black_options') let l:options = ale#Var(a:buffer, 'python_black_options')
return { return {
\ 'command': ale#Escape(l:executable) \ 'command': ale#Escape(l:executable) . l:exec_args
\ . (!empty(l:options) ? ' ' . l:options : '') \ . (!empty(l:options) ? ' ' . l:options : '')
\ . ' -', \ . ' -',
\} \}

View File

@ -1,7 +1,7 @@
" Author: w0rp <devw0rp@gmail.com> " Author: w0rp <devw0rp@gmail.com>
" Description: Generic functions for fixing files with. " Description: Generic functions for fixing files with.
function! ale#fixers#generic#RemoveTrailingBlankLines(buffer, lines) abort function! ale#fixers#generic#RemoveTrailingBlankLines(buffer, done, lines) abort
let l:end_index = len(a:lines) - 1 let l:end_index = len(a:lines) - 1
while l:end_index > 0 && empty(a:lines[l:end_index]) while l:end_index > 0 && empty(a:lines[l:end_index])
@ -12,7 +12,7 @@ function! ale#fixers#generic#RemoveTrailingBlankLines(buffer, lines) abort
endfunction endfunction
" Remove all whitespaces at the end of lines " Remove all whitespaces at the end of lines
function! ale#fixers#generic#TrimWhitespace(buffer, lines) abort function! ale#fixers#generic#TrimWhitespace(buffer, done, lines) abort
let l:index = 0 let l:index = 0
let l:lines_new = range(len(a:lines)) let l:lines_new = range(len(a:lines))

View File

@ -2,7 +2,7 @@
" Description: Generic fixer functions for Python. " Description: Generic fixer functions for Python.
" Add blank lines before control statements. " Add blank lines before control statements.
function! ale#fixers#generic_python#AddLinesBeforeControlStatements(buffer, lines) abort function! ale#fixers#generic_python#AddLinesBeforeControlStatements(buffer, done, lines) abort
let l:new_lines = [] let l:new_lines = []
let l:last_indent_size = 0 let l:last_indent_size = 0
let l:last_line_is_blank = 0 let l:last_line_is_blank = 0
@ -41,7 +41,7 @@ endfunction
" This function breaks up long lines so that autopep8 or other tools can " This function breaks up long lines so that autopep8 or other tools can
" fix the badly-indented code which is produced as a result. " fix the badly-indented code which is produced as a result.
function! ale#fixers#generic_python#BreakUpLongLines(buffer, lines) abort function! ale#fixers#generic_python#BreakUpLongLines(buffer, done, lines) abort
" Default to a maximum line length of 79 " Default to a maximum line length of 79
let l:max_line_length = 79 let l:max_line_length = 79
let l:conf = ale#path#FindNearestFile(a:buffer, 'setup.cfg') let l:conf = ale#path#FindNearestFile(a:buffer, 'setup.cfg')

View File

@ -1,7 +1,7 @@
" Author: w0rp <devw0rp@gmail.com> " Author: w0rp <devw0rp@gmail.com>
" Description: Generic fixer functions for Vim help documents. " Description: Generic fixer functions for Vim help documents.
function! ale#fixers#help#AlignTags(buffer, lines) abort function! ale#fixers#help#AlignTags(buffer, done, lines) abort
let l:new_lines = [] let l:new_lines = []
for l:line in a:lines for l:line in a:lines

View File

@ -14,9 +14,11 @@ endfunction
function! ale#fixers#standard#Fix(buffer) abort function! ale#fixers#standard#Fix(buffer) abort
let l:executable = ale#fixers#standard#GetExecutable(a:buffer) let l:executable = ale#fixers#standard#GetExecutable(a:buffer)
let l:options = ale#Var(a:buffer, 'javascript_standard_options')
return { return {
\ 'command': ale#node#Executable(a:buffer, l:executable) \ 'command': ale#node#Executable(a:buffer, l:executable)
\ . (!empty(l:options) ? ' ' . l:options : '')
\ . ' --fix %t', \ . ' --fix %t',
\ 'read_temporary_file': 1, \ 'read_temporary_file': 1,
\} \}

View File

@ -173,10 +173,6 @@ endfunction
function! ale#job#PrepareCommand(buffer, command) abort function! ale#job#PrepareCommand(buffer, command) abort
let l:wrapper = ale#Var(a:buffer, 'command_wrapper') let l:wrapper = ale#Var(a:buffer, 'command_wrapper')
let l:command = !empty(l:wrapper)
\ ? s:PrepareWrappedCommand(l:wrapper, a:command)
\ : a:command
" The command will be executed in a subshell. This fixes a number of " The command will be executed in a subshell. This fixes a number of
" issues, including reading the PATH variables correctly, %PATHEXT% " issues, including reading the PATH variables correctly, %PATHEXT%
" expansion on Windows, etc. " expansion on Windows, etc.
@ -184,6 +180,17 @@ function! ale#job#PrepareCommand(buffer, command) abort
" NeoVim handles this issue automatically if the command is a String, " NeoVim handles this issue automatically if the command is a String,
" but we'll do this explicitly, so we use the same exact command for both " but we'll do this explicitly, so we use the same exact command for both
" versions. " versions.
let l:command = !empty(l:wrapper)
\ ? s:PrepareWrappedCommand(l:wrapper, a:command)
\ : a:command
" If a custom shell is specified, use that.
if exists('g:ale_shell')
let l:shell_arguments = get(g:, 'ale_shell_arguments', &shellcmdflag)
return split(g:ale_shell) + split(l:shell_arguments) + [l:command]
endif
if has('win32') if has('win32')
return 'cmd /s/c "' . l:command . '"' return 'cmd /s/c "' . l:command . '"'
endif endif

View File

@ -27,6 +27,7 @@ function! ale#references#HandleTSServerResponse(conn_id, response) abort
\ 'filename': l:response_item.file, \ 'filename': l:response_item.file,
\ 'line': l:response_item.start.line, \ 'line': l:response_item.start.line,
\ 'column': l:response_item.start.offset, \ 'column': l:response_item.start.offset,
\ 'match': substitute(l:response_item.lineText, '^\s*\(.\{-}\)\s*$', '\1', ''),
\}) \})
endfor endfor

View File

@ -87,12 +87,25 @@ function! ale#util#GetFunction(string_or_ref) abort
return a:string_or_ref return a:string_or_ref
endfunction endfunction
" Open the file (at the given line).
" options['open_in'] can be:
" current-buffer (default)
" tab
" vertical-split
" horizontal-split
function! ale#util#Open(filename, line, column, options) abort function! ale#util#Open(filename, line, column, options) abort
if get(a:options, 'open_in_tab', 0) let l:open_in = get(a:options, 'open_in', 'current-buffer')
call ale#util#Execute('tabedit +' . a:line . ' ' . fnameescape(a:filename)) let l:args_to_open = '+' . a:line . ' ' . fnameescape(a:filename)
if l:open_in is# 'tab'
call ale#util#Execute('tabedit ' . l:args_to_open)
elseif l:open_in is# 'horizontal-split'
call ale#util#Execute('split ' . l:args_to_open)
elseif l:open_in is# 'vertical-split'
call ale#util#Execute('vsplit ' . l:args_to_open)
elseif bufnr(a:filename) isnot bufnr('') elseif bufnr(a:filename) isnot bufnr('')
" Open another file only if we need to. " Open another file only if we need to.
call ale#util#Execute('edit +' . a:line . ' ' . fnameescape(a:filename)) call ale#util#Execute('edit ' . l:args_to_open)
else else
normal! m` normal! m`
endif endif

View File

@ -7,7 +7,7 @@ Integration Information
The `gometalinter` linter is disabled by default. ALE enables `gofmt`, The `gometalinter` linter is disabled by default. ALE enables `gofmt`,
`golint` and `go vet` by default. It also supports `staticcheck`, `go `golint` and `go vet` by default. It also supports `staticcheck`, `go
build`, `gosimple`, and `golangserver`. build`, `gosimple`, `golangserver`.
To enable `gometalinter`, update |g:ale_linters| as appropriate: To enable `gometalinter`, update |g:ale_linters| as appropriate:
> >
@ -195,5 +195,21 @@ g:ale_go_golangci_lint_package *g:ale_go_golangci_lint_package*
current file. current file.
===============================================================================
bingo *ale-go-bingo*
g:ale_go_bingo_executable *g:ale_go_bingo_executable*
*b:ale_go_bingo_executable*
Type: |String|
Default: `'go-bingo'`
Location of the go-bingo binary file.
g:ale_go_bingo_options *g:ale_go_bingo_options*
*b:ale_go_bingo_options*
Type: |String|
Default: `''`
=============================================================================== ===============================================================================
vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl:

View File

@ -75,7 +75,7 @@ g:ale_python_black_executable *g:ale_python_black_executable*
See |ale-integrations-local-executables| See |ale-integrations-local-executables|
autopep8
g:ale_python_black_options *g:ale_python_black_options* g:ale_python_black_options *g:ale_python_black_options*
*b:ale_python_black_options* *b:ale_python_black_options*
Type: |String| Type: |String|
@ -92,6 +92,15 @@ g:ale_python_black_use_global *g:ale_python_black_use_global*
See |ale-integrations-local-executables| See |ale-integrations-local-executables|
g:ale_python_black_auto_pipenv *g:ale_python_black_auto_pipenv*
*b:ale_python_black_auto_pipenv*
Type: |Number|
Default: `0`
Detect whether the file is inside a pipenv, and set the executable to `pipenv`
if true. This is overridden by a manually-set executable.
=============================================================================== ===============================================================================
flake8 *ale-python-flake8* flake8 *ale-python-flake8*

View File

@ -118,6 +118,7 @@ CONTENTS *ale-contents*
staticcheck.........................|ale-go-staticcheck| staticcheck.........................|ale-go-staticcheck|
golangserver........................|ale-go-golangserver| golangserver........................|ale-go-golangserver|
golangci-lint.......................|ale-go-golangci-lint| golangci-lint.......................|ale-go-golangci-lint|
bingo...............................|ale-go-bingo|
graphql...............................|ale-graphql-options| graphql...............................|ale-graphql-options|
eslint..............................|ale-graphql-eslint| eslint..............................|ale-graphql-eslint|
gqlint..............................|ale-graphql-gqlint| gqlint..............................|ale-graphql-gqlint|
@ -438,7 +439,7 @@ Notes:
* FusionScript: `fusion-lint` * FusionScript: `fusion-lint`
* Git Commit Messages: `gitlint` * Git Commit Messages: `gitlint`
* GLSL: glslang, `glslls` * GLSL: glslang, `glslls`
* Go: `gofmt`, `goimports`, `go mod`!!, `go vet`!!, `golint`, `gotype`!!, `gometalinter`!!, `go build`!!, `gosimple`!!, `staticcheck`!!, `golangserver`, `golangci-lint`!! * Go: `gofmt`, `goimports`, `go mod`!!, `go vet`!!, `golint`, `gotype`!!, `gometalinter`!!, `go build`!!, `gosimple`!!, `staticcheck`!!, `golangserver`, `golangci-lint`!!, `bingo`
* GraphQL: `eslint`, `gqlint`, `prettier` * GraphQL: `eslint`, `gqlint`, `prettier`
* Hack: `hack`, `hackfmt`, `hhast` * Hack: `hack`, `hackfmt`, `hhast`
* Haml: `haml-lint` * Haml: `haml-lint`
@ -675,10 +676,14 @@ The values for `g:ale_fixers` can be a list of |String|, |Funcref|, or
for a function set in the ALE fixer registry. for a function set in the ALE fixer registry.
Each function for fixing errors must accept either one argument `(buffer)` or Each function for fixing errors must accept either one argument `(buffer)` or
two arguments `(buffer, lines)`, representing the buffer being fixed and the three arguments `(buffer, done, lines)`, representing the buffer being fixed,
lines to fix. The functions must return either `0`, for changing nothing, a a function to call with results, and the lines to fix. The functions must
|List| for new lines to set, or a |Dictionary| for describing a command to be return either `0`, for changing nothing, a |List| for new lines to set, a
run in the background. |Dictionary| for describing a command to be run in the background, or `v:true`
for indicating that results will be provided asynchronously via the `done`
callback.
NOTE: The `done` function has not been implemented yet.
Functions receiving a variable number of arguments will not receive the second Functions receiving a variable number of arguments will not receive the second
argument `lines`. Functions should name two arguments if the `lines` argument argument `lines`. Functions should name two arguments if the `lines` argument
@ -816,6 +821,9 @@ with |g:ale_completion_max_suggestions|.
If you don't like some of the suggestions you see, you can filter them out If you don't like some of the suggestions you see, you can filter them out
with |g:ale_completion_excluded_words| or |b:ale_completion_excluded_words|. with |g:ale_completion_excluded_words| or |b:ale_completion_excluded_words|.
The |ALEComplete| command can be used to show completion suggestions manually,
even when |g:ale_completion_enabled| is set to `0`.
*ale-completion-completopt-bug* *ale-completion-completopt-bug*
ALE implements completion as you type by temporarily adjusting |completeopt| ALE implements completion as you type by temporarily adjusting |completeopt|
@ -836,6 +844,8 @@ information returned by LSP servers. The following commands are supported:
|ALEGoToDefinition| - Open the definition of the symbol under the cursor. |ALEGoToDefinition| - Open the definition of the symbol under the cursor.
|ALEGoToDefinitionInTab| - The same, but for opening the file in a new tab. |ALEGoToDefinitionInTab| - The same, but for opening the file in a new tab.
|ALEGoToDefinitionInSplit| - The same, but in a new split.
|ALEGoToDefinitionInVSplit| - The same, but in a new vertical split.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
@ -1787,6 +1797,33 @@ g:ale_set_signs *g:ale_set_signs*
To limit the number of signs ALE will set, see |g:ale_max_signs|. To limit the number of signs ALE will set, see |g:ale_max_signs|.
g:ale_shell *g:ale_shell*
Type: |String|
Default: not set
Override the shell used by ALE for executing commands. ALE uses 'shell' by
default, but falls back in `/bin/sh` if the default shell looks like `fish`
or `pwsh`, which are not compatible with all of the commands run by ALE. The
shell specified with this option will be used even if it might not work in
all cases.
For Windows, ALE uses `cmd` when this option isn't set. Setting this option
will apply shell escaping to the command string, even on Windows.
NOTE: Consider setting |g:ale_shell_arguments| if this option is defined.
g:ale_shell_arguments *g:ale_shell_arguments*
Type: |String|
Default: not set
This option specifies the arguments to use for executing a command with a
custom shell, per |g:ale_shell|. If this option is not set, 'shellcmdflag'
will be used instead.
g:ale_sign_column_always *g:ale_sign_column_always* g:ale_sign_column_always *g:ale_sign_column_always*
Type: |Number| Type: |Number|
@ -2202,6 +2239,17 @@ ALE will use to search for Python executables.
=============================================================================== ===============================================================================
8. Commands/Keybinds *ale-commands* 8. Commands/Keybinds *ale-commands*
ALEComplete *ALEComplete*
Manually trigger LSP autocomplete and show the menu. Works only when called
from insert mode. >
inoremap <silent> <C-Space> <C-\><C-O>:AleComplete<CR>
<
A plug mapping `<Plug>(ale_complete)` is defined for this command. >
imap <C-Space> <Plug>(ale_complete)
<
ALEDocumentation *ALEDocumentation* ALEDocumentation *ALEDocumentation*
Similar to the |ALEHover| command, retrieve documentation information for Similar to the |ALEHover| command, retrieve documentation information for
@ -2262,6 +2310,22 @@ ALEGoToDefinitionInTab *ALEGoToDefinitionInTab*
command. command.
ALEGoToDefinitionInSplit *ALEGoToDefinitionInSplit*
The same as |ALEGoToDefinition|, but opens results in a new split.
A plug mapping `<Plug>(ale_go_to_definition_in_split)` is defined for this
command.
ALEGoToDefinitionInVSplit *ALEGoToDefinitionInVSplit*
The same as |ALEGoToDefinition|, but opens results in a new vertical split.
A plug mapping `<Plug>(ale_go_to_definition_in_vsplit)` is defined for this
command.
ALEHover *ALEHover* ALEHover *ALEHover*
Print brief information about the symbol under the cursor, taken from any Print brief information about the symbol under the cursor, taken from any

View File

@ -188,7 +188,9 @@ command! -bar ALEFixSuggest :call ale#fix#registry#Suggest(&filetype)
" Go to definition for tsserver and LSP " Go to definition for tsserver and LSP
command! -bar ALEGoToDefinition :call ale#definition#GoTo({}) command! -bar ALEGoToDefinition :call ale#definition#GoTo({})
command! -bar ALEGoToDefinitionInTab :call ale#definition#GoTo({'open_in_tab': 1}) command! -bar ALEGoToDefinitionInTab :call ale#definition#GoTo({'open_in': 'tab'})
command! -bar ALEGoToDefinitionInSplit :call ale#definition#GoTo({'open_in': 'horizontal-split'})
command! -bar ALEGoToDefinitionInVSplit :call ale#definition#GoTo({'open_in': 'vertical-split'})
" Find references for tsserver and LSP " Find references for tsserver and LSP
command! -bar ALEFindReferences :call ale#references#Find() command! -bar ALEFindReferences :call ale#references#Find()
@ -202,6 +204,8 @@ command! -bar ALEDocumentation :call ale#hover#ShowDocumentationAtCursor()
" Search for appearances of a symbol, such as a type name or function name. " Search for appearances of a symbol, such as a type name or function name.
command! -nargs=1 ALESymbolSearch :call ale#symbol#Search(<q-args>) command! -nargs=1 ALESymbolSearch :call ale#symbol#Search(<q-args>)
command! -bar ALEComplete :call ale#completion#AlwaysGetCompletions()
" <Plug> mappings for commands " <Plug> mappings for commands
nnoremap <silent> <Plug>(ale_previous) :ALEPrevious<Return> nnoremap <silent> <Plug>(ale_previous) :ALEPrevious<Return>
nnoremap <silent> <Plug>(ale_previous_wrap) :ALEPreviousWrap<Return> nnoremap <silent> <Plug>(ale_previous_wrap) :ALEPreviousWrap<Return>
@ -222,9 +226,12 @@ nnoremap <silent> <Plug>(ale_detail) :ALEDetail<Return>
nnoremap <silent> <Plug>(ale_fix) :ALEFix<Return> nnoremap <silent> <Plug>(ale_fix) :ALEFix<Return>
nnoremap <silent> <Plug>(ale_go_to_definition) :ALEGoToDefinition<Return> nnoremap <silent> <Plug>(ale_go_to_definition) :ALEGoToDefinition<Return>
nnoremap <silent> <Plug>(ale_go_to_definition_in_tab) :ALEGoToDefinitionInTab<Return> nnoremap <silent> <Plug>(ale_go_to_definition_in_tab) :ALEGoToDefinitionInTab<Return>
nnoremap <silent> <Plug>(ale_go_to_definition_in_split) :ALEGoToDefinitionInSplit<Return>
nnoremap <silent> <Plug>(ale_go_to_definition_in_vsplit) :ALEGoToDefinitionInVSplit<Return>
nnoremap <silent> <Plug>(ale_find_references) :ALEFindReferences<Return> nnoremap <silent> <Plug>(ale_find_references) :ALEFindReferences<Return>
nnoremap <silent> <Plug>(ale_hover) :ALEHover<Return> nnoremap <silent> <Plug>(ale_hover) :ALEHover<Return>
nnoremap <silent> <Plug>(ale_documentation) :ALEDocumentation<Return> nnoremap <silent> <Plug>(ale_documentation) :ALEDocumentation<Return>
inoremap <silent> <Plug>(ale_complete) <C-\><C-O>:ALEComplete<Return>
" Set up autocmd groups now. " Set up autocmd groups now.
call ale#events#Init() call ale#events#Init()

File diff suppressed because it is too large Load Diff

View File

@ -29,9 +29,9 @@ that are part of Git repositories).
*fugitive-:Glcd* *fugitive-:Glcd*
:Glcd [directory] |:lcd| relative to the repository. :Glcd [directory] |:lcd| relative to the repository.
*fugitive-:Gstatus* *fugitive-:Gstatus* *fugitive-:G*
:Gstatus Bring up the output of git-status in the preview :Gstatus Bring up a git-status inspired summary in the preview
window. The following maps, which work on the cursor :G window. The following maps, which work on the cursor
line file where sensible, are provided: line file where sensible, are provided:
g? show this help g? show this help
@ -40,42 +40,48 @@ that are part of Git repositories).
<CR> |:Gedit| <CR> |:Gedit|
- |:Git| add - |:Git| add
- |:Git| reset (staged files) - |:Git| reset (staged files)
a Show alternative format
ca |:Gcommit| --amend ca |:Gcommit| --amend
cc |:Gcommit| cc |:Gcommit|
ce |:Gcommit| --amend --no-edit ce |:Gcommit| --amend --no-edit
cw |:Gcommit| --amend --only cw |:Gcommit| --amend --only
cva |:Gcommit| --verbose --amend cva |:Gcommit| --verbose --amend
cvc |:Gcommit| --verbose cvc |:Gcommit| --verbose
cf |:Gcommit| --fixup=
cs |:Gcommit| --squash=
cA |:Gcommit| --edit --squash=
= toggle inline diff
< show inline diff
> hide inline diff
D |:Gdiff| D |:Gdiff|
ds |:Gsdiff| ds |:Gsdiff|
dp |:Git!| diff (p for patch; use :Gw to apply) dp |:Git!| diff (p for patch; use :Gw to apply)
dp |:Git| add --intent-to-add (untracked files) dp |:Git| add --intent-to-add (untracked files)
dv |:Gvdiff| dv |:Gvdiff|
gO |:Gvsplit|
O |:Gtabedit| O |:Gtabedit|
o |:Gsplit| o |:Gsplit|
P |:Git| add --patch P |:Git| add --patch
P |:Git| reset --patch (staged files) P |:Git| reset --patch (staged files)
s |:Git| add
u |:Git| reset
X |:Git| checkout
X |:Git| checkout HEAD (staged files)
X |:Git| clean (untracked files)
X |:Git| rm (unmerged files)
q close status q close status
r reload status R reload status
S |:Gvsplit|
U |:Git| checkout
U |:Git| checkout HEAD (staged files)
U |:Git| clean (untracked files)
U |:Git| rm (unmerged files)
. enter |:| command line with file prepopulated . enter |:| command line with file prepopulated
*fugitive-:Gcommit* *fugitive-:Gcommit*
:Gcommit [args] A wrapper around git-commit. If there is nothing :Gcommit [args] A wrapper around git-commit. Unless the arguments
to commit, |:Gstatus| is called instead. Unless the given would skip the invocation of an editor (e.g.,
arguments given would skip the invocation of an editor -m), a split window will be used to obtain a commit
(e.g., -m), a split window will be used to obtain a message, or a new tab if -v is given. Write and close
commit message, or a new tab if -v is given. Write that window (:wq or |:Gwrite|) to finish the commit.
and close that window (:wq or |:Gwrite|) to finish the Unlike when running the actual git-commit command, it
commit. Unlike when running the actual git-commit is possible (but unadvisable) to alter the index with
command, it is possible (but unadvisable) to alter the commands like git-add and git-reset while a commit
index with commands like git-add and git-reset while a message is pending.
commit message is pending.
*fugitive-:Gmerge* *fugitive-:Gmerge*
:Gmerge [args] Calls git-merge and loads errors and conflicted files :Gmerge [args] Calls git-merge and loads errors and conflicted files
@ -90,7 +96,7 @@ that are part of Git repositories).
*fugitive-:Grebase* *fugitive-:Grebase*
:Grebase [args] Like |:Gmerge|, but for git-rebase. Interactive :Grebase [args] Like |:Gmerge|, but for git-rebase. Interactive
rebase not supported. rebase is experimentally supported.
*fugitive-:Gpush* *fugitive-:Gpush*
:Gpush [args] Invoke git-push, load the results into the |quickfix| :Gpush [args] Invoke git-push, load the results into the |quickfix|
@ -108,17 +114,18 @@ that are part of Git repositories).
:Glgrep[!] [args] |:lgrep|[!] with git-grep as 'grepprg'. :Glgrep[!] [args] |:lgrep|[!] with git-grep as 'grepprg'.
*fugitive-:Glog* *fugitive-:Glog*
:Glog [args] Load all previous revisions of the current file into :Glog [args] Load the commit history into the |quickfix| list.
the |quickfix| list. Additional git-log arguments can Additional git-log arguments can be given (for
be given (for example, --reverse). If "--" appears as example, --reverse). Provide "--" in the argument
an argument, no file specific filtering is done, and list to target all commits. Otherwise, only commits
previous commits rather than previous file revisions changing the current file will be targeted. This
are loaded. special casing is slated to be removed.
:{range}Glog [args] Use git-log -L to load previous revisions of the given :{range}Glog [args] Use git-log -L to load previous revisions of the given
range of the current file into the |quickfix| list. range of the current file into the |quickfix| list.
The cursor is positioned on the first line of the The cursor is positioned on the first line of the
first diff hunk for each commit. first diff hunk for each commit. Use :0Glog to target
the entire file.
*fugitive-:Gllog* *fugitive-:Gllog*
:Gllog [args] Like |:Glog|, but use the location list instead of the :Gllog [args] Like |:Glog|, but use the location list instead of the
@ -284,8 +291,8 @@ These maps are available in committed Git objects.
o Jump to the |fugitive-object| under the cursor in a o Jump to the |fugitive-object| under the cursor in a
new split. new split.
*fugitive-S* *fugitive-gO*
S Jump to the |fugitive-object| under the cursor in a gO Jump to the |fugitive-object| under the cursor in a
new vertical split. new vertical split.
*fugitive-O* *fugitive-O*
@ -293,7 +300,8 @@ O Jump to the |fugitive-object| under the cursor in a
new tab. new tab.
*fugitive--* *fugitive--*
- Go to the tree containing the current tree or blob. - Go to the tree containing the current tree or blob
(i.e, the parent directory).
*fugitive-~* *fugitive-~*
~ Go to the current file in the [count]th first ~ Go to the current file in the [count]th first

View File

@ -72,8 +72,14 @@ function! FugitivePrepare(...) abort
return call('fugitive#Prepare', a:000) return call('fugitive#Prepare', a:000)
endfunction endfunction
function! FugitiveConfig(key, ...) abort function! FugitiveConfig(...) abort
return fugitive#Config(a:key, FugitiveGitDir(a:0 ? a:1 : -1)) if a:0 == 2 && type(a:2) != type({})
return fugitive#Config(a:1, FugitiveGitDir(a:2))
elseif a:0 == 1 && a:1 !~# '^[[:alnum:]-]\+\.'
return fugitive#Config(FugitiveGitDir(a:1))
else
return call('fugitive#Config', a:000)
endif
endfunction endfunction
function! FugitiveRemoteUrl(...) abort function! FugitiveRemoteUrl(...) abort
@ -250,6 +256,10 @@ augroup fugitive
\ call fugitive#MapCfile() | \ call fugitive#MapCfile() |
\ endif \ endif
autocmd FileType gitcommit autocmd FileType gitcommit
\ if exists('b:git_dir') |
\ call fugitive#MapCfile('fugitive#MessageCfile()') |
\ endif
autocmd FileType fugitive
\ if exists('b:git_dir') | \ if exists('b:git_dir') |
\ call fugitive#MapCfile('fugitive#StatusCfile()') | \ call fugitive#MapCfile('fugitive#StatusCfile()') |
\ endif \ endif

View File

@ -0,0 +1,36 @@
if exists("b:current_syntax")
finish
endif
syn sync fromstart
syn spell notoplevel
syn include @fugitiveDiff syntax/diff.vim
syn match fugitiveHeader /^[A-Z][a-z][^:]*:/ nextgroup=fugitiveHash,fugitiveSymbolicRef skipwhite
syn region fugitiveSection start=/^\%(.*(\d\+)$\)\@=/ contains=fugitiveHeading end=/^$\@=/
syn match fugitiveHeading /^[A-Z][a-z][^:]*\ze (\d\+)$/ contains=fugitivePreposition contained nextgroup=fugitiveCount skipwhite
syn match fugitiveCount /(\d\+)/hs=s+1,he=e-1 contained
syn match fugitivePreposition /\<\%([io]nto\|from\|to\|Rebasing\%( detached\)\=\)\>/ transparent contained nextgroup=fugitiveHash,fugitiveSymbolicRef skipwhite
syn match fugitiveInstruction /^\l\l\+\>/ contained containedin=fugitiveSection nextgroup=fugitiveHash skipwhite
syn match fugitiveDone /^done\>/ contained containedin=fugitiveSection nextgroup=fugitiveHash skipwhite
syn match fugitiveStop /^stop\>/ contained containedin=fugitiveSection nextgroup=fugitiveHash skipwhite
syn match fugitiveModifier /^[MADRCU?]\{1,2} / contained containedin=fugitiveSection
syn match FugitiveSymbolicRef /\.\@!\%(\.\.\@!\|[^[:space:][:cntrl:]\:.]\)\+\.\@<!/ contained
syn match fugitiveHash /^\x\{4,\}\>/ contained containedin=fugitiveSection
syn match fugitiveHash /\<\x\{4,\}\>/ contained
syn region fugitiveHunk start=/^\%(@@ -\)\@=/ end=/^\%([A-Za-z?@]\|$\)\@=/ contains=@fugitiveDiff containedin=fugitiveSection fold
hi def link fugitiveHeader Label
hi def link fugitiveHeading PreProc
hi def link fugitiveModifier Type
hi def link fugitiveInstruction Type
hi def link fugitiveStop Function
hi def link fugitiveHash Identifier
hi def link fugitiveSymbolicRef Function
hi def link fugitiveCount Number
let b:current_syntax = "fugitive"

View File

@ -1,2 +1,5 @@
.local/ .local/
.cache/
.dlv/
.git/ .git/
.viminfo

View File

@ -1,5 +1,9 @@
## unplanned ## unplanned
BACKWARDS INCOMPATABILITIES:
* g:go_highlight_fuction_arguments is renamed to g:go_highlight_function_parameters
[[GH-2117]](https://github.com/fatih/vim-go/pull/2117)
IMPROVEMENTS: IMPROVEMENTS:
* Disable `g:go_gocode_propose_source` by default. * Disable `g:go_gocode_propose_source` by default.
[[GH-2050]](https://github.com/fatih/vim-go/pull/2050) [[GH-2050]](https://github.com/fatih/vim-go/pull/2050)
@ -15,6 +19,10 @@ IMPROVEMENTS:
* Do not require `'autowrite'` or `'autowriteall'` to be set when using * Do not require `'autowrite'` or `'autowriteall'` to be set when using
autocompletion in module mode. autocompletion in module mode.
[[GH-2091]](https://github.com/fatih/vim-go/pull/2091) [[GH-2091]](https://github.com/fatih/vim-go/pull/2091)
* Fix use of g:go_metalinter_command _and_ apply it even when autosaving.
[[GH-2101]](https://github.com/fatih/vim-go/pull/2101)
* Report errors in quickfix when Delve fails to start (e.g. compiler errors).
[[GH-2111]](https://github.com/fatih/vim-go/pull/2111)
BUG FIXES: BUG FIXES:
* Fix opening of non-existent file from `:GoDeclsDir` when the current * Fix opening of non-existent file from `:GoDeclsDir` when the current
@ -28,6 +36,13 @@ BUG FIXES:
[[GH-2075]](https://github.com/fatih/vim-go/pull/2075) [[GH-2075]](https://github.com/fatih/vim-go/pull/2075)
* Fix `:GoSameIdsToggle`. * Fix `:GoSameIdsToggle`.
[[GH-2086]](https://github.com/fatih/vim-go/pull/2086) [[GH-2086]](https://github.com/fatih/vim-go/pull/2086)
* Do not set fileencoding or fileformat options or populate from template when
the buffer is not modifiable.
[[GH-2097]](https://github.com/fatih/vim-go/pull/2097)
* Do not clear buffer-local autocmds of other buffers.
[[GH-2109]](https://github.com/fatih/vim-go/pull/2109)
* Highlight return parameter types when g:go_highlight_function_arguments is set.
[[GH-2116]](https://github.com/fatih/vim-go/pull/2116)
## 1.19 - (November 4, 2018) ## 1.19 - (November 4, 2018)

View File

@ -26,9 +26,7 @@ endfunction
function! go#cmd#Build(bang, ...) abort function! go#cmd#Build(bang, ...) abort
" Create our command arguments. go build discards any results when it " Create our command arguments. go build discards any results when it
" compiles multiple packages. So we pass the `errors` package just as an " compiles multiple packages. So we pass the `errors` package just as an
" placeholder with the current folder (indicated with '.'). We also pass -i " placeholder with the current folder (indicated with '.').
" that tries to install the dependencies, this has the side effect that it
" caches the build results, so every other build is faster.
let l:args = let l:args =
\ ['build', '-tags', go#config#BuildTags()] + \ ['build', '-tags', go#config#BuildTags()] +
\ map(copy(a:000), "expand(v:val)") + \ map(copy(a:000), "expand(v:val)") +
@ -63,6 +61,7 @@ function! go#cmd#Build(bang, ...) abort
redraw! redraw!
finally finally
execute cd . fnameescape(dir) execute cd . fnameescape(dir)
let &makeprg = default_makeprg
endtry endtry
let errors = go#list#Get(l:listtype) let errors = go#list#Get(l:listtype)
@ -72,8 +71,6 @@ function! go#cmd#Build(bang, ...) abort
else else
call go#util#EchoSuccess("[build] SUCCESS") call go#util#EchoSuccess("[build] SUCCESS")
endif endif
let &makeprg = default_makeprg
endif endif
endfunction endfunction
@ -169,11 +166,15 @@ function! go#cmd#Run(bang, ...) abort
let l:listtype = go#list#Type("GoRun") let l:listtype = go#list#Type("GoRun")
if l:listtype == "locationlist" try
exe 'lmake!' if l:listtype == "locationlist"
else exe 'lmake!'
exe 'make!' else
endif exe 'make!'
endif
finally
let &makeprg = default_makeprg
endtry
let items = go#list#Get(l:listtype) let items = go#list#Get(l:listtype)
let errors = go#tool#FilterValids(items) let errors = go#tool#FilterValids(items)
@ -184,7 +185,6 @@ function! go#cmd#Run(bang, ...) abort
call go#list#JumpToFirst(l:listtype) call go#list#JumpToFirst(l:listtype)
endif endif
let &makeprg = default_makeprg
endfunction endfunction
" Install installs the package by simple calling 'go install'. If any argument " Install installs the package by simple calling 'go install'. If any argument
@ -226,6 +226,7 @@ function! go#cmd#Install(bang, ...) abort
redraw! redraw!
finally finally
execute cd . fnameescape(dir) execute cd . fnameescape(dir)
let &makeprg = default_makeprg
endtry endtry
let errors = go#list#Get(l:listtype) let errors = go#list#Get(l:listtype)
@ -235,8 +236,6 @@ function! go#cmd#Install(bang, ...) abort
else else
call go#util#EchoSuccess("installed to ". go#path#Default()) call go#util#EchoSuccess("installed to ". go#path#Default())
endif endif
let &makeprg = default_makeprg
endfunction endfunction
" Generate runs 'go generate' in similar fashion to go#cmd#Build() " Generate runs 'go generate' in similar fashion to go#cmd#Build()
@ -255,12 +254,17 @@ function! go#cmd#Generate(bang, ...) abort
let l:listtype = go#list#Type("GoGenerate") let l:listtype = go#list#Type("GoGenerate")
echon "vim-go: " | echohl Identifier | echon "generating ..."| echohl None echon "vim-go: " | echohl Identifier | echon "generating ..."| echohl None
if l:listtype == "locationlist"
silent! exe 'lmake!' try
else if l:listtype == "locationlist"
silent! exe 'make!' silent! exe 'lmake!'
endif else
redraw! silent! exe 'make!'
endif
finally
redraw!
let &makeprg = default_makeprg
endtry
let errors = go#list#Get(l:listtype) let errors = go#list#Get(l:listtype)
call go#list#Window(l:listtype, len(errors)) call go#list#Window(l:listtype, len(errors))
@ -272,7 +276,6 @@ function! go#cmd#Generate(bang, ...) abort
redraws! | echon "vim-go: " | echohl Function | echon "[generate] SUCCESS"| echohl None redraws! | echon "vim-go: " | echohl Function | echon "[generate] SUCCESS"| echohl None
endif endif
let &makeprg = default_makeprg
endfunction endfunction
" --------------------- " ---------------------

View File

@ -388,8 +388,9 @@ function! go#config#HighlightFunctions() abort
return get(g:, 'go_highlight_functions', 0) return get(g:, 'go_highlight_functions', 0)
endfunction endfunction
function! go#config#HighlightFunctionArguments() abort function! go#config#HighlightFunctionParameters() abort
return get(g:, 'go_highlight_function_arguments', 0) " fallback to highlight_function_arguments for backwards compatibility
return get(g:, 'go_highlight_function_parameters', get(g:, 'go_highlight_function_arguments', 0))
endfunction endfunction
function! go#config#HighlightFunctionCalls() abort function! go#config#HighlightFunctionCalls() abort

View File

@ -85,7 +85,7 @@ function! go#coverage#Clear() abort
" remove the autocmd we defined " remove the autocmd we defined
augroup vim-go-coverage augroup vim-go-coverage
autocmd! autocmd! * <buffer>
augroup end augroup end
endfunction endfunction
@ -242,7 +242,7 @@ function! go#coverage#overlay(file) abort
" clear the matches if we leave the buffer " clear the matches if we leave the buffer
augroup vim-go-coverage augroup vim-go-coverage
autocmd! autocmd! * <buffer>
autocmd BufWinLeave <buffer> call go#coverage#Clear() autocmd BufWinLeave <buffer> call go#coverage#Clear()
augroup end augroup end

View File

@ -30,6 +30,21 @@ function! s:groutineID() abort
endfunction endfunction
function! s:complete(job, exit_status, data) abort function! s:complete(job, exit_status, data) abort
let l:gotready = get(s:state, 'ready', 0)
" copy messages to a:data _only_ when dlv exited non-zero and it was never
" detected as ready (e.g. there was a compiler error).
if a:exit_status > 0 && !l:gotready
" copy messages to data so that vim-go's usual handling of errors from
" async jobs will occur.
call extend(a:data, s:state['message'])
endif
" return early instead of clearing any variables when the current job is not
" a:job
if has_key(s:state, 'job') && s:state['job'] != a:job
return
endif
if has_key(s:state, 'job') if has_key(s:state, 'job')
call remove(s:state, 'job') call remove(s:state, 'job')
endif endif
@ -38,10 +53,11 @@ function! s:complete(job, exit_status, data) abort
call remove(s:state, 'ready') call remove(s:state, 'ready')
endif endif
call s:clearState() if has_key(s:state, 'ch')
if a:exit_status > 0 call remove(s:state, 'ch')
call go#util#EchoError(s:state['message'])
endif endif
call s:clearState()
endfunction endfunction
function! s:logger(prefix, ch, msg) abort function! s:logger(prefix, ch, msg) abort
@ -217,8 +233,8 @@ endfunction
function! s:stop() abort function! s:stop() abort
let l:res = s:call_jsonrpc('RPCServer.Detach', {'kill': v:true}) let l:res = s:call_jsonrpc('RPCServer.Detach', {'kill': v:true})
call s:clearState()
if has_key(s:state, 'job') if has_key(s:state, 'job')
call go#job#Wait(s:state['job'])
call remove(s:state, 'job') call remove(s:state, 'job')
endif endif
@ -230,9 +246,7 @@ function! s:stop() abort
call remove(s:state, 'ch') call remove(s:state, 'ch')
endif endif
if has_key( s:state, 'data') call s:clearState()
call remove(s:state, 'data')
endif
endfunction endfunction
function! go#debug#Stop() abort function! go#debug#Stop() abort
@ -473,7 +487,7 @@ function! s:start_cb(res) abort
exe bufwinnr(oldbuf) 'wincmd w' exe bufwinnr(oldbuf) 'wincmd w'
augroup vim-go-debug augroup vim-go-debug
autocmd! autocmd! * <buffer>
autocmd FileType go nmap <buffer> <F5> <Plug>(go-debug-continue) autocmd FileType go nmap <buffer> <F5> <Plug>(go-debug-continue)
autocmd FileType go nmap <buffer> <F6> <Plug>(go-debug-print) autocmd FileType go nmap <buffer> <F6> <Plug>(go-debug-print)
autocmd FileType go nmap <buffer> <F9> <Plug>(go-debug-breakpoint) autocmd FileType go nmap <buffer> <F9> <Plug>(go-debug-breakpoint)
@ -489,7 +503,6 @@ function! s:err_cb(ch, msg) abort
return return
endif endif
call go#util#EchoError(a:msg)
let s:state['message'] += [a:msg] let s:state['message'] += [a:msg]
endfunction endfunction
@ -499,7 +512,6 @@ function! s:out_cb(ch, msg) abort
return return
endif endif
call go#util#EchoProgress(a:msg)
let s:state['message'] += [a:msg] let s:state['message'] += [a:msg]
if stridx(a:msg, go#config#DebugAddress()) != -1 if stridx(a:msg, go#config#DebugAddress()) != -1
@ -572,7 +584,7 @@ function! go#debug#Start(is_test, ...) abort
" It's already running. " It's already running.
if has_key(s:state, 'job') if has_key(s:state, 'job')
return return s:state['job']
endif endif
let s:start_args = a:000 let s:start_args = a:000
@ -634,7 +646,7 @@ function! go#debug#Start(is_test, ...) abort
let s:state['message'] = [] let s:state['message'] = []
let l:opts = { let l:opts = {
\ 'for': '_', \ 'for': 'GoDebug',
\ 'statustype': 'debug', \ 'statustype': 'debug',
\ 'complete': function('s:complete'), \ 'complete': function('s:complete'),
\ } \ }
@ -647,6 +659,8 @@ function! go#debug#Start(is_test, ...) abort
catch catch
call go#util#EchoError(v:exception) call go#util#EchoError(v:exception)
endtry endtry
return s:state['job']
endfunction endfunction
" Translate a reflect kind constant to a human string. " Translate a reflect kind constant to a human string.
@ -872,7 +886,7 @@ function! go#debug#Restart() abort
call go#cmd#autowrite() call go#cmd#autowrite()
try try
call go#job#Stop(s:state['job']) call s:stop()
let l:breaks = s:state['breakpoint'] let l:breaks = s:state['breakpoint']
let s:state = { let s:state = {

View File

@ -7,11 +7,49 @@ function! Test_GoDebugStart_Empty() abort
endfunction endfunction
function! Test_GoDebugStart_RelativePackage() abort function! Test_GoDebugStart_RelativePackage() abort
call s:debug('./debugmain') call s:debug('./debug/debugmain')
endfunction endfunction
function! Test_GoDebugStart_Package() abort function! Test_GoDebugStart_Package() abort
call s:debug('debugmain') call s:debug('debug/debugmain')
endfunction
function! Test_GoDebugStart_Errors() abort
if !go#util#has_job()
return
endif
try
let l:expected = [
\ {'lnum': 0, 'bufnr': 0, 'col': 0, 'valid': 0, 'vcol': 0, 'nr': -1, 'type': '', 'pattern': '', 'text': '# debug/compilerror'},
\ {'lnum': 6, 'bufnr': 7, 'col': 22, 'valid': 1, 'vcol': 0, 'nr': -1, 'type': '', 'pattern': '', 'text': ' syntax error: unexpected newline, expecting comma or )'},
\ {'lnum': 0, 'bufnr': 0, 'col': 0, 'valid': 0, 'vcol': 0, 'nr': -1, 'type': '', 'pattern': '', 'text': 'exit status 2'}
\]
call setqflist([], 'r')
let l:tmp = gotest#load_fixture('debug/compilerror/main.go')
call assert_false(exists(':GoDebugStop'))
let l:cd = exists('*haslocaldir') && haslocaldir() ? 'lcd' : 'cd'
execute l:cd . ' debug/compilerror'
call go#debug#Start(0)
let l:actual = getqflist()
let l:start = reltime()
while len(l:actual) == 0 && reltimefloat(reltime(l:start)) < 10
sleep 100m
let l:actual = getqflist()
endwhile
call gotest#assert_quickfix(l:actual, l:expected)
call assert_false(exists(':GoDebugStop'))
finally
call delete(l:tmp, 'rf')
" clear the quickfix lists
call setqflist([], 'r')
endtry
endfunction endfunction
function! s:debug(...) abort function! s:debug(...) abort
@ -20,7 +58,7 @@ function! s:debug(...) abort
endif endif
try try
let l:tmp = gotest#load_fixture('debugmain/debugmain.go') let l:tmp = gotest#load_fixture('debug/debugmain/debugmain.go')
call go#debug#Breakpoint(6) call go#debug#Breakpoint(6)
@ -28,10 +66,10 @@ function! s:debug(...) abort
if a:0 == 0 if a:0 == 0
let l:cd = exists('*haslocaldir') && haslocaldir() ? 'lcd' : 'cd' let l:cd = exists('*haslocaldir') && haslocaldir() ? 'lcd' : 'cd'
execute l:cd . ' debugmain' execute l:cd . ' debug/debugmain'
call go#debug#Start(0) let l:job = go#debug#Start(0)
else else
call go#debug#Start(0, a:1) let l:job = go#debug#Start(0, a:1)
endif endif
let l:start = reltime() let l:start = reltime()
@ -39,9 +77,17 @@ function! s:debug(...) abort
sleep 100m sleep 100m
endwhile endwhile
call assert_true(exists(':GoDebugStop'))
call gotest#assert_quickfix(getqflist(), [])
call go#debug#Stop() call go#debug#Stop()
if !has('nvim')
call assert_equal(job_status(l:job), 'dead')
endif
call assert_false(exists(':GoDebugStop')) call assert_false(exists(':GoDebugStop'))
finally finally
call delete(l:tmp, 'rf') call delete(l:tmp, 'rf')
endtry endtry

View File

@ -84,7 +84,6 @@ function! s:jump_to_declaration_cb(mode, bin_name, job, exit_status, data) abort
endif endif
call go#def#jump_to_declaration(a:data[0], a:mode, a:bin_name) call go#def#jump_to_declaration(a:data[0], a:mode, a:bin_name)
call go#util#EchoSuccess(fnamemodify(a:data[0], ":t"))
" capture the active window so that after the exit_cb and close_cb callbacks " capture the active window so that after the exit_cb and close_cb callbacks
" can return to it when a:mode caused a split. " can return to it when a:mode caused a split.

View File

@ -486,7 +486,7 @@ function! s:same_ids_highlight(exit_val, output, mode) abort
" re-apply SameIds at the current cursor position at the time the buffer " re-apply SameIds at the current cursor position at the time the buffer
" is redisplayed: e.g. :edit, :GoRename, etc. " is redisplayed: e.g. :edit, :GoRename, etc.
augroup vim-go-sameids augroup vim-go-sameids
autocmd! autocmd! * <buffer>
autocmd BufWinEnter <buffer> nested call go#guru#SameIds(0) autocmd BufWinEnter <buffer> nested call go#guru#SameIds(0)
augroup end augroup end
endif endif
@ -511,7 +511,7 @@ function! go#guru#ClearSameIds() abort
" remove the autocmds we defined " remove the autocmds we defined
augroup vim-go-sameids augroup vim-go-sameids
autocmd! autocmd! * <buffer>
augroup end augroup end
return 0 return 0

View File

@ -343,77 +343,19 @@ function! s:neooptions(options)
continue continue
endif endif
" dealing with the channel lines of Neovim sucks. The docs (:help
" channel-lines) say:
" stream event handlers may receive partial (incomplete) lines. For a
" given invocation of on_stdout etc, `a:data` is not guaranteed to end
" with a newline.
" - `abcdefg` may arrive as `['abc']`, `['defg']`.
" - `abc\nefg` may arrive as `['abc', '']`, `['efg']` or `['abc']`,
" `['','efg']`, or even `['ab']`, `['c','efg']`.
if key == 'callback' if key == 'callback'
let l:options['callback'] = a:options['callback'] let l:options['callback'] = a:options['callback']
if !has_key(a:options, 'out_cb') if !has_key(a:options, 'out_cb')
function! s:callback2on_stdout(ch, data, event) dict function! s:callback2on_stdout(ch, data, event) dict
" a single empty string means EOF was reached. let self.stdout_buf = s:neocb(a:ch, self.stdout_buf, a:data, self.callback)
if len(a:data) == 1 && a:data[0] == ''
" when there's nothing buffered, return early so that an
" erroneous message will not be added.
if self.stdout_buf == ''
return
endif
let l:data = [self.stdout_buf]
let self.stdout_buf = ''
else
let l:data = copy(a:data)
let l:data[0] = self.stdout_buf . l:data[0]
" The last element may be a partial line; save it for next time.
let self.stdout_buf = l:data[-1]
let l:data = l:data[:-2]
if len(l:data) == 0
return
endif
endif
for l:msg in l:data
call self.callback(a:ch, l:msg)
endfor
endfunction endfunction
let l:options['on_stdout'] = function('s:callback2on_stdout', [], l:options) let l:options['on_stdout'] = function('s:callback2on_stdout', [], l:options)
endif endif
if !has_key(a:options, 'err_cb') if !has_key(a:options, 'err_cb')
function! s:callback2on_stderr(ch, data, event) dict function! s:callback2on_stderr(ch, data, event) dict
" a single empty string means EOF was reached. let self.stderr_buf = s:neocb(a:ch, self.stderr_buf, a:data, self.callback)
if len(a:data) == 1 && a:data[0] == ''
" when there's nothing buffered, return early so that an
" erroneous message will not be added.
if self.stderr_buf == ''
return
endif
let l:data = [self.stderr_buf]
let self.stderr_buf = ''
else
let l:data = copy(a:data)
let l:data[0] = self.stderr_buf . l:data[0]
" The last element may be a partial line; save it for next time.
let self.stderr_buf = l:data[-1]
let l:data = l:data[:-2]
if len(l:data) == 0
return
endif
endif
for l:msg in l:data
call self.callback(a:ch, l:msg)
endfor
endfunction endfunction
let l:options['on_stderr'] = function('s:callback2on_stderr', [], l:options) let l:options['on_stderr'] = function('s:callback2on_stderr', [], l:options)
endif endif
@ -424,31 +366,7 @@ function! s:neooptions(options)
if key == 'out_cb' if key == 'out_cb'
let l:options['out_cb'] = a:options['out_cb'] let l:options['out_cb'] = a:options['out_cb']
function! s:on_stdout(ch, data, event) dict function! s:on_stdout(ch, data, event) dict
" a single empty string means EOF was reached. let self.stdout_buf = s:neocb(a:ch, self.stdout_buf, a:data, self.out_cb)
if len(a:data) == 1 && a:data[0] == ''
" when there's nothing buffered, return early so that an
" erroneous message will not be added.
if self.stdout_buf == ''
return
endif
let l:data = [self.stdout_buf]
let self.stdout_buf = ''
else
let l:data = copy(a:data)
let l:data[0] = self.stdout_buf . l:data[0]
" The last element may be a partial line; save it for next time.
let self.stdout_buf = l:data[-1]
let l:data = l:data[:-2]
if len(l:data) == 0
return
endif
endif
for l:msg in l:data
call self.out_cb(a:ch, l:msg)
endfor
endfunction endfunction
let l:options['on_stdout'] = function('s:on_stdout', [], l:options) let l:options['on_stdout'] = function('s:on_stdout', [], l:options)
@ -458,31 +376,7 @@ function! s:neooptions(options)
if key == 'err_cb' if key == 'err_cb'
let l:options['err_cb'] = a:options['err_cb'] let l:options['err_cb'] = a:options['err_cb']
function! s:on_stderr(ch, data, event) dict function! s:on_stderr(ch, data, event) dict
" a single empty string means EOF was reached. let self.stderr_buf = s:neocb(a:ch, self.stderr_buf, a:data, self.err_cb )
if len(a:data) == 1 && a:data[0] == ''
" when there's nothing buffered, return early so that an
" erroneous message will not be added.
if self.stderr_buf == ''
return
endif
let l:data = [self.stderr_buf]
let self.stderr_buf = ''
else
let l:data = copy(a:data)
let l:data[0] = self.stderr_buf . l:data[0]
" The last element may be a partial line; save it for next time.
let self.stderr_buf = l:data[-1]
let l:data = l:data[:-2]
if len(l:data) == 0
return
endif
endif
for l:msg in l:data
call self.err_cb(a:ch, l:msg)
endfor
endfunction endfunction
let l:options['on_stderr'] = function('s:on_stderr', [], l:options) let l:options['on_stderr'] = function('s:on_stderr', [], l:options)
@ -542,6 +436,43 @@ function! s:winjobarg(idx, val) abort
return a:val return a:val
endfunction endfunction
function! s:neocb(ch, buf, data, callback)
" dealing with the channel lines of Neovim is awful. The docs (:help
" channel-lines) say:
" stream event handlers may receive partial (incomplete) lines. For a
" given invocation of on_stdout etc, `a:data` is not guaranteed to end
" with a newline.
" - `abcdefg` may arrive as `['abc']`, `['defg']`.
" - `abc\nefg` may arrive as `['abc', '']`, `['efg']` or `['abc']`,
" `['','efg']`, or even `['ab']`, `['c','efg']`.
" a single empty string means EOF was reached.
if len(a:data) == 1 && a:data[0] == ''
" when there's nothing buffered, return early so that an
" erroneous message will not be added.
if a:buf == ''
return ''
endif
let l:data = [a:buf]
let l:buf = ''
else
let l:data = copy(a:data)
let l:data[0] = a:buf . l:data[0]
" The last element may be a partial line; save it for next time.
let l:buf = l:data[-1]
let l:data = l:data[:-2]
endif
for l:msg in l:data
call a:callback(a:ch, l:msg)
endfor
return l:buf
endfunction
" restore Vi compatibility settings " restore Vi compatibility settings
let &cpo = s:cpo_save let &cpo = s:cpo_save
unlet s:cpo_save unlet s:cpo_save

View File

@ -9,15 +9,22 @@ function! go#lint#Gometa(bang, autosave, ...) abort
let goargs = a:000 let goargs = a:000
endif endif
let bin_path = go#path#CheckBinPath("gometalinter") if empty(go#config#MetalinterCommand())
if empty(bin_path) let bin_path = go#path#CheckBinPath("gometalinter")
return if empty(bin_path)
endif return
endif
let cmd = [bin_path] let cmd = [bin_path]
let cmd += ["--disable-all"] let cmd += ["--disable-all"]
" gometalinter has a --tests flag to tell its linters whether to run
" against tests. While not all of its linters respect this flag, for those
" that do, it means if we don't pass --tests, the linter won't run against
" test files. One example of a linter that will not run against tests if
" we do not specify this flag is errcheck.
let cmd += ["--tests"]
if a:autosave || empty(go#config#MetalinterCommand())
" linters " linters
let linters = a:autosave ? go#config#MetalinterAutosaveEnabled() : go#config#MetalinterEnabled() let linters = a:autosave ? go#config#MetalinterAutosaveEnabled() : go#config#MetalinterEnabled()
for linter in linters for linter in linters
@ -27,16 +34,9 @@ function! go#lint#Gometa(bang, autosave, ...) abort
for linter in go#config#MetalinterDisabled() for linter in go#config#MetalinterDisabled()
let cmd += ["--disable=".linter] let cmd += ["--disable=".linter]
endfor endfor
" gometalinter has a --tests flag to tell its linters whether to run
" against tests. While not all of its linters respect this flag, for those
" that do, it means if we don't pass --tests, the linter won't run against
" test files. One example of a linter that will not run against tests if
" we do not specify this flag is errcheck.
let cmd += ["--tests"]
else else
" the user wants something else, let us use it. " the user wants something else, let us use it.
let cmd += split(go#config#MetalinterCommand(), " ") let cmd = split(go#config#MetalinterCommand(), " ")
endif endif
if a:autosave if a:autosave
@ -78,8 +78,8 @@ function! go#lint#Gometa(bang, autosave, ...) abort
echon "vim-go: " | echohl Function | echon "[metalinter] PASS" | echohl None echon "vim-go: " | echohl Function | echon "[metalinter] PASS" | echohl None
else else
" GoMetaLinter can output one of the two, so we look for both: " GoMetaLinter can output one of the two, so we look for both:
" <file>:<line>:[<column>]: <message> (<linter>) " <file>:<line>:<column>:<severity>: <message> (<linter>)
" <file>:<line>:: <message> (<linter>) " <file>:<line>::<severity>: <message> (<linter>)
" This can be defined by the following errorformat: " This can be defined by the following errorformat:
let errformat = "%f:%l:%c:%t%*[^:]:\ %m,%f:%l::%t%*[^:]:\ %m" let errformat = "%f:%l:%c:%t%*[^:]:\ %m,%f:%l::%t%*[^:]:\ %m"
@ -123,7 +123,9 @@ endfunction
function! go#lint#Vet(bang, ...) abort function! go#lint#Vet(bang, ...) abort
call go#cmd#autowrite() call go#cmd#autowrite()
call go#util#EchoProgress('calling vet...') if go#config#EchoCommandInfo()
call go#util#EchoProgress('calling vet...')
endif
if a:0 == 0 if a:0 == 0
let [l:out, l:err] = go#util#Exec(['go', 'vet', go#package#ImportPath()]) let [l:out, l:err] = go#util#Exec(['go', 'vet', go#package#ImportPath()])
@ -140,7 +142,6 @@ function! go#lint#Vet(bang, ...) abort
if !empty(errors) && !a:bang if !empty(errors) && !a:bang
call go#list#JumpToFirst(l:listtype) call go#list#JumpToFirst(l:listtype)
endif endif
call go#util#EchoError('[vet] FAIL')
else else
call go#list#Clean(l:listtype) call go#list#Clean(l:listtype)
call go#util#EchoSuccess('[vet] PASS') call go#util#EchoSuccess('[vet] PASS')

View File

@ -138,6 +138,7 @@ endfunction
" in g:go_list_type_commands. " in g:go_list_type_commands.
let s:default_list_type_commands = { let s:default_list_type_commands = {
\ "GoBuild": "quickfix", \ "GoBuild": "quickfix",
\ "GoDebug": "quickfix",
\ "GoErrCheck": "quickfix", \ "GoErrCheck": "quickfix",
\ "GoFmt": "locationlist", \ "GoFmt": "locationlist",
\ "GoGenerate": "quickfix", \ "GoGenerate": "quickfix",

View File

@ -89,7 +89,6 @@ function s:parse_errors(exit_val, bang, out)
let l:listtype = go#list#Type("GoRename") let l:listtype = go#list#Type("GoRename")
if a:exit_val != 0 if a:exit_val != 0
call go#util#EchoError("FAILED")
let errors = go#tool#ParseErrors(a:out) let errors = go#tool#ParseErrors(a:out)
call go#list#Populate(l:listtype, errors, 'Rename') call go#list#Populate(l:listtype, errors, 'Rename')
call go#list#Window(l:listtype, len(errors)) call go#list#Window(l:listtype, len(errors))

View File

@ -8,39 +8,34 @@ function! go#template#create() abort
let l:go_template_use_pkg = go#config#TemplateUsePkg() let l:go_template_use_pkg = go#config#TemplateUsePkg()
let l:root_dir = fnamemodify(s:current_file, ':h:h:h') let l:root_dir = fnamemodify(s:current_file, ':h:h:h')
let cd = exists('*haslocaldir') && haslocaldir() ? 'lcd ' : 'cd ' let l:package_name = go#tool#PackageName()
let dir = getcwd()
let l:package_name = -1
if isdirectory(expand('%:p:h')) " if we can't figure out any package name (i.e. no Go files in the directory)
execute cd . fnameescape(expand('%:p:h')) " from the directory create the template or use the directory as the name.
let l:package_name = go#tool#PackageName() if l:package_name == -1
endif if l:go_template_use_pkg == 1
let l:path = fnamemodify(expand('%:p:h'), ':t')
" if we can't figure out any package name(no Go files or non Go package let l:content = printf("package %s", l:path)
" files) from the directory create the template or use the cwd call append(0, l:content)
" as the name
if l:package_name == -1 && l:go_template_use_pkg != 1
let l:filename = fnamemodify(expand("%"), ':t')
if l:filename =~ "_test.go$"
let l:template_file = go#config#TemplateTestFile()
else else
let l:template_file = go#config#TemplateFile() let l:filename = expand('%:t')
if l:filename =~ "_test.go$"
let l:template_file = go#config#TemplateTestFile()
else
let l:template_file = go#config#TemplateFile()
endif
let l:template_path = go#util#Join(l:root_dir, "templates", l:template_file)
silent exe 'keepalt 0r ' . fnameescape(l:template_path)
endif endif
let l:template_path = go#util#Join(l:root_dir, "templates", l:template_file)
silent exe 'keepalt 0r ' . fnameescape(l:template_path)
elseif l:package_name == -1 && l:go_template_use_pkg == 1
" cwd is now the dir of the package
let l:path = fnamemodify(getcwd(), ':t')
let l:content = printf("package %s", l:path)
call append(0, l:content)
else else
let l:content = printf("package %s", l:package_name) let l:content = printf("package %s", l:package_name)
call append(0, l:content) call append(0, l:content)
endif endif
$delete _ " checking that the last line is empty shouldn't be necessary, but for some
" reason the last line isn't the expected empty line when run via tests.
execute cd . fnameescape(dir) if getline('$') is ''
$delete _
endif
endfunction endfunction
function! go#template#ToggleAutoCreate() abort function! go#template#ToggleAutoCreate() abort

View File

@ -0,0 +1,62 @@
" don't spam the user when Vim is started in Vi compatibility mode
let s:cpo_save = &cpo
set cpo&vim
func! Test_TemplateCreate() abort
try
let l:tmp = gotest#write_file('foo/empty.txt', [''])
edit foo/bar.go
call gotest#assert_buffer(1, [
\ 'func main() {',
\ '\tfmt.Println("vim-go")',
\ '}'])
finally
call delete(l:tmp, 'rf')
endtry
try
let l:tmp = gotest#write_file('foo/empty.txt', [''])
edit foo/bar_test.go
call gotest#assert_buffer(1, [
\ 'func TestHelloWorld(t *testing.T) {',
\ '\t// t.Fatal("not implemented")',
\ '}'])
finally
call delete(l:tmp, 'rf')
endtry
endfunc
func! Test_TemplateCreate_UsePkg() abort
try
let l:tmp = gotest#write_file('foo/empty.txt', [''])
let g:go_template_use_pkg = 1
edit foo/bar.go
call gotest#assert_buffer(0, ['package foo'])
finally
unlet g:go_template_use_pkg
call delete(l:tmp, 'rf')
endtry
endfunc
func! Test_TemplateCreate_PackageExists() abort
try
let l:tmp = gotest#write_file('quux/quux.go', ['package foo'])
edit quux/bar.go
call gotest#assert_buffer(0, ['package foo'])
finally
call delete(l:tmp, 'rf')
endtry
endfunc
" restore Vi compatibility settings
let &cpo = s:cpo_save
unlet s:cpo_save
" vim: sw=2 ts=2 et

View File

@ -0,0 +1,7 @@
package main
import "fmt"
func main() {
fmt.Println("vim-go"
}

View File

@ -84,7 +84,6 @@ function! go#test#Test(bang, compile, ...) abort
" failed to parse errors, output the original content " failed to parse errors, output the original content
call go#util#EchoError(out) call go#util#EchoError(out)
endif endif
call go#util#EchoError("[test] FAIL")
else else
call go#list#Clean(l:listtype) call go#list#Clean(l:listtype)

View File

@ -130,8 +130,8 @@ function! go#tool#ParseErrors(lines) abort
return errors return errors
endfunction endfunction
"FilterValids filters the given items with only items that have a valid " FilterValids filters the given items with only items that have a valid
"filename. Any non valid filename is filtered out. " filename. Any non valid filename is filtered out.
function! go#tool#FilterValids(items) abort function! go#tool#FilterValids(items) abort
" Remove any nonvalid filename from the location list to avoid opening an " Remove any nonvalid filename from the location list to avoid opening an
" empty buffer. See https://github.com/fatih/vim-go/issues/287 for " empty buffer. See https://github.com/fatih/vim-go/issues/287 for

View File

@ -1836,13 +1836,13 @@ Highlight function and method declarations.
> >
let g:go_highlight_functions = 0 let g:go_highlight_functions = 0
< <
*'g:go_highlight_function_arguments'* *'g:go_highlight_function_parameters'*
Highlight the variable names in arguments and return values in function Highlight the variable names in parameters (including named return parameters)
declarations. Setting this implies the functionality from in function declarations. Setting this implies the functionality from
|'g:go_highlight_functions'|. |'g:go_highlight_functions'|.
> >
let g:go_highlight_function_arguments = 0 let g:go_highlight_function_parameters = 0
< <
*'g:go_highlight_function_calls'* *'g:go_highlight_function_calls'*

View File

@ -25,11 +25,11 @@ function! s:gofiletype_post()
endfunction endfunction
" Note: should not use augroup in ftdetect (see :help ftdetect) " Note: should not use augroup in ftdetect (see :help ftdetect)
au BufNewFile *.go setfiletype go | setlocal fileencoding=utf-8 fileformat=unix au BufNewFile *.go setfiletype go | if &modifiable | setlocal fileencoding=utf-8 fileformat=unix | endif
au BufRead *.go call s:gofiletype_pre("go") au BufRead *.go call s:gofiletype_pre("go")
au BufReadPost *.go call s:gofiletype_post() au BufReadPost *.go call s:gofiletype_post()
au BufNewFile *.s setfiletype asm | setlocal fileencoding=utf-8 fileformat=unix au BufNewFile *.s setfiletype asm | if &modifiable | setlocal fileencoding=utf-8 fileformat=unix | endif
au BufRead *.s call s:gofiletype_pre("asm") au BufRead *.s call s:gofiletype_pre("asm")
au BufReadPost *.s call s:gofiletype_post() au BufReadPost *.s call s:gofiletype_post()

View File

@ -277,7 +277,7 @@ endfunction
function! s:template_autocreate() function! s:template_autocreate()
" create new template from scratch " create new template from scratch
if get(g:, "go_template_autocreate", 1) if get(g:, "go_template_autocreate", 1) && &modifiable
call go#template#create() call go#template#create()
endif endif
endfunction endfunction

View File

@ -48,7 +48,7 @@ redir @q
redir END redir END
let s:tests = split(substitute(@q, 'function \(\k\+()\)', '\1', 'g')) let s:tests = split(substitute(@q, 'function \(\k\+()\)', '\1', 'g'))
" log any messages that we may already accumulated. " log any messages already accumulated.
call s:logmessages() call s:logmessages()
" Iterate over all tests and execute them. " Iterate over all tests and execute them.
for s:test in sort(s:tests) for s:test in sort(s:tests)

View File

@ -148,14 +148,14 @@ endif
" var, const " var, const
if go#config#FoldEnable('varconst') if go#config#FoldEnable('varconst')
syn region goVar start='var (' end='^\s*)$' transparent fold syn region goVar start='var (' end='^\s*)$' transparent fold
\ contains=ALLBUT,goParen,goBlock,goFunction,goTypeName,goReceiverType,goReceiverVar,goArgumentName,goArgumentType,goSimpleArguments,goPointerOperator \ contains=ALLBUT,goParen,goBlock,goFunction,goTypeName,goReceiverType,goReceiverVar,goParamName,goParamType,goSimpleParams,goPointerOperator
syn region goConst start='const (' end='^\s*)$' transparent fold syn region goConst start='const (' end='^\s*)$' transparent fold
\ contains=ALLBUT,goParen,goBlock,goFunction,goTypeName,goReceiverType,goReceiverVar,goArgumentName,goArgumentType,goSimpleArguments,goPointerOperator \ contains=ALLBUT,goParen,goBlock,goFunction,goTypeName,goReceiverType,goReceiverVar,goParamName,goParamType,goSimpleParams,goPointerOperator
else else
syn region goVar start='var (' end='^\s*)$' transparent syn region goVar start='var (' end='^\s*)$' transparent
\ contains=ALLBUT,goParen,goBlock,goFunction,goTypeName,goReceiverType,goReceiverVar,goArgumentName,goArgumentType,goSimpleArguments,goPointerOperator \ contains=ALLBUT,goParen,goBlock,goFunction,goTypeName,goReceiverType,goReceiverVar,goParamName,goParamType,goSimpleParams,goPointerOperator
syn region goConst start='const (' end='^\s*)$' transparent syn region goConst start='const (' end='^\s*)$' transparent
\ contains=ALLBUT,goParen,goBlock,goFunction,goTypeName,goReceiverType,goReceiverVar,goArgumentName,goArgumentType,goSimpleArguments,goPointerOperator \ contains=ALLBUT,goParen,goBlock,goFunction,goTypeName,goReceiverType,goReceiverVar,goParamName,goParamType,goSimpleParams,goPointerOperator
endif endif
" Single-line var, const, and import. " Single-line var, const, and import.
@ -263,19 +263,20 @@ endif
hi def link goOperator Operator hi def link goOperator Operator
" Functions; " Functions;
if go#config#HighlightFunctions() || go#config#HighlightFunctionArguments() if go#config#HighlightFunctions() || go#config#HighlightFunctionParameters()
syn match goDeclaration /\<func\>/ nextgroup=goReceiver,goFunction,goSimpleArguments skipwhite skipnl syn match goDeclaration /\<func\>/ nextgroup=goReceiver,goFunction,goSimpleParams skipwhite skipnl
syn match goReceiverVar /\w\+\ze\s\+\(\w\|\*\)/ nextgroup=goPointerOperator,goReceiverType skipwhite skipnl contained syn match goReceiverVar /\w\+\ze\s\+\(\w\|\*\)/ nextgroup=goPointerOperator,goReceiverType skipwhite skipnl contained
syn match goPointerOperator /\*/ nextgroup=goReceiverType contained skipwhite skipnl syn match goPointerOperator /\*/ nextgroup=goReceiverType contained skipwhite skipnl
syn match goFunction /\w\+/ nextgroup=goSimpleArguments contained skipwhite skipnl syn match goFunction /\w\+/ nextgroup=goSimpleParams contained skipwhite skipnl
syn match goReceiverType /\w\+/ contained syn match goReceiverType /\w\+/ contained
if go#config#HighlightFunctionArguments() if go#config#HighlightFunctionParameters()
syn match goSimpleArguments /(\(\w\|\_s\|[*\.\[\],\{\}<>-]\)*)/ contained contains=goArgumentName nextgroup=goSimpleArguments skipwhite skipnl syn match goSimpleParams /(\(\w\|\_s\|[*\.\[\],\{\}<>-]\)*)/ contained contains=goParamName,goType nextgroup=goFunctionReturn skipwhite skipnl
syn match goArgumentName /\w\+\(\s*,\s*\w\+\)*\ze\s\+\(\w\|\.\|\*\|\[\)/ contained nextgroup=goArgumentType skipwhite skipnl syn match goFunctionReturn /(\(\w\|\_s\|[*\.\[\],\{\}<>-]\)*)/ contained contains=goParamName,goType skipwhite skipnl
syn match goArgumentType /\([^,)]\|\_s\)\+,\?/ contained nextgroup=goArgumentName skipwhite skipnl syn match goParamName /\w\+\(\s*,\s*\w\+\)*\ze\s\+\(\w\|\.\|\*\|\[\)/ contained nextgroup=goParamType skipwhite skipnl
syn match goParamType /\([^,)]\|\_s\)\+,\?/ contained nextgroup=goParamName skipwhite skipnl
\ contains=goVarArgs,goType,goSignedInts,goUnsignedInts,goFloats,goComplexes,goDeclType,goBlock \ contains=goVarArgs,goType,goSignedInts,goUnsignedInts,goFloats,goComplexes,goDeclType,goBlock
hi def link goReceiverVar goArgumentName hi def link goReceiverVar goParamName
hi def link goArgumentName Identifier hi def link goParamName Identifier
endif endif
syn match goReceiver /(\s*\w\+\(\s\+\*\?\s*\w\+\)\?\s*)\ze\s*\w/ contained nextgroup=goFunction contains=goReceiverVar skipwhite skipnl syn match goReceiver /(\s*\w\+\(\s\+\*\?\s*\w\+\)\?\s*)\ze\s*\w/ contained nextgroup=goFunction contains=goReceiverVar skipwhite skipnl
else else

@ -0,0 +1 @@
Subproject commit 2fbab3401b7f81ac7f629e34e4f40a7e52934a99

View File

@ -1,3 +1,8 @@
if !has('patch-7.4.480')
" Before this patch, vim used modula2 for .md.
au! filetypedetect BufRead,BufNewFile *.md
endif
" markdown filetype file " markdown filetype file
au BufRead,BufNewFile *.{md,mdown,mkd,mkdn,markdown,mdwn} set filetype=markdown au BufRead,BufNewFile *.{md,mdown,mkd,mkdn,markdown,mdwn} setfiletype markdown
au BufRead,BufNewFile *.{md,mdown,mkd,mkdn,markdown,mdwn}.{des3,des,bf,bfa,aes,idea,cast,rc2,rc4,rc5,desx} set filetype=markdown au BufRead,BufNewFile *.{md,mdown,mkd,mkdn,markdown,mdwn}.{des3,des,bf,bfa,aes,idea,cast,rc2,rc4,rc5,desx} setfiletype markdown

View File

@ -734,7 +734,7 @@ function! s:MarkdownHighlightSources(force)
let include = '@' . toupper(filetype) let include = '@' . toupper(filetype)
endif endif
let command = 'syntax region %s matchgroup=%s start="^\s*```\s*%s$" matchgroup=%s end="\s*```$" keepend contains=%s%s' let command = 'syntax region %s matchgroup=%s start="^\s*```\s*%s$" matchgroup=%s end="\s*```$" keepend contains=%s%s'
execute printf(command, group, startgroup, ft, endgroup, include, has('conceal') && get(g:, 'vim_markdown_conceal', 1) ? ' concealends' : '') execute printf(command, group, startgroup, ft, endgroup, include, has('conceal') && get(g:, 'vim_markdown_conceal', 1) && get(g:, 'vim_markdown_conceal_code_blocks', 1) ? ' concealends' : '')
execute printf('syntax cluster mkdNonListItem add=%s', group) execute printf('syntax cluster mkdNonListItem add=%s', group)
let b:mkd_known_filetypes[ft] = 1 let b:mkd_known_filetypes[ft] = 1

View File

@ -36,10 +36,14 @@ syn sync linebreaks=1
let s:conceal = '' let s:conceal = ''
let s:concealends = '' let s:concealends = ''
let s:concealcode = ''
if has('conceal') && get(g:, 'vim_markdown_conceal', 1) if has('conceal') && get(g:, 'vim_markdown_conceal', 1)
let s:conceal = ' conceal' let s:conceal = ' conceal'
let s:concealends = ' concealends' let s:concealends = ' concealends'
endif endif
if has('conceal') && get(g:, 'vim_markdown_conceal_code_blocks', 1)
let s:concealcode = ' concealends'
endif
" additions to HTML groups " additions to HTML groups
if get(g:, 'vim_markdown_emphasis_multiline', 1) if get(g:, 'vim_markdown_emphasis_multiline', 1)
@ -94,13 +98,13 @@ syn match htmlH2 /^.\+\n-\+$/ contains=mkdLink,mkdInlineURL,@Spell
"define Markdown groups "define Markdown groups
syn match mkdLineBreak / \+$/ syn match mkdLineBreak / \+$/
syn region mkdBlockquote start=/^\s*>/ end=/$/ contains=mkdLink,mkdInlineURL,mkdLineBreak,@Spell syn region mkdBlockquote start=/^\s*>/ end=/$/ contains=mkdLink,mkdInlineURL,mkdLineBreak,@Spell
execute 'syn region mkdCode matchgroup=mkdCodeDelimiter start=/\(\([^\\]\|^\)\\\)\@<!`/ end=/\(\([^\\]\|^\)\\\)\@<!`/' . s:concealends execute 'syn region mkdCode matchgroup=mkdCodeDelimiter start=/\(\([^\\]\|^\)\\\)\@<!`/ end=/\(\([^\\]\|^\)\\\)\@<!`/' . s:concealcode
execute 'syn region mkdCode matchgroup=mkdCodeDelimiter start=/\(\([^\\]\|^\)\\\)\@<!``/ skip=/[^`]`[^`]/ end=/\(\([^\\]\|^\)\\\)\@<!``/' . s:concealends execute 'syn region mkdCode matchgroup=mkdCodeDelimiter start=/\(\([^\\]\|^\)\\\)\@<!``/ skip=/[^`]`[^`]/ end=/\(\([^\\]\|^\)\\\)\@<!``/' . s:concealcode
execute 'syn region mkdCode matchgroup=mkdCodeDelimiter start=/^\s*\z(`\{3,}\)[^`]*$/ end=/^\s*\z1`*\s*$/' . s:concealends execute 'syn region mkdCode matchgroup=mkdCodeDelimiter start=/^\s*\z(`\{3,}\)[^`]*$/ end=/^\s*\z1`*\s*$/' . s:concealcode
execute 'syn region mkdCode matchgroup=mkdCodeDelimiter start=/\(\([^\\]\|^\)\\\)\@<!\~\~/ end=/\(\([^\\]\|^\)\\\)\@<!\~\~/' . s:concealends execute 'syn region mkdCode matchgroup=mkdCodeDelimiter start=/\(\([^\\]\|^\)\\\)\@<!\~\~/ end=/\(\([^\\]\|^\)\\\)\@<!\~\~/' . s:concealcode
execute 'syn region mkdCode matchgroup=mkdCodeDelimiter start=/^\s*\z(\~\{3,}\)\s*[0-9A-Za-z_+-]*\s*$/ end=/^\s*\z1\~*\s*$/' . s:concealends execute 'syn region mkdCode matchgroup=mkdCodeDelimiter start=/^\s*\z(\~\{3,}\)\s*[0-9A-Za-z_+-]*\s*$/ end=/^\s*\z1\~*\s*$/' . s:concealcode
execute 'syn region mkdCode matchgroup=mkdCodeDelimiter start="<pre[^>]*\\\@<!>" end="</pre>"' . s:concealends execute 'syn region mkdCode matchgroup=mkdCodeDelimiter start="<pre[^>]*\\\@<!>" end="</pre>"' . s:concealcode
execute 'syn region mkdCode matchgroup=mkdCodeDelimiter start="<code[^>]*\\\@<!>" end="</code>"' . s:concealends execute 'syn region mkdCode matchgroup=mkdCodeDelimiter start="<code[^>]*\\\@<!>" end="</code>"' . s:concealcode
syn region mkdFootnote start="\[^" end="\]" syn region mkdFootnote start="\[^" end="\]"
syn match mkdCode /^\s*\n\(\(\s\{8,}[^ ]\|\t\t\+[^\t]\).*\n\)\+/ syn match mkdCode /^\s*\n\(\(\s\{8,}[^ ]\|\t\t\+[^\t]\).*\n\)\+/
syn match mkdCode /\%^\(\(\s\{4,}[^ ]\|\t\+[^\t]\).*\n\)\+/ syn match mkdCode /\%^\(\(\s\{4,}[^ ]\|\t\+[^\t]\).*\n\)\+/

View File

@ -56,19 +56,28 @@ ${1:class_name}.prototype.${2:method_name} = function`!p snip.rv = space_before_
endsnippet endsnippet
snippet fun "function (fun)" w snippet fun "function (named)" b
function ${1:function_name}`!p snip.rv = space_before_function_paren(snip)`(${2:argument}) { function ${1:function_name}`!p snip.rv = space_before_function_paren(snip)`(${2:argument}) {
${VISUAL}$0 ${VISUAL}$0
} }
endsnippet endsnippet
snippet vf "Function assigned to var" snippet vf "function (assigned to var)"
${1:var }${2:function_name} = function $2`!p snip.rv = space_before_function_paren(snip)`($3) { ${1:var }${2:function_name} = function $2`!p snip.rv = space_before_function_paren(snip)`($3) {
${VISUAL}$0 ${VISUAL}$0
}`!p snip.rv = semi(snip)` }`!p snip.rv = semi(snip)`
endsnippet endsnippet
snippet anf "Anonymous Function" i # Drop priority so this only triggers when not beginning of line.
priority -51
snippet fun "function (anonymous)" w
function`!p snip.rv = space_before_function_paren(snip)`($1) {
${VISUAL}$0
}$2
endsnippet
priority -50
snippet anf "function (anonymous)" i
function`!p snip.rv = space_before_function_paren(snip)`($1) { function`!p snip.rv = space_before_function_paren(snip)`($1) {
${VISUAL}$0 ${VISUAL}$0
} }

View File

@ -28,7 +28,7 @@ snippet fmt "format!(..)"
format!("$1"${2/..*/, /}$2); format!("$1"${2/..*/, /}$2);
endsnippet endsnippet
snippet it ".iter()" i snippet .it ".iter()" i
.iter()$0 .iter()$0
endsnippet endsnippet

View File

@ -22,6 +22,11 @@ snippet docs
Description: ${0} Description: ${0}
""" """
# Unittest skip
snippet sk "skip unittests" b
@unittest.skip(${1:skip_reason})
endsnippet
snippet wh snippet wh
while ${1:condition}: while ${1:condition}:
${0:${VISUAL}} ${0:${VISUAL}}