mirror of
1
0
Fork 0

Update plugins using update_plugins.py

This commit is contained in:
Geezus 2019-07-08 11:44:45 -05:00
parent a25315c274
commit 0502b849ed
115 changed files with 3723 additions and 1662 deletions

View File

@ -1,4 +1,4 @@
Copyright (c) 2016-2018, w0rp <devw0rp@gmail.com>
Copyright (c) 2016-2019, w0rp <devw0rp@gmail.com>
All rights reserved.
Redistribution and use in source and binary forms, with or without

View File

@ -11,9 +11,12 @@ call ale#Set('c_clangtidy_executable', 'clang-tidy')
" http://clang.llvm.org/extra/clang-tidy/checks/list.html
call ale#Set('c_clangtidy_checks', [])
" Set this option to manually set some options for clang-tidy.
" Set this option to manually set some options for clang-tidy to use as compile
" flags.
" This will disable compile_commands.json detection.
call ale#Set('c_clangtidy_options', '')
" Set this option to manually set options for clang-tidy directly.
call ale#Set('c_clangtidy_extra_options', '')
call ale#Set('c_build_dir', '')
function! ale_linters#c#clangtidy#GetCommand(buffer) abort
@ -25,8 +28,12 @@ function! ale_linters#c#clangtidy#GetCommand(buffer) abort
\ ? ale#Var(a:buffer, 'c_clangtidy_options')
\ : ''
" Get the options to pass directly to clang-tidy
let l:extra_options = ale#Var(a:buffer, 'c_clangtidy_extra_options')
return '%e'
\ . (!empty(l:checks) ? ' -checks=' . ale#Escape(l:checks) : '')
\ . (!empty(l:extra_options) ? ' ' . ale#Escape(l:extra_options) : '')
\ . ' %s'
\ . (!empty(l:build_dir) ? ' -p ' . ale#Escape(l:build_dir) : '')
\ . (!empty(l:options) ? ' -- ' . l:options : '')

View File

@ -5,20 +5,17 @@ call ale#Set('c_cppcheck_executable', 'cppcheck')
call ale#Set('c_cppcheck_options', '--enable=style')
function! ale_linters#c#cppcheck#GetCommand(buffer) abort
" Search upwards from the file for compile_commands.json.
"
" If we find it, we'll `cd` to where the compile_commands.json file is,
" then use the file to set up import paths, etc.
let [l:dir, l:json_path] = ale#c#FindCompileCommands(a:buffer)
let l:cd_command = !empty(l:dir) ? ale#path#CdString(l:dir) : ''
let l:compile_commands_option = !empty(l:json_path)
\ ? '--project=' . ale#Escape(l:json_path[len(l:dir) + 1: ])
let l:cd_command = ale#handlers#cppcheck#GetCdCommand(a:buffer)
let l:compile_commands_option = ale#handlers#cppcheck#GetCompileCommandsOptions(a:buffer)
let l:buffer_path_include = empty(l:compile_commands_option)
\ ? ale#handlers#cppcheck#GetBufferPathIncludeOptions(a:buffer)
\ : ''
return l:cd_command
\ . '%e -q --language=c'
\ . ale#Pad(l:compile_commands_option)
\ . ale#Pad(ale#Var(a:buffer, 'c_cppcheck_options'))
\ . l:buffer_path_include
\ . ' %t'
endfunction

View File

@ -5,9 +5,12 @@
call ale#Set('cpp_clangtidy_executable', 'clang-tidy')
" Set this option to check the checks clang-tidy will apply.
call ale#Set('cpp_clangtidy_checks', [])
" Set this option to manually set some options for clang-tidy.
" Set this option to manually set some options for clang-tidy to use as compile
" flags.
" This will disable compile_commands.json detection.
call ale#Set('cpp_clangtidy_options', '')
" Set this option to manually set options for clang-tidy directly.
call ale#Set('cpp_clangtidy_extra_options', '')
call ale#Set('c_build_dir', '')
function! ale_linters#cpp#clangtidy#GetCommand(buffer) abort
@ -19,8 +22,12 @@ function! ale_linters#cpp#clangtidy#GetCommand(buffer) abort
\ ? ale#Var(a:buffer, 'cpp_clangtidy_options')
\ : ''
" Get the options to pass directly to clang-tidy
let l:extra_options = ale#Var(a:buffer, 'cpp_clangtidy_extra_options')
return '%e'
\ . (!empty(l:checks) ? ' -checks=' . ale#Escape(l:checks) : '')
\ . (!empty(l:extra_options) ? ' ' . ale#Escape(l:extra_options) : '')
\ . ' %s'
\ . (!empty(l:build_dir) ? ' -p ' . ale#Escape(l:build_dir) : '')
\ . (!empty(l:options) ? ' -- ' . l:options : '')

View File

@ -5,20 +5,17 @@ call ale#Set('cpp_cppcheck_executable', 'cppcheck')
call ale#Set('cpp_cppcheck_options', '--enable=style')
function! ale_linters#cpp#cppcheck#GetCommand(buffer) abort
" Search upwards from the file for compile_commands.json.
"
" If we find it, we'll `cd` to where the compile_commands.json file is,
" then use the file to set up import paths, etc.
let [l:dir, l:json_path] = ale#c#FindCompileCommands(a:buffer)
let l:cd_command = !empty(l:dir) ? ale#path#CdString(l:dir) : ''
let l:compile_commands_option = !empty(l:json_path)
\ ? '--project=' . ale#Escape(l:json_path[len(l:dir) + 1: ])
let l:cd_command = ale#handlers#cppcheck#GetCdCommand(a:buffer)
let l:compile_commands_option = ale#handlers#cppcheck#GetCompileCommandsOptions(a:buffer)
let l:buffer_path_include = empty(l:compile_commands_option)
\ ? ale#handlers#cppcheck#GetBufferPathIncludeOptions(a:buffer)
\ : ''
return l:cd_command
\ . '%e -q --language=c++'
\ . ale#Pad(l:compile_commands_option)
\ . ale#Pad(ale#Var(a:buffer, 'cpp_cppcheck_options'))
\ . l:buffer_path_include
\ . ' %t'
endfunction

View File

@ -0,0 +1,95 @@
call ale#Set('cs_csc_options', '')
call ale#Set('cs_csc_source', '')
call ale#Set('cs_csc_assembly_path', [])
call ale#Set('cs_csc_assemblies', [])
function! s:GetWorkingDirectory(buffer) abort
let l:working_directory = ale#Var(a:buffer, 'cs_csc_source')
if !empty(l:working_directory)
return l:working_directory
endif
return expand('#' . a:buffer . ':p:h')
endfunction
function! ale_linters#cs#csc#GetCommand(buffer) abort
" Pass assembly paths via the -lib: parameter.
let l:path_list = ale#Var(a:buffer, 'cs_csc_assembly_path')
let l:lib_option = !empty(l:path_list)
\ ? '/lib:' . join(map(copy(l:path_list), 'ale#Escape(v:val)'), ',')
\ : ''
" Pass paths to DLL files via the -r: parameter.
let l:assembly_list = ale#Var(a:buffer, 'cs_csc_assemblies')
let l:r_option = !empty(l:assembly_list)
\ ? '/r:' . join(map(copy(l:assembly_list), 'ale#Escape(v:val)'), ',')
\ : ''
" register temporary module target file with ale
" register temporary module target file with ALE.
let l:out = ale#command#CreateFile(a:buffer)
" The code is compiled as a module and the output is redirected to a
" temporary file.
return ale#path#CdString(s:GetWorkingDirectory(a:buffer))
\ . 'csc /unsafe'
\ . ale#Pad(ale#Var(a:buffer, 'cs_csc_options'))
\ . ale#Pad(l:lib_option)
\ . ale#Pad(l:r_option)
\ . ' /out:' . l:out
\ . ' /t:module'
\ . ' /recurse:' . ale#Escape('*.cs')
endfunction
function! ale_linters#cs#csc#Handle(buffer, lines) abort
" Look for lines like the following.
"
" Tests.cs(12,29): error CSXXXX: ; expected
"
" NOTE: pattern also captures file name as linter compiles all
" files within the source tree rooted at the specified source
" path and not just the file loaded in the buffer
let l:patterns = [
\ '^\v(.+\.cs)\((\d+),(\d+)\)\:\s+([^ ]+)\s+([cC][sS][^ ]+):\s(.+)$',
\ '^\v([^ ]+)\s+([Cc][sS][^ ]+):\s+(.+)$',
\]
let l:output = []
let l:dir = s:GetWorkingDirectory(a:buffer)
for l:match in ale#util#GetMatches(a:lines, l:patterns)
if len(l:match) > 6 && strlen(l:match[5]) > 2 && l:match[5][:1] is? 'CS'
call add(l:output, {
\ 'filename': ale#path#GetAbsPath(l:dir, l:match[1]),
\ 'lnum': l:match[2] + 0,
\ 'col': l:match[3] + 0,
\ 'type': l:match[4] is# 'error' ? 'E' : 'W',
\ 'code': l:match[5],
\ 'text': l:match[6] ,
\})
elseif strlen(l:match[2]) > 2 && l:match[2][:1] is? 'CS'
call add(l:output, {
\ 'filename':'<csc>',
\ 'lnum': -1,
\ 'col': -1,
\ 'type': l:match[1] is# 'error' ? 'E' : 'W',
\ 'code': l:match[2],
\ 'text': l:match[3],
\})
endif
endfor
return l:output
endfunction
call ale#linter#Define('cs',{
\ 'name': 'csc',
\ 'output_stream': 'stdout',
\ 'executable': 'csc',
\ 'command': function('ale_linters#cs#csc#GetCommand'),
\ 'callback': 'ale_linters#cs#csc#Handle',
\ 'lint_file': 1
\})

View File

@ -52,20 +52,34 @@ function! ale_linters#cs#mcsc#Handle(buffer, lines) abort
" NOTE: pattern also captures file name as linter compiles all
" files within the source tree rooted at the specified source
" path and not just the file loaded in the buffer
let l:pattern = '^\v(.+\.cs)\((\d+),(\d+)\)\: ([^ ]+) ([^ ]+): (.+)$'
let l:patterns = [
\ '^\v(.+\.cs)\((\d+),(\d+)\)\:\s+([^ ]+)\s+([cC][sS][^ ]+):\s(.+)$',
\ '^\v([^ ]+)\s+([Cc][sS][^ ]+):\s+(.+)$',
\]
let l:output = []
let l:dir = s:GetWorkingDirectory(a:buffer)
for l:match in ale#util#GetMatches(a:lines, l:pattern)
call add(l:output, {
\ 'filename': ale#path#GetAbsPath(l:dir, l:match[1]),
\ 'lnum': l:match[2] + 0,
\ 'col': l:match[3] + 0,
\ 'type': l:match[4] is# 'error' ? 'E' : 'W',
\ 'code': l:match[5],
\ 'text': l:match[6],
\})
for l:match in ale#util#GetMatches(a:lines, l:patterns)
if len(l:match) > 6 && strlen(l:match[5]) > 2 && l:match[5][:1] is? 'CS'
call add(l:output, {
\ 'filename': ale#path#GetAbsPath(l:dir, l:match[1]),
\ 'lnum': l:match[2] + 0,
\ 'col': l:match[3] + 0,
\ 'type': l:match[4] is# 'error' ? 'E' : 'W',
\ 'code': l:match[5],
\ 'text': l:match[6] ,
\})
elseif strlen(l:match[2]) > 2 && l:match[2][:1] is? 'CS'
call add(l:output, {
\ 'filename':'<mcs>',
\ 'lnum': -1,
\ 'col': -1,
\ 'type': l:match[1] is# 'error' ? 'E' : 'W',
\ 'code': l:match[2],
\ 'text': l:match[3],
\})
endif
endfor
return l:output

View File

@ -1,6 +1,10 @@
" Author: Devon Meunier <devon.meunier@gmail.com>
" Description: checkstyle for Java files
call ale#Set('java_checkstyle_executable', 'checkstyle')
call ale#Set('java_checkstyle_config', '/google_checks.xml')
call ale#Set('java_checkstyle_options', '')
function! ale_linters#java#checkstyle#Handle(buffer, lines) abort
let l:output = []
@ -35,19 +39,32 @@ function! ale_linters#java#checkstyle#Handle(buffer, lines) abort
return l:output
endfunction
function! s:GetConfig(buffer, config) abort
if ale#path#IsAbsolute(a:config)
return a:config
endif
let s:file = ale#path#FindNearestFile(a:buffer, a:config)
return !empty(s:file) ? s:file : a:config
endfunction
function! ale_linters#java#checkstyle#GetCommand(buffer) abort
return 'checkstyle '
\ . ale#Var(a:buffer, 'java_checkstyle_options')
let l:options = ale#Var(a:buffer, 'java_checkstyle_options')
let l:config_option = ale#Var(a:buffer, 'java_checkstyle_config')
let l:config = l:options !~# '\v(^| )-c' && !empty(l:config_option)
\ ? s:GetConfig(a:buffer, l:config_option)
\ : ''
return '%e'
\ . ale#Pad(l:options)
\ . (!empty(l:config) ? ' -c ' . ale#Escape(l:config) : '')
\ . ' %s'
endfunction
if !exists('g:ale_java_checkstyle_options')
let g:ale_java_checkstyle_options = '-c /google_checks.xml'
endif
call ale#linter#Define('java', {
\ 'name': 'checkstyle',
\ 'executable': 'checkstyle',
\ 'executable': {b -> ale#Var(b, 'java_checkstyle_executable')},
\ 'command': function('ale_linters#java#checkstyle#GetCommand'),
\ 'callback': 'ale_linters#java#checkstyle#Handle',
\ 'lint_file': 1,

View File

@ -21,6 +21,11 @@ function! ale_linters#java#javac#RunWithImportPaths(buffer) abort
let l:command = ale#gradle#BuildClasspathCommand(a:buffer)
endif
" Try to use Ant if Gradle and Maven aren't available
if empty(l:command)
let l:command = ale#ant#BuildClasspathCommand(a:buffer)
endif
if empty(l:command)
return ale_linters#java#javac#GetCommand(a:buffer, [], {})
endif

View File

@ -1,16 +1,47 @@
" Author: Horacio Sanson <https://github.com/hsanson>
" Description: Support for the Java language server https://github.com/georgewfraser/vscode-javac
call ale#Set('java_javalsp_executable', 'java')
call ale#Set('java_javalsp_executable', '')
call ale#Set('java_javalsp_config', {})
function! ale_linters#java#javalsp#Executable(buffer) abort
return ale#Var(a:buffer, 'java_javalsp_executable')
endfunction
function! ale_linters#java#javalsp#Config(buffer) abort
let l:defaults = { 'java': { 'classPath': [], 'externalDependencies': [] } }
let l:config = ale#Var(a:buffer, 'java_javalsp_config')
" Ensure the config dictionary contains both classPath and
" externalDependencies keys to avoid a NPE crash on Java Language Server.
call extend(l:config, l:defaults, 'keep')
call extend(l:config['java'], l:defaults['java'], 'keep')
return l:config
endfunction
function! ale_linters#java#javalsp#Command(buffer) abort
let l:executable = ale_linters#java#javalsp#Executable(a:buffer)
return ale#Escape(l:executable) . ' -Xverify:none -m javacs/org.javacs.Main'
if fnamemodify(l:executable, ':t') is# 'java'
" For backward compatibility.
let l:cmd = [
\ ale#Escape(l:executable),
\ '--add-exports jdk.compiler/com.sun.tools.javac.api=javacs',
\ '--add-exports jdk.compiler/com.sun.tools.javac.code=javacs',
\ '--add-exports jdk.compiler/com.sun.tools.javac.comp=javacs',
\ '--add-exports jdk.compiler/com.sun.tools.javac.main=javacs',
\ '--add-exports jdk.compiler/com.sun.tools.javac.tree=javacs',
\ '--add-exports jdk.compiler/com.sun.tools.javac.model=javacs',
\ '--add-exports jdk.compiler/com.sun.tools.javac.util=javacs',
\ '--add-opens jdk.compiler/com.sun.tools.javac.api=javacs',
\ '-m javacs/org.javacs.Main',
\]
return join(l:cmd, ' ')
else
return ale#Escape(l:executable)
endif
endfunction
call ale#linter#Define('java', {
@ -20,4 +51,5 @@ call ale#linter#Define('java', {
\ 'command': function('ale_linters#java#javalsp#Command'),
\ 'language': 'java',
\ 'project_root': function('ale#java#FindProjectRoot'),
\ 'lsp_config': function('ale_linters#java#javalsp#Config')
\})

View File

@ -6,5 +6,5 @@ call ale#linter#Define('javascript', {
\ 'output_stream': 'both',
\ 'executable': function('ale#handlers#eslint#GetExecutable'),
\ 'command': function('ale#handlers#eslint#GetCommand'),
\ 'callback': 'ale#handlers#eslint#Handle',
\ 'callback': 'ale#handlers#eslint#HandleJSON',
\})

View File

@ -14,7 +14,7 @@ endfunction
function! ale_linters#javascript#xo#GetCommand(buffer) abort
return ale#Escape(ale_linters#javascript#xo#GetExecutable(a:buffer))
\ . ' ' . ale#Var(a:buffer, 'javascript_xo_options')
\ . ' --reporter unix --stdin --stdin-filename %s'
\ . ' --reporter json --stdin --stdin-filename %s'
endfunction
" xo uses eslint and the output format is the same
@ -22,5 +22,5 @@ call ale#linter#Define('javascript', {
\ 'name': 'xo',
\ 'executable': function('ale_linters#javascript#xo#GetExecutable'),
\ 'command': function('ale_linters#javascript#xo#GetCommand'),
\ 'callback': 'ale#handlers#eslint#Handle',
\ 'callback': 'ale#handlers#eslint#HandleJSON',
\})

View File

@ -49,11 +49,19 @@ function! ale_linters#powershell#powershell#Handle(buffer, lines) abort
let l:matchcount = 1
endif
let l:item = {
\ 'lnum': str2nr(l:match[1]),
\ 'col': str2nr(l:match[2]),
\ 'type': 'E',
\}
" If the match is 0, it was a failed match
" probably due to an unexpected token which
" contained a newline. Reset matchcount. to
" continue to the next match
if !empty(l:match[1])
let l:item = {
\ 'lnum': str2nr(l:match[1]),
\ 'col': str2nr(l:match[2]),
\ 'type': 'E',
\}
else
let l:matchcount = 0
endif
elseif l:matchcount == 2
" Second match[0] grabs the full line in order
" to handles the text
@ -84,8 +92,8 @@ endfunction
call ale#linter#Define('powershell', {
\ 'name': 'powershell',
\ 'executable_callback': 'ale_linters#powershell#powershell#GetExecutable',
\ 'command_callback': 'ale_linters#powershell#powershell#GetCommand',
\ 'executable': function('ale_linters#powershell#powershell#GetExecutable'),
\ 'command': function('ale_linters#powershell#powershell#GetCommand'),
\ 'output_stream': 'stdout',
\ 'callback': 'ale_linters#powershell#powershell#Handle',
\})

View File

@ -0,0 +1,49 @@
" Author: Drew Olson <drew@drewolson.org>
" Description: Integrate ALE with purescript-language-server.
call ale#Set('purescript_ls_executable', 'purescript-language-server')
call ale#Set('purescript_ls_use_global', get(g:, 'ale_use_global_executables', 0))
call ale#Set('purescript_ls_config', {})
function! ale_linters#purescript#ls#GetExecutable(buffer) abort
return ale#node#FindExecutable(a:buffer, 'purescript_ls', [
\ 'node_modules/.bin/purescript-language-server',
\])
endfunction
function! ale_linters#purescript#ls#GetCommand(buffer) abort
let l:executable = ale_linters#purescript#ls#GetExecutable(a:buffer)
return ale#Escape(l:executable) . ' --stdio'
endfunction
function! ale_linters#purescript#ls#FindProjectRoot(buffer) abort
let l:config = ale#path#FindNearestFile(a:buffer, 'bower.json')
if !empty(l:config)
return fnamemodify(l:config, ':h')
endif
let l:config = ale#path#FindNearestFile(a:buffer, 'psc-package.json')
if !empty(l:config)
return fnamemodify(l:config, ':h')
endif
let l:config = ale#path#FindNearestFile(a:buffer, 'spago.dhall')
if !empty(l:config)
return fnamemodify(l:config, ':h')
endif
return ''
endfunction
call ale#linter#Define('purescript', {
\ 'name': 'purescript-language-server',
\ 'lsp': 'stdio',
\ 'executable': function('ale_linters#purescript#ls#GetExecutable'),
\ 'command': function('ale_linters#purescript#ls#GetCommand'),
\ 'project_root': function('ale_linters#purescript#ls#FindProjectRoot'),
\ 'lsp_config': {b -> ale#Var(b, 'purescript_ls_config')},
\})

View File

@ -0,0 +1,23 @@
" Author: David Buchan-Swanson <github@deecewan.com>
" Description: Integrate ALE with reason-language-server.
call ale#Set('reason_ls_executable', '')
function! ale_linters#reason#ls#FindProjectRoot(buffer) abort
let l:reason_config = ale#path#FindNearestFile(a:buffer, 'bsconfig.json')
if !empty(l:reason_config)
return fnamemodify(l:reason_config, ':h')
endif
return ''
endfunction
call ale#linter#Define('reason', {
\ 'name': 'reason-language-server',
\ 'lsp': 'stdio',
\ 'executable': {buffer -> ale#Var(buffer, 'reason_ls_executable')},
\ 'command': '%e',
\ 'project_root': function('ale_linters#reason#ls#FindProjectRoot'),
\ 'language': 'reason',
\})

View File

@ -5,5 +5,5 @@ call ale#linter#Define('typescript', {
\ 'name': 'eslint',
\ 'executable': function('ale#handlers#eslint#GetExecutable'),
\ 'command': function('ale#handlers#eslint#GetCommand'),
\ 'callback': 'ale#handlers#eslint#Handle',
\ 'callback': 'ale#handlers#eslint#HandleJSON',
\})

View File

@ -11,7 +11,7 @@ endfunction
function! ale_linters#typescript#xo#GetCommand(buffer) abort
return ale#Escape(ale_linters#typescript#xo#GetExecutable(a:buffer))
\ . ale#Pad(ale#Var(a:buffer, 'typescript_xo_options'))
\ . ' --reporter unix --stdin --stdin-filename %s'
\ . ' --reporter json --stdin --stdin-filename %s'
endfunction
" xo uses eslint and the output format is the same
@ -19,5 +19,5 @@ call ale#linter#Define('typescript', {
\ 'name': 'xo',
\ 'executable': function('ale_linters#typescript#xo#GetExecutable'),
\ 'command': function('ale_linters#typescript#xo#GetCommand'),
\ 'callback': 'ale#handlers#eslint#Handle',
\ 'callback': 'ale#handlers#eslint#HandleJSON',
\})

View File

@ -156,7 +156,7 @@ function! ale#Queue(delay, ...) abort
endif
endfunction
let s:current_ale_version = [2, 4, 0]
let s:current_ale_version = [2, 5, 0]
" A function used to check for ALE features in files outside of the project.
function! ale#Has(feature) abort

View File

@ -0,0 +1,41 @@
" Author: Andrew Lee <andrewl@mbda.fun>.
" Inspired by ale/gradle.vim by Michael Pardo <michael@michaelpardo.com>
" Description: Functions for working with Ant projects.
" Given a buffer number, find an Ant project root
function! ale#ant#FindProjectRoot(buffer) abort
let l:build_xml_path = ale#path#FindNearestFile(a:buffer, 'build.xml')
if !empty(l:build_xml_path)
return fnamemodify(l:build_xml_path, ':h')
endif
return ''
endfunction
" Given a buffer number, find the path to the `ant` executable. Returns an empty
" string if cannot find the executable.
function! ale#ant#FindExecutable(buffer) abort
if executable('ant')
return 'ant'
endif
return ''
endfunction
" Given a buffer number, build a command to print the classpath of the root
" project. Returns an empty string if cannot build the command.
function! ale#ant#BuildClasspathCommand(buffer) abort
let l:executable = ale#ant#FindExecutable(a:buffer)
let l:project_root = ale#ant#FindProjectRoot(a:buffer)
if !empty(l:executable) && !empty(l:project_root)
return ale#path#CdString(l:project_root)
\ . ale#Escape(l:executable)
\ . ' classpath'
\ . ' -S'
\ . ' -q'
endif
return ''
endfunction

View File

@ -52,6 +52,7 @@ let s:should_complete_map = {
\ 'lisp': s:lisp_regex,
\ 'typescript': '\v[a-zA-Z$_][a-zA-Z$_0-9]*$|\.$|''$|"$',
\ 'rust': '\v[a-zA-Z$_][a-zA-Z$_0-9]*$|\.$|::$',
\ 'cpp': '\v[a-zA-Z$_][a-zA-Z$_0-9]*$|\.$|::$|-\>$',
\}
" Regular expressions for finding the start column to replace with completion.
@ -64,6 +65,7 @@ let s:trigger_character_map = {
\ '<default>': ['.'],
\ 'typescript': ['.', '''', '"'],
\ 'rust': ['.', '::'],
\ 'cpp': ['.', '::', '->'],
\}
function! s:GetFiletypeValue(map, filetype) abort

View File

@ -128,7 +128,7 @@ function! ale#events#Init() abort
endif
if g:ale_lint_on_insert_leave
autocmd InsertLeave * call ale#Queue(0)
autocmd InsertLeave * if ale#Var(str2nr(expand('<abuf>')), 'lint_on_insert_leave') | call ale#Queue(0) | endif
endif
if g:ale_echo_cursor || g:ale_cursor_detail

View File

@ -54,7 +54,7 @@ function! ale#fix#ApplyQueuedFixes(buffer) abort
endif
if l:data.should_save
let l:should_lint = g:ale_fix_on_save
let l:should_lint = ale#Var(a:buffer, 'fix_on_save')
\ && ale#Var(a:buffer, 'lint_on_save')
else
let l:should_lint = l:data.changes_made

View File

@ -145,6 +145,11 @@ let s:default_registry = {
\ 'suggested_filetypes': ['php'],
\ 'description': 'Fix PHP files with php-cs-fixer.',
\ },
\ 'clangtidy': {
\ 'function': 'ale#fixers#clangtidy#Fix',
\ 'suggested_filetypes': ['c', 'cpp', 'objc'],
\ 'description': 'Fix C/C++ and ObjectiveC files with clang-tidy.',
\ },
\ 'clang-format': {
\ 'function': 'ale#fixers#clangformat#Fix',
\ 'suggested_filetypes': ['c', 'cpp', 'cuda'],
@ -297,7 +302,7 @@ let s:default_registry = {
\ },
\ 'styler': {
\ 'function': 'ale#fixers#styler#Fix',
\ 'suggested_filetypes': ['r'],
\ 'suggested_filetypes': ['r', 'rmarkdown'],
\ 'description': 'Fix R files with styler.',
\ },
\ 'latexindent': {
@ -310,6 +315,11 @@ let s:default_registry = {
\ 'suggested_filetypes': ['sql'],
\ 'description': 'A PostgreSQL SQL syntax beautifier',
\ },
\ 'reorder-python-imports': {
\ 'function': 'ale#fixers#reorder_python_imports#Fix',
\ 'suggested_filetypes': ['python'],
\ 'description': 'Sort Python imports with reorder-python-imports.',
\ },
\}
" Reset the function registry to the default entries.

View File

@ -0,0 +1,52 @@
scriptencoding utf-8
" Author: ObserverOfTime <chronobserver@disroot.org>
" Description: Fixing C/C++ files with clang-tidy.
function! s:set_variables() abort
let l:use_global = get(g:, 'ale_use_global_executables', 0)
for l:ft in ['c', 'cpp']
call ale#Set(l:ft . '_clangtidy_executable', 'clang-tidy')
call ale#Set(l:ft . '_clangtidy_use_global', l:use_global)
call ale#Set(l:ft . '_clangtidy_checks', [])
call ale#Set(l:ft . '_clangtidy_options', '')
call ale#Set(l:ft . '_clangtidy_extra_options', '')
call ale#Set(l:ft . '_clangtidy_fix_errors', 1)
endfor
call ale#Set('c_build_dir', '')
endfunction
call s:set_variables()
function! ale#fixers#clangtidy#Var(buffer, name) abort
let l:ft = getbufvar(str2nr(a:buffer), '&filetype')
let l:ft = l:ft =~# 'cpp' ? 'cpp' : 'c'
return ale#Var(a:buffer, l:ft . '_clangtidy_' . a:name)
endfunction
function! ale#fixers#clangtidy#GetCommand(buffer) abort
let l:checks = join(ale#fixers#clangtidy#Var(a:buffer, 'checks'), ',')
let l:extra_options = ale#fixers#clangtidy#Var(a:buffer, 'extra_options')
let l:build_dir = ale#c#GetBuildDirectory(a:buffer)
let l:options = empty(l:build_dir)
\ ? ale#fixers#clangtidy#Var(a:buffer, 'options') : ''
let l:fix_errors = ale#fixers#clangtidy#Var(a:buffer, 'fix_errors')
return ' -fix' . (l:fix_errors ? ' -fix-errors' : '')
\ . (empty(l:checks) ? '' : ' -checks=' . ale#Escape(l:checks))
\ . (empty(l:extra_options) ? '' : ' ' . l:extra_options)
\ . (empty(l:build_dir) ? '' : ' -p ' . ale#Escape(l:build_dir))
\ . ' %t' . (empty(l:options) ? '' : ' -- ' . l:options)
endfunction
function! ale#fixers#clangtidy#Fix(buffer) abort
let l:executable = ale#fixers#clangtidy#Var(a:buffer, 'executable')
let l:command = ale#fixers#clangtidy#GetCommand(a:buffer)
return {
\ 'command': ale#Escape(l:executable) . l:command,
\ 'read_temporary_file': 1,
\}
endfunction

View File

@ -39,9 +39,15 @@ function! ale#fixers#prettier#ApplyFixForVersion(buffer, version) abort
let l:options = ale#Var(a:buffer, 'javascript_prettier_options')
let l:parser = ''
let l:filetypes = split(getbufvar(a:buffer, '&filetype'), '\.')
if index(l:filetypes, 'handlebars') > -1
let l:parser = 'glimmer'
endif
" Append the --parser flag depending on the current filetype (unless it's
" already set in g:javascript_prettier_options).
if empty(expand('#' . a:buffer . ':e')) && match(l:options, '--parser') == -1
if empty(expand('#' . a:buffer . ':e')) && l:parser is# '' && match(l:options, '--parser') == -1
" Mimic Prettier's defaults. In cases without a file extension or
" filetype (scratch buffer), Prettier needs `parser` set to know how
" to process the buffer.
@ -65,7 +71,7 @@ function! ale#fixers#prettier#ApplyFixForVersion(buffer, version) abort
\ 'html': 'html',
\}
for l:filetype in split(getbufvar(a:buffer, '&filetype'), '\.')
for l:filetype in l:filetypes
if has_key(l:prettier_parsers, l:filetype)
let l:parser = l:prettier_parsers[l:filetype]
break

View File

@ -0,0 +1,25 @@
" Author: jake <me@jake.computer>
" Description: Fixing Python imports with reorder-python-imports.
call ale#Set('python_reorder_python_imports_executable', 'reorder-python-imports')
call ale#Set('python_reorder_python_imports_options', '')
call ale#Set('python_reorder_python_imports_use_global', get(g:, 'ale_use_global_executables', 0))
function! ale#fixers#reorder_python_imports#Fix(buffer) abort
let l:executable = ale#python#FindExecutable(
\ a:buffer,
\ 'python_reorder_python_imports',
\ ['reorder-python-imports'],
\)
if !executable(l:executable)
return 0
endif
let l:options = ale#Var(a:buffer, 'python_reorder_python_imports_options')
return {
\ 'command': ale#Escape(l:executable)
\ . (!empty(l:options) ? ' ' . l:options : '') . ' -',
\}
endfunction

View File

@ -1,5 +1,46 @@
" Description: Handle errors for cppcheck.
function! ale#handlers#cppcheck#GetCdCommand(buffer) abort
let [l:dir, l:json_path] = ale#c#FindCompileCommands(a:buffer)
let l:cd_command = !empty(l:dir) ? ale#path#CdString(l:dir) : ''
return l:cd_command
endfunction
function! ale#handlers#cppcheck#GetBufferPathIncludeOptions(buffer) abort
let l:buffer_path_include = ''
" Get path to this buffer so we can include it into cppcheck with -I
" This could be expanded to get more -I directives from the compile
" command in compile_commands.json, if it's found.
let l:buffer_path = fnamemodify(bufname(a:buffer), ':p:h')
let l:buffer_path_include = ' -I' . ale#Escape(l:buffer_path)
return l:buffer_path_include
endfunction
function! ale#handlers#cppcheck#GetCompileCommandsOptions(buffer) abort
" If the current buffer is modified, using compile_commands.json does no
" good, so include the file's directory instead. It's not quite as good as
" using --project, but is at least equivalent to running cppcheck on this
" file manually from the file's directory.
let l:modified = getbufvar(a:buffer, '&modified')
if l:modified
return ''
endif
" Search upwards from the file for compile_commands.json.
"
" If we find it, we'll `cd` to where the compile_commands.json file is,
" then use the file to set up import paths, etc.
let [l:dir, l:json_path] = ale#c#FindCompileCommands(a:buffer)
return !empty(l:json_path)
\ ? '--project=' . ale#Escape(l:json_path[len(l:dir) + 1: ])
\ : ''
endfunction
function! ale#handlers#cppcheck#HandleCppCheckFormat(buffer, lines) abort
" Look for lines like the following.
"

View File

@ -44,16 +44,9 @@ function! ale#handlers#eslint#GetCommand(buffer) abort
return ale#node#Executable(a:buffer, l:executable)
\ . (!empty(l:options) ? ' ' . l:options : '')
\ . ' -f unix --stdin --stdin-filename %s'
\ . ' -f json --stdin --stdin-filename %s'
endfunction
let s:col_end_patterns = [
\ '\vParsing error: Unexpected token (.+) ?',
\ '\v''(.+)'' is not defined.',
\ '\v%(Unexpected|Redundant use of) [''`](.+)[''`]',
\ '\vUnexpected (console) statement',
\]
function! s:AddHintsForTypeScriptParsingErrors(output) abort
for l:item in a:output
let l:item.text = substitute(
@ -90,22 +83,71 @@ function! s:CheckForBadConfig(buffer, lines) abort
return 0
endfunction
function! ale#handlers#eslint#Handle(buffer, lines) abort
if s:CheckForBadConfig(a:buffer, a:lines)
return [{
\ 'lnum': 1,
\ 'text': 'eslint configuration error (type :ALEDetail for more information)',
\ 'detail': join(a:lines, "\n"),
\}]
function! s:parseJSON(buffer, lines) abort
try
let l:parsed = json_decode(a:lines[-1])
catch
return []
endtry
if type(l:parsed) != v:t_list || empty(l:parsed)
return []
endif
if a:lines == ['Could not connect']
return [{
\ 'lnum': 1,
\ 'text': 'Could not connect to eslint_d. Try updating eslint_d or killing it.',
\}]
let l:errors = l:parsed[0]['messages']
if empty(l:errors)
return []
endif
let l:output = []
for l:error in l:errors
let l:obj = ({
\ 'lnum': get(l:error, 'line', 0),
\ 'text': get(l:error, 'message', ''),
\ 'type': 'E',
\})
if get(l:error, 'severity', 0) is# 1
let l:obj.type = 'W'
endif
if has_key(l:error, 'ruleId')
let l:code = l:error['ruleId']
" Sometimes ESLint returns null here
if !empty(l:code)
let l:obj.code = l:code
endif
endif
if has_key(l:error, 'column')
let l:obj.col = l:error['column']
endif
if has_key(l:error, 'endColumn')
let l:obj.end_col = l:error['endColumn'] - 1
endif
if has_key(l:error, 'endLine')
let l:obj.end_lnum = l:error['endLine']
endif
call add(l:output, l:obj)
endfor
return l:output
endfunction
let s:col_end_patterns = [
\ '\vParsing error: Unexpected token (.+) ?',
\ '\v''(.+)'' is not defined.',
\ '\v%(Unexpected|Redundant use of) [''`](.+)[''`]',
\ '\vUnexpected (console) statement',
\]
function! s:parseLines(buffer, lines) abort
" Matches patterns line the following:
"
" /path/to/some-filename.js:47:14: Missing trailing comma. [Warning/comma-dangle]
@ -120,12 +162,6 @@ function! ale#handlers#eslint#Handle(buffer, lines) abort
for l:match in ale#util#GetMatches(a:lines, [l:pattern, l:parsing_pattern])
let l:text = l:match[3]
if ale#Var(a:buffer, 'javascript_eslint_suppress_eslintignore')
if l:text =~# '^File ignored'
continue
endif
endif
let l:obj = {
\ 'lnum': l:match[1] + 0,
\ 'col': l:match[2] + 0,
@ -143,11 +179,6 @@ function! ale#handlers#eslint#Handle(buffer, lines) abort
" The code can be something like 'Error/foo/bar', or just 'Error'
if !empty(get(l:split_code, 1))
let l:obj.code = join(l:split_code[1:], '/')
if l:obj.code is# 'no-trailing-spaces'
\&& !ale#Var(a:buffer, 'warn_about_trailing_whitespace')
continue
endif
endif
for l:col_match in ale#util#GetMatches(l:text, s:col_end_patterns)
@ -157,9 +188,59 @@ function! ale#handlers#eslint#Handle(buffer, lines) abort
call add(l:output, l:obj)
endfor
return l:output
endfunction
function! s:FilterResult(buffer, obj) abort
if ale#Var(a:buffer, 'javascript_eslint_suppress_eslintignore')
if a:obj.text =~# '^File ignored'
return 0
endif
endif
if has_key(a:obj, 'code') && a:obj.code is# 'no-trailing-spaces'
\&& !ale#Var(a:buffer, 'warn_about_trailing_whitespace')
return 0
endif
return 1
endfunction
function! s:HandleESLintOutput(buffer, lines, type) abort
if s:CheckForBadConfig(a:buffer, a:lines)
return [{
\ 'lnum': 1,
\ 'text': 'eslint configuration error (type :ALEDetail for more information)',
\ 'detail': join(a:lines, "\n"),
\}]
endif
if a:lines == ['Could not connect']
return [{
\ 'lnum': 1,
\ 'text': 'Could not connect to eslint_d. Try updating eslint_d or killing it.',
\}]
endif
if a:type is# 'json'
let l:output = s:parseJSON(a:buffer, a:lines)
else
let l:output = s:parseLines(a:buffer, a:lines)
endif
call filter(l:output, {idx, obj -> s:FilterResult(a:buffer, obj)})
if expand('#' . a:buffer . ':t') =~? '\.tsx\?$'
call s:AddHintsForTypeScriptParsingErrors(l:output)
endif
return l:output
endfunction
function! ale#handlers#eslint#HandleJSON(buffer, lines) abort
return s:HandleESLintOutput(a:buffer, a:lines, 'json')
endfunction
function! ale#handlers#eslint#Handle(buffer, lines) abort
return s:HandleESLintOutput(a:buffer, a:lines, 'lines')
endfunction

View File

@ -56,14 +56,20 @@ function! ale#handlers#rust#HandleRustErrors(buffer, lines) abort
endif
if !empty(l:span)
call add(l:output, {
let l:output_line = {
\ 'lnum': l:span.line_start,
\ 'end_lnum': l:span.line_end,
\ 'col': l:span.column_start,
\ 'end_col': l:span.column_end-1,
\ 'text': empty(l:span.label) ? l:error.message : printf('%s: %s', l:error.message, l:span.label),
\ 'type': toupper(l:error.level[0]),
\})
\}
if has_key(l:error, 'rendered') && !empty(l:error.rendered)
let l:output_line.detail = l:error.rendered
endif
call add(l:output, l:output_line)
endif
endfor
endfor

View File

@ -52,7 +52,7 @@ endfunction
function! ale#highlight#RemoveHighlights() abort
for l:match in getmatches()
if l:match.group =~# '^ALE'
if l:match.group =~? '\v^ALE(Style)?(Error|Warning|Info)(Line)?$'
call matchdelete(l:match.id)
endif
endfor

View File

@ -16,5 +16,11 @@ function! ale#java#FindProjectRoot(buffer) abort
return fnamemodify(l:maven_pom_file, ':h')
endif
let l:ant_root = ale#ant#FindProjectRoot(a:buffer)
if !empty(l:ant_root)
return l:ant_root
endif
return ''
endfunction

View File

@ -13,10 +13,13 @@ let s:default_ale_linter_aliases = {
\ 'Dockerfile': 'dockerfile',
\ 'csh': 'sh',
\ 'plaintex': 'tex',
\ 'rmarkdown': 'r',
\ 'systemverilog': 'verilog',
\ 'verilog_systemverilog': ['verilog_systemverilog', 'verilog'],
\ 'vimwiki': 'markdown',
\ 'vue': ['vue', 'javascript'],
\ 'xsd': ['xsd', 'xml'],
\ 'xslt': ['xslt', 'xml'],
\ 'zsh': 'sh',
\}
@ -355,12 +358,14 @@ function! ale#linter#Define(filetype, linter) abort
" This command will throw from the sandbox.
let &l:equalprg=&l:equalprg
let l:new_linter = ale#linter#PreProcess(a:filetype, a:linter)
if !has_key(s:linters, a:filetype)
let s:linters[a:filetype] = []
endif
let l:new_linter = ale#linter#PreProcess(a:filetype, a:linter)
" Remove previously defined linters with the same name.
call filter(s:linters[a:filetype], 'v:val.name isnot# a:linter.name')
call add(s:linters[a:filetype], l:new_linter)
endfunction

View File

@ -71,8 +71,8 @@ function! s:FixList(buffer, list) abort
return l:new_list
endfunction
function! s:BufWinId(buffer) abort
return exists('*bufwinid') ? bufwinid(str2nr(a:buffer)) : 0
function! s:WinFindBuf(buffer) abort
return exists('*win_findbuf') ? win_findbuf(str2nr(a:buffer)) : [0]
endfunction
function! s:SetListsImpl(timer_id, buffer, loclist) abort
@ -88,17 +88,19 @@ function! s:SetListsImpl(timer_id, buffer, loclist) abort
call setqflist([], 'r', {'title': l:title})
endif
elseif g:ale_set_loclist
" If windows support is off, bufwinid() may not exist.
" If windows support is off, win_findbuf() may not exist.
" We'll set result in the current window, which might not be correct,
" but it's better than nothing.
let l:id = s:BufWinId(a:buffer)
let l:ids = s:WinFindBuf(a:buffer)
if has('nvim')
call setloclist(l:id, s:FixList(a:buffer, a:loclist), ' ', l:title)
else
call setloclist(l:id, s:FixList(a:buffer, a:loclist))
call setloclist(l:id, [], 'r', {'title': l:title})
endif
for l:id in l:ids
if has('nvim')
call setloclist(l:id, s:FixList(a:buffer, a:loclist), ' ', l:title)
else
call setloclist(l:id, s:FixList(a:buffer, a:loclist))
call setloclist(l:id, [], 'r', {'title': l:title})
endif
endfor
endif
" Open a window to show the problems if we need to.
@ -108,8 +110,6 @@ function! s:SetListsImpl(timer_id, buffer, loclist) abort
if s:ShouldOpen(a:buffer) && !empty(a:loclist)
let l:winnr = winnr()
let l:mode = mode()
let l:reset_visual_selection = l:mode is? 'v' || l:mode is# "\<c-v>"
let l:reset_character_selection = l:mode is? 's' || l:mode is# "\<c-s>"
" open windows vertically instead of default horizontally
let l:open_type = ''
@ -131,12 +131,13 @@ function! s:SetListsImpl(timer_id, buffer, loclist) abort
wincmd p
endif
if l:reset_visual_selection || l:reset_character_selection
" If we were in a selection mode before, select the last selection.
normal! gv
if l:reset_character_selection
" Switch back to Select mode, if we were in that.
" Return to original mode when applicable
if mode() != l:mode
if l:mode is? 'v' || l:mode is# "\<c-v>"
" Reset our last visual selection
normal! gv
elseif l:mode is? 's' || l:mode is# "\<c-s>"
" Reset our last character selection
normal! "\<c-g>"
endif
endif
@ -181,11 +182,13 @@ function! s:CloseWindowIfNeeded(buffer) abort
cclose
endif
else
let l:win_id = s:BufWinId(a:buffer)
let l:win_ids = s:WinFindBuf(a:buffer)
if g:ale_set_loclist && empty(getloclist(l:win_id))
lclose
endif
for l:win_id in l:win_ids
if g:ale_set_loclist && empty(getloclist(l:win_id))
lclose
endif
endfor
endif
" Ignore 'Cannot close last window' errors.
catch /E444/

View File

@ -90,7 +90,7 @@ function! ale#lsp#response#ReadTSServerDiagnostics(response) abort
\ 'lnum': l:diagnostic.start.line,
\ 'col': l:diagnostic.start.offset,
\ 'end_lnum': l:diagnostic.end.line,
\ 'end_col': l:diagnostic.end.offset,
\ 'end_col': l:diagnostic.end.offset - 1,
\}
if has_key(l:diagnostic, 'code')

View File

@ -8,6 +8,9 @@ if !has_key(s:, 'lsp_linter_map')
let s:lsp_linter_map = {}
endif
" A Dictionary to track one-shot handlers for custom LSP requests
let s:custom_handlers_map = get(s:, 'custom_handlers_map', {})
" Check if diagnostics for a particular linter should be ignored.
function! s:ShouldIgnore(buffer, linter_name) abort
" Ignore all diagnostics if LSP integration is disabled.
@ -407,9 +410,57 @@ endfunction
" Clear LSP linter data for the linting engine.
function! ale#lsp_linter#ClearLSPData() abort
let s:lsp_linter_map = {}
let s:custom_handlers_map = {}
endfunction
" Just for tests.
function! ale#lsp_linter#SetLSPLinterMap(replacement_map) abort
let s:lsp_linter_map = a:replacement_map
endfunction
function! s:HandleLSPResponseToCustomRequests(conn_id, response) abort
if has_key(a:response, 'id')
\&& has_key(s:custom_handlers_map, a:response.id)
let l:Handler = remove(s:custom_handlers_map, a:response.id)
call l:Handler(a:response)
endif
endfunction
function! s:OnReadyForCustomRequests(args, linter, lsp_details) abort
let l:id = a:lsp_details.connection_id
let l:request_id = ale#lsp#Send(l:id, a:args.message)
if l:request_id > 0 && has_key(a:args, 'handler')
let l:Callback = function('s:HandleLSPResponseToCustomRequests')
call ale#lsp#RegisterCallback(l:id, l:Callback)
let s:custom_handlers_map[l:request_id] = a:args.handler
endif
endfunction
" Send a custom request to an LSP linter.
function! ale#lsp_linter#SendRequest(buffer, linter_name, message, ...) abort
let l:filetype = ale#linter#ResolveFiletype(getbufvar(a:buffer, '&filetype'))
let l:linter_list = ale#linter#GetAll(l:filetype)
let l:linter_list = filter(l:linter_list, {_, v -> v.name is# a:linter_name})
if len(l:linter_list) < 1
throw 'Linter "' . a:linter_name . '" not found!'
endif
let l:linter = l:linter_list[0]
if empty(l:linter.lsp)
throw 'Linter "' . a:linter_name . '" does not support LSP!'
endif
let l:is_notification = a:message[0]
let l:callback_args = {'message': a:message}
if !l:is_notification && a:0
let l:callback_args.handler = a:1
endif
let l:Callback = function('s:OnReadyForCustomRequests', [l:callback_args])
return ale#lsp_linter#StartLSP(a:buffer, l:linter, l:Callback)
endfunction

View File

@ -3,13 +3,20 @@
" simplify a path, and fix annoying issues with paths on Windows.
"
" Forward slashes are changed to back slashes so path equality works better.
" Forward slashes are changed to back slashes so path equality works better
" on Windows. Back slashes are changed to forward slashes on Unix.
"
" Unix paths can technically contain back slashes, but in practice no path
" should, and replacing back slashes with forward slashes makes linters work
" in environments like MSYS.
"
" Paths starting with more than one forward slash are changed to only one
" forward slash, to prevent the paths being treated as special MSYS paths.
function! ale#path#Simplify(path) abort
if has('unix')
return substitute(simplify(a:path), '^//\+', '/', 'g') " no-custom-checks
let l:unix_path = substitute(a:path, '\\', '/', 'g')
return substitute(simplify(l:unix_path), '^//\+', '/', 'g') " no-custom-checks
endif
let l:win_path = substitute(a:path, '/', '\\', 'g')

View File

@ -156,7 +156,7 @@ g:ale_c_clangtidy_options *g:ale_c_clangtidy_options*
Type: |String|
Default: `''`
This variable can be changed to modify flags given to clang-tidy.
This variable can be changed to modify compiler flags given to clang-tidy.
- Setting this variable to a non-empty string,
- and working in a buffer where no compilation database is found using
@ -169,6 +169,23 @@ g:ale_c_clangtidy_options *g:ale_c_clangtidy_options*
of the |g:ale_c_build_dir_names| directories of the project tree.
g:ale_c_clangtidy_extra_options *g:ale_c_clangtidy_extra_options*
*b:ale_c_clangtidy_extra_options*
Type: |String|
Default: `''`
This variable can be changed to modify flags given to clang-tidy.
g:ale_c_clangtidy_fix_errors *g:ale_c_clangtidy_fix_errors*
*b:ale_c_clangtidy_fix_errors*
Type: |Number|
Default: `1`
This variable can be changed to disable the `-fix-errors` option for the
|clangtidy| fixer.
===============================================================================
cppcheck *ale-c-cppcheck*

View File

@ -125,7 +125,7 @@ g:ale_cpp_clangtidy_options *g:ale_cpp_clangtidy_options*
Type: |String|
Default: `''`
This variable can be changed to modify flags given to clang-tidy.
This variable can be changed to modify compiler flags given to clang-tidy.
- Setting this variable to a non-empty string,
- and working in a buffer where no compilation database is found using
@ -138,6 +138,23 @@ g:ale_cpp_clangtidy_options *g:ale_cpp_clangtidy_options*
of the |g:ale_c_build_dir_names| directories of the project tree.
g:ale_cpp_clangtidy_extra_options *g:ale_cpp_clangtidy_extra_options*
*b:ale_cpp_clangtidy_extra_options*
Type: |String|
Default: `''`
This variable can be changed to modify flags given to clang-tidy.
g:ale_cpp_clangtidy_fix_errors *g:ale_cpp_clangtidy_fix_errors*
*b:ale_cpp_clangtidy_fix_errors*
Type: |Number|
Default: `1`
This variable can be changed to disable the `-fix-errors` option for the
|clangtidy| fixer.
===============================================================================
clazy *ale-cpp-clazy*

View File

@ -6,11 +6,97 @@ In addition to the linters that are provided with ALE, C# code can be checked
with the OmniSharp plugin. See here: https://github.com/OmniSharp/omnisharp-vim
===============================================================================
csc *ale-cs-csc*
The |ale-cs-csc| linter checks for semantic errors when files are opened or
saved.
See |ale-lint-file-linters| for more information on linters which do not
check for problems while you type.
The csc linter uses the mono csc compiler providing full c# 7 and newer
support to generate a temporary module target file (/t:module). The module
includes including all '*.cs' files contained in the directory tree rooted
at the path defined by the |g:ale_cs_csc_source| or |b:ale_cs_csc_source|
variabl and all sub directories.
It will in future replace the |ale-cs-mcs| and |ale-cs-mcsc| linters as both
utilizer the mcsc compiler which according to mono porject ist further
developed and as of writint these lines only receives maintenance updates.
The down is that the csc compiler does not support the -sytax option any more
and therefore |ale-cs-csc| linter doese not offer any as you type syntax
checking like the |ale-cs-mcsc| linter doesn't.
The paths to search for additional assembly files can be specified using the
|g:ale_cs_csc_assembly_path| or |b:ale_cs_csc_assembly_path| variables.
NOTE: ALE will not find any errors in files apart from syntax errors if any
one of the source files contains a syntax error. Syntax errors must be fixed
first before other errors will be shown.
g:ale_cs_csc_options *g:ale_cs_csc_options*
*b:ale_cs_csc_options*
Type: |String|
Default: `''`
This option can be set to pass additional arguments to the `csc` compiler.
For example, to add the dotnet package which is not added per default: >
let g:ale_cs_mcs_options = ' /warn:4 /langversion:7.2'
<
NOTE: the `/unsafe` option is always passed to `csc`.
g:ale_cs_csc_source *g:ale_cs_csc_source*
*b:ale_cs_csc_source*
Type: |String|
Default: `''`
This variable defines the root path of the directory tree searched for the
'*.cs' files to be linted. If this option is empty, the source file's
directory will be used.
NOTE: Currently it is not possible to specify sub directories and
directory sub trees which shall not be searched for *.cs files.
g:ale_cs_csc_assembly_path *g:ale_cs_csc_assembly_path*
*b:ale_cs_csc_assembly_path*
Type: |List|
Default: `[]`
This variable defines a list of path strings to be searched for external
assembly files. The list is passed to the csc compiler using the `/lib:`
flag.
g:ale_cs_csc_assemblies *g:ale_cs_csc_assemblies*
*b:ale_cs_csc_assemblies*
Type: |List|
Default: `[]`
This variable defines a list of external assembly (*.dll) files required
by the mono mcs compiler to generate a valid module target. The list is
passed the csc compiler using the `/r:` flag.
For example: >
" Compile C# programs with the Unity engine DLL file on Mac.
let g:ale_cs_mcsc_assemblies = [
\ '/Applications/Unity/Unity.app/Contents/Frameworks/Managed/UnityEngine.dll',
\ 'path-to-unityproject/obj/Debug',
\]
<
===============================================================================
mcs *ale-cs-mcs*
The `mcs` linter looks only for syntax errors while you type. See |ale-cs-mcsc|
for the separately configured linter for checking for semantic errors.
The `mcs` linter looks only for syntax errors while you type. See
|ale-cs-mcsc| for the separately configured linter for checking for semantic
errors.
g:ale_cs_mcs_options *g:ale_cs_mcs_options*

View File

@ -2,6 +2,13 @@
ALE Handlebars Integration *ale-handlebars-options*
===============================================================================
prettier *ale-handlebars-prettier*
See |ale-javascript-prettier| for information about the available options.
Uses glimmer parser by default.
===============================================================================
ember-template-lint *ale-handlebars-embertemplatelint*

View File

@ -5,14 +5,41 @@ ALE Java Integration *ale-java-options*
===============================================================================
checkstyle *ale-java-checkstyle*
g:ale_java_checkstyle_config *g:ale_java_checkstyle_config*
*b:ale_java_checkstyle_config*
Type: |String|
Default: `'/google_checks.xml'`
A path to a checkstyle configuration file.
If a configuration file is specified with |g:ale_java_checkstyle_options|,
it will be preferred over this setting.
The path to the configuration file can be an absolute path or a relative
path. ALE will search for the relative path in parent directories.
g:ale_java_checkstyle_executable *g:ale_java_checkstyle_executable*
*b:ale_java_checkstyle_executable*
Type: |String|
Default: 'checkstyle'
This variable can be changed to modify the executable used for checkstyle.
g:ale_java_checkstyle_options *g:ale_java_checkstyle_options*
*b:ale_java_checkstyle_options*
Type: String
Default: '-c /google_checks.xml'
Type: |String|
Default: `''`
This variable can be changed to modify flags given to checkstyle.
If a configuration file is specified with `-c`, it will be used instead of
configuration files set with |g:ale_java_checkstyle_config|.
===============================================================================
javac *ale-java-javac*
@ -90,16 +117,46 @@ or
This generates a dist/mac or dist/windows directory that contains the
language server. To let ALE use this language server you need to set the
g:ale_java_javalsp_executable variable to the absolute path of the java
g:ale_java_javalsp_executable variable to the absolute path of the launcher
executable in this directory.
g:ale_java_javalsp_executable *g:ale_java_javalsp_executable*
*b:ale_java_javalsp_executable*
Type: |String|
Default: `'java'`
Default: `''`
This variable can be changed to use a different executable for java.
This variable must be set to the absolute path of the language server launcher
executable. For example:
>
let g:ale_java_javalsp_executable=/java-language-server/dist/mac/bin/launcher
<
g:ale_java_javalsp_config *g:ale_java_javalsp_config*
*b:ale_java_javalsp_config*
Type: |Dictionary|
Default: `{}`
The javalsp linter automatically detects external depenencies for Maven and
Gradle projects. In case the javalsp fails to detect some of them, you can
specify them setting a dictionary to |g:ale_java_javalsp_config| variable.
>
let g:ale_java_javalsp_executable =
\ {
\ 'java': {
\ 'externalDependencies': [
\ 'junit:junit:jar:4.12:test', " Maven format
\ 'junit:junit:4.1' " Gradle format
\ ],
\ 'classPath': [
\ 'lib/some-dependency.jar',
\ '/android-sdk/platforms/android-28.jar'
\ ]
\ }
\ }
The Java language server will look for the dependencies you specify in
`externalDependencies` array in your Maven and Gradle caches ~/.m2 and
~/.gradle.
===============================================================================
eclipselsp *ale-java-eclipselsp*
@ -118,7 +175,7 @@ located inside the repository folder `eclipse.jdt.ls`. Please ensure to set
|g:ale_java_eclipselsp_path| to the absolute path of that folder.
You could customize compiler options and code assists of the server.
Under your project folder, modify the file `.settings/org.eclipse.jdt.core.prefs`
Under your project folder, modify the file `.settings/org.eclipse.jdt.core.prefs`
with options presented at
https://help.eclipse.org/neon/topic/org.eclipse.jdt.doc.isv/reference/api/org/eclipse/jdt/core/JavaCore.html.
@ -141,8 +198,8 @@ g:ale_java_eclipselsp_executable *g:ale_java_eclipse_executable*
This variable can be set to change the executable path used for java.
g:ale_java_eclipselsp_config_path *g:ale_java_eclipse_config_path*
*b:ale_java_eclipse_config_path*
g:ale_java_eclipselsp_config_path *g:ale_java_eclipse_config_path*
*b:ale_java_eclipse_config_path*
Type: |String|
Default: `''`
@ -155,8 +212,8 @@ g:ale_java_eclipselsp_config_path *g:ale_java_eclipse_config_path
installed via system package.
g:ale_java_eclipselsp_workspace_path *g:ale_java_eclipselsp_workspace_path*
*b:ale_java_eclipselsp_workspace_path*
g:ale_java_eclipselsp_workspace_path *g:ale_java_eclipselsp_workspace_path*
*b:ale_java_eclipselsp_workspace_path*
Type: |String|
Default: `''`

View File

@ -0,0 +1,33 @@
===============================================================================
ALE PureScript Integration *ale-purescript-options*
===============================================================================
purescript-language-server *ale-purescript-language-server*
PureScript Language Server
(https://github.com/nwolverson/purescript-language-server)
g:ale_purescript_ls_executable g:ale_purescript_ls_executable
b:ale_purescript_ls_executable
Type: |String|
Default: `'purescript-language-server'`
PureScript language server executable.
g:ale_purescript_ls_config g:ale_purescript_ls_config
b:ale_purescript_ls_config
Type: |Dictionary|
Default: `{}`
Dictionary containing configuration settings that will be passed to the
language server. For example, with a spago project:
{
\ 'purescript': {
\ 'addSpagoSources': v:true,
\ 'addNpmPath': v:true,
\ 'buildCommand': 'spago build -- --json-errors'
\ }
\}
===============================================================================
vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl:

View File

@ -672,6 +672,36 @@ g:ale_python_pyre_auto_pipenv *g:ale_python_pyre_auto_pipenv*
if true. This is overridden by a manually-set executable.
===============================================================================
reorder-python-imports *ale-python-reorder_python_imports*
g:ale_python_reorder_python_imports_executable
*g:ale_python_reorder_python_imports_executable*
*b:ale_python_reorder_python_imports_executable*
Type: |String|
Default: `'reorder-python-imports'`
See |ale-integrations-local-executables|
g:ale_python_reorder_python_imports_options
*g:ale_python_reorder_python_imports_options*
*b:ale_python_reorder_python_imports_options*
Type: |String|
Default: `''`
This variable can be set to pass extra options to reorder-python-imports.
g:ale_python_reorder_python_imports_use_global
*g:ale_python_reorder_python_imports_use_global*
*b:ale_python_reorder_python_imports_use_global*
Type: |Number|
Default: `get(g:, 'ale_use_global_executables', 0)`
See |ale-integrations-local-executables|
===============================================================================
vulture *ale-python-vulture*

View File

@ -5,18 +5,19 @@ ALE ReasonML Integration *ale-reasonml-options*
===============================================================================
merlin *ale-reasonml-merlin*
To use merlin linter for ReasonML source code you need to make sure Merlin
for Vim is correctly configured. See the corresponding Merlin wiki page for
detailed instructions
(https://github.com/the-lambda-church/merlin/wiki/vim-from-scratch).
To use merlin linter for ReasonML source code you need to make sure Merlin for
Vim is correctly configured. See the corresponding Merlin wiki page for
detailed instructions:
https://github.com/the-lambda-church/merlin/wiki/vim-from-scratch
===============================================================================
ols *ale-reasonml-ols*
The `ocaml-language-server` is the engine that powers OCaml and ReasonML
editor support using the Language Server Protocol. See the installation
instructions:
https://github.com/freebroccolo/ocaml-language-server#installation
The `ocaml-language-server` is the engine that powers OCaml and ReasonML
editor support using the Language Server Protocol. See the installation
instructions:
https://github.com/freebroccolo/ocaml-language-server#installation
g:ale_reason_ols_executable *g:ale_reason_ols_executable*
*b:ale_reason_ols_executable*
@ -25,6 +26,7 @@ g:ale_reason_ols_executable *g:ale_reason_ols_executable*
This variable can be set to change the executable path for `ols`.
g:ale_reason_ols_use_global *g:ale_reason_ols_use_global*
*b:ale_reason_ols_use_global*
Type: |String|
@ -33,6 +35,24 @@ g:ale_reason_ols_use_global *g:ale_reason_ols_use_global*
This variable can be set to `1` to always use the globally installed
executable. See also |ale-integrations-local-executables|.
===============================================================================
reason-language-server *ale-reasonml-language-server*
Note: You must set an executable - there is no 'default' install location.
Go to https://github.com/jaredly/reason-language-server and download the
latest release. You can place it anywhere, but ensure you set the executable
path.
g:ale_reason_ls_executable *g:ale_reason_ls_executable*
*b:ale_reason_ls_executable*
Type: |String|
This variable defines the standard location of the language server
executable. This must be set.
===============================================================================
refmt *ale-reasonml-refmt*
@ -43,6 +63,7 @@ g:ale_reasonml_refmt_executable *g:ale_reasonml_refmt_executable*
This variable can be set to pass the path of the refmt fixer.
g:ale_reasonml_refmt_options *g:ale_reasonml_refmt_options*
*b:ale_reasonml_refmt_options*
Type: |String|
@ -50,5 +71,6 @@ g:ale_reasonml_refmt_options *g:ale_reasonml_refmt_options*
This variable can be set to pass additional options to the refmt fixer.
===============================================================================
vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl:

View File

@ -53,6 +53,7 @@ Notes:
* `gcc`
* `uncrustify`
* C#
* `csc`!!
* `mcs`
* `mcsc`!!
* `uncrustify`
@ -338,6 +339,8 @@ Notes:
* `languageserver`
* `puppet`
* `puppet-lint`
* PureScript
* `purescript-language-server`
* Python
* `autopep8`
* `bandit`
@ -353,6 +356,7 @@ Notes:
* `pylint`!!
* `pyls`
* `pyre`
* `reorder-python-imports`
* `vulture`!!
* `yapf`
* QML
@ -366,6 +370,7 @@ Notes:
* ReasonML
* `merlin`
* `ols`
* `reason-language-server`
* `refmt`
* reStructuredText
* `alex`!!

View File

@ -84,7 +84,7 @@ have even saved your changes. ALE will check your code in the following
circumstances, which can be configured with the associated options.
* When you modify a buffer. - |g:ale_lint_on_text_changed|
* On leaving insert mode. (off by default) - |g:ale_lint_on_insert_leave|
* On leaving insert mode. - |g:ale_lint_on_insert_leave|
* When you open a new or modified buffer. - |g:ale_lint_on_enter|
* When you save a buffer. - |g:ale_lint_on_save|
* When the filetype changes for a buffer. - |g:ale_lint_on_filetype_changed|
@ -953,7 +953,7 @@ g:ale_lint_on_save *g:ale_lint_on_save*
g:ale_lint_on_text_changed *g:ale_lint_on_text_changed*
Type: |String|
Default: `'always'`
Default: `'normal'`
This option controls how ALE will check your files as you make changes.
The following values can be used.
@ -978,9 +978,10 @@ g:ale_lint_on_text_changed *g:ale_lint_on_text_changed*
g:ale_lint_on_insert_leave *g:ale_lint_on_insert_leave*
*b:ale_lint_on_insert_leave*
Type: |Number|
Default: `0`
Default: `1`
When set to `1` in your vimrc file, this option will cause ALE to run
linters when you leave insert mode.
@ -992,6 +993,10 @@ g:ale_lint_on_insert_leave *g:ale_lint_on_insert_leave*
" Make using Ctrl+C do the same as Escape, to trigger autocmd commands
inoremap <C-c> <Esc>
<
A buffer-local version of this setting `b:ale_lint_on_insert_leave` can be
set to `0` to disable linting when leaving insert mode. The setting must
be enabled globally to be enabled locally.
You should set this setting once before ALE is loaded, and restart Vim if
you want to change your preferences. See |ale-lint-settings-on-startup|.
@ -1012,10 +1017,13 @@ g:ale_linter_aliases *g:ale_linter_aliases*
\ 'Dockerfile': 'dockerfile',
\ 'csh': 'sh',
\ 'plaintex': 'tex',
\ 'rmarkdown': 'r',
\ 'systemverilog': 'verilog',
\ 'verilog_systemverilog': ['verilog_systemverilog', 'verilog'],
\ 'vimwiki': 'markdown',
\ 'vue': ['vue', 'javascript'],
\ 'xsd': ['xsd', 'xml'],
\ 'xslt': ['xslt', 'xml'],
\ 'zsh': 'sh',
\}
<
@ -1967,6 +1975,7 @@ documented in additional help files.
uncrustify............................|ale-cpp-uncrustify|
ccls..................................|ale-cpp-ccls|
c#......................................|ale-cs-options|
csc...................................|ale-cs-csc|
mcs...................................|ale-cs-mcs|
mcsc..................................|ale-cs-mcsc|
uncrustify............................|ale-cs-uncrustify|
@ -2034,6 +2043,7 @@ documented in additional help files.
hackfmt...............................|ale-hack-hackfmt|
hhast.................................|ale-hack-hhast|
handlebars..............................|ale-handlebars-options|
prettier..............................|ale-handlebars-prettier|
ember-template-lint...................|ale-handlebars-embertemplatelint|
haskell.................................|ale-haskell-options|
brittany..............................|ale-haskell-brittany|
@ -2167,6 +2177,8 @@ documented in additional help files.
puppet................................|ale-puppet-puppet|
puppetlint............................|ale-puppet-puppetlint|
puppet-languageserver.................|ale-puppet-languageserver|
purescript..............................|ale-purescript-options|
purescript-language-server............|ale-purescript-language-server|
pyrex (cython)..........................|ale-pyrex-options|
cython................................|ale-pyrex-cython|
python..................................|ale-python-options|
@ -2184,6 +2196,7 @@ documented in additional help files.
pylint................................|ale-python-pylint|
pyls..................................|ale-python-pyls|
pyre..................................|ale-python-pyre|
reorder-python-imports................|ale-python-reorder_python_imports|
vulture...............................|ale-python-vulture|
yapf..................................|ale-python-yapf|
qml.....................................|ale-qml-options|
@ -2194,6 +2207,7 @@ documented in additional help files.
reasonml................................|ale-reasonml-options|
merlin................................|ale-reasonml-merlin|
ols...................................|ale-reasonml-ols|
reason-language-server................|ale-reasonml-language-server|
refmt.................................|ale-reasonml-refmt|
restructuredtext........................|ale-restructuredtext-options|
textlint..............................|ale-restructuredtext-textlint|
@ -3191,6 +3205,33 @@ ale#linter#PreventLoading(filetype) *ale#linter#PreventLoading()*
|runtimepath| for that filetype. This function can be called from vimrc or
similar to prevent ALE from loading linters.
ale#lsp_linter#SendRequest(buffer, linter_name, message, [Handler])
*ale#lsp_linter#SendRequest()*
Send a custom request to an LSP linter. The arguments are defined as
follows:
`buffer` A valid buffer number.
`linter_name` A |String| identifying an LSP linter that is available and
enabled for the |filetype| of `buffer`.
`message` A |List| in the form `[is_notification, method, parameters]`,
containing three elements:
`is_notification` - an |Integer| that has value 1 if the
request is a notification, 0 otherwise;
`method` - a |String|, identifying an LSP method supported
by `linter`;
`parameters` - a |dictionary| of LSP parameters that are
applicable to `method`.
`Handler` Optional argument, meaningful only when `message[0]` is 0.
A |Funcref| that is called when a response to the request is
received, and takes as unique argument a dictionary
representing the response obtained from the server.
ale#other_source#ShowResults(buffer, linter_name, loclist)
*ale#other_source#ShowResults()*

View File

@ -71,12 +71,12 @@ let g:ale_linter_aliases = get(g:, 'ale_linter_aliases', {})
let g:ale_lint_delay = get(g:, 'ale_lint_delay', 200)
" This flag can be set to 'never' to disable linting when text is changed.
" This flag can also be set to 'insert' or 'normal' to lint when text is
" changed only in insert or normal mode respectively.
let g:ale_lint_on_text_changed = get(g:, 'ale_lint_on_text_changed', 'always')
" This flag can also be set to 'always' or 'insert' to lint when text is
" changed in both normal and insert mode, or only in insert mode respectively.
let g:ale_lint_on_text_changed = get(g:, 'ale_lint_on_text_changed', 'normal')
" This flag can be set to 1 to enable linting when leaving insert mode.
let g:ale_lint_on_insert_leave = get(g:, 'ale_lint_on_insert_leave', 0)
let g:ale_lint_on_insert_leave = get(g:, 'ale_lint_on_insert_leave', 1)
" This flag can be set to 0 to disable linting when the buffer is entered.
let g:ale_lint_on_enter = get(g:, 'ale_lint_on_enter', 1)

View File

@ -21,7 +21,7 @@ class Source(Base):
self.name = 'ale'
self.mark = '[L]'
self.rank = 100
self.rank = 1000
self.is_bytepos = True
self.min_pattern_length = 1

View File

@ -62,6 +62,7 @@ formatting.
* [gcc](https://gcc.gnu.org/)
* [uncrustify](https://github.com/uncrustify/uncrustify)
* C#
* [csc](http://www.mono-project.com/docs/about-mono/languages/csharp/) :floppy_disk: see:`help ale-cs-csc` for details and configuration
* [mcs](http://www.mono-project.com/docs/about-mono/languages/csharp/) see:`help ale-cs-mcs` for details
* [mcsc](http://www.mono-project.com/docs/about-mono/languages/csharp/) :floppy_disk: see:`help ale-cs-mcsc` for details and configuration
* [uncrustify](https://github.com/uncrustify/uncrustify)
@ -131,7 +132,7 @@ formatting.
* Elm
* [elm-format](https://github.com/avh4/elm-format)
* [elm-lsp](https://github.com/antew/elm-lsp)
* [elm-make](https://github.com/elm-lang/elm-make)
* [elm-make](https://github.com/elm/compiler)
* Erb
* [erb](https://apidock.com/ruby/ERB)
* [erubi](https://github.com/jeremyevans/erubi)
@ -347,6 +348,8 @@ formatting.
* [languageserver](https://github.com/lingua-pupuli/puppet-editor-services)
* [puppet](https://puppet.com)
* [puppet-lint](https://puppet-lint.com)
* PureScript
* [purescript-language-server](https://github.com/nwolverson/purescript-language-server)
* Python
* [autopep8](https://github.com/hhatto/autopep8)
* [bandit](https://github.com/PyCQA/bandit) :warning:
@ -362,6 +365,7 @@ formatting.
* [pylint](https://www.pylint.org/) :floppy_disk:
* [pyls](https://github.com/palantir/python-language-server) :warning:
* [pyre](https://github.com/facebook/pyre-check) :warning:
* [reorder-python-imports](https://github.com/asottile/reorder_python_imports)
* [vulture](https://github.com/jendrikseipp/vulture) :warning: :floppy_disk:
* [yapf](https://github.com/google/yapf)
* QML
@ -375,6 +379,7 @@ formatting.
* ReasonML
* [merlin](https://github.com/the-lambda-church/merlin) see `:help ale-reasonml-ols` for configuration instructions
* [ols](https://github.com/freebroccolo/ocaml-language-server)
* [reason-language-server](https://github.com/jaredly/reason-language-server)
* [refmt](https://github.com/reasonml/reason-cli)
* reStructuredText
* [alex](https://github.com/wooorm/alex) :floppy_disk:

View File

@ -260,7 +260,7 @@ function! s:goyo_on(dim)
augroup goyo
autocmd!
autocmd TabLeave * call s:goyo_off()
autocmd TabLeave * nested call s:goyo_off()
autocmd VimResized * call s:resize_pads()
autocmd ColorScheme * call s:tranquilize()
autocmd BufWinEnter * call s:hide_linenr() | call s:hide_statusline()

View File

@ -57,6 +57,8 @@ landscape is my colorscheme, which is a high-contrast cterm-supported colorschem
git clone https://github.com/itchyny/lightline.vim ~/.vim/bundle/lightline.vim
2. Generate help tags with `:Helptags`.
### [Vundle](https://github.com/VundleVim/Vundle.vim)
1. Add the following configuration to your `.vimrc`.

View File

@ -0,0 +1,28 @@
" =============================================================================
" Filename: autoload/lightline/colorscheme/powerlineish.vim
" Author: itchyny
" License: MIT License
" Last Change: 2019/06/12 18:47:00.
" =============================================================================
let s:p = {'normal': {}, 'inactive': {}, 'insert': {}, 'replace': {}, 'visual': {}, 'tabline': {}}
let s:p.normal.left = [ ['darkestgreen', 'brightgreen', 'bold'], ['white', 'gray0'] ]
let s:p.normal.right = [ ['gray10', 'gray2'], ['white', 'gray1'], ['white', 'gray0'] ]
let s:p.inactive.right = [ ['gray1', 'gray5'], ['gray4', 'gray1'], ['gray4', 'gray0'] ]
let s:p.inactive.left = s:p.inactive.right[1:]
let s:p.insert.left = [ ['darkestcyan', 'white', 'bold'], ['mediumcyan', 'darkestblue'] ]
let s:p.insert.right = [ [ 'darkestblue', 'mediumcyan' ], [ 'mediumcyan', 'darkblue' ], [ 'mediumcyan', 'darkestblue' ] ]
let s:p.replace.left = [ ['white', 'brightred', 'bold'], ['white', 'gray0'] ]
let s:p.visual.left = [ ['black', 'brightestorange', 'bold'], ['white', 'gray0'] ]
let s:p.normal.middle = [ [ 'white', 'gray0' ] ]
let s:p.insert.middle = [ [ 'mediumcyan', 'darkestblue' ] ]
let s:p.replace.middle = s:p.normal.middle
let s:p.replace.right = s:p.normal.right
let s:p.tabline.left = [ [ 'gray9', 'gray0' ] ]
let s:p.tabline.tabsel = [ [ 'gray9', 'gray2' ] ]
let s:p.tabline.middle = [ [ 'gray2', 'gray0' ] ]
let s:p.tabline.right = [ [ 'gray9', 'gray1' ] ]
let s:p.normal.error = [ [ 'gray9', 'brightestred' ] ]
let s:p.normal.warning = [ [ 'gray1', 'yellow' ] ]
let g:lightline#colorscheme#powerlineish#palette = lightline#colorscheme#fill(s:p)

View File

@ -4,7 +4,7 @@ Version: 0.1
Author: itchyny (https://github.com/itchyny)
License: MIT License
Repository: https://github.com/itchyny/lightline.vim
Last Change: 2018/04/28 00:08:18.
Last Change: 2019/06/12 18:47:11.
CONTENTS *lightline-contents*
@ -226,8 +226,8 @@ OPTIONS *lightline-option*
<
g:lightline.colorscheme *g:lightline.colorscheme*
The colorscheme for lightline.vim.
Currently, wombat, solarized, powerline, jellybeans, Tomorrow,
Tomorrow_Night, Tomorrow_Night_Blue, Tomorrow_Night_Eighties,
Currently, wombat, solarized, powerline, powerlineish, jellybeans,
Tomorrow, Tomorrow_Night, Tomorrow_Night_Blue, Tomorrow_Night_Eighties,
PaperColor, seoul256, landscape, one, darcula, molokai, materia,
material, OldHope, nord, 16color and deus are available.
The default value is:
@ -986,12 +986,15 @@ Problem 1: *lightline-problem-1*
1. Put all the files under $VIM.
If you are using |vim-pathogen|, install this plugin with the
following command.
If you are to install this plugin using |vim-pathogen|:
1. Install this plugin with the following command.
>
git clone https://github.com/itchyny/lightline.vim \
~/.vim/bundle/lightline.vim
<
2. Generate help tags with |:Helptags|.
If you are to install this plugin using |Vundle|:
1. Add the following configuration to your

View File

@ -1,28 +0,0 @@
<!--- To assist in resolving your issue, provide as much information as possible. -->
### 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:
```vim
```
### 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 have expected from this process. -->
### Screenshot(s)
### Possible Fix
<!--- If you have explored the code, share what you've found. -->

View File

@ -0,0 +1,45 @@
---
name: "Bug Report"
about: "NERDTree is misbehaving? Tell us about it."
labels: bug
---
# Attention! Please Read!
Please fill out **ALL the information** below so that the issue can be fully understood. Omitting information will delay the resolution of your issue. It will be labeled **`Needs More Info`**, and *may* be closed until there is enough information.
Keep in mind that others may have the same question in the future. The better your information, the more likely they'll be able to help themselves.
After reading, and before submitting your issue, please remove this introductory text.
──────────────────── ✄ ────────────────────
#### Self-Diagnosis
- [ ] I have searched the [issues](https://github.com/scrooloose/nerdtree/issues) for an answer to my question.
- [ ] I have reviewed the NERDTree documentation. `:h NERDTree`
- [ ] I have reviewed the [Wiki](https://github.com/scrooloose/nerdtree/wiki).
- [ ] I have searched the web for an answer to my question.
#### Environment (for bug reports)
- [ ] Operating System:
- [ ] Vim/Neovim version `:echo v:version`:
- [ ] NERDTree version, found on 1st line in NERDTree quickhelp `?`:
- [ ] vimrc settings
- [ ] NERDTree variables
```vim
```
- Other NERDTree-dependent Plugins
- [ ] jistr/vim-nerdtree-tabs
- [ ] ryanoasis/vim-devicons
- [ ] tiagofumo/vim-nerdtree-syntax-highlight
- [ ] Xuyuanp/nerdtree-git-plugin
- [ ] Others (specify):
- [ ] I've verified the issue occurs with only NERDTree installed.
#### Steps to Reproduce the Issue
1.
#### Current Result (Include screenshots where appropriate.)
#### Expected Result

View File

@ -0,0 +1,8 @@
---
name: "Feature Request"
about: "What new feature are you requesting for NERDTree?"
labels: "feature request"
---
#### Description

View File

@ -0,0 +1,24 @@
---
name: "General Question"
about: "Having trouble setting up NERDTree? Need clarification on a setting? Ask your question here."
labels: "general question"
---
# Attention! Please Read!
Please fill out **ALL the information** below so that the issue can be fully understood. Omitting information will delay the resolution of your issue. It will be labeled **`Needs More Info`**, and *may* be closed until there is enough information.
Keep in mind that others may have the same question in the future. The better your information, the more likely they'll be able to help themselves.
After reading, and before submitting your issue, please remove this introductory text.
──────────────────── ✄ ────────────────────
#### Self-Diagnosis
- [ ] I have searched the [issues](https://github.com/scrooloose/nerdtree/issues) for an answer to my question.
- [ ] I have reviewed the NERDTree documentation. `:h NERDTree`
- [ ] I have reviewed the [Wiki](https://github.com/scrooloose/nerdtree/wiki).
- [ ] I have searched the web for an answer to my question.
#### State Your Question

View File

@ -0,0 +1,20 @@
### Description of Changes
Closes # <!-- Issue number this PR addresses. If none, remove this line. -->
---
### New Version Info
- [ ] Derive a new version number. Increment the:
- [ ] `MAJOR` version when you make incompatible API changes
- [ ] `MINOR` version when you add functionality in a backwards-compatible manner
- [ ] `PATCH` version when you make backwards-compatible bug fixes
- [ ] Update [CHANGELOG.md](https://github.com/scrooloose/nerdtree/blob/master/CHANGELOG.md), following this format/example:
```
#### MAJOR.MINOR...
- **.PATCH**: PR Title (Author) [#PR Number](link to PR)
#### 5.1...
- **.1**: Update Changelog and create PR Template (PhilRunninger) [#1007](https://github.com/scrooloose/nerdtree/pull/1007)
- **.0**: Too many changes for one patch...
```

View File

@ -1,179 +0,0 @@
Next
- Fix broken "t" and "T" mappings, tabs now open at end (lifecrisis) #759
- Update doc with already existing mapping variables (asnr) #699
- Fix the broken g:NERDTreeBookmarksSort setting (lifecrisis) #696
- Correct NERDTreeIgnore pattern in doc (cntoplolicon) #648
- Remove empty segments when splitting path (sooth-sayer) #574
- Suppress autocmds less agressively (wincent) #578 #691
- Add an Issues template to ask for more info initially.
- Fix markdown headers in readme (josephfrazier) #676
- Don't touch @o and @h registers when rendering
- Fix bug with files and directories with dollar signs (alegen) #649
- Reuse/reopen existing window trees where possible #244
- Remove NERDTree.previousBuf()
- Change color of arrow (Leeiio) #630
- Improved a tip in README.markdown (ggicci) #628
- Shorten delete confimration of empty directory to 'y' (mikeperri) #530
- Fix API call to open directory tree in window (devm33) #533
- Change default arrows on non-Windows platforms (gwilk) #546
- Update to README - combine cd and git clone (zwhitchcox) #584
- Update to README - Tip: start NERDTree when vim starts (therealplato) #593
- Escape filename when moving an open buffer (zacharyvoase) #595
- Fixed incorrect :helptags command in README (curran) #619
- Fixed incomplete escaping of folder arrows (adityanatraj) #548
- Added NERDTreeCascadeSingleChildDir option (juanibiapina) #558
- Replace strchars() with backward compatible workaround.
- Add support for copy command in Windows (SkylerLipthay) #231
- Fixed typo in README.markdown - :Helptags -> :helptags
- Rename "primary" and "secondary" trees to "tab" and "window" trees.
- Move a bunch of buffer level variables into the NERDTree and UI classes.
- Display cascading dirs on one line to save vertical/horizontal space (@matt-gardner: brainstorming/testing)
- Remove the old style UI - Remove 'NERDTreeDirArrows' option.
- On windows default to + and ~ for expand/collapse directory symbols.
- Lots more refactoring. Move a bunch of b: level vars into b:NERDTree and friends.
5.0.0
- Refactor the code significantly:
* Break the classes out into their own files.
* Make the majority of the code OO - previously large parts were
effectively a tangle of "global" methods.
- Add an API to assign flags to nodes. This allows VCS plugins like
https://github.com/Xuyuanp/nerdtree-git-plugin to exist. Thanks to
Xuyuanp for helping design/test/build said API.
- add 'scope' argument to the key map API see :help NERDTreeAddKeyMap()
- add magic [[dir]] and [[file]] flags to NERDTreeIgnore
- add support for custom path filters. See :help NERDTreeAddPathFilter()
- add path listener API. See :help NERDTreePathListenerAPI.
- expand the fs menu functionality to list file properties (PhilRunninger,
apbarrero, JESii)
- make bookmarks work with `~` home shortcuts (hiberabyss)
- show OSX specific fsmenu options in regular vim on mac (evindor)
- make dir arrow icons configurable (PickRelated)
- optimise node sorting performance when opening large dirs (vtsang)
- make the root note render prettier by truncating it at a path slash (gcmt)
- remove NERDChristmasTree option - its always christmas now
- add "cascade" open and closing for dirs containing only another single
dir. See :help NERDTreeCascadeOpenSingleChildDir (pendulm)
Many other fixes, doc updates and contributions from:
actionshrimp
SchDen
egalpin
cperl82 - many small fixes
toiffel
WoLpH
handcraftedbits
devmanhinton
xiaodili
zhangoose
gastropoda
mixvin
alvan
lucascaton
kelaban
shanesmith
staeff
pendulm
stephenprater
franksort
agrussellknives
AndrewRadev
Twinside
4.2.0
- Add NERDTreeDirArrows option to make the UI use pretty arrow chars
instead of the old +~| chars to define the tree structure (sickill)
- shift the syntax highlighting out into its own syntax file (gnap)
- add some mac specific options to the filesystem menu - for macvim
only (andersonfreitas)
- Add NERDTreeMinimalUI option to remove some non functional parts of the
nerdtree ui (camthompson)
- tweak the behaviour of :NERDTreeFind - see :help :NERDTreeFind for the
new behaviour (benjamingeiger)
- if no name is given to :Bookmark, make it default to the name of the
target file/dir (minyoung)
- use 'file' completion when doing copying, create, and move
operations (EvanDotPro)
- lots of misc bug fixes (paddyoloughlin, sdewald, camthompson, Vitaly
Bogdanov, AndrewRadev, mathias, scottstvnsn, kml, wycats, me RAWR!)
4.1.0
features:
- NERDTreeFind to reveal the node for the current buffer in the tree,
see |NERDTreeFind|. This effectively merges the FindInNERDTree plugin (by
Doug McInnes) into the script.
- make NERDTreeQuitOnOpen apply to the t/T keymaps too. Thanks to Stefan
Ritter and Rémi Prévost.
- truncate the root node if wider than the tree window. Thanks to Victor
Gonzalez.
bugfixes:
- really fix window state restoring
- fix some win32 path escaping issues. Thanks to Stephan Baumeister, Ricky,
jfilip1024, and Chris Chambers
4.0.0
- add a new programmable menu system (see :help NERDTreeMenu).
- add new APIs to add menus/menu-items to the menu system as well as
custom key mappings to the NERD tree buffer (see :help NERDTreeAPI).
- removed the old API functions
- added a mapping to maximize/restore the size of nerd tree window, thanks
to Guillaume Duranceau for the patch. See :help NERDTree-A for details.
- fix a bug where secondary nerd trees (netrw hijacked trees) and
NERDTreeQuitOnOpen didnt play nicely, thanks to Curtis Harvey.
- fix a bug where the script ignored directories whose name ended in a dot,
thanks to Aggelos Orfanakos for the patch.
- fix a bug when using the x mapping on the tree root, thanks to Bryan
Venteicher for the patch.
- fix a bug where the cursor position/window size of the nerd tree buffer
wasnt being stored on closing the window, thanks to Richard Hart.
- fix a bug where NERDTreeMirror would mirror the wrong tree
3.1.1
- fix a bug where a non-listed no-name buffer was getting created every
time the tree windows was created, thanks to Derek Wyatt and owen1
- make <CR> behave the same as the 'o' mapping
- some helptag fixes in the doc, thanks strull
- fix a bug when using :set nohidden and opening a file where the previous
buf was modified. Thanks iElectric
- other minor fixes
3.1.0
New features:
- add mappings to open files in a vsplit, see :help NERDTree-s and :help
NERDTree-gs
- make the statusline for the nerd tree window default to something
hopefully more useful. See :help 'NERDTreeStatusline'
Bugfixes:
- make the hijack netrw functionality work when vim is started with "vim
<some dir>" (thanks to Alf Mikula for the patch).
- fix a bug where the CWD wasnt being changed for some operations even when
NERDTreeChDirMode==2 (thanks to Lucas S. Buchala)
- add -bar to all the nerd tree :commands so they can chain with other
:commands (thanks to tpope)
- fix bugs when ignorecase was set (thanks to nach)
- fix a bug with the relative path code (thanks to nach)
- fix a bug where doing a :cd would cause :NERDTreeToggle to fail (thanks nach)
3.0.1
Bugfixes:
- fix bugs with :NERDTreeToggle and :NERDTreeMirror when 'hidden
was not set
- fix a bug where :NERDTree <path> would fail if <path> was relative and
didnt start with a ./ or ../ Thanks to James Kanze.
- make the q mapping work with secondary (:e <dir> style) trees,
thanks to jamessan
- fix a bunch of small bugs with secondary trees
More insane refactoring.
3.0.0
- hijack netrw so that doing an :edit <directory> will put a NERD tree in
the window rather than a netrw browser. See :help 'NERDTreeHijackNetrw'
- allow sharing of trees across tabs, see :help :NERDTreeMirror
- remove "top" and "bottom" as valid settings for NERDTreeWinPos
- change the '<tab>' mapping to 'i'
- change the 'H' mapping to 'I'
- lots of refactoring

View File

@ -0,0 +1,217 @@
# Change Log
#### 5.2...
- **.6**: In CHANGELOG.md and PR template, make reference to PR a true HTML link. [#1017](https://github.com/scrooloose/nerdtree/pull/1017)
- **.5**: Use `:mode` instead of `:redraw!` when updating menu. (PhilRunninger) [#1016](https://github.com/scrooloose/nerdtree/pull/1016)
- **.4**: When searching for root line num, stop at end of file. (PhilRunninger) [#1015](https://github.com/scrooloose/nerdtree/pull/1015)
- **.3**: Fix `<CR>` key map on the bookmark (lkebin) [#1014](https://github.com/scrooloose/nerdtree/pull/1014)
- **.2**: Make Enter work on the `.. ( up a dir )` line (PhilRunninger) [#1013](https://github.com/scrooloose/nerdtree/pull/1013)
- **.1**: Fix nerdtree#version() on Windows. (PhilRunninger)
- **.0**: Expand functionality of `<CR>` mapping. (PhilRunninger) [#1011](https://github.com/scrooloose/nerdtree/pull/1011)
#### 5.1...
- **.3**: Remove @mentions from PR template and change log. They weren't working. (PhilRunninger) [#1009](https://github.com/scrooloose/nerdtree/pull/1009)
- **.2**: Fix NERDTree opening with the wrong size. (PhilRunninger) [#1008](https://github.com/scrooloose/nerdtree/pull/1008)
- **.1**: Update Changelog and create PR Template (PhilRunninger) [#1007](https://github.com/scrooloose/nerdtree/pull/1007)
- **.0**: Too many changes for one patch...
- Refresh a dir_node if the file wasn't found in it, and look once more. (PhilRunninger) [#1005](https://github.com/scrooloose/nerdtree/pull/1005)
- Add a "copy path to clipboard" menu option (PhilRunninger) [#1002](https://github.com/scrooloose/nerdtree/pull/1002)
- Enable root refresh on "vim ." a different way than [#999](https://github.com/scrooloose/nerdtree/pull/999). (PhilRunninger) [#1001](https://github.com/scrooloose/nerdtree/pull/1001)
- Fix refreshroot (PhilRunninger) [#999](https://github.com/scrooloose/nerdtree/pull/999)
- Change version check to look for 703 not 730 (vhalis) [#994](https://github.com/scrooloose/nerdtree/pull/994)
- Change minimum vim (PhilRunninger) [#991](https://github.com/scrooloose/nerdtree/pull/991)
- Allow multi-character DirArrows (PhilRunninger) [#985](https://github.com/scrooloose/nerdtree/pull/985)
- Remove redraw! while still clearing last message empty string. (PhilRunninger) [#979](https://github.com/scrooloose/nerdtree/pull/979)
- fix `_initChildren` function value set to numChildrenCached error (terryding77) [#969](https://github.com/scrooloose/nerdtree/pull/969)
- On Windows, do a case-insensitive comparison of paths. (PhilRunninger) [#967](https://github.com/scrooloose/nerdtree/pull/967)
- Remove the **Please wait... DONE** messages. (PhilRunninger) [#966](https://github.com/scrooloose/nerdtree/pull/966)
- Smarter delimiter default (PhilRunninger) [#963](https://github.com/scrooloose/nerdtree/pull/963)
- Update directory .vimdc readme example (spencerdcarlson) [#961](https://github.com/scrooloose/nerdtree/pull/961)
- Preview bookmarks (PhilRunninger) [#956](https://github.com/scrooloose/nerdtree/pull/956)
- Add new value to NERDTreeQuitOnOpen to close bookmark table (PhilRunninger) [#955](https://github.com/scrooloose/nerdtree/pull/955)
- Add an :EditBookmarks command to edit the bookmarks file (PhilRunninger) [#954](https://github.com/scrooloose/nerdtree/pull/954)
- Before copying, turn off &shellslash. Restore after copy is finished. (PhilRunninger) [#952](https://github.com/scrooloose/nerdtree/pull/952)
- Set a maximum window size when zooming. (PhilRunninger) [#950](https://github.com/scrooloose/nerdtree/pull/950)
- Confirm the wipeout of a unsaved buffer whose file has been renamed. (PhilRunninger) [#949](https://github.com/scrooloose/nerdtree/pull/949)
- Escape a backslash so it can be used in a key mapping. (PhilRunninger) [#948](https://github.com/scrooloose/nerdtree/pull/948)
- Add a NERDTreeMinimalMenu feature (tuzz) [#938](https://github.com/scrooloose/nerdtree/pull/938)
- fixed root path error for windows (zcodes) [#935](https://github.com/scrooloose/nerdtree/pull/935)
- Restore getDirChildren for use in nerdtree-project-plugin. (PhilRunninger) [#929](https://github.com/scrooloose/nerdtree/pull/929)
- Document NERDTreeNodeDelimiter [#912](https://github.com/scrooloose/nerdtree/pull/912) (PhilRunninger) [#926](https://github.com/scrooloose/nerdtree/pull/926)
- Allow modification of menu keybindings (Leandros) [#923](https://github.com/scrooloose/nerdtree/pull/923)
- Add two more disqualifications for isCascadable(). (PhilRunninger) [#914](https://github.com/scrooloose/nerdtree/pull/914)
- Allow highlighting more than one flag. (kristijanhusak) [#908](https://github.com/scrooloose/nerdtree/pull/908)
- Support sorting files and directories by modification time. (PhilRunninger) [#901](https://github.com/scrooloose/nerdtree/pull/901)
- Parse . and .. from path string with trailing slash. (PhilRunninger) [#899](https://github.com/scrooloose/nerdtree/pull/899)
- Force sort to recalculate the cached sortKey. (PhilRunninger) [#898](https://github.com/scrooloose/nerdtree/pull/898)
- Add NERDTreeRefreshRoot command (wgfm) [#897](https://github.com/scrooloose/nerdtree/pull/897)
- Call Resolve on the file's path when calling :NERDTreeFind. (PhilRunninger) [#896](https://github.com/scrooloose/nerdtree/pull/896)
- Catch all errors, not just NERDTree errors. (PhilRunninger) [#894](https://github.com/scrooloose/nerdtree/pull/894)
- Fix typo in help file (lvoisin) [#892](https://github.com/scrooloose/nerdtree/pull/892)
- Make NERDTreeCreator set the `'nolist'` option (lifecrisis) [#889](https://github.com/scrooloose/nerdtree/pull/889)
- Refresh buffers after `m`, `m` operation on a folder (PhilRunninger) [#888](https://github.com/scrooloose/nerdtree/pull/888)
- Use a better arg for FINDSTR when using the m,l command in Windows. (PhilRunninger) [#887](https://github.com/scrooloose/nerdtree/pull/887)
- Fix the <C-J>/<C-K> motions, which currently fail with cascades (lifecrisis) [#886](https://github.com/scrooloose/nerdtree/pull/886)
- Function "s:UI.getLineNum()" doesn't always work on cascades. (lifecrisis) [#882](https://github.com/scrooloose/nerdtree/pull/882)
- NERDTreeCWD: reset CWD if changed by NERDTreeFocus (PhilRunninger) [#878](https://github.com/scrooloose/nerdtree/pull/878)
- Use <count>tabnext instead of <count>gt to allow users to remap gt. (PhilRunninger) [#877](https://github.com/scrooloose/nerdtree/pull/877)
- Do a case sensitive comparison of new/existing buffers. (PhilRunninger) [#875](https://github.com/scrooloose/nerdtree/pull/875)
- Fix opening sub-directories that have commas in their name. (PhilRunninger) [#873](https://github.com/scrooloose/nerdtree/pull/873)
- Add new command to open NERDTree in the root of a VCS repository. (PhilRunninger) [#872](https://github.com/scrooloose/nerdtree/pull/872)
- Make sure the path to the bookmarks file exists before writing it. (PhilRunninger) [#871](https://github.com/scrooloose/nerdtree/pull/871)
- Unzoom NERDTree when opening a file (PhilRunninger) [#870](https://github.com/scrooloose/nerdtree/pull/870)
- Support unusual characters in file and directory names (PhilRunninger) [#868](https://github.com/scrooloose/nerdtree/pull/868)
- Reword renamed-buffer prompt to be more clear (aflock) [#867](https://github.com/scrooloose/nerdtree/pull/867)
- Default to placing cursor on root when closing bookmark table (lifecrisis) [#866](https://github.com/scrooloose/nerdtree/pull/866)
- Fix issues with sorting of nodes (PhilRunninger) [#856](https://github.com/scrooloose/nerdtree/pull/856)
- Better OSX detection (bubba-h57) [#853](https://github.com/scrooloose/nerdtree/pull/853)
- Bugfix - ensure keymaps dictionary exists before using it (mnussbaum) [#852](https://github.com/scrooloose/nerdtree/pull/852)
- Decrease startup-time by avoiding linear-time iteration over key mappings (mnussbaum) [#851](https://github.com/scrooloose/nerdtree/pull/851)
- Add code to sort mappings in quickhelp (lifecrisis) [#849](https://github.com/scrooloose/nerdtree/pull/849)
- Use ":clearjumps" in new NERDTree windows (lifecrisis) [#844](https://github.com/scrooloose/nerdtree/pull/844)
- Like m-c did before, create parent directories if needed on m-m. (PhilRunninger) [#840](https://github.com/scrooloose/nerdtree/pull/840)
- BUGFIX: Repair a problem with the `'u'` mapping. (lifecrisis) [#838](https://github.com/scrooloose/nerdtree/pull/838)
- Make the NERDTree buffer writable when rendering it. (PhilRunninger) [#837](https://github.com/scrooloose/nerdtree/pull/837)
- Code cleanup: Remove unsupported bookmark table mappings (lifecrisis) [#835](https://github.com/scrooloose/nerdtree/pull/835)
- Replace strcharpart() with substitute() for backward compatibility (bravestarr) [#834](https://github.com/scrooloose/nerdtree/pull/834)
- Fixed error `unknown function strcharpart` for older versions of Vim (hav4ik) [#833](https://github.com/scrooloose/nerdtree/pull/833)
- Clear output when NERDTree menu is aborted (lifecrisis) [#832](https://github.com/scrooloose/nerdtree/pull/832)
- Display a path with multi-byte characters correctly when it is truncated (bravestarr) [#830](https://github.com/scrooloose/nerdtree/pull/830)
- Support revealing file and executing file with xdg-open for Linux (ngnmhieu) [#824](https://github.com/scrooloose/nerdtree/pull/824)
- If node isn't open, count children on disk before deleting. (PhilRunninger) [#822](https://github.com/scrooloose/nerdtree/pull/822)
- Add new variable g:NERDTreeRemoveFileCmd (kutsan) [#816](https://github.com/scrooloose/nerdtree/pull/816)
- Use a better check for existence of the NERDTree buffer. (PhilRunninger) [#814](https://github.com/scrooloose/nerdtree/pull/814)
- Fix focussing previous buffer when closing NERDTree (mrubli) [#801](https://github.com/scrooloose/nerdtree/pull/801)
- Update the docs for "NERDTreeStatusline" (lifecrisis) [#796](https://github.com/scrooloose/nerdtree/pull/796)
- BUGFIX: Unstable behavior in the "getPath()" method (lifecrisis) [#795](https://github.com/scrooloose/nerdtree/pull/795)
- Revert the bugfix from pull request [#785](https://github.com/scrooloose/nerdtree/pull/785) (lifecrisis) [#794](https://github.com/scrooloose/nerdtree/pull/794)
- BUGFIX: Allow ":NERDTreeFind" to discover hidden files (lifecrisis) [#786](https://github.com/scrooloose/nerdtree/pull/786)
- BUGFIX: Allow ":NERDTreeFind" to reveal new files (lifecrisis) [#785](https://github.com/scrooloose/nerdtree/pull/785)
- Add modelines (lifecrisis) [#782](https://github.com/scrooloose/nerdtree/pull/782)
- Change the type of completion used by NERDTreeFind (lifecrisis) [#781](https://github.com/scrooloose/nerdtree/pull/781)
- change NERDTreeFind with args (zhenyangze) [#778](https://github.com/scrooloose/nerdtree/pull/778)
- Style Choice: Using confirm() when deleting a bookmark (lifecrisis) [#777](https://github.com/scrooloose/nerdtree/pull/777)
- remove useless substitute when `file =~# "/$"` (skyblueee) [#773](https://github.com/scrooloose/nerdtree/pull/773)
- remove useless removeLeadingSpaces in _stripMarkup (skyblueee) [#772](https://github.com/scrooloose/nerdtree/pull/772)
- Make the "o" mapping consistent with "x" (lifecrisis) [#769](https://github.com/scrooloose/nerdtree/pull/769)
- Fix a problem with the "x" handler (lifecrisis) [#768](https://github.com/scrooloose/nerdtree/pull/768)
- Clean up the handler for the "x" mapping (lifecrisis) [#767](https://github.com/scrooloose/nerdtree/pull/767)
- Revert change to tab opening method (lifecrisis) [#766](https://github.com/scrooloose/nerdtree/pull/766)
- BUGFIX: Add back support for "b:NERDTreeRoot" (lifecrisis) [#765](https://github.com/scrooloose/nerdtree/pull/765)
- Fix broken "t" and "T" mappings, tabs now open at end (lifecrisis) [#759](https://github.com/scrooloose/nerdtree/pull/759)
- Update doc with already existing mapping variables (asnr) [#699](https://github.com/scrooloose/nerdtree/pull/699)
- Fix the broken g:NERDTreeBookmarksSort setting (lifecrisis) [#696](https://github.com/scrooloose/nerdtree/pull/696)
- Correct NERDTreeIgnore pattern in doc (cntoplolicon) [#648](https://github.com/scrooloose/nerdtree/pull/648)
- Remove empty segments when splitting path (sooth-sayer) [#574](https://github.com/scrooloose/nerdtree/pull/574)
- Suppress autocmds less agressively (wincent) [#578](https://github.com/scrooloose/nerdtree/pull/578) [#691](https://github.com/scrooloose/nerdtree/pull/691)
- Add an Issues template to ask for more info initially.
- Fix markdown headers in readme (josephfrazier) [#676](https://github.com/scrooloose/nerdtree/pull/676)
- Don't touch `@o` and `@h` registers when rendering
- Fix bug with files and directories with dollar signs (alegen) [#649](https://github.com/scrooloose/nerdtree/pull/649)
- Reuse/reopen existing window trees where possible [#244](https://github.com/scrooloose/nerdtree/pull/244)
- Remove NERDTree.previousBuf()
- Change color of arrow (Leeiio) [#630](https://github.com/scrooloose/nerdtree/pull/630)
- Improved a tip in README.markdown (ggicci) [#628](https://github.com/scrooloose/nerdtree/pull/628)
- Shorten delete confimration of empty directory to `y` (mikeperri) [#530](https://github.com/scrooloose/nerdtree/pull/530)
- Fix API call to open directory tree in window (devm33) [#533](https://github.com/scrooloose/nerdtree/pull/533)
- Change default arrows on non-Windows platforms (gwilk) [#546](https://github.com/scrooloose/nerdtree/pull/546)
- Update to README - combine cd and git clone (zwhitchcox) [#584](https://github.com/scrooloose/nerdtree/pull/584)
- Update to README - Tip: start NERDTree when vim starts (therealplato) [#593](https://github.com/scrooloose/nerdtree/pull/593)
- Escape filename when moving an open buffer (zacharyvoase) [#595](https://github.com/scrooloose/nerdtree/pull/595)
- Fixed incorrect :helptags command in README (curran) [#619](https://github.com/scrooloose/nerdtree/pull/619)
- Fixed incomplete escaping of folder arrows (adityanatraj) [#548](https://github.com/scrooloose/nerdtree/pull/548)
- Added NERDTreeCascadeSingleChildDir option (juanibiapina) [#558](https://github.com/scrooloose/nerdtree/pull/558)
- Replace strchars() with backward compatible workaround.
- Add support for copy command in Windows (SkylerLipthay) [#231](https://github.com/scrooloose/nerdtree/pull/231)
- Fixed typo in README.markdown - :Helptags -> :helptags
- Rename "primary" and "secondary" trees to "tab" and "window" trees.
- Move a bunch of buffer level variables into the NERDTree and UI classes.
- Display cascading dirs on one line to save vertical/horizontal space (matt-gardner: brainstorming/testing)
- Remove the old style UI - Remove `NERDTreeDirArrows` option.
- On windows default to + and ~ for expand/collapse directory symbols.
- Lots more refactoring. Move a bunch of b: level vars into b:NERDTree and friends.
#### 5.0.0
- Refactor the code significantly:
* Break the classes out into their own files.
* Make the majority of the code OO - previously large parts were effectively a tangle of "global" methods.
- Add an API to assign flags to nodes. This allows VCS plugins like https://github.com/Xuyuanp/nerdtree-git-plugin to exist. Thanks to **Xuyuanp** for helping design/test/build said API.
- add `scope` argument to the key map API see :help NERDTreeAddKeyMap()
- add magic [[dir]] and [[file]] flags to NERDTreeIgnore
- add support for custom path filters. See :help NERDTreeAddPathFilter()
- add path listener API. See :help NERDTreePathListenerAPI.
- expand the fs menu functionality to list file properties (PhilRunninger, apbarrero, JESii)
- make bookmarks work with `~` home shortcuts (hiberabyss)
- show OSX specific fsmenu options in regular vim on mac (evindor)
- make dir arrow icons configurable (PickRelated)
- optimise node sorting performance when opening large dirs (vtsang)
- make the root note render prettier by truncating it at a path slash (gcmt)
- remove NERDChristmasTree option - its always christmas now
- add "cascade" open and closing for dirs containing only another single dir. See :help NERDTreeCascadeOpenSingleChildDir (pendulm)
- Many other fixes, doc updates and contributions from: **actionshrimp**, **agrussellknives**, **alvan**, **AndrewRadev**, **cperl82** (*many small fixes*), **devmanhinton**, **egalpin**, **franksort**, **gastropoda**, **handcraftedbits**, **kelaban**, **lucascaton**, **mixvin**, **pendulm**, **SchDen**, **shanesmith**, **staeff**, **stephenprater**, **toiffel**, **Twinside**, **WoLpH**, **xiaodili**, **zhangoose**
#### 4.2.0
- Add NERDTreeDirArrows option to make the UI use pretty arrow chars instead of the old +~| chars to define the tree structure (sickill)
- shift the syntax highlighting out into its own syntax file (gnap)
- add some mac specific options to the filesystem menu - for macvim only (andersonfreitas)
- Add NERDTreeMinimalUI option to remove some non functional parts of the nerdtree ui (camthompson)
- tweak the behaviour of :NERDTreeFind - see :help :NERDTreeFind for the new behaviour (benjamingeiger)
- if no name is given to :Bookmark, make it default to the name of the target file/dir (minyoung)
- use `file` completion when doing copying, create, and move operations (EvanDotPro)
- lots of misc bug fixes from: **AndrewRadev**, **Bogdanov**, **camthompson**, **kml**, **mathias**, **paddyoloughlin**, **scottstvnsn**, **sdewald**, **Vitaly**, **wycats**, me RAWR!
#### 4.1.0
- features:
- NERDTreeFind to reveal the node for the current buffer in the tree, see `|NERDTreeFind|`. This effectively merges the FindInNERDTree plugin (by **Doug McInnes**) into the script.
- make NERDTreeQuitOnOpen apply to the t/T keymaps too. Thanks to **Stefan Ritter** and **Rémi Prévost**.
- truncate the root node if wider than the tree window. Thanks to **Victor Gonzalez**.
- bugfixes:
- really fix window state restoring
- fix some win32 path escaping issues. Thanks to **Stephan Baumeister**, **Ricky**, **jfilip1024**, and **Chris Chambers**.
#### 4.0.0
- add a new programmable menu system (see `:help NERDTreeMenu`).
- add new APIs to add menus/menu-items to the menu system as well as custom key mappings to the NERD tree buffer (see `:help NERDTreeAPI`).
- removed the old API functions
- added a mapping to maximize/restore the size of nerd tree window, thanks to Guillaume Duranceau for the patch. See :help NERDTree-A for details.
- fix a bug where secondary nerd trees (netrw hijacked trees) and NERDTreeQuitOnOpen didnt play nicely, thanks to **Curtis Harvey**.
- fix a bug where the script ignored directories whose name ended in a dot, thanks to **Aggelos Orfanakos** for the patch.
- fix a bug when using the x mapping on the tree root, thanks to **Bryan Venteicher** for the patch.
- fix a bug where the cursor position/window size of the nerd tree buffer wasnt being stored on closing the window, thanks to **Richard Hart**.
- fix a bug where NERDTreeMirror would mirror the wrong tree
#### 3.1.1
- fix a bug where a non-listed no-name buffer was getting created every time the tree windows was created, thanks to **Derek Wyatt** and **owen1**
- make `<CR>` behave the same as the `o` mapping
- some helptag fixes in the doc, thanks **strull**.
- fix a bug when using `:set nohidden` and opening a file where the previous buf was modified. Thanks **iElectric**.
- other minor fixes
#### 3.1.0
- New features:
- add mappings to open files in a vsplit, see `:help NERDTree-s` and `:help NERDTree-gs`
- make the statusline for the nerd tree window default to something hopefully more useful. See `:help 'NERDTreeStatusline'`
- Bugfixes:
- make the hijack netrw functionality work when vim is started with `vim <some dir>` (thanks to **Alf Mikula** for the patch).
- fix a bug where the CWD wasnt being changed for some operations even when NERDTreeChDirMode==2 (thanks to **Lucas S. Buchala**)
- add -bar to all the nerd tree :commands so they can chain with other :commands (thanks to **tpope**)
- fix bugs when ignorecase was set (thanks to **nach**)
- fix a bug with the relative path code (thanks to **nach**)
- fix a bug where doing a `:cd` would cause `:NERDTreeToggle` to fail (thanks **nach**)
#### 3.0.1
- Bugfixes:
- fix bugs with :NERDTreeToggle and :NERDTreeMirror when `'hidden'` was not set
- fix a bug where `:NERDTree <path>` would fail if `<path>` was relative and didnt start with a `./` or `../` Thanks to **James Kanze**.
- make the `q` mapping work with secondary (`:e <dir>` style) trees, thanks to **jamessan**
- fix a bunch of small bugs with secondary trees
- More insane refactoring.
#### 3.0.0
- hijack netrw so that doing an `:edit <directory>` will put a NERD tree in the window rather than a netrw browser. See :help 'NERDTreeHijackNetrw'
- allow sharing of trees across tabs, see `:help :NERDTreeMirror`
- remove "top" and "bottom" as valid settings for NERDTreeWinPos
- change the `'<tab>'` mapping to `'i'`
- change the `'H'` mapping to `'I'`
- lots of refactoring

View File

@ -3,13 +3,38 @@ if exists("g:loaded_nerdtree_autoload")
endif
let g:loaded_nerdtree_autoload = 1
function! nerdtree#version()
return '5.0.0'
let s:rootNERDTreePath = resolve(expand("<sfile>:p:h:h"))
function! nerdtree#version(...)
let l:changelog = readfile(join([s:rootNERDTreePath, "CHANGELOG.md"], nerdtree#slash()))
let l:text = 'Unknown'
let l:line = 0
while l:line <= len(l:changelog)
if l:changelog[l:line] =~ '\d\+\.\d\+'
let l:text = substitute(l:changelog[l:line], '.*\(\d\+.\d\+\).*', '\1', '')
let l:text .= substitute(l:changelog[l:line+1], '^.\{-}\(\.\d\+\).\{-}:\(.*\)', a:0>0 ? '\1:\2' : '\1', '')
break
endif
let l:line += 1
endwhile
return l:text
endfunction
" SECTION: General Functions {{{1
"============================================================
function! nerdtree#slash()
if nerdtree#runningWindows()
if exists('+shellslash') && &shellslash
return '/'
endif
return '\'
endif
return '/'
endfunction
"FUNCTION: nerdtree#and(x,y) {{{2
" Implements and() function for Vim <= 7.2
function! nerdtree#and(x,y)

View File

@ -14,6 +14,10 @@ function! nerdtree#ui_glue#createDefaultBindings()
call NERDTreeAddKeyMap({ 'key': '<2-LeftMouse>', 'scope': "Bookmark", 'callback': s."activateBookmark" })
call NERDTreeAddKeyMap({ 'key': '<2-LeftMouse>', 'scope': "all", 'callback': s."activateAll" })
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapCustomOpen, 'scope':'FileNode', 'callback': s."customOpenFile"})
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapCustomOpen, 'scope':'DirNode', 'callback': s."customOpenDir"})
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapCustomOpen, 'scope':'Bookmark', 'callback': s."customOpenBookmark"})
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapCustomOpen, 'scope':'all', 'callback': s."activateAll" })
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapActivateNode, 'scope': "DirNode", 'callback': s."activateDirNode" })
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapActivateNode, 'scope': "FileNode", 'callback': s."activateFileNode" })
@ -76,6 +80,35 @@ endfunction
"SECTION: Interface bindings {{{1
"============================================================
"FUNCTION: s:customOpenFile() {{{1
" Open file node with the "custom" key, initially <CR>.
function! s:customOpenFile(node)
call a:node.activate(s:initCustomOpenArgs().file)
endfunction
"FUNCTION: s:customOpenDir() {{{1
" Open directory node with the "custom" key, initially <CR>.
function! s:customOpenDir(node)
call s:activateDirNode(a:node, s:initCustomOpenArgs().dir)
endfunction
"FUNCTION: s:customOpenBookmark() {{{1
" Open bookmark node with the "custom" key, initially <CR>.
function! s:customOpenBookmark(node)
if a:node.path.isDirectory
call a:node.activate(b:NERDTree, s:initCustomOpenArgs().dir)
else
call a:node.activate(b:NERDTree, s:initCustomOpenArgs().file)
endif
endfunction
"FUNCTION: s:initCustomOpenArgs() {{{1
" Make sure NERDTreeCustomOpenArgs has needed keys
function! s:initCustomOpenArgs()
let g:NERDTreeCustomOpenArgs = get(g:, 'NERDTreeCustomOpenArgs', {})
return extend(g:NERDTreeCustomOpenArgs, {'file':{'reuse': 'all', 'where': 'p'}, 'dir':{}}, 'keep')
endfunction
"FUNCTION: s:activateAll() {{{1
"handle the user activating the updir line
function! s:activateAll()
@ -84,15 +117,16 @@ function! s:activateAll()
endif
endfunction
" FUNCTION: s:activateDirNode(directoryNode) {{{1
function! s:activateDirNode(directoryNode)
" FUNCTION: s:activateDirNode(directoryNode, options) {{{1
" Open a directory with optional options
function! s:activateDirNode(directoryNode, ...)
if a:directoryNode.isRoot() && a:directoryNode.isOpen
call nerdtree#echo('cannot close tree root')
return
endif
call a:directoryNode.activate()
call a:directoryNode.activate((a:0 > 0) ? a:1 : {})
endfunction
"FUNCTION: s:activateFileNode() {{{1
@ -367,7 +401,7 @@ function! s:jumpToLastChild(node)
call s:jumpToChild(a:node, 1)
endfunction
" FUNCTION: s:jumpToChild(node, last) {{{2
" FUNCTION: s:jumpToChild(node, last) {{{1
" Jump to the first or last child node at the same file system level.
"
" Args:
@ -425,7 +459,7 @@ function! s:jumpToPrevSibling(node)
call s:jumpToSibling(a:node, 0)
endfunction
" FUNCTION: s:jumpToSibling(node, forward) {{{2
" FUNCTION: s:jumpToSibling(node, forward) {{{1
" Move the cursor to the next or previous node at the same file system level.
"
" Args:

View File

@ -247,12 +247,12 @@ i........Open selected file in a split window.......................|NERDTree-i|
gi.......Same as i, but leave the cursor on the NERDTree...........|NERDTree-gi|
s........Open selected file in a new vsplit.........................|NERDTree-s|
gs.......Same as s, but leave the cursor on the NERDTree...........|NERDTree-gs|
<CR>.....User-definable custom open action.......................|NERDTree-<CR>|
O........Recursively open the selected directory....................|NERDTree-O|
x........Close the current nodes parent.............................|NERDTree-x|
X........Recursively close all children of the current node.........|NERDTree-X|
e........Edit the current dir.......................................|NERDTree-e|
<CR>............same as |NERDTree-o|.
double-click....same as |NERDTree-o|.
middle-click....same as |NERDTree-i| for files, and |NERDTree-e| for dirs.
@ -319,7 +319,7 @@ The default key combo for this mapping is "g" + NERDTreeMapActivateNode (see
------------------------------------------------------------------------------
*NERDTree-t*
Default key: t
Map setting: NERDTreeMapOpenInTab
Map setting: *NERDTreeMapOpenInTab*
Applies to: files and directories.
Opens the selected file in a new tab. If a directory is selected, a fresh
@ -332,7 +332,7 @@ in a new tab.
------------------------------------------------------------------------------
*NERDTree-T*
Default key: T
Map setting: NERDTreeMapOpenInTabSilent
Map setting: *NERDTreeMapOpenInTabSilent*
Applies to: files and directories.
The same as |NERDTree-t| except that the focus is kept in the current tab.
@ -340,7 +340,7 @@ The same as |NERDTree-t| except that the focus is kept in the current tab.
------------------------------------------------------------------------------
*NERDTree-i*
Default key: i
Map setting: NERDTreeMapOpenSplit
Map setting: *NERDTreeMapOpenSplit*
Applies to: files.
Opens the selected file in a new split window and puts the cursor in the new
@ -349,7 +349,7 @@ window.
------------------------------------------------------------------------------
*NERDTree-gi*
Default key: gi
Map setting: NERDTreeMapPreviewSplit
Map setting: *NERDTreeMapPreviewSplit*
Applies to: files.
The same as |NERDTree-i| except that the cursor is not moved.
@ -360,7 +360,7 @@ The default key combo for this mapping is "g" + NERDTreeMapOpenSplit (see
------------------------------------------------------------------------------
*NERDTree-s*
Default key: s
Map setting: NERDTreeMapOpenVSplit
Map setting: *NERDTreeMapOpenVSplit*
Applies to: files.
Opens the selected file in a new vertically split window and puts the cursor
@ -369,7 +369,7 @@ in the new window.
------------------------------------------------------------------------------
*NERDTree-gs*
Default key: gs
Map setting: NERDTreeMapPreviewVSplit
Map setting: *NERDTreeMapPreviewVSplit*
Applies to: files.
The same as |NERDTree-s| except that the cursor is not moved.
@ -377,10 +377,19 @@ The same as |NERDTree-s| except that the cursor is not moved.
The default key combo for this mapping is "g" + NERDTreeMapOpenVSplit (see
|NERDTree-s|).
------------------------------------------------------------------------------
*NERDTree-<CR>*
Default key: <CR>
Map setting: *NERDTreeMapCustomOpen*
Applies to: files, directories, and bookmarks
Performs a customized open action on the selected node. This allows the user
to define an action that behaves differently from any of the standard
keys. See |NERDTreeCustomOpenArgs| for more details.
------------------------------------------------------------------------------
*NERDTree-O*
Default key: O
Map setting: NERDTreeMapOpenRecursively
Map setting: *NERDTreeMapOpenRecursively*
Applies to: directories.
Recursively opens the selected directory.
@ -393,7 +402,7 @@ cached. This is handy, especially if you have .svn directories.
------------------------------------------------------------------------------
*NERDTree-x*
Default key: x
Map setting: NERDTreeMapCloseDir
Map setting: *NERDTreeMapCloseDir*
Applies to: files and directories.
Closes the parent of the selected node.
@ -401,7 +410,7 @@ Closes the parent of the selected node.
------------------------------------------------------------------------------
*NERDTree-X*
Default key: X
Map setting: NERDTreeMapCloseChildren
Map setting: *NERDTreeMapCloseChildren*
Applies to: directories.
Recursively closes all children of the selected directory.
@ -411,7 +420,7 @@ Tip: To quickly "reset" the tree, use |NERDTree-P| with this mapping.
------------------------------------------------------------------------------
*NERDTree-e*
Default key: e
Map setting: NERDTreeMapOpenExpl
Map setting: *NERDTreeMapOpenExpl*
Applies to: files and directories.
|:edit|s the selected directory, or the selected file's directory. This could
@ -421,7 +430,7 @@ result in a NERDTree or a netrw being opened, depending on
------------------------------------------------------------------------------
*NERDTree-D*
Default key: D
Map setting: NERDTreeMapDeleteBookmark
Map setting: *NERDTreeMapDeleteBookmark*
Applies to: lines in the bookmarks table
Deletes the currently selected bookmark.
@ -429,7 +438,7 @@ Deletes the currently selected bookmark.
------------------------------------------------------------------------------
*NERDTree-P*
Default key: P
Map setting: NERDTreeMapJumpRoot
Map setting: *NERDTreeMapJumpRoot*
Applies to: no restrictions.
Jump to the tree root.
@ -437,7 +446,7 @@ Jump to the tree root.
------------------------------------------------------------------------------
*NERDTree-p*
Default key: p
Map setting: NERDTreeMapJumpParent
Map setting: *NERDTreeMapJumpParent*
Applies to: files and directories.
Jump to the parent node of the selected node.
@ -445,7 +454,7 @@ Jump to the parent node of the selected node.
------------------------------------------------------------------------------
*NERDTree-K*
Default key: K
Map setting: NERDTreeMapJumpFirstChild
Map setting: *NERDTreeMapJumpFirstChild*
Applies to: files and directories.
Jump to the first child of the current nodes parent.
@ -458,7 +467,7 @@ If the cursor is already on the first node then do the following:
------------------------------------------------------------------------------
*NERDTree-J*
Default key: J
Map setting: NERDTreeMapJumpLastChild
Map setting: *NERDTreeMapJumpLastChild*
Applies to: files and directories.
Jump to the last child of the current nodes parent.
@ -471,7 +480,7 @@ If the cursor is already on the last node then do the following:
------------------------------------------------------------------------------
*NERDTree-C-J*
Default key: <C-J>
Map setting: NERDTreeMapJumpNextSibling
Map setting: *NERDTreeMapJumpNextSibling*
Applies to: files and directories.
Jump to the next sibling of the selected node.
@ -479,7 +488,7 @@ Jump to the next sibling of the selected node.
------------------------------------------------------------------------------
*NERDTree-C-K*
Default key: <C-K>
Map setting: NERDTreeMapJumpPrevSibling
Map setting: *NERDTreeMapJumpPrevSibling*
Applies to: files and directories.
Jump to the previous sibling of the selected node.
@ -487,7 +496,7 @@ Jump to the previous sibling of the selected node.
------------------------------------------------------------------------------
*NERDTree-C*
Default key: C
Map setting: NERDTreeMapChangeRoot
Map setting: *NERDTreeMapChangeRoot*
Applies to: files and directories.
Make the selected directory node the new tree root. If a file is selected, its
@ -496,7 +505,7 @@ parent is used.
------------------------------------------------------------------------------
*NERDTree-u*
Default key: u
Map setting: NERDTreeMapUpdir
Map setting: *NERDTreeMapUpdir*
Applies to: no restrictions.
Move the tree root up a dir (like doing a "cd ..").
@ -504,7 +513,7 @@ Move the tree root up a dir (like doing a "cd ..").
------------------------------------------------------------------------------
*NERDTree-U*
Default key: U
Map setting: NERDTreeMapUpdirKeepOpen
Map setting: *NERDTreeMapUpdirKeepOpen*
Applies to: no restrictions.
Like |NERDTree-u| except that the old tree root is kept open.
@ -512,7 +521,7 @@ Like |NERDTree-u| except that the old tree root is kept open.
------------------------------------------------------------------------------
*NERDTree-r*
Default key: r
Map setting: NERDTreeMapRefresh
Map setting: *NERDTreeMapRefresh*
Applies to: files and directories.
If a dir is selected, recursively refresh that dir, i.e. scan the filesystem
@ -523,7 +532,7 @@ If a file node is selected then the above is done on it's parent.
------------------------------------------------------------------------------
*NERDTree-R*
Default key: R
Map setting: NERDTreeMapRefreshRoot
Map setting: *NERDTreeMapRefreshRoot*
Applies to: no restrictions.
Recursively refresh the tree root.
@ -531,7 +540,7 @@ Recursively refresh the tree root.
------------------------------------------------------------------------------
*NERDTree-m*
Default key: m
Map setting: NERDTreeMapMenu
Map setting: *NERDTreeMapMenu*
Applies to: files and directories.
Display the NERDTree menu. See |NERDTreeMenu| for details.
@ -539,7 +548,7 @@ Display the NERDTree menu. See |NERDTreeMenu| for details.
------------------------------------------------------------------------------
*NERDTree-cd*
Default key: cd
Map setting: NERDTreeMapChdir
Map setting: *NERDTreeMapChdir*
Applies to: files and directories.
Change Vim's current working directory to that of the selected node.
@ -547,7 +556,7 @@ Change Vim's current working directory to that of the selected node.
------------------------------------------------------------------------------
*NERDTree-CD*
Default key: CD
Map setting: NERDTreeMapCWD
Map setting: *NERDTreeMapCWD*
Applies to: no restrictions.
Change the NERDTree root to Vim's current working directory.
@ -555,7 +564,7 @@ Change the NERDTree root to Vim's current working directory.
------------------------------------------------------------------------------
*NERDTree-I*
Default key: I
Map setting: NERDTreeMapToggleHidden
Map setting: *NERDTreeMapToggleHidden*
Applies to: no restrictions.
Toggles whether hidden files (i.e. "dot files") are displayed.
@ -563,7 +572,7 @@ Toggles whether hidden files (i.e. "dot files") are displayed.
------------------------------------------------------------------------------
*NERDTree-f*
Default key: f
Map setting: NERDTreeMapToggleFilters
Map setting: *NERDTreeMapToggleFilters*
Applies to: no restrictions.
Toggles whether file filters are used. See |NERDTreeIgnore| for details.
@ -571,7 +580,7 @@ Toggles whether file filters are used. See |NERDTreeIgnore| for details.
------------------------------------------------------------------------------
*NERDTree-F*
Default key: F
Map setting: NERDTreeMapToggleFiles
Map setting: *NERDTreeMapToggleFiles*
Applies to: no restrictions.
Toggles whether file nodes are displayed.
@ -579,7 +588,7 @@ Toggles whether file nodes are displayed.
------------------------------------------------------------------------------
*NERDTree-B*
Default key: B
Map setting: NERDTreeMapToggleBookmarks
Map setting: *NERDTreeMapToggleBookmarks*
Applies to: no restrictions.
Toggles whether the bookmarks table is displayed.
@ -587,7 +596,7 @@ Toggles whether the bookmarks table is displayed.
------------------------------------------------------------------------------
*NERDTree-q*
Default key: q
Map setting: NERDTreeMapQuit
Map setting: *NERDTreeMapQuit*
Applies to: no restrictions.
Closes the NERDTree window.
@ -595,7 +604,7 @@ Closes the NERDTree window.
------------------------------------------------------------------------------
*NERDTree-A*
Default key: A
Map setting: NERDTreeMapToggleZoom
Map setting: *NERDTreeMapToggleZoom*
Applies to: no restrictions.
Maximize (zoom) and minimize the NERDTree window.
@ -603,7 +612,7 @@ Maximize (zoom) and minimize the NERDTree window.
------------------------------------------------------------------------------
*NERDTree-?*
Default key: ?
Map setting: NERDTreeMapHelp
Map setting: *NERDTreeMapHelp*
Applies to: no restrictions.
Toggles whether the quickhelp is displayed.
@ -625,7 +634,7 @@ Related tags: |NERDTree-m| |NERDTreeApi|
------------------------------------------------------------------------------
*NERDTreeMenu-j*
Default key: j
Map option: NERDTreeMenuDown
Map option: *NERDTreeMenuDown*
Applies to: The NERDTree menu.
Moves the cursor down.
@ -633,7 +642,7 @@ Moves the cursor down.
------------------------------------------------------------------------------
*NERDTreeMenu-k*
Default key: k
Map option: NERDTreeMenuUp
Map option: *NERDTreeMenuUp*
Applies to: The NERDTree menu.
Moves the cursor up.
@ -754,6 +763,9 @@ the NERDTree. These settings should be set in your vimrc, using `:let`.
file or directory name from the rest of the
characters on the line of text.
|NERDTreeCustomOpenArgs| A dictionary with values that control how a node
is opened with the |NERDTree-<CR>| key.
------------------------------------------------------------------------------
3.2. Customisation details *NERDTreeSettingsDetails*
@ -1233,6 +1245,32 @@ when specifying by hex or Unicode. >
let NERDTreeNodeDelimiter="\u00a0" "non-breaking space
let NERDTreeNodeDelimiter="😀" "smiley face
<
------------------------------------------------------------------------------
*NERDTreeCustomOpenArgs*
Values: A nested dictionary, as described below
Default: {'file': {'reuse': 'all', 'where': 'p'}, 'dir': {}}
This dictionary contains two keys, 'file' and 'dir', whose values each are
another dictionary. The inner dictionary is a set of parameters used by
|NERDTree-<CR>| to open a file or directory. Setting these parameters allows you
to customize the way the node is opened. The default value matches what
|NERDTree-o| does. To change that behavior, use these keys and
values in the inner dictionaries:
'where': specifies whether the node should be opened in a new split ("h" or
"v"), in a new tab ("t") or, in the last window ("p").
'reuse': if file is already shown in a window, jump there; takes values
"all", "currenttab", or empty
'keepopen': boolean (0 or 1); if true, the tree window will not be closed
'stay': boolean (0 or 1); if true, remain in tree window after opening
For example:
To open files and directories (creating a new NERDTree) in a new tab, >
{'file':{'where': 't'}, 'dir':{'where':'t'}}
<
To open a file always in the current tab, and expand directories in place, >
{'file': {'reuse':'currenttab', 'where':'p', 'keepopen':1, 'stay':1}}
<
==============================================================================
4. The NERDTree API *NERDTreeAPI*

View File

@ -13,9 +13,6 @@ let g:NERDTreeCreator = s:Creator
" FUNCTION: s:Creator._bindMappings() {{{1
function! s:Creator._bindMappings()
"make <cr> do the same as the activate node mapping
nnoremap <silent> <buffer> <cr> :call nerdtree#ui_glue#invokeKeyMap(g:NERDTreeMapActivateNode)<cr>
call g:NERDTreeKeyMap.BindAll()
command! -buffer -nargs=? Bookmark :call nerdtree#ui_glue#bookmarkNode('<args>')
@ -189,18 +186,20 @@ function! s:Creator._createTreeWin()
let t:NERDTreeBufName = self._nextBufferName()
silent! execute l:splitLocation . 'vertical ' . l:splitSize . ' new'
silent! execute 'edit ' . t:NERDTreeBufName
silent! execute 'vertical resize '. l:splitSize
else
silent! execute l:splitLocation . 'vertical ' . l:splitSize . ' split'
silent! execute 'buffer ' . t:NERDTreeBufName
endif
setlocal winfixwidth
call self._setCommonBufOptions()
if has('patch-7.4.1925')
clearjumps
endif
setlocal winfixwidth
endfunction
" FUNCTION: s:Creator._isBufHidden(nr) {{{1
@ -218,14 +217,14 @@ function! s:Creator.New()
return newCreator
endfunction
" FUNCTION: s:Creator._nextBufferName() {{{2
" FUNCTION: s:Creator._nextBufferName() {{{1
" returns the buffer name for the next nerd tree
function! s:Creator._nextBufferName()
let name = s:Creator.BufNamePrefix() . self._nextBufferNumber()
return name
endfunction
" FUNCTION: s:Creator._nextBufferNumber() {{{2
" FUNCTION: s:Creator._nextBufferNumber() {{{1
" the number to add to the nerd tree buffer name to make the buf name unique
function! s:Creator._nextBufferNumber()
if !exists("s:Creator._NextBufNum")

View File

@ -31,7 +31,7 @@ function! s:MenuController.showMenu()
let l:done = 0
while !l:done
redraw!
mode
call self._echoPrompt()
let l:key = nr2char(getchar())

View File

@ -153,7 +153,7 @@ endfunction
"FUNCTION: s:NERDTree.IsOpen() {{{1
function! s:NERDTree.IsOpen()
return s:NERDTree.GetWinNum() != -1
return s:NERDTree.GetWinNum() != -1 || bufname('%') =~# '^' . g:NERDTreeCreator.BufNamePrefix() . '\d\+$'
endfunction
"FUNCTION: s:NERDTree.isTabTree() {{{1

View File

@ -620,6 +620,11 @@ function! s:TreeDirNode.reveal(path, ...)
if self.path.equals(a:path.getParent())
let n = self.findNode(a:path)
" We may be looking for a newly-saved file that isn't in the tree yet.
if n == {}
call self.refresh()
let n = self.findNode(a:path)
endif
if has_key(opts, "open")
call n.open()
endif

View File

@ -6,7 +6,7 @@
let s:UI = {}
let g:NERDTreeUI = s:UI
" FUNCTION: s:UI.centerView() {{{2
" FUNCTION: s:UI.centerView() {{{1
" centers the nerd tree window around the cursor (provided the nerd tree
" options permit)
function! s:UI.centerView()
@ -28,7 +28,6 @@ function! s:UI._dumpHelp()
let help .= "\" ============================\n"
let help .= "\" File node mappings~\n"
let help .= "\" ". (g:NERDTreeMouseMode ==# 3 ? "single" : "double") ."-click,\n"
let help .= "\" <CR>,\n"
if self.nerdtree.isTabTree()
let help .= "\" ". g:NERDTreeMapActivateNode .": open in prev window\n"
else
@ -44,6 +43,7 @@ function! s:UI._dumpHelp()
let help .= "\" ". g:NERDTreeMapPreviewSplit .": preview split\n"
let help .= "\" ". g:NERDTreeMapOpenVSplit .": open vsplit\n"
let help .= "\" ". g:NERDTreeMapPreviewVSplit .": preview vsplit\n"
let help .= "\" ". g:NERDTreeMapCustomOpen .": custom open\n"
let help .= "\"\n\" ----------------------------\n"
let help .= "\" Directory node mappings~\n"
@ -52,6 +52,7 @@ function! s:UI._dumpHelp()
let help .= "\" ". g:NERDTreeMapOpenRecursively .": recursively open node\n"
let help .= "\" ". g:NERDTreeMapOpenInTab.": open in new tab\n"
let help .= "\" ". g:NERDTreeMapOpenInTabSilent .": open in new tab silently\n"
let help .= "\" ". g:NERDTreeMapCustomOpen .": custom open\n"
let help .= "\" ". g:NERDTreeMapCloseDir .": close parent of node\n"
let help .= "\" ". g:NERDTreeMapCloseChildren .": close all child nodes of\n"
let help .= "\" current node recursively\n"
@ -66,6 +67,7 @@ function! s:UI._dumpHelp()
let help .= "\" ". g:NERDTreeMapPreview .": find dir in tree\n"
let help .= "\" ". g:NERDTreeMapOpenInTab.": open in new tab\n"
let help .= "\" ". g:NERDTreeMapOpenInTabSilent .": open in new tab silently\n"
let help .= "\" ". g:NERDTreeMapCustomOpen .": custom open\n"
let help .= "\" ". g:NERDTreeMapDeleteBookmark .": delete bookmark\n"
let help .= "\"\n\" ----------------------------\n"
@ -252,7 +254,7 @@ endfunction
" gets the line number of the root node
function! s:UI.getRootLineNum()
let rootLine = 1
while getline(rootLine) !~# '^\(/\|<\)'
while rootLine <= line('$') && getline(rootLine) !~# '^\(/\|<\)'
let rootLine = rootLine + 1
endwhile
return rootLine

View File

@ -37,6 +37,7 @@ endif
if g:NERDTreePath.CopyingSupported()
call NERDTreeAddMenuItem({'text': '(c)opy the current node', 'shortcut': 'c', 'callback': 'NERDTreeCopyNode'})
endif
call NERDTreeAddMenuItem({'text': (has("clipboard")?'copy (p)ath to clipboard':'print (p)ath to screen'), 'shortcut': 'p', 'callback': 'NERDTreeCopyPath'})
if has("unix") || has("osx")
call NERDTreeAddMenuItem({'text': '(l)ist the current node', 'shortcut': 'l', 'callback': 'NERDTreeListNode'})
@ -364,6 +365,17 @@ function! NERDTreeCopyNode()
redraw!
endfunction
" FUNCTION: NERDTreeCopyPath() {{{1
function! NERDTreeCopyPath()
let l:nodePath = g:NERDTreeFileNode.GetSelected().path.str()
if has("clipboard")
let @* = l:nodePath
call nerdtree#echo("The path [" . l:nodePath . "] was copied to your clipboard.")
else
call nerdtree#echo("The full path is: " . l:nodePath)
endif
endfunction
" FUNCTION: NERDTreeQuickLook() {{{1
function! NERDTreeQuickLook()
let treenode = g:NERDTreeFileNode.GetSelected()

View File

@ -121,6 +121,7 @@ endif
"SECTION: Init variable calls for key mappings {{{2
call s:initVariable("g:NERDTreeMapCustomOpen", "<CR>")
call s:initVariable("g:NERDTreeMapActivateNode", "o")
call s:initVariable("g:NERDTreeMapChangeRoot", "C")
call s:initVariable("g:NERDTreeMapChdir", "cd")

File diff suppressed because it is too large Load Diff

View File

@ -15,13 +15,18 @@ COMMANDS *fugitive-commands*
These commands are local to the buffers in which they work (generally, buffers
that are part of Git repositories).
*fugitive-:G* *fugitive-:Gstatus*
:G Bring up a summary window vaguely akin to git-status.
:Gstatus Press g? or see |fugitive-mappings| for usage.
*fugitive-:Git*
:Git [args] Run an arbitrary git command. Similar to :!git [args]
but chdir to the repository tree first.
:Git {args} Run an arbitrary git command. Similar to :!git [args]
:G {args} but chdir to the repository tree first.
*fugitive-:Git!*
:Git! [args] Like |:Git|, but capture the output into a temp file,
and edit that temp file.
:Git! {args} Like |:Git|, but capture the output into a temp file,
and |:split| that that temp file. Use :0Git to
|:edit| the temp file instead.
*fugitive-:Gcd*
:Gcd [directory] |:cd| relative to the repository.
@ -29,20 +34,13 @@ that are part of Git repositories).
*fugitive-:Glcd*
:Glcd [directory] |:lcd| relative to the repository.
*fugitive-:Gstatus* *fugitive-:G*
:G Bring up a summary window vaguely akin to git-status.
:Gstatus Press g? or see |fugitive-mappings| for usage.
*fugitive-:Gcommit*
:Gcommit [args] A wrapper around git-commit. Unless the arguments
given would skip the invocation of an editor (e.g.,
-m), a split window will be used to obtain a commit
message, or a new tab if -v is given. Write and close
that window (:wq or |:Gwrite|) to finish the commit.
Unlike when running the actual git-commit command, it
is possible (but unadvisable) to alter the index with
commands like git-add and git-reset while a commit
message is pending.
the window (:wq) to finish the commit. To cancel, use
an empty message.
*fugitive-:Gmerge*
:Gmerge [args] Calls git-merge and loads errors and conflicted files
@ -75,14 +73,11 @@ that are part of Git repositories).
:Glgrep[!] [args] |:lgrep|[!] with git-grep as 'grepprg'.
*fugitive-:Glog*
:Glog [args] Load the commit history into the |quickfix| list.
Additional git-log arguments can be given (for
example, --reverse). Provide "--" in the argument
list to target all commits. Otherwise, only commits
changing the current file will be targeted. This
special casing is slated to be removed.
:Glog[!] [args] Use git-log [args] to load the commit history into the
|quickfix| list. Jump to the first commit unless [!]
is given.
:{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.
The cursor is positioned on the first line of the
first diff hunk for each commit. Use :0Glog to target
@ -109,8 +104,10 @@ that are part of Git repositories).
:Gsplit! [args] *fugitive-:Gsplit!* *fugitive-:Gvsplit!*
:Gvsplit! [args] *fugitive-:Gtabedit!* *fugitive-:Gpedit!*
:Gtabedit! [args] Like |:Git!|, but open the resulting temp file in a
:Gpedit! [args] split, tab, or preview window.
:Gtabedit! [args] Capture the output of `git [args]` to a temp file and
:Gpedit! [args] open it in a split, tab, or preview window. Use
:0Gsplit! to suppress the split and open it in the
current window.
*fugitive-:Gread*
:Gread [object] Empty the buffer and |:read| a |fugitive-object|.
@ -136,7 +133,7 @@ that are part of Git repositories).
:Gwrite {path} You can give |:Gwrite| an explicit path of where in
the work tree to write. You can also give a path like
:0:foo.txt or even :0 to write to just that stage in
:0:foo.txt or :0:% to write to just that stage in
the index.
*fugitive-:Gwq*
@ -146,25 +143,28 @@ that are part of Git repositories).
:Gwq! [path] Like |:Gwrite|! followed by |:quit|! if the write
succeeded.
*fugitive-:Gdiff*
:Gdiff [object] Perform a |vimdiff| against the given file, or if a
*fugitive-:Gdiffsplit*
:Gdiffsplit [object] Perform a |vimdiff| against the given file, or if a
commit is given, the current file in that commit.
With no argument, the version in the index is used
(which means a three-way diff during a merge conflict,
making it a git-mergetool alternative). The newer of
the two files is placed to the right or bottom,
depending on 'diffopt', and the width of the window
relative to 'textwidth'. Use |do| and |dp| and write
to the index file to simulate "git add --patch". For
the three-way diff, there is also d2o and d3o pulling
the hunk to the middle from the left or the right
window, respectively.
With no argument, the version in the index or work
tree is used. The newer of the two files is placed to
the right or bottom, depending on 'diffopt' and the
width of the window relative to 'textwidth'. Use
Vim's |do| and |dp| to stage and unstage changes.
*fugitive-:Gsdiff*
:Gsdiff [object] Like |:Gdiff|, but always split horizontally.
*fugitive-:Gdiffsplit!*
:Gdiffsplit! [object] During a merge conflict, do a three-way diff against
both ancestors. Additional d2o and d3o maps are
provided to to obtain the hunk from the "ours" or
"theirs" ancestor, respectively. If the file is not
conflicted, behaves the same as if no bang was given,
but keeps focus in the original window.
*fugitive-:Gvdiff*
:Gvdiff [object] Like |:Gdiff|, but always split vertically.
*fugitive-:Gvdiffsplit*
:Gvdiffsplit [object] Like |:Gdiffsplit|, but always split vertically.
*fugitive-:Ghdiffsplit* *fugitive-:Gsdiff*
:Ghdiffsplit [object] Like |:Gdiffsplit|, but always split horizontally.
*fugitive-:Gmove*
:Gmove {destination} Wrapper around git-mv that renames the buffer
@ -186,7 +186,7 @@ that are part of Git repositories).
*fugitive-:Gblame*
:Gblame [flags] Run git-blame on the file and open the results in a
scroll bound vertical split. You can give any of
ltfnsewMC as flags and they will be passed along to
-ltsewMC as flags and they will be passed along to
git-blame. The following maps, which work on the
cursor line commit where sensible, are provided:
@ -279,13 +279,14 @@ i On untracked files, call |:Git| add --intent-to-add.
automatically.
*fugitive_dd*
dd Perform a |:Gdiff| on the file under the cursor.
*fugitive_ds*
ds Perform a |:Gsdiff| on the file under the cursor.
dd Perform a |:Gdiffsplit| on the file under the cursor.
*fugitive_dv*
dv Perform a |:Gvdiff| on the file under the cursor.
dv Perform a |:Gvdiffsplit| on the file under the cursor.
*fugitive_ds* *fugitive_dh*
ds Perform a |:Ghdiffsplit| on the file under the cursor.
dh
*fugitive_dp*
dp Invoke |:Git!| diff on the file under the cursor.
@ -326,6 +327,21 @@ C Open the commit containing the current file.
<C-W>C Open the commit containing the current file in a new
split.
*fugitive_gu*
gu Jump to "Unstaged" section.
*fugitive_gU*
gU Jump to "Untracked" section.
*fugitive_gs*
gs Jump to "Staged" section.
*fugitive_gp*
gp Jump to "Unpushed" section.
*fugitive_gP*
gP Jump to "Unpulled" section.
*fugitive_c*
Commit mappings ~
@ -388,9 +404,6 @@ Miscellaneous mappings ~
*fugitive_gq* *fugitive_q*
gq Close the status buffer.
*fugitive_R*
R Reload the status buffer.
*fugitive_.*
. Start a |:| command line with the file under the
cursor prepopulated.

View File

@ -103,7 +103,7 @@ endfunction
function! FugitiveIsGitDir(path) abort
let path = substitute(a:path, '[\/]$', '', '') . '/'
return getfsize(path.'HEAD') > 10 && (
return len(a:path) && getfsize(path.'HEAD') > 10 && (
\ isdirectory(path.'objects') && isdirectory(path.'refs') ||
\ getftype(path.'commondir') ==# 'file')
endfunction
@ -159,9 +159,11 @@ function! FugitiveExtractGitDir(path) abort
endif
let root = resolve(path)
if root !=# path
silent! exe haslocaldir() ? 'lcd .' : 'cd .'
silent! exe (haslocaldir() ? 'lcd' : exists(':tcd') && haslocaldir(-1) ? 'tcd' : 'cd') '.'
endif
let previous = ""
let env_git_dir = len($GIT_DIR) ? s:Slash(simplify(fnamemodify($GIT_DIR, ':p:s?[\/]$??'))) : ''
call s:Tree(env_git_dir)
while root !=# previous
if root =~# '\v^//%([^/]+/?)?$'
break
@ -169,14 +171,10 @@ function! FugitiveExtractGitDir(path) abort
if index(split($GIT_CEILING_DIRECTORIES, ':'), root) >= 0
break
endif
if root ==# $GIT_WORK_TREE && FugitiveIsGitDir($GIT_DIR)
return simplify(fnamemodify($GIT_DIR, ':p:s?[\/]$??'))
endif
if FugitiveIsGitDir($GIT_DIR)
call s:Tree(simplify(fnamemodify($GIT_DIR, ':p:s?[\/]$??')))
if has_key(s:dir_for_worktree, root)
return s:dir_for_worktree[root]
endif
if root ==# $GIT_WORK_TREE && FugitiveIsGitDir(env_git_dir)
return env_git_dir
elseif has_key(s:dir_for_worktree, root)
return s:dir_for_worktree[root]
endif
let dir = substitute(root, '[\/]$', '', '') . '/.git'
let type = getftype(dir)
@ -234,7 +232,10 @@ function! s:ProjectionistDetect() abort
if exists('+shellslash') && !&shellslash
let base = tr(base, '/', '\')
endif
call projectionist#append(base, FugitiveCommonDir(dir) . '/info/projections.json')
let file = FugitiveCommonDir(dir) . '/info/projections.json'
if filereadable(file)
call projectionist#append(base, file)
endif
endif
endfunction

View File

@ -0,0 +1,7 @@
if exists("b:current_syntax")
finish
endif
call fugitive#BlameSyntax()
let b:current_syntax = "fugitiveblame"

View File

@ -2,7 +2,3 @@
> What vim/nvim version are you on?
> If no signs are showing at all, what does `:echo b:gitgutter.path` give?
> If no signs are showing at all, and the `path` value is a path and not `-2`, does it work with `let g:gitgutter_grep=''`?

View File

@ -26,7 +26,7 @@ Features:
Constraints:
* Supports git only. If you work with other version control systems, I recommend [vim-signify](https://github.com/mhinz/vim-signify).
* Relies on the `FocusGained` event. If your terminal doesn't report focus events, either use something like [Terminus][] or set `let g:gitgutter_terminal_reports_focus=0`. For tmux, `set -f focus-events on` in your tmux.conf.
* Relies on the `FocusGained` event. If your terminal doesn't report focus events, either use something like [Terminus][] or set `let g:gitgutter_terminal_reports_focus=0`. For tmux, `set -g focus-events on` in your tmux.conf.
### Screenshot
@ -557,7 +557,7 @@ Here are some things you can check:
#### When signs don't update after focusing Vim
* Your terminal probably isn't reporting focus events. Either try installing [Terminus][] or set `let g:gitgutter_terminal_reports_focus=0`. For tmux, try `set -f focus-events on` in your tmux.conf.
* Your terminal probably isn't reporting focus events. Either try installing [Terminus][] or set `let g:gitgutter_terminal_reports_focus=0`. For tmux, try `set -g focus-events on` in your tmux.conf.
### Shameless Plug

View File

@ -173,4 +173,5 @@ function! s:clear(bufnr)
call gitgutter#sign#remove_dummy_sign(a:bufnr, 1)
call gitgutter#hunk#reset(a:bufnr)
call s:reset_tick(a:bufnr)
call gitgutter#utility#setbufvar(a:bufnr, 'path', '')
endfunction

View File

@ -4,7 +4,7 @@ let s:hunk_re = '^@@ -\(\d\+\),\?\(\d*\) +\(\d\+\),\?\(\d*\) @@'
" True for git v1.7.2+.
function! s:git_supports_command_line_config_override() abort
call system(g:gitgutter_git_executable.' -c foo.bar=baz --version')
call system(g:gitgutter_git_executable.' '.g:gitgutter_git_args.' -c foo.bar=baz --version')
return !v:shell_error
endfunction
@ -119,14 +119,14 @@ function! gitgutter#diff#run_diff(bufnr, from, preserve_full_diff) abort
" Write file from index to temporary file.
let index_name = g:gitgutter_diff_base.':'.gitgutter#utility#repo_path(a:bufnr, 1)
let cmd .= g:gitgutter_git_executable.' --no-pager show '.index_name.' > '.from_file.' && '
let cmd .= g:gitgutter_git_executable.' '.g:gitgutter_git_args.' --no-pager show '.index_name.' > '.from_file.' && '
elseif a:from ==# 'working_tree'
let from_file = gitgutter#utility#repo_path(a:bufnr, 1)
endif
" Call git-diff.
let cmd .= g:gitgutter_git_executable.' --no-pager '.g:gitgutter_git_args
let cmd .= g:gitgutter_git_executable.' '.g:gitgutter_git_args.' --no-pager '.g:gitgutter_git_args
if s:c_flag
let cmd .= ' -c "diff.autorefreshindex=0"'
let cmd .= ' -c "diff.noprefix=false"'

View File

@ -131,40 +131,22 @@ function! s:define_sign_line_highlights() abort
endif
endfunction
function! s:get_foreground_colors(group) abort
redir => highlight
silent execute 'silent highlight ' . a:group
redir END
let link_matches = matchlist(highlight, 'links to \(\S\+\)')
if len(link_matches) > 0 " follow the link
return s:get_foreground_colors(link_matches[1])
function! s:get_hl(group, what, mode) abort
let r = synIDattr(synIDtrans(hlID(a:group)), a:what, a:mode)
if empty(r) || r == -1
return 'NONE'
endif
return r
endfunction
let ctermfg = s:match_highlight(highlight, 'ctermfg=\([0-9A-Za-z]\+\)')
let guifg = s:match_highlight(highlight, 'guifg=\([#0-9A-Za-z]\+\)')
function! s:get_foreground_colors(group) abort
let ctermfg = s:get_hl(a:group, 'fg', 'cterm')
let guifg = s:get_hl(a:group, 'fg', 'gui')
return [guifg, ctermfg]
endfunction
function! s:get_background_colors(group) abort
redir => highlight
silent execute 'silent highlight ' . a:group
redir END
let link_matches = matchlist(highlight, 'links to \(\S\+\)')
if len(link_matches) > 0 " follow the link
return s:get_background_colors(link_matches[1])
endif
let ctermbg = s:match_highlight(highlight, 'ctermbg=\([0-9A-Za-z]\+\)')
let guibg = s:match_highlight(highlight, 'guibg=\([#0-9A-Za-z]\+\)')
let ctermbg = s:get_hl(a:group, 'bg', 'cterm')
let guibg = s:get_hl(a:group, 'bg', 'gui')
return [guibg, ctermbg]
endfunction
function! s:match_highlight(highlight, pattern) abort
let matches = matchlist(a:highlight, a:pattern)
if len(matches) == 0
return 'NONE'
endif
return matches[1]
endfunction

View File

@ -221,7 +221,7 @@ function! s:stage(hunk_diff)
let diff = s:adjust_header(bufnr, a:hunk_diff)
" Apply patch to index.
call gitgutter#utility#system(
\ gitgutter#utility#cd_cmd(bufnr, g:gitgutter_git_executable.' apply --cached --unidiff-zero - '),
\ gitgutter#utility#cd_cmd(bufnr, g:gitgutter_git_executable.' '.g:gitgutter_git_args.' apply --cached --unidiff-zero - '),
\ diff)
" Refresh gitgutter's view of buffer.
@ -240,10 +240,10 @@ function! s:undo(hunk_diff)
if removed_only
call append(lnum, lines)
elseif added_only
execute lnum .','. (lnum+len(lines)-1) .'d'
execute lnum .','. (lnum+len(lines)-1) .'d _'
else
call append(lnum-1, lines[0:hunk[1]])
execute (lnum+hunk[1]) .','. (lnum+hunk[1]+hunk[3]) .'d'
execute (lnum+hunk[1]) .','. (lnum+hunk[1]+hunk[3]) .'d _'
endif
endfunction

View File

@ -22,14 +22,16 @@ function! gitgutter#utility#setbufvar(buffer, varname, val)
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
let bvars = getbufvar(a:buffer, '')
if !empty(bvars)
let dict = get(bvars, 'gitgutter', {})
if has_key(dict, a:varname)
return dict[a:varname]
endif
endif
if a:0
return a:1
endif
endfunction
function! gitgutter#utility#warn(message) abort
@ -143,9 +145,9 @@ function! gitgutter#utility#set_repo_path(bufnr, continuation) abort
" * -2 - not tracked by git
call gitgutter#utility#setbufvar(a:bufnr, 'path', -1)
let cmd = gitgutter#utility#cd_cmd(a:bufnr, g:gitgutter_git_executable.' ls-files --error-unmatch --full-name -z -- '.gitgutter#utility#shellescape(s:filename(a:bufnr)))
let cmd = gitgutter#utility#cd_cmd(a:bufnr, g:gitgutter_git_executable.' '.g:gitgutter_git_args.' ls-files --error-unmatch --full-name -z -- '.gitgutter#utility#shellescape(s:filename(a:bufnr)))
if g:gitgutter_async && gitgutter#async#available()
if g:gitgutter_async && gitgutter#async#available() && !has('vim_starting')
let handler = copy(s:set_path_handler)
let handler.continuation = a:continuation
call gitgutter#async#execute(cmd, a:bufnr, handler)

View File

@ -214,6 +214,9 @@ augroup gitgutter
autocmd ShellCmdPost * call gitgutter#all(1)
autocmd BufLeave term://* call gitgutter#all(1)
autocmd BufFilePre * GitGutterBufferDisable
autocmd BufFilePost * GitGutterBufferEnable
" Handle all buffers when focus is gained, but only after it was lost.
" FocusGained gets triggered on startup with Neovim at least already.
" Therefore this tracks also if it was lost before.

View File

@ -1,5 +1,9 @@
## unplanned
BACKWARDS INCOMPATABILITIES:
* `g:go_metalinter_disabled` has been removed.
[[GH-2375]](https://github.com/fatih/vim-go/pull/2117)
IMPROVEMENTS:
* Add a new option, `g:go_code_completion_enabled`, to control whether omnifunc
is set.
@ -14,11 +18,32 @@ IMPROVEMENTS:
[[GH-2289]](https://github.com/fatih/vim-go/pull/2289)
* Improve the user experience when using null modules.
[[GH-2300]](https://github.com/fatih/vim-go/pull/2300)
* Add option, `g:go_null_module_warning` to silence the warning when trying to
use gopls with a null module.
* Add a new option, `g:go_null_module_warning` to silence the warning when
trying to use gopls with a null module.
[[GH-2309]](https://github.com/fatih/vim-go/pull/2309)
* Modify `:GoReportGitHubIssue` to include vim-go configuration values
[[GH-2323]](https://github.com/fatih/vim-go/pull/2323)
* Respect `g:go_info_mode='gopls'` in go#complete#GetInfo.
[[GH-2313]](https://github.com/fatih/vim-go/pull/2313)
* Allow `:GoLint`, `:GoErrCheck`, and `:GoDebug` to work in null modules.
[[GH-2335]](https://github.com/fatih/vim-go/pull/2335)
* Change default value for `g:go_info_mode` and `g:go_def_mode` to `'gopls'`.
[[GH-2329]](https://github.com/fatih/vim-go/pull/2329)
* Add a new option, `g:go_doc_popup_window` to optionally use a popup window
for godoc in Vim 8.1.1513 and later.
[[GH-2347]](https://github.com/fatih/vim-go/pull/2347)
* Check for null modules in the background when initializing gopls.
[[GH-2351]](https://github.com/fatih/vim-go/pull/2351)
* Add `:GoAddWorkspace` function to support multiple workspaces with gopls.
[[GH-2356]](https://github.com/fatih/vim-go/pull/2356)
* Rename `errn` Ultisnip snippet to `err`.
[[GH-2358]](https://github.com/fatih/vim-go/pull/2358)
* Install gopls from its stable package.
[[GH-2360]](https://github.com/fatih/vim-go/pull/2360)
* Disambiguate progress message when initializing gopls.
[[GH-2369]](https://github.com/fatih/vim-go/pull/2369)
* Remove warnings and lsp short-circuiting when using a null module.
[[GH-2371]](https://github.com/fatih/vim-go/pull/2371)
BUG FIXES:
* display info about function and function types whose parameters are
@ -53,6 +78,16 @@ BUG FIXES:
* Do not jump back to the originating window when jumping to definitions with
`g:go_def_mode='gopls'`.
[[GH-2327]](https://github.com/fatih/vim-go/pull/2327)
* Fix getting information about a valid identifier for which gopls returns no
information (e.g. calling `:GoInfo` on a package identifier).
[[GH-2339]](https://github.com/fatih/vim-go/pull/2339)
* Fix tab completion of package names on the cmdline in null modules.
[[GH-2342]](https://github.com/fatih/vim-go/pull/2342)
* Display identifier info correctly when the identifier has no godoc.
[[GH-2373]](https://github.com/fatih/vim-go/pull/2373)
* Fix false positives when saving a buffer and `g:go_metalinter_command` is
`golangci-lint`.
[[GH-2367]](https://github.com/fatih/vim-go/pull/2367)
## 1.20 - (April 22, 2019)

View File

@ -79,7 +79,12 @@ endfunction
" go#complete#GoInfo returns the description of the identifier under the
" cursor.
function! go#complete#GetInfo() abort
return s:sync_info(0)
let l:mode = go#config#InfoMode()
if l:mode == 'gopls' && go#util#has_job()
return go#lsp#GetInfo()
else
return s:sync_info(0)
endif
endfunction
function! go#complete#Info(showstatus) abort

View File

@ -2,23 +2,33 @@
let s:cpo_save = &cpo
set cpo&vim
func! Test_GetInfo()
func! Test_GetInfo_gocode()
let g:go_info_mode = 'gocode'
call s:getinfo()
unlet g:go_info_mode
endfunction
func! Test_GetInfo_guru()
let g:go_info_mode = 'guru'
call s:getinfo()
unlet g:go_info_mode
endfunction
func! Test_GetInfo_gopls()
let g:go_info_mode = 'gopls'
call s:getinfo()
unlet g:go_info_mode
endfunction
func! s:getinfo()
let l:filename = 'complete/complete.go'
let l:tmp = gotest#load_fixture(l:filename)
call cursor(8, 3)
let g:go_info_mode = 'gocode'
let expected = 'func Example(s string)'
let actual = go#complete#GetInfo()
call assert_equal(expected, actual)
let g:go_info_mode = 'guru'
call go#config#InfoMode()
let actual = go#complete#GetInfo()
call assert_equal(expected, actual)
unlet g:go_info_mode
endfunction
" restore Vi compatibility settings

View File

@ -14,10 +14,6 @@ function! go#config#VersionWarning() abort
return get(g:, 'go_version_warning', 1)
endfunction
function! go#config#NullModuleWarning() abort
return get(g:, 'go_null_module_warning', 1)
endfunction
function! go#config#BuildTags() abort
return get(g:, 'go_build_tags', '')
endfunction
@ -118,7 +114,7 @@ function! go#config#ListAutoclose() abort
endfunction
function! go#config#InfoMode() abort
return get(g:, 'go_info_mode', 'gocode')
return get(g:, 'go_info_mode', 'gopls')
endfunction
function! go#config#GuruScope() abort
@ -178,12 +174,15 @@ function! go#config#DocUrl() abort
return godoc_url
endfunction
function! go#config#DocPopupWindow() abort
return get(g:, 'go_doc_popup_window', 0)
endfunction
function! go#config#DefReuseBuffer() abort
return get(g:, 'go_def_reuse_buffer', 0)
endfunction
function! go#config#DefMode() abort
return get(g:, 'go_def_mode', 'guru')
return get(g:, 'go_def_mode', 'gopls')
endfunction
function! go#config#DeclsIncludes() abort
@ -272,10 +271,6 @@ function! go#config#MetalinterEnabled() abort
return get(g:, "go_metalinter_enabled", default_enabled)
endfunction
function! go#config#MetalinterDisabled() abort
return get(g:, "go_metalinter_disabled", [])
endfunction
function! go#config#GolintBin() abort
return get(g:, "go_golint_bin", "golint")
endfunction

View File

@ -595,10 +595,23 @@ function! go#debug#Start(is_test, ...) abort
" append the package when it's given.
if len(a:000) > 0
let l:pkgname = go#package#FromPath(a:1)
if l:pkgname is -1
call go#util#EchoError('could not determine package name')
return
let l:pkgname = a:1
if l:pkgname[0] == '.'
let l:pkgabspath = fnamemodify(l:pkgname, ':p')
let l:cd = exists('*haslocaldir') && haslocaldir() ? 'lcd' : 'cd'
let l:dir = getcwd()
execute l:cd fnameescape(expand('%:p:h'))
try
let l:pkgname = go#package#FromPath(l:pkgabspath)
if type(l:pkgname) == type(0)
call go#util#EchoError('could not determine package name')
return
endif
finally
execute l:cd fnameescape(l:dir)
endtry
endif
let l:cmd += [l:pkgname]

View File

@ -10,6 +10,10 @@ function! Test_GoDebugStart_RelativePackage() abort
call s:debug('./debug/debugmain')
endfunction
function! Test_GoDebugStart_RelativePackage_NullModule() abort
call s:debug('./debug/debugmain', 1)
endfunction
function! Test_GoDebugStart_Package() abort
call s:debug('debug/debugmain')
endfunction
@ -52,14 +56,22 @@ function! Test_GoDebugStart_Errors() abort
endtry
endfunction
" s:debug takes 2 optional arguments. The first is a package to debug. The
" second is a flag to indicate whether to reset GOPATH after
" gotest#load_fixture is called in order to test behavior outside of GOPATH.
function! s:debug(...) abort
if !go#util#has_job()
return
endif
try
let $oldgopath = $GOPATH
let l:tmp = gotest#load_fixture('debug/debugmain/debugmain.go')
if a:0 > 1 && a:2 == 1
let $GOPATH = $oldgopath
endif
call go#debug#Breakpoint(6)
call assert_false(exists(':GoDebugStop'))

View File

@ -50,8 +50,16 @@ func! Test_Jump_leaves_lists() abort
let l:bufnr = bufnr('%')
call cursor(6, 7)
if !go#util#has_job()
let g:go_def_mode='godef'
endif
call go#def#Jump('', 0)
if !go#util#has_job()
unlet g:go_def_mode
endif
let start = reltime()
while bufnr('%') == l:bufnr && reltimefloat(reltime(start)) < 10
sleep 100m

View File

@ -76,6 +76,18 @@ function! go#doc#Open(newmode, mode, ...) abort
endfunction
function! s:GodocView(newposition, position, content) abort
" popup window
if go#config#DocPopupWindow() && has("patch-8.1.1513")
call popup_clear()
call popup_atcursor(split(a:content, '\n'), {
\ 'padding': [1, 1, 1, 1],
\ 'borderchars': ['-','|','-','|','+','+','+','+'],
\ "border": [1, 1, 1, 1],
\ })
return
endif
" reuse existing buffer window if it exists otherwise create a new one
let is_visible = bufexists(s:buf_nr) && bufwinnr(s:buf_nr) != -1
if !bufexists(s:buf_nr)

View File

@ -22,10 +22,6 @@ function! go#lint#Gometa(bang, autosave, ...) abort
for linter in linters
let cmd += ["--enable=".linter]
endfor
for linter in go#config#MetalinterDisabled()
let cmd += ["--disable=".linter]
endfor
else
" the user wants something else, let us use it.
let cmd = split(go#config#MetalinterCommand(), " ")
@ -44,7 +40,7 @@ function! go#lint#Gometa(bang, autosave, ...) abort
endif
let cmd += include
elseif l:metalinter == "golangci-lint"
let goargs[0] = expand('%:p')
let goargs[0] = expand('%:p:h')
endif
endif
@ -88,7 +84,13 @@ function! go#lint#Gometa(bang, autosave, ...) abort
else
let l:winid = win_getid(winnr())
" Parse and populate our location list
call go#list#ParseFormat(l:listtype, errformat, split(out, "\n"), 'GoMetaLinter')
let l:messages = split(out, "\n")
if a:autosave
call s:metalinterautosavecomplete(fnamemodify(expand('%:p'), ":."), 0, 1, l:messages)
endif
call go#list#ParseFormat(l:listtype, errformat, l:messages, 'GoMetaLinter')
let errors = go#list#Get(l:listtype)
call go#list#Window(l:listtype, len(errors))
@ -101,10 +103,11 @@ function! go#lint#Gometa(bang, autosave, ...) abort
endif
endfunction
" Golint calls 'golint'.
" Golint calls 'golint' on the current directory. Any warnings are populated in
" the location list
function! go#lint#Golint(bang, ...) abort
if a:0 == 0
let [l:out, l:err] = go#util#ExecInDir([go#config#GolintBin(), '.'])
let [l:out, l:err] = go#util#Exec([go#config#GolintBin(), expand('%:p:h')])
else
let [l:out, l:err] = go#util#Exec([go#config#GolintBin()] + a:000)
endif
@ -140,7 +143,7 @@ function! go#lint#Vet(bang, ...) abort
if a:0 == 0
let [l:out, l:err] = go#util#Exec(['go', 'vet', go#package#ImportPath()])
else
let [l:out, l:err] = go#util#Exec(['go', 'tool', 'vet'] + a:000)
let [l:out, l:err] = go#util#ExecInDir(['go', 'tool', 'vet'] + a:000)
endif
let l:listtype = go#list#Type("GoVet")
@ -229,6 +232,7 @@ function! s:lint_job(args, bang, autosave)
if a:autosave
let l:opts.for = "GoMetaLinterAutoSave"
let l:opts.complete = funcref('s:metalinterautosavecomplete', [expand('%:p:t')])
endif
" autowrite is not enabled for jobs
@ -278,6 +282,21 @@ function! s:golangcilintcmd(bin_path)
return cmd
endfunction
function! s:metalinterautosavecomplete(filepath, job, exit_code, messages)
if len(a:messages) == 0
return
endif
let l:file = expand('%:p:t')
let l:idx = len(a:messages) - 1
while l:idx >= 0
if a:messages[l:idx] !~# '^' . a:filepath . ':'
call remove(a:messages, l:idx)
endif
let l:idx -= 1
endwhile
endfunction
" restore Vi compatibility settings
let &cpo = s:cpo_save
unlet s:cpo_save

View File

@ -3,7 +3,7 @@ let s:cpo_save = &cpo
set cpo&vim
func! Test_Gometa() abort
call s:gometa('gometaliner')
call s:gometa('gometalinter')
endfunc
func! Test_GometaGolangciLint() abort
@ -11,14 +11,19 @@ func! Test_GometaGolangciLint() abort
endfunc
func! s:gometa(metalinter) abort
let $GOPATH = fnameescape(fnamemodify(getcwd(), ':p')) . 'test-fixtures/lint'
let RestoreGOPATH = go#util#SetEnv('GOPATH', fnamemodify(getcwd(), ':p') . 'test-fixtures/lint')
silent exe 'e ' . $GOPATH . '/src/lint/lint.go'
try
let g:go_metalinter_comand = a:metalinter
let g:go_metalinter_command = a:metalinter
let expected = [
\ {'lnum': 5, 'bufnr': bufnr('%')+1, 'col': 1, 'valid': 1, 'vcol': 0, 'nr': -1, 'type': 'w', 'pattern': '', 'text': 'exported function MissingFooDoc should have comment or be unexported (golint)'}
\ ]
if a:metalinter == 'golangci-lint'
let expected = [
\ {'lnum': 5, 'bufnr': bufnr('%')+1, 'col': 1, 'valid': 1, 'vcol': 0, 'nr': -1, 'type': '', 'pattern': '', 'text': 'exported function `MissingFooDoc` should have comment or be unexported (golint)'}
\ ]
endif
" clear the quickfix lists
call setqflist([], 'r')
@ -36,48 +41,11 @@ func! s:gometa(metalinter) abort
call gotest#assert_quickfix(actual, expected)
finally
call call(RestoreGOPATH, [])
unlet g:go_metalinter_enabled
endtry
endfunc
func! Test_GometaWithDisabled() abort
call s:gometawithdisabled('gometalinter')
endfunc
func! Test_GometaWithDisabledGolangciLint() abort
call s:gometawithdisabled('golangci-lint')
endfunc
func! s:gometawithdisabled(metalinter) abort
let $GOPATH = fnameescape(fnamemodify(getcwd(), ':p')) . 'test-fixtures/lint'
silent exe 'e ' . $GOPATH . '/src/lint/lint.go'
try
let g:go_metalinter_comand = a:metalinter
let expected = [
\ {'lnum': 5, 'bufnr': bufnr('%')+1, 'col': 1, 'valid': 1, 'vcol': 0, 'nr': -1, 'type': 'w', 'pattern': '', 'text': 'exported function MissingFooDoc should have comment or be unexported (golint)'}
\ ]
" clear the quickfix lists
call setqflist([], 'r')
let g:go_metalinter_disabled = ['vet']
call go#lint#Gometa(0, 0, $GOPATH . '/src/foo')
let actual = getqflist()
let start = reltime()
while len(actual) == 0 && reltimefloat(reltime(start)) < 10
sleep 100m
let actual = getqflist()
endwhile
call gotest#assert_quickfix(actual, expected)
finally
unlet g:go_metalinter_disabled
endtry
endfunc
func! Test_GometaAutoSave() abort
call s:gometaautosave('gometalinter')
endfunc
@ -87,14 +55,19 @@ func! Test_GometaAutoSaveGolangciLint() abort
endfunc
func! s:gometaautosave(metalinter) abort
let $GOPATH = fnameescape(fnamemodify(getcwd(), ':p')) . 'test-fixtures/lint'
let RestoreGOPATH = go#util#SetEnv('GOPATH', fnameescape(fnamemodify(getcwd(), ':p')) . 'test-fixtures/lint')
silent exe 'e ' . $GOPATH . '/src/lint/lint.go'
try
let g:go_metalinter_comand = a:metalinter
let g:go_metalinter_command = a:metalinter
let expected = [
\ {'lnum': 5, 'bufnr': bufnr('%'), 'col': 1, 'valid': 1, 'vcol': 0, 'nr': -1, 'type': 'w', 'pattern': '', 'text': 'exported function MissingDoc should have comment or be unexported (golint)'}
\ ]
if a:metalinter == 'golangci-lint'
let expected = [
\ {'lnum': 5, 'bufnr': bufnr('%'), 'col': 1, 'valid': 1, 'vcol': 0, 'nr': -1, 'type': '', 'pattern': '', 'text': 'exported function `MissingDoc` should have comment or be unexported (golint)'}
\ ]
endif
let winnr = winnr()
@ -114,12 +87,13 @@ func! s:gometaautosave(metalinter) abort
call gotest#assert_quickfix(actual, expected)
finally
call call(RestoreGOPATH, [])
unlet g:go_metalinter_autosave_enabled
endtry
endfunc
func! Test_Vet() abort
let $GOPATH = fnameescape(fnamemodify(getcwd(), ':p')) . 'test-fixtures/lint'
let RestoreGOPATH = go#util#SetEnv('GOPATH', fnameescape(fnamemodify(getcwd(), ':p')) . 'test-fixtures/lint')
silent exe 'e ' . $GOPATH . '/src/vet/vet.go'
compiler go
@ -142,6 +116,63 @@ func! Test_Vet() abort
let actual = getqflist()
endwhile
call gotest#assert_quickfix(actual, expected)
call call(RestoreGOPATH, [])
endfunc
func! Test_Lint_GOPATH() abort
let RestoreGOPATH = go#util#SetEnv('GOPATH', fnameescape(fnamemodify(getcwd(), ':p')) . 'test-fixtures/lint')
silent exe 'e ' . $GOPATH . '/src/lint/lint.go'
compiler go
let expected = [
\ {'lnum': 5, 'bufnr': bufnr('%'), 'col': 1, 'valid': 1, 'vcol': 0, 'nr': -1, 'type': '', 'pattern': '', 'text': 'exported function MissingDoc should have comment or be unexported'},
\ {'lnum': 5, 'bufnr': 6, 'col': 1, 'valid': 1, 'vcol': 0, 'nr': -1, 'type': '', 'pattern': '', 'text': 'exported function AlsoMissingDoc should have comment or be unexported'}
\ ]
let winnr = winnr()
" clear the location lists
call setqflist([], 'r')
call go#lint#Golint(1)
let actual = getqflist()
let start = reltime()
while len(actual) == 0 && reltimefloat(reltime(start)) < 10
sleep 100m
let actual = getqflist()
endwhile
call gotest#assert_quickfix(actual, expected)
call call(RestoreGOPATH, [])
endfunc
func! Test_Lint_NullModule() abort
silent exe 'e ' . fnameescape(fnamemodify(getcwd(), ':p')) . 'test-fixtures/lint/src/lint/lint.go'
compiler go
let expected = [
\ {'lnum': 5, 'bufnr': bufnr('%'), 'col': 1, 'valid': 1, 'vcol': 0, 'nr': -1, 'type': '', 'pattern': '', 'text': 'exported function MissingDoc should have comment or be unexported'},
\ {'lnum': 5, 'bufnr': 6, 'col': 1, 'valid': 1, 'vcol': 0, 'nr': -1, 'type': '', 'pattern': '', 'text': 'exported function AlsoMissingDoc should have comment or be unexported'}
\ ]
let winnr = winnr()
" clear the location lists
call setqflist([], 'r')
call go#lint#Golint(1)
let actual = getqflist()
let start = reltime()
while len(actual) == 0 && reltimefloat(reltime(start)) < 10
sleep 100m
let actual = getqflist()
endwhile
call gotest#assert_quickfix(actual, expected)
endfunc

View File

@ -26,7 +26,6 @@ function! s:newlsp() abort
if has('nvim')
set shortmess-=F
endif
" TODO(bc): start the server in the background using a shell that waits for the right output before returning.
call go#util#EchoWarning('Features that rely on gopls will not work without either Vim 8.0.0087 or newer with +job or Neovim')
" Sleep one second to make sure people see the message. Otherwise it is
" often immediately overwritten by an async message.
@ -55,6 +54,7 @@ function! s:newlsp() abort
\ 'last_request_id': 0,
\ 'buf': '',
\ 'handlers': {},
\ 'workspaceDirectories': [],
\ }
function! l:lsp.readMessage(data) dict abort
@ -83,19 +83,17 @@ function! s:newlsp() abort
endif
" get the start of the rest
let l:rest_start_idx = l:body_start_idx + str2nr(l:length_match[1])
let l:next_start_idx = l:body_start_idx + str2nr(l:length_match[1])
if len(l:rest) < l:rest_start_idx
if len(l:rest) < l:next_start_idx
" incomplete response body
break
endif
if go#util#HasDebug('lsp')
let g:go_lsp_log = add(go#config#LspLog(), "<-\n" . l:rest[:l:rest_start_idx - 1])
endif
call s:debug('received', l:rest[:l:next_start_idx - 1])
let l:body = l:rest[l:body_start_idx : l:rest_start_idx - 1]
let l:rest = l:rest[l:rest_start_idx :]
let l:body = l:rest[l:body_start_idx : l:next_start_idx - 1]
let l:rest = l:rest[l:next_start_idx :]
try
" add the json body to the list.
@ -113,53 +111,77 @@ function! s:newlsp() abort
function! l:lsp.handleMessage(ch, data) dict abort
let self.buf .= a:data
let [self.buf, l:responses] = self.readMessage(self.buf)
let [self.buf, l:messages] = self.readMessage(self.buf)
" TODO(bc): handle notifications (e.g. window/showMessage).
for l:response in l:responses
if has_key(l:response, 'id') && has_key(self.handlers, l:response.id)
try
let l:handler = self.handlers[l:response.id]
let l:winid = win_getid(winnr())
" Always set the active window to the window that was active when
" the request was sent. Among other things, this makes sure that
" the correct window's location list will be populated when the
" list type is 'location' and the user has moved windows since
" sending the reques.
call win_gotoid(l:handler.winid)
if has_key(l:response, 'error')
call l:handler.requestComplete(0)
if has_key(l:handler, 'error')
call call(l:handler.error, [l:response.error.message])
else
call go#util#EchoError(l:response.error.message)
endif
call win_gotoid(l:winid)
return
endif
call l:handler.requestComplete(1)
let l:winidBeforeHandler = l:handler.winid
call call(l:handler.handleResult, [l:response.result])
" change the window back to the window that was active when
" starting to handle the response _only_ if the handler didn't
" update the winid, so that handlers can set the winid if needed
" (e.g. :GoDef).
if l:handler.winid == l:winidBeforeHandler
call win_gotoid(l:winid)
endif
finally
call remove(self.handlers, l:response.id)
endtry
for l:message in l:messages
if has_key(l:message, 'method')
if has_key(l:message, 'id')
call self.handleRequest(l:message)
else
call self.handleNotification(l:message)
endif
elseif has_key(l:message, 'result') || has_key(l:message, 'error')
call self.handleResponse(l:message)
endif
endfor
endfunction
function! l:lsp.handleRequest(req) dict abort
if a:req.method == 'workspace/workspaceFolders'
let l:resp = go#lsp#message#workspaceFolders(self.workspaceDirectories)
endif
let l:msg = self.newResponse(l:resp)
call self.write(l:msg)
endfunction
function! l:lsp.handleNotification(req) dict abort
" TODO(bc): handle notifications (e.g. window/showMessage).
endfunction
function! l:lsp.handleResponse(resp) dict abort
if has_key(a:resp, 'id') && has_key(self.handlers, a:resp.id)
try
let l:handler = self.handlers[a:resp.id]
let l:winid = win_getid(winnr())
" Always set the active window to the window that was active when
" the request was sent. Among other things, this makes sure that
" the correct window's location list will be populated when the
" list type is 'location' and the user has moved windows since
" sending the request.
call win_gotoid(l:handler.winid)
if has_key(a:resp, 'error')
call l:handler.requestComplete(0)
if has_key(l:handler, 'error')
call call(l:handler.error, [a:resp.error.message])
else
call go#util#EchoError(a:resp.error.message)
endif
call win_gotoid(l:winid)
return
endif
call l:handler.requestComplete(1)
let l:winidBeforeHandler = l:handler.winid
call call(l:handler.handleResult, [a:resp.result])
" change the window back to the window that was active when
" starting to handle the message _only_ if the handler didn't
" update the winid, so that handlers can set the winid if needed
" (e.g. :GoDef).
if l:handler.winid == l:winidBeforeHandler
call win_gotoid(l:winid)
endif
finally
call remove(self.handlers, a:resp.id)
endtry
endif
endfunction
function! l:lsp.handleInitializeResult(result) dict abort
call go#util#EchoProgress("initialized gopls")
let self.ready = 1
" TODO(bc): send initialized message to the server?
@ -173,7 +195,15 @@ function! s:newlsp() abort
endfunction
function! l:lsp.sendMessage(data, handler) dict abort
" block while waiting on any in flight initializations to avoid race
" conditions initializing gopls.
while get(self, 'checkingmodule', 0)
sleep 50 m
redraw
endwhile
if !self.last_request_id
call go#util#EchoProgress("initializing gopls")
" TODO(bc): run a server per module and one per GOPATH? (may need to
" keep track of servers by rootUri).
let l:wd = go#util#ModuleRoot()
@ -186,25 +216,7 @@ function! s:newlsp() abort
let l:wd = getcwd()
endif
" do not attempt to send a message to gopls when using neither GOPATH
" mode nor module mode.
if go#package#FromPath(l:wd) == -2
if go#config#NullModuleWarning() && (!has_key(self, 'warned') || !self.warned)
let l:oldshortmess=&shortmess
if has('nvim')
set shortmess-=F
endif
call go#util#EchoWarning('Features that rely on gopls will not work correctly outside of GOPATH or a module.')
let self.warned = 1
" Sleep one second to make sure people see the message. Otherwise it is
" often immediately overwritten by an async message.
sleep 1
let &shortmess=l:oldshortmess
endif
return -1
endif
let self.workspaceDirectories = add(self.workspaceDirectories, l:wd)
let l:msg = self.newMessage(go#lsp#message#Initialize(l:wd))
let l:state = s:newHandlerState('')
@ -235,7 +247,7 @@ function! s:newlsp() abort
let l:msg = {
\ 'method': a:data.method,
\ 'jsonrpc': '2.0',
\ }
\ }
if !a:data.notification
let self.last_request_id += 1
@ -249,13 +261,19 @@ function! s:newlsp() abort
return l:msg
endfunction
function l:lsp.newResponse(id, result) dict abort
let l:msg = {
\ 'jsonrpc': '2.0',
\ 'id': a:id,
\ 'result': a:result,
\ }
endfunction
function! l:lsp.write(msg) dict abort
let l:body = json_encode(a:msg)
let l:data = 'Content-Length: ' . strlen(l:body) . "\r\n\r\n" . l:body
if go#util#HasDebug('lsp')
let g:go_lsp_log = add(go#config#LspLog(), "->\n" . l:data)
endif
call s:debug('sent', l:data)
if has('nvim')
call chansend(self.job, l:data)
@ -275,9 +293,7 @@ function! s:newlsp() abort
endfunction
function! l:lsp.err_cb(ch, msg) dict abort
if go#util#HasDebug('lsp')
let g:go_lsp_log = add(go#config#LspLog(), "<-stderr\n" . a:msg)
endif
call s:debug('stderr', a:msg)
endfunction
" explicitly bind callbacks to l:lsp so that within it, self will always refer
@ -303,7 +319,6 @@ function! s:newlsp() abort
" start in.
let l:lsp.job = go#job#Start([l:bin_path], l:opts)
" TODO(bc): send the initialize message now?
return l:lsp
endfunction
@ -363,16 +378,17 @@ function! s:requestComplete(ok) abort dict
endfunction
function! s:start() abort dict
if self.statustype != ''
let status = {
\ 'desc': 'current status',
\ 'type': self.statustype,
\ 'state': "started",
\ }
call go#statusline#Update(self.jobdir, status)
endif
let self.started_at = reltime()
if self.statustype == ''
return
endif
let status = {
\ 'desc': 'current status',
\ 'type': self.statustype,
\ 'state': "started",
\ }
call go#statusline#Update(self.jobdir, status)
endfunction
" go#lsp#Definition calls gopls to get the definition of the identifier at
@ -506,7 +522,17 @@ function! s:completionHandler(next, msg) abort dict
if has_key(l:item, 'detail')
let l:match.info = l:item.detail
if go#lsp#completionitemkind#IsFunction(l:item.kind) || go#lsp#completionitemkind#IsMethod(l:item.kind)
let l:match.info = printf('func %s %s', l:item.label, l:item.detail)
let l:match.info = printf('%s %s', l:item.label, l:item.detail)
" The detail provided by gopls hasn't always provided the the full
" signature including the return value. The label used to be the
" function signature and the detail was the return value. Handle
" that case for backward compatibility. This can be removed in the
" future once it's likely that the majority of users are on a recent
" version of gopls.
if l:item.detail !~ '^func'
let l:match.info = printf('func %s %s', l:item.label, l:item.detail)
endif
endif
endif
@ -561,13 +587,32 @@ function! go#lsp#Info(showstatus)
let l:state = s:newHandlerState('')
endif
let l:state.handleResult = funcref('s:infoDefinitionHandler', [a:showstatus], l:state)
let l:state.handleResult = funcref('s:infoDefinitionHandler', [function('s:info', [1], l:state), a:showstatus], l:state)
let l:state.error = funcref('s:noop')
let l:msg = go#lsp#message#Definition(l:fname, l:line, l:col)
return l:lsp.sendMessage(l:msg, l:state)
endfunction
function! s:infoDefinitionHandler(showstatus, msg) abort dict
function! go#lsp#GetInfo()
let l:fname = expand('%:p')
let [l:line, l:col] = getpos('.')[1:2]
call go#lsp#DidChange(l:fname)
let l:lsp = s:lspfactory.get()
let l:state = s:newHandlerState('')
let l:info = go#promise#New(function('s:info', [0], l:state), 10000, '')
let l:state.handleResult = funcref('s:infoDefinitionHandler', [l:info.wrapper, 0], l:state)
let l:state.error = funcref('s:noop')
let l:msg = go#lsp#message#Definition(l:fname, l:line, l:col)
call l:lsp.sendMessage(l:msg, l:state)
return l:info.await()
endfunction
function! s:infoDefinitionHandler(next, showstatus, msg) abort dict
" gopls returns a []Location; just take the first one.
let l:msg = a:msg[0]
@ -584,22 +629,101 @@ function! s:infoDefinitionHandler(showstatus, msg) abort dict
let l:state = s:newHandlerState('')
endif
let l:state.handleResult = funcref('s:hoverHandler', [function('s:info', [], l:state)], l:state)
let l:state.handleResult = funcref('s:hoverHandler', [a:next], l:state)
let l:state.error = funcref('s:noop')
return l:lsp.sendMessage(l:msg, l:state)
endfunction
function! s:info(content) abort dict
function! s:info(show, content) abort dict
let l:content = s:infoFromHoverContent(a:content)
if a:show
call go#util#ShowInfo(l:content)
endif
return l:content
endfunction
function! s:infoFromHoverContent(content) abort
if len(a:content) < 1
return ''
endif
let l:content = a:content[0]
" strip godoc summary
let l:content = substitute(l:content, '^[^\n]\+\n', '', '')
" Hover content with godoc summary will have the godoc summary in the first
" line, and the second line will not have leading whitespace. When there is
" leading whitespace on the second line, then the hover content is for a
" struct or interface without godoc.
let l:lines = split(l:content, '\n')
if len(l:lines) > 1 && (l:lines[1] !~# '^\s')
let l:content = substitute(l:content, '^[^\n]\+\n', '', '')
endif
" strip off the method set and fields of structs and interfaces.
if l:content =~# '^type [^ ]\+ \(struct\|interface\)'
if l:content =~# '^\(type \)\?[^ ]\+ \(struct\|interface\)'
let l:content = substitute(l:content, '{.*', '', '')
endif
call go#util#ShowInfo(l:content)
return l:content
endfunction
function! go#lsp#AddWorkspace(...) abort
if a:0 == 0
return
endif
let l:workspaces = []
for l:dir in a:000
let l:dir = fnamemodify(l:dir, ':p')
if !isdirectory(l:dir)
continue
endif
let l:workspaces = add(l:workspaces, l:dir)
endfor
let l:lsp = s:lspfactory.get()
let l:state = s:newHandlerState('')
let l:state.handleResult = funcref('s:noop')
let l:lsp.workspaceDirectories = extend(l:lsp.workspaceDirectories, l:workspaces)
let l:msg = go#lsp#message#AddWorkspaces(l:workspaces)
call l:lsp.sendMessage(l:msg, l:state)
return 0
endfunction
function! s:debug(event, data) abort
if !go#util#HasDebug('lsp')
return
endif
let l:winid = win_getid()
let l:name = '__GOLSP_LOG__'
let l:log_winid = bufwinid(l:name)
if l:log_winid == -1
silent keepalt botright 10new
silent file `='__GOLSP_LOG__'`
setlocal buftype=nofile bufhidden=wipe nomodified nobuflisted noswapfile nowrap nonumber nocursorline
setlocal filetype=golsplog
else
call win_gotoid(l:log_winid)
endif
try
setlocal modifiable
if getline(1) == ''
call setline('$', printf('%s: %s', a:event, a:data))
else
call append('$', printf('%s: %s', a:event, a:data))
endif
normal! G
setlocal nomodifiable
finally
call win_gotoid(l:winid)
endtry
endfunction
" restore Vi compatibility settings

View File

@ -10,7 +10,9 @@ function! go#lsp#message#Initialize(wd) abort
\ 'processId': getpid(),
\ 'rootUri': go#path#ToURI(a:wd),
\ 'capabilities': {
\ 'workspace': {},
\ 'workspace': {
\ 'workspaceFolders': v:true,
\ },
\ 'textDocument': {
\ 'hover': {
\ 'contentFormat': ['plaintext'],
@ -21,6 +23,14 @@ function! go#lsp#message#Initialize(wd) abort
\ }
endfunction
function! go#lsp#message#workspaceFolders(dirs) abort
return map(copy(a:dirs), function('s:workspaceFolderToURI', []))
endfunction
function s:workspaceFolderToURI(key, val) abort
return go#path#ToURI(a:val)
endfunction
function! go#lsp#message#Definition(file, line, col) abort
return {
\ 'notification': 0,
@ -116,6 +126,25 @@ function! go#lsp#message#Hover(file, line, col) abort
\ }
endfunction
function! go#lsp#message#AddWorkspaces(dirs) abort
let l:dirs = map(copy(a:dirs), function('s:workspaceFodlerToAddURI', []))
return {
\ 'notification': 1,
\ 'method': 'workspace/didChangeWorkspaceFolders',
\ 'params': {
\ 'event': {
\ 'added': l:dirs,
\ },
\ }
\ }
endfunction
function s:workspaceFolderToAddURI(key, val) abort
return {'uri': go#path#ToURI(a:val), 'name': a:val}
endfunction
function! s:position(line, col) abort
return {'line': a:line - 1, 'character': a:col-1}
endfunction

View File

@ -8,10 +8,14 @@ function! go#mod#Format() abort
" go mod only exists in `v1.11`
if empty(s:go_major_version)
let tokens = matchlist(go#util#Exec(['go', 'version']), '\d\+.\(\d\+\)\(\.\d\+\)\? ')
let s:go_major_version = str2nr(tokens[1])
if len(tokens) > 0
let s:go_major_version = str2nr(tokens[1])
else
let s:go_major_version = ""
endif
endif
if s:go_major_version < "11"
if !empty(s:go_major_version) && s:go_major_version < "11"
call go#util#EchoError("Go v1.11 is required to format go.mod file")
return
endif

View File

@ -82,6 +82,10 @@ function! s:vendordirs() abort
if l:err != 0
return []
endif
if empty(l:root)
return []
endif
let l:root = split(l:root, '\n')[0] . go#util#PathSep() . 'src'
let [l:dir, l:err] = go#util#ExecInDir(['go', 'list', '-f', '{{.Dir}}'])
@ -111,35 +115,29 @@ function! s:vendordirs() abort
endfunction
let s:import_paths = {}
" ImportPath returns the import path of the package for current buffer.
" ImportPath returns the import path of the package for current buffer. It
" returns -1 if the import path cannot be determined.
function! go#package#ImportPath() abort
let dir = expand("%:p:h")
let l:dir = expand("%:p:h")
if has_key(s:import_paths, dir)
return s:import_paths[dir]
return s:import_paths[l:dir]
endif
let [l:out, l:err] = go#util#ExecInDir(['go', 'list'])
if l:err != 0
let l:importpath = go#package#FromPath(l:dir)
if type(l:importpath) == type(0)
return -1
endif
let l:importpath = split(out, '\n')[0]
" go list returns '_CURRENTDIRECTORY' if the directory is not inside GOPATH.
" Check it and retun an error if that is the case
if l:importpath[0] ==# '_'
return -1
endif
let s:import_paths[dir] = l:importpath
let s:import_paths[l:dir] = l:importpath
return l:importpath
endfunction
" go#package#FromPath returns the import path of arg. -1 is returned when arg
" does not specify a package. -2 is returned when arg is a relative path
" outside of GOPATH and not in a module.
" outside of GOPATH, not in a module, and not below the current working
" directory. A relative path is returned when in a null module at or below the
" current working directory..
function! go#package#FromPath(arg) abort
let l:cd = exists('*haslocaldir') && haslocaldir() ? 'lcd' : 'cd'
let l:dir = getcwd()
@ -150,25 +148,44 @@ function! go#package#FromPath(arg) abort
endif
execute l:cd fnameescape(l:path)
if glob("*.go") == ""
" There's no Go code in this directory. We might be in a module directory
" which doesn't have any code at this level.
if !empty(s:module())
try
if glob("*.go") == ""
" There's no Go code in this directory. We might be in a module directory
" which doesn't have any code at this level. To avoid `go list` making a
" bunch of HTTP requests to fetch dependencies, short-circuit `go list`
" and return -1 immediately.
if !empty(s:module())
return -1
endif
endif
let [l:out, l:err] = go#util#Exec(['go', 'list'])
if l:err != 0
return -1
endif
endif
let [l:out, l:err] = go#util#Exec(['go', 'list'])
execute l:cd fnameescape(l:dir)
if l:err != 0
return -1
endif
let l:importpath = split(l:out, '\n')[0]
let l:importpath = split(l:out, '\n')[0]
finally
execute l:cd fnameescape(l:dir)
endtry
" go list returns '_CURRENTDIRECTORY' if the directory is neither in GOPATH
" nor in a module. Check it and retun an error if that is the case
" go list returns '_CURRENTDIRECTORY' if the directory is in a null module
" (i.e. neither in GOPATH nor in a module). Return a relative import path
" if possible or an error if that is the case.
if l:importpath[0] ==# '_'
return -2
let l:relativeimportpath = fnamemodify(l:importpath[1:], ':.')
if go#util#IsWin()
let l:relativeimportpath = substitute(l:relativeimportpath, '\\', '/', 'g')
endif
if l:relativeimportpath == l:importpath[1:]
return '.'
endif
if l:relativeimportpath[0] == '/'
return -2
endif
let l:importpath= printf('./%s', l:relativeimportpath)
endif
return l:importpath

View File

@ -0,0 +1,50 @@
" don't spam the user when Vim is started in Vi compatibility mode
let s:cpo_save = &cpo
set cpo&vim
scriptencoding utf-8
" New returns a promise. A promise's primary purpose is to make async jobs
" synchronous by awaiting fn.
"
" A promise is a dictionary with two keys:
" 'wrapper':
" A function that wraps fn. It can be used in place of fn.
" 'await':
" A function that waits for wrapper to be called and returns the value
" returned by fn. Returns default if timeout expires.
function! go#promise#New(fn, timeout, default) abort
let l:state = {}
" explicitly bind to state so that within l:promise's methods, self will
" always refer to state. See :help Partial for more information.
return {
\ 'wrapper': function('s:wrapper', [a:fn], l:state),
\ 'await': function('s:await', [a:timeout, a:default], l:state),
\ }
endfunction
function! s:wrapper(fn, ...) dict
let self.retval = call(a:fn, a:000)
return self.retval
endfunction
function! s:await(timeout, default) dict
let l:timer = timer_start(a:timeout, function('s:setretval', [a:default], self))
while !has_key(self, 'retval')
sleep 50m
endwhile
call timer_stop(l:timer)
return self.retval
endfunction
function! s:setretval(val, timer) dict
let self.retval = a:val
endfunction
" restore Vi compatibility settings
let &cpo = s:cpo_save
unlet s:cpo_save
" vim: sw=2 ts=2 et

View File

@ -0,0 +1,41 @@
" don't spam the user when Vim is started in Vi compatibility mode
let s:cpo_save = &cpo
set cpo&vim
func! Test_PromiseNew() abort
let l:sut = go#promise#New(function('s:work', []), 100, -1)
call assert_true(has_key(l:sut, 'wrapper'))
call assert_true(has_key(l:sut, 'await'))
endfunc
func! Test_PromiseAwait() abort
let l:expected = 1
let l:default = -1
let l:sut = go#promise#New(function('s:work', [l:expected]), 100, l:default)
call timer_start(10, l:sut.wrapper)
let l:actual = call(l:sut.await, [])
call assert_equal(l:expected, l:actual)
endfunc
func! Test_PromiseAwait_Timeout() abort
let l:desired = 1
let l:expected = -1
let l:sut = go#promise#New(function('s:work', [l:desired]), 10, l:expected)
call timer_start(100, l:sut.wrapper)
let l:actual = call(l:sut.await, [])
call assert_equal(l:expected, l:actual)
endfunc
func! s:work(val, timer)
return a:val
endfunc
" restore Vi compatibility settings
let &cpo = s:cpo_save
unlet s:cpo_save
" vim: sw=2 ts=2 et

View File

@ -94,26 +94,26 @@ For Pathogen or Vim |packages|, just clone the repo. For other plugin managers
you may also need to add the lines to your vimrc to execute the plugin
manager's install command.
* Vim 8 |packages|
>
* Vim 8 |packages| >
git clone https://github.com/fatih/vim-go.git \
~/.vim/pack/plugins/start/vim-go
<
* https://github.com/tpope/vim-pathogen >
git clone https://github.com/fatih/vim-go.git ~/.vim/bundle/vim-go
<
* https://github.com/junegunn/vim-plug >
Plug 'fatih/vim-go'
Plug 'fatih/vim-go', { 'do': ':GoUpdateBinaries' }
<
* https://github.com/Shougo/neobundle.vim >
NeoBundle 'fatih/vim-go'
<
* https://github.com/gmarik/vundle >
Plugin 'fatih/vim-go', { 'do': ':GoUpdateBinaries' }
Plugin 'fatih/vim-go'
<
* Manual (not recommended) >
@ -536,7 +536,7 @@ CTRL-t
*:GoGuruScope*
:GoGuruScope [pattern] [pattern2] ... [patternN]
:GoGuruScope [pattern] ...
Changes the custom |'g:go_guru_scope'| setting and overrides it with the
given package patterns. The custom scope is cleared (unset) if `""` is
@ -906,6 +906,11 @@ CTRL-t
tries to preserve cursor position and avoids replacing the buffer with
stderr output.
*:GoAddWorkspace*
:GoAddWorkspace [dir] ...
Add directories to the `gopls` workspace.
==============================================================================
MAPPINGS *go-mappings*
@ -1212,14 +1217,6 @@ enabled.
let g:go_version_warning = 1
<
*'g:go_null_module_warning'*
Enable warning when trying to use lsp features in a null module. By default it
is enabled.
>
let g:go_null_module_warning = 1
<
*'g:go_code_completion_enabled'*
Enable code completion with |'omnifunc'|. By default it is enabled.
@ -1275,11 +1272,11 @@ updated. By default it's disabled. The delay can be configured with the
*'g:go_info_mode'*
Use this option to define the command to be used for |:GoInfo|. By default
`gocode` is being used as it's the fastest option. But one might also use
`gopls` or `guru` as they cover more cases and are more accurate. Current
valid options are: `[gocode, guru, gopls]` >
let g:go_info_mode = 'gocode'
`gopls` is used, because it is the fastest and is known to be highly accurate.
One might also use `guru` for its accuracy or `gocode` for its performance.
Valid options are `gocode`, `gopls`, and `guru`.
>
let g:go_info_mode = 'gopls'
<
*'g:go_auto_sameids'*
@ -1391,10 +1388,11 @@ a private internal service. Default is 'https://godoc.org'.
*'g:go_def_mode'*
Use this option to define the command to be used for |:GoDef|. By default
`guru` is being used as it covers all edge cases. But one might also use
`godef` as it's faster. Current valid options are: `[guru, godef, gopls]` >
let g:go_def_mode = 'guru'
`gopls` is used, because it is the fastest. One might also use `guru` for its
accuracy or `godef` for its performance. Valid options are `godef`, `gopls`,
and `guru`.
>
let g:go_def_mode = 'gopls'
<
*'g:go_def_mapping_enabled'*
@ -1804,7 +1802,8 @@ Currently accepted values:
debugger-state Expose debugger state in 'g:go_debug_diag'.
debugger-commands Echo communication between vim-go and `dlv`; requests and
responses are recorded in `g:go_debug_commands`.
lsp Record lsp requests and responses in g:go_lsp_log.
lsp Echo communication between vim-go and `gopls`. All
communication is shown in a dedicated window.
>
let g:go_debug = []
<
@ -2043,8 +2042,7 @@ rest of the commands and mappings become available after starting debug mode.
* Make the `:GoDebug*` commands and `(go-debug-*)` mappings available.
The directory of the current buffer is used if [pkg] is empty. Any other
arguments will be passed to the program. When [pkg] is relative, it will
be interpreted relative to the directory of the current buffer.
arguments will be passed to the program.
Use |:GoDebugStop| to stop `dlv` and exit debugging mode.

View File

@ -116,4 +116,7 @@ command! -nargs=0 GoReportGitHubIssue call go#issue#New()
" -- iferr
command! -nargs=0 GoIfErr call go#iferr#Generate()
" -- lsp
command! -nargs=+ -complete=dir GoAddWorkspace call go#lsp#AddWorkspace(<f-args>)
" vim: sw=2 ts=2 et

Some files were not shown because too many files have changed in this diff Show More