Enable gopls by default with GOPATH detection

This commit is contained in:
w0rp 2021-05-26 22:43:30 +01:00
parent 3f386ae5e9
commit f53431331e
No known key found for this signature in database
GPG Key ID: 0FC1ECAA8C81CD83
75 changed files with 183 additions and 116 deletions

View File

@ -11,7 +11,7 @@ endfunction
call ale#linter#Define('css', {
\ 'name': 'stylelint',
\ 'executable': {b -> ale#node#FindExecutable(b, 'css_stylelint', [
\ 'executable': {b -> ale#path#FindExecutable(b, 'css_stylelint', [
\ 'node_modules/.bin/stylelint',
\ ])},
\ 'command': function('ale_linters#css#stylelint#GetCommand'),

View File

@ -28,7 +28,7 @@ endfunction
call ale#linter#Define('elm', {
\ 'name': 'elm_ls',
\ 'lsp': 'stdio',
\ 'executable': {b -> ale#node#FindExecutable(b, 'elm_ls', [
\ 'executable': {b -> ale#path#FindExecutable(b, 'elm_ls', [
\ 'node_modules/.bin/elm-language-server',
\ 'node_modules/.bin/elm-lsp',
\ 'elm-lsp'

View File

@ -202,7 +202,7 @@ function! ale_linters#elm#make#GetCommand(buffer) abort
" elm-test needs to know the path of elm-make if elm isn't installed globally.
" https://github.com/rtfeldman/node-test-runner/blob/57728f10668f2d2ab3179e7e3208bcfa9a1f19aa/README.md#--compiler
if l:is_v19 && l:is_using_elm_test
let l:elm_make_executable = ale#node#FindExecutable(a:buffer, 'elm_make', ['node_modules/.bin/elm'])
let l:elm_make_executable = ale#path#FindExecutable(a:buffer, 'elm_make', ['node_modules/.bin/elm'])
let l:elm_test_compiler_flag = ' --compiler ' . l:elm_make_executable . ' '
else
let l:elm_test_compiler_flag = ' '
@ -222,13 +222,13 @@ function! ale_linters#elm#make#GetExecutable(buffer) abort
let l:is_v19 = ale_linters#elm#make#IsVersionGte19(a:buffer)
if l:is_test && l:is_v19
return ale#node#FindExecutable(
return ale#path#FindExecutable(
\ a:buffer,
\ 'elm_make',
\ ['node_modules/.bin/elm-test', 'node_modules/.bin/elm']
\)
else
return ale#node#FindExecutable(a:buffer, 'elm_make', ['node_modules/.bin/elm'])
return ale#path#FindExecutable(a:buffer, 'elm_make', ['node_modules/.bin/elm'])
endif
endfunction

View File

@ -5,6 +5,21 @@
call ale#Set('go_gopls_executable', 'gopls')
call ale#Set('go_gopls_options', '--mode stdio')
call ale#Set('go_gopls_init_options', {})
call ale#Set('go_gopls_use_global', get(g:, 'ale_use_global_executables', 0))
function! s:GetGoPathExecutable(suffix) abort
let l:prefix = $GOPATH
if !empty($GOPATH)
let l:prefix = $GOPATH
elseif has('win32')
let l:prefix = $USERPROFILE . '/go'
else
let l:prefix = $HOME . '/go'
endif
return ale#path#Simplify(l:prefix . '/' . a:suffix)
endfunction
function! ale_linters#go#gopls#GetCommand(buffer) abort
return ale#go#EnvString(a:buffer)
@ -29,7 +44,9 @@ endfunction
call ale#linter#Define('go', {
\ 'name': 'gopls',
\ 'lsp': 'stdio',
\ 'executable': {b -> ale#Var(b, 'go_gopls_executable')},
\ 'executable': {b -> ale#path#FindExecutable(b, 'go_gopls', [
\ s:GetGoPathExecutable('bin/gopls'),
\ ])},
\ 'command': function('ale_linters#go#gopls#GetCommand'),
\ 'project_root': function('ale_linters#go#gopls#FindProjectRoot'),
\ 'initialization_options': {b -> ale#Var(b, 'go_gopls_init_options')},

View File

@ -5,7 +5,7 @@ call ale#Set('handlebars_embertemplatelint_executable', 'ember-template-lint')
call ale#Set('handlebars_embertemplatelint_use_global', get(g:, 'ale_use_global_executables', 0))
function! ale_linters#handlebars#embertemplatelint#GetExecutable(buffer) abort
return ale#node#FindExecutable(a:buffer, 'handlebars_embertemplatelint', [
return ale#path#FindExecutable(a:buffer, 'handlebars_embertemplatelint', [
\ 'node_modules/.bin/ember-template-lint',
\])
endfunction

View File

@ -11,7 +11,7 @@ function! ale_linters#html#angular#GetProjectRoot(buffer) abort
endfunction
function! ale_linters#html#angular#GetExecutable(buffer) abort
return ale#node#FindExecutable(a:buffer, 'html_angular', [
return ale#path#FindExecutable(a:buffer, 'html_angular', [
\ 'node_modules/@angular/language-server/bin/ngserver',
\ 'node_modules/@angular/language-server/index.js',
\])

View File

@ -24,7 +24,7 @@ endfunction
call ale#linter#Define('html', {
\ 'name': 'htmlhint',
\ 'executable': {b -> ale#node#FindExecutable(b, 'html_htmlhint', [
\ 'executable': {b -> ale#path#FindExecutable(b, 'html_htmlhint', [
\ 'node_modules/.bin/htmlhint',
\ ])},
\ 'command': function('ale_linters#html#htmlhint#GetCommand'),

View File

@ -5,7 +5,7 @@ call ale#Set('html_stylelint_options', '')
call ale#Set('html_stylelint_use_global', 0)
function! ale_linters#html#stylelint#GetExecutable(buffer) abort
return ale#node#FindExecutable(a:buffer, 'html_stylelint', [
return ale#path#FindExecutable(a:buffer, 'html_stylelint', [
\ 'node_modules/.bin/stylelint',
\])
endfunction

View File

@ -6,7 +6,7 @@ call ale#Set('ink_ls_use_global', get(g:, 'ale_use_global_executables', 0))
call ale#Set('ink_ls_initialization_options', {})
function! ale_linters#ink#ls#GetExecutable(buffer) abort
return ale#node#FindExecutable(a:buffer, 'ink_ls', [
return ale#path#FindExecutable(a:buffer, 'ink_ls', [
\ 'ink-language-server',
\ 'node_modules/.bin/ink-language-server',
\])

View File

@ -22,7 +22,7 @@ function! ale_linters#javascript#flow#GetExecutable(buffer) abort
return ''
endif
return ale#node#FindExecutable(a:buffer, 'javascript_flow', [
return ale#path#FindExecutable(a:buffer, 'javascript_flow', [
\ 'node_modules/.bin/flow',
\])
endfunction

View File

@ -19,7 +19,7 @@ endfunction
call ale#linter#Define('javascript', {
\ 'name': 'flow-language-server',
\ 'lsp': 'stdio',
\ 'executable': {b -> ale#node#FindExecutable(b, 'javascript_flow_ls', [
\ 'executable': {b -> ale#path#FindExecutable(b, 'javascript_flow_ls', [
\ 'node_modules/.bin/flow',
\ ])},
\ 'command': '%e lsp --from ale-lsp',

View File

@ -53,7 +53,7 @@ endfunction
call ale#linter#Define('javascript', {
\ 'name': 'jscs',
\ 'executable': {b -> ale#node#FindExecutable(b, 'javascript_jscs', [
\ 'executable': {b -> ale#path#FindExecutable(b, 'javascript_jscs', [
\ 'node_modules/.bin/jscs',
\ ])},
\ 'command': function('ale_linters#javascript#jscs#GetCommand'),

View File

@ -25,7 +25,7 @@ endfunction
call ale#linter#Define('javascript', {
\ 'name': 'jshint',
\ 'executable': {b -> ale#node#FindExecutable(b, 'javascript_jshint', [
\ 'executable': {b -> ale#path#FindExecutable(b, 'javascript_jshint', [
\ 'node_modules/.bin/jshint',
\ ])},
\ 'command': function('ale_linters#javascript#jshint#GetCommand'),

View File

@ -6,7 +6,7 @@ call ale#Set('javascript_standard_use_global', get(g:, 'ale_use_global_executabl
call ale#Set('javascript_standard_options', '')
function! ale_linters#javascript#standard#GetExecutable(buffer) abort
return ale#node#FindExecutable(a:buffer, 'javascript_standard', [
return ale#path#FindExecutable(a:buffer, 'javascript_standard', [
\ 'node_modules/standardx/bin/cmd.js',
\ 'node_modules/standard/bin/cmd.js',
\ 'node_modules/semistandard/bin/cmd.js',

View File

@ -8,7 +8,7 @@ call ale#Set('javascript_tsserver_use_global', get(g:, 'ale_use_global_executabl
call ale#linter#Define('javascript', {
\ 'name': 'tsserver',
\ 'lsp': 'tsserver',
\ 'executable': {b -> ale#node#FindExecutable(b, 'javascript_tsserver', [
\ 'executable': {b -> ale#path#FindExecutable(b, 'javascript_tsserver', [
\ 'node_modules/.bin/tsserver',
\ ])},
\ 'command': '%e',

View File

@ -4,7 +4,7 @@ call ale#Set('json_jsonlint_executable', 'jsonlint')
call ale#Set('json_jsonlint_use_global', get(g:, 'ale_use_global_executables', 0))
function! ale_linters#json#jsonlint#GetExecutable(buffer) abort
return ale#node#FindExecutable(a:buffer, 'json_jsonlint', [
return ale#path#FindExecutable(a:buffer, 'json_jsonlint', [
\ 'node_modules/.bin/jsonlint',
\ 'node_modules/jsonlint/lib/cli.js',
\])

View File

@ -6,7 +6,7 @@ call ale#Set('json_spectral_use_global', get(g:, 'ale_use_global_executables', 0
call ale#linter#Define('json', {
\ 'name': 'spectral',
\ 'executable': {b -> ale#node#FindExecutable(b, 'json_spectral', [
\ 'executable': {b -> ale#path#FindExecutable(b, 'json_spectral', [
\ 'node_modules/.bin/spectral',
\ ])},
\ 'command': '%e lint --ignore-unknown-format -q -f text %t',

View File

@ -38,7 +38,7 @@ endfunction
call ale#linter#Define('less', {
\ 'name': 'lessc',
\ 'executable': {b -> ale#node#FindExecutable(b, 'less_lessc', [
\ 'executable': {b -> ale#path#FindExecutable(b, 'less_lessc', [
\ 'node_modules/.bin/lessc',
\ ])},
\ 'command': function('ale_linters#less#lessc#GetCommand'),

View File

@ -12,7 +12,7 @@ endfunction
call ale#linter#Define('less', {
\ 'name': 'stylelint',
\ 'executable': {b -> ale#node#FindExecutable(b, 'less_stylelint', [
\ 'executable': {b -> ale#path#FindExecutable(b, 'less_stylelint', [
\ 'node_modules/.bin/stylelint',
\ ])},
\ 'command': function('ale_linters#less#stylelint#GetCommand'),

View File

@ -39,7 +39,7 @@ endfunction
call ale#linter#Define('markdown', {
\ 'name': 'remark_lint',
\ 'aliases': ['remark-lint'],
\ 'executable': {b -> ale#node#FindExecutable(b, 'markdown_remark_lint', [
\ 'executable': {b -> ale#path#FindExecutable(b, 'markdown_remark_lint', [
\ 'node_modules/.bin/remark',
\ ])},
\ 'command': function('ale_linters#markdown#remark_lint#GetCommand'),

View File

@ -26,7 +26,7 @@ call ale#linter#Define('php', {
\ 'name': 'intelephense',
\ 'lsp': 'stdio',
\ 'initialization_options': function('ale_linters#php#intelephense#GetInitializationOptions'),
\ 'executable': {b -> ale#node#FindExecutable(b, 'php_intelephense', [])},
\ 'executable': {b -> ale#path#FindExecutable(b, 'php_intelephense', [])},
\ 'command': '%e --stdio',
\ 'project_root': function('ale_linters#php#intelephense#GetProjectRoot'),
\})

View File

@ -19,7 +19,7 @@ endfunction
call ale#linter#Define('php', {
\ 'name': 'langserver',
\ 'lsp': 'stdio',
\ 'executable': {b -> ale#node#FindExecutable(b, 'php_langserver', [
\ 'executable': {b -> ale#path#FindExecutable(b, 'php_langserver', [
\ 'vendor/bin/php-language-server.php',
\ ])},
\ 'command': 'php %e',

View File

@ -44,7 +44,7 @@ endfunction
call ale#linter#Define('php', {
\ 'name': 'phpcs',
\ 'executable': {b -> ale#node#FindExecutable(b, 'php_phpcs', [
\ 'executable': {b -> ale#path#FindExecutable(b, 'php_phpcs', [
\ 'vendor/bin/phpcs',
\ 'phpcs'
\ ])},

View File

@ -18,7 +18,7 @@ endfunction
call ale#linter#Define('php', {
\ 'name': 'psalm',
\ 'lsp': 'stdio',
\ 'executable': {b -> ale#node#FindExecutable(b, 'php_psalm', [
\ 'executable': {b -> ale#path#FindExecutable(b, 'php_psalm', [
\ 'vendor/bin/psalm',
\ ])},
\ 'command': function('ale_linters#php#psalm#GetCommand'),

View File

@ -20,7 +20,7 @@ function! ale_linters#php#tlint#GetProjectRoot(buffer) abort
endfunction
function! ale_linters#php#tlint#GetExecutable(buffer) abort
return ale#node#FindExecutable(a:buffer, 'php_tlint', [
return ale#path#FindExecutable(a:buffer, 'php_tlint', [
\ 'vendor/bin/tlint',
\ 'tlint',
\])

View File

@ -47,7 +47,7 @@ endfunction
call ale#linter#Define('pug', {
\ 'name': 'puglint',
\ 'executable': {b -> ale#node#FindExecutable(b, 'pug_puglint', [
\ 'executable': {b -> ale#path#FindExecutable(b, 'pug_puglint', [
\ 'node_modules/.bin/pug-lint',
\ ])},
\ 'output_stream': 'stderr',

View File

@ -6,7 +6,7 @@ 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', [
return ale#path#FindExecutable(a:buffer, 'purescript_ls', [
\ 'node_modules/.bin/purescript-language-server',
\])
endfunction

View File

@ -5,7 +5,7 @@ call ale#Set('sass_sasslint_options', '')
call ale#Set('sass_sasslint_use_global', get(g:, 'ale_use_global_executables', 0))
function! ale_linters#sass#sasslint#GetExecutable(buffer) abort
return ale#node#FindExecutable(a:buffer, 'sass_sasslint', [
return ale#path#FindExecutable(a:buffer, 'sass_sasslint', [
\ 'node_modules/sass-lint/bin/sass-lint.js',
\ 'node_modules/.bin/sass-lint',
\])

View File

@ -5,7 +5,7 @@ call ale#Set('sass_stylelint_use_global', get(g:, 'ale_use_global_executables',
call ale#linter#Define('sass', {
\ 'name': 'stylelint',
\ 'executable': {b -> ale#node#FindExecutable(b, 'sass_stylelint', [
\ 'executable': {b -> ale#path#FindExecutable(b, 'sass_stylelint', [
\ 'node_modules/.bin/stylelint',
\ ])},
\ 'command': '%e --stdin-filename %s',

View File

@ -5,7 +5,7 @@ call ale#Set('scss_sasslint_options', '')
call ale#Set('scss_sasslint_use_global', get(g:, 'ale_use_global_executables', 0))
function! ale_linters#scss#sasslint#GetExecutable(buffer) abort
return ale#node#FindExecutable(a:buffer, 'scss_sasslint', [
return ale#path#FindExecutable(a:buffer, 'scss_sasslint', [
\ 'node_modules/sass-lint/bin/sass-lint.js',
\ 'node_modules/.bin/sass-lint',
\])

View File

@ -11,7 +11,7 @@ endfunction
call ale#linter#Define('scss', {
\ 'name': 'stylelint',
\ 'executable': {b -> ale#node#FindExecutable(b, 'scss_stylelint', [
\ 'executable': {b -> ale#path#FindExecutable(b, 'scss_stylelint', [
\ 'node_modules/.bin/stylelint',
\ ])},
\ 'command': function('ale_linters#scss#stylelint#GetCommand'),

View File

@ -6,7 +6,7 @@ call ale#Set('sh_language_server_executable', 'bash-language-server')
call ale#Set('sh_language_server_use_global', get(g:, 'ale_use_global_executables', 0))
function! ale_linters#sh#language_server#GetExecutable(buffer) abort
return ale#node#FindExecutable(a:buffer, 'sh_language_server', [
return ale#path#FindExecutable(a:buffer, 'sh_language_server', [
\ 'node_modules/.bin/bash-language-server',
\])
endfunction

View File

@ -12,7 +12,7 @@ endfunction
call ale#linter#Define('stylus', {
\ 'name': 'stylelint',
\ 'executable': {b -> ale#node#FindExecutable(b, 'stylus_stylelint', [
\ 'executable': {b -> ale#path#FindExecutable(b, 'stylus_stylelint', [
\ 'node_modules/.bin/stylelint',
\ ])},
\ 'command': function('ale_linters#stylus#stylelint#GetCommand'),

View File

@ -13,7 +13,7 @@ endfunction
call ale#linter#Define('sugarss', {
\ 'name': 'stylelint',
\ 'executable': {b -> ale#node#FindExecutable(b, 'sugarss_stylelint', [
\ 'executable': {b -> ale#path#FindExecutable(b, 'sugarss_stylelint', [
\ 'node_modules/.bin/stylelint',
\ ])},
\ 'command': function('ale_linters#sugarss#stylelint#GetCommand'),

View File

@ -13,7 +13,7 @@ endfunction
call ale#linter#Define('svelte', {
\ 'name': 'svelteserver',
\ 'lsp': 'stdio',
\ 'executable': {b -> ale#node#FindExecutable(b, 'svelte_svelteserver', [
\ 'executable': {b -> ale#path#FindExecutable(b, 'svelte_svelteserver', [
\ 'node_modules/.bin/svelteserver',
\ ])},
\ 'command': '%e --stdio',

View File

@ -5,7 +5,7 @@ call ale#Set('swift_swiftlint_executable', 'swiftlint')
call ale#Set('swift_swiftlint_use_global', get(g:, 'ale_use_global_executables', 0))
function! ale_linters#swift#swiftlint#GetExecutable(buffer) abort
return ale#node#FindExecutable(a:buffer, 'swift_swiftlint', [
return ale#path#FindExecutable(a:buffer, 'swift_swiftlint', [
\ 'Pods/SwiftLint/swiftlint',
\ 'ios/Pods/SwiftLint/swiftlint',
\ 'swiftlint',

View File

@ -6,7 +6,7 @@ call ale#Set('typescript_standard_use_global', get(g:, 'ale_use_global_executabl
call ale#Set('typescript_standard_options', '')
function! ale_linters#typescript#standard#GetExecutable(buffer) abort
return ale#node#FindExecutable(a:buffer, 'typescript_standard', [
return ale#path#FindExecutable(a:buffer, 'typescript_standard', [
\ 'node_modules/standardx/bin/cmd.js',
\ 'node_modules/standard/bin/cmd.js',
\ 'node_modules/.bin/standard',

View File

@ -8,7 +8,7 @@ call ale#Set('typescript_tsserver_use_global', get(g:, 'ale_use_global_executabl
call ale#linter#Define('typescript', {
\ 'name': 'tsserver',
\ 'lsp': 'tsserver',
\ 'executable': {b -> ale#node#FindExecutable(b, 'typescript_tsserver', [
\ 'executable': {b -> ale#path#FindExecutable(b, 'typescript_tsserver', [
\ '.yarn/sdks/typescript/bin/tsserver',
\ 'node_modules/.bin/tsserver',
\ ])},

View File

@ -52,7 +52,7 @@ call ale#linter#Define('vim', {
\ 'name': 'vimls',
\ 'lsp': 'stdio',
\ 'lsp_config': {b -> ale#Var(b, 'vim_vimls_config')},
\ 'executable': {b -> ale#node#FindExecutable(b, 'vim_vimls', [
\ 'executable': {b -> ale#path#FindExecutable(b, 'vim_vimls', [
\ 'node_modules/.bin/vim-language-server',
\ ])},
\ 'command': '%e --stdio',

View File

@ -13,7 +13,7 @@ endfunction
call ale#linter#Define('vue', {
\ 'name': 'vls',
\ 'lsp': 'stdio',
\ 'executable': {b -> ale#node#FindExecutable(b, 'vue_vls', [
\ 'executable': {b -> ale#path#FindExecutable(b, 'vue_vls', [
\ 'node_modules/.bin/vls',
\ ])},
\ 'command': '%e --stdio',

View File

@ -6,7 +6,7 @@ call ale#Set('yaml_spectral_use_global', get(g:, 'ale_use_global_executables', 0
call ale#linter#Define('yaml', {
\ 'name': 'spectral',
\ 'executable': {b -> ale#node#FindExecutable(b, 'yaml_spectral', [
\ 'executable': {b -> ale#path#FindExecutable(b, 'yaml_spectral', [
\ 'node_modules/.bin/spectral',
\ ])},
\ 'command': '%e lint --ignore-unknown-format -q -f text %t',

View File

@ -32,7 +32,7 @@ endfunction
call ale#linter#Define('yaml', {
\ 'name': 'swaglint',
\ 'executable': {b -> ale#node#FindExecutable(b, 'yaml_swaglint', [
\ 'executable': {b -> ale#path#FindExecutable(b, 'yaml_swaglint', [
\ 'node_modules/.bin/swaglint',
\ ])},
\ 'command': '%e -r compact --stdin',

View File

@ -6,7 +6,7 @@ call ale#Set('bazel_buildifier_use_global', get(g:, 'ale_use_global_executables'
call ale#Set('bazel_buildifier_options', '')
function! ale#fixers#buildifier#GetExecutable(buffer) abort
return ale#node#FindExecutable(a:buffer, 'bazel_buildifier', [
return ale#path#FindExecutable(a:buffer, 'bazel_buildifier', [
\ 'buildifier',
\])
endfunction

View File

@ -9,7 +9,7 @@ call ale#Set('c_clangformat_style_option', '')
call ale#Set('c_clangformat_use_local_file', 0)
function! ale#fixers#clangformat#GetExecutable(buffer) abort
return ale#node#FindExecutable(a:buffer, 'c_clangformat', [
return ale#path#FindExecutable(a:buffer, 'c_clangformat', [
\ 'clang-format',
\])
endfunction

View File

@ -6,7 +6,7 @@ call ale#Set('elm_format_use_global', get(g:, 'ale_use_global_executables', 0))
call ale#Set('elm_format_options', '--yes')
function! ale#fixers#elm_format#GetExecutable(buffer) abort
return ale#node#FindExecutable(a:buffer, 'elm_format', [
return ale#path#FindExecutable(a:buffer, 'elm_format', [
\ 'node_modules/.bin/elm-format',
\])
endfunction

View File

@ -6,7 +6,7 @@ call ale#Set('erlang_erlfmt_use_global', get(g:, 'ale_use_global_executables', 0
call ale#Set('erlang_erlfmt_options', '')
function! ale#fixers#erlfmt#GetExecutable(buffer) abort
return ale#node#FindExecutable(a:buffer, 'erlang_erlfmt', ['erlfmt'])
return ale#path#FindExecutable(a:buffer, 'erlang_erlfmt', ['erlfmt'])
endfunction
function! ale#fixers#erlfmt#Fix(buffer) abort

View File

@ -6,7 +6,7 @@ call ale#Set('json_fixjson_options', '')
call ale#Set('json_fixjson_use_global', get(g:, 'ale_use_global_executables', 0))
function! ale#fixers#fixjson#GetExecutable(buffer) abort
return ale#node#FindExecutable(a:buffer, 'json_fixjson', [
return ale#path#FindExecutable(a:buffer, 'json_fixjson', [
\ 'node_modules/.bin/fixjson',
\])
endfunction

View File

@ -6,7 +6,7 @@ call ale#Set('php_cs_fixer_use_global', get(g:, 'ale_use_global_executables', 0)
call ale#Set('php_cs_fixer_options', '')
function! ale#fixers#php_cs_fixer#GetExecutable(buffer) abort
return ale#node#FindExecutable(a:buffer, 'php_cs_fixer', [
return ale#path#FindExecutable(a:buffer, 'php_cs_fixer', [
\ 'vendor/bin/php-cs-fixer',
\ 'php-cs-fixer'
\])

View File

@ -7,7 +7,7 @@ call ale#Set('php_phpcbf_executable', 'phpcbf')
call ale#Set('php_phpcbf_use_global', get(g:, 'ale_use_global_executables', 0))
function! ale#fixers#phpcbf#GetExecutable(buffer) abort
return ale#node#FindExecutable(a:buffer, 'php_phpcbf', [
return ale#path#FindExecutable(a:buffer, 'php_phpcbf', [
\ 'vendor/bin/phpcbf',
\ 'phpcbf'
\])

View File

@ -7,7 +7,7 @@ call ale#Set('javascript_prettier_use_global', get(g:, 'ale_use_global_executabl
call ale#Set('javascript_prettier_options', '')
function! ale#fixers#prettier#GetExecutable(buffer) abort
return ale#node#FindExecutable(a:buffer, 'javascript_prettier', [
return ale#path#FindExecutable(a:buffer, 'javascript_prettier', [
\ 'node_modules/.bin/prettier_d',
\ 'node_modules/prettier-cli/index.js',
\ 'node_modules/.bin/prettier',

View File

@ -7,7 +7,7 @@ call ale#Set('javascript_prettier_eslint_use_global', get(g:, 'ale_use_global_ex
call ale#Set('javascript_prettier_eslint_options', '')
function! ale#fixers#prettier_eslint#GetExecutable(buffer) abort
return ale#node#FindExecutable(a:buffer, 'javascript_prettier_eslint', [
return ale#path#FindExecutable(a:buffer, 'javascript_prettier_eslint', [
\ 'node_modules/prettier-eslint-cli/dist/index.js',
\ 'node_modules/.bin/prettier-eslint',
\])

View File

@ -6,7 +6,7 @@ call ale#Set('javascript_prettier_standard_use_global', get(g:, 'ale_use_global_
call ale#Set('javascript_prettier_standard_options', '')
function! ale#fixers#prettier_standard#GetExecutable(buffer) abort
return ale#node#FindExecutable(a:buffer, 'javascript_prettier_standard', [
return ale#path#FindExecutable(a:buffer, 'javascript_prettier_standard', [
\ 'node_modules/prettier-standard/lib/index.js',
\ 'node_modules/.bin/prettier-standard',
\])

View File

@ -6,7 +6,7 @@ call ale#Set('markdown_remark_lint_use_global', get(g:, 'ale_use_global_executab
call ale#Set('markdown_remark_lint_options', '')
function! ale#fixers#remark_lint#GetExecutable(buffer) abort
return ale#node#FindExecutable(a:buffer, 'markdown_remark_lint', [
return ale#path#FindExecutable(a:buffer, 'markdown_remark_lint', [
\ 'node_modules/remark-cli/cli.js',
\ 'node_modules/.bin/remark',
\])

View File

@ -6,7 +6,7 @@ call ale#Set('javascript_standard_use_global', get(g:, 'ale_use_global_executabl
call ale#Set('javascript_standard_options', '')
function! ale#fixers#standard#GetExecutable(buffer) abort
return ale#node#FindExecutable(a:buffer, 'javascript_standard', [
return ale#path#FindExecutable(a:buffer, 'javascript_standard', [
\ 'node_modules/standardx/bin/cmd.js',
\ 'node_modules/standard/bin/cmd.js',
\ 'node_modules/.bin/standard',

View File

@ -6,7 +6,7 @@ call ale#Set('stylelint_use_global', get(g:, 'ale_use_global_executables', 0))
call ale#Set('stylelint_options', '')
function! ale#fixers#stylelint#GetExecutable(buffer) abort
return ale#node#FindExecutable(a:buffer, 'stylelint', [
return ale#path#FindExecutable(a:buffer, 'stylelint', [
\ 'node_modules/stylelint/bin/stylelint.js',
\ 'node_modules/.bin/stylelint',
\])

View File

@ -6,7 +6,7 @@ call ale#Set('swift_swiftformat_use_global', get(g:, 'ale_use_global_executables
call ale#Set('swift_swiftformat_options', '')
function! ale#fixers#swiftformat#GetExecutable(buffer) abort
return ale#node#FindExecutable(a:buffer, 'swift_swiftformat', [
return ale#path#FindExecutable(a:buffer, 'swift_swiftformat', [
\ 'Pods/SwiftFormat/CommandLineTool/swiftformat',
\ 'ios/Pods/SwiftFormat/CommandLineTool/swiftformat',
\ 'swiftformat',

View File

@ -5,7 +5,7 @@ call ale#Set('html_tidy_executable', 'tidy')
call ale#Set('html_tidy_use_global', get(g:, 'ale_use_global_executables', 0))
function! ale#fixers#tidy#Fix(buffer) abort
let l:executable = ale#node#FindExecutable(
let l:executable = ale#path#FindExecutable(
\ a:buffer,
\ 'html_tidy',
\ ['tidy'],

View File

@ -3,7 +3,7 @@ scriptencoding utf-8
" Description: Error handling for errors in alex output format
function! ale#handlers#alex#GetExecutable(buffer) abort
return ale#node#FindExecutable(a:buffer, 'alex', [
return ale#path#FindExecutable(a:buffer, 'alex', [
\ 'node_modules/.bin/alex',
\ 'node_modules/alex/cli.js',
\])

View File

@ -36,7 +36,7 @@ function! ale#handlers#eslint#FindConfig(buffer) abort
endfunction
function! ale#handlers#eslint#GetExecutable(buffer) abort
return ale#node#FindExecutable(a:buffer, 'javascript_eslint', s:executables)
return ale#path#FindExecutable(a:buffer, 'javascript_eslint', s:executables)
endfunction
" Given a buffer, return an appropriate working directory for ESLint.
@ -49,7 +49,7 @@ function! ale#handlers#eslint#GetCwd(buffer) abort
" If eslint is installed in a directory which contains the buffer, assume
" it is the ESLint project root. Otherwise, use nearest node_modules.
" Note: If node_modules not present yet, can't load local deps anyway.
let l:executable = ale#node#FindNearestExecutable(a:buffer, s:executables)
let l:executable = ale#path#FindNearestExecutable(a:buffer, s:executables)
if !empty(l:executable)
let l:nmi = strridx(l:executable, 'node_modules')

View File

@ -9,7 +9,7 @@ function! ale#handlers#fecs#GetCommand(buffer) abort
endfunction
function! ale#handlers#fecs#GetExecutable(buffer) abort
return ale#node#FindExecutable(a:buffer, 'javascript_fecs', [
return ale#path#FindExecutable(a:buffer, 'javascript_fecs', [
\ 'node_modules/.bin/fecs',
\ 'node_modules/fecs/bin/fecs',
\])

View File

@ -4,7 +4,7 @@
function! ale#handlers#ols#GetExecutable(buffer) abort
let l:ols_setting = ale#handlers#ols#GetLanguage(a:buffer) . '_ols'
return ale#node#FindExecutable(a:buffer, l:ols_setting, [
return ale#path#FindExecutable(a:buffer, l:ols_setting, [
\ 'node_modules/.bin/ocaml-language-server',
\])
endfunction

View File

@ -66,7 +66,7 @@ function! ale#handlers#solhint#FindConfig(buffer) abort
endfunction
function! ale#handlers#solhint#GetExecutable(buffer) abort
return ale#node#FindExecutable(a:buffer, 'solidity_solhint', s:executables)
return ale#path#FindExecutable(a:buffer, 'solidity_solhint', s:executables)
endfunction
" Given a buffer, return an appropriate working directory for solhint.
@ -74,7 +74,7 @@ function! ale#handlers#solhint#GetCwd(buffer) abort
" If solhint is installed in a directory which contains the buffer, assume
" it is the solhint project root. Otherwise, use nearest node_modules.
" Note: If node_modules not present yet, can't load local deps anyway.
let l:executable = ale#node#FindNearestExecutable(a:buffer, s:executables)
let l:executable = ale#path#FindNearestExecutable(a:buffer, s:executables)
if !empty(l:executable)
let l:nmi = strridx(l:executable, 'node_modules')

View File

@ -6,7 +6,7 @@ call ale#Set('textlint_use_global', get(g:, 'ale_use_global_executables', 0))
call ale#Set('textlint_options', '')
function! ale#handlers#textlint#GetExecutable(buffer) abort
return ale#node#FindExecutable(a:buffer, 'textlint', [
return ale#path#FindExecutable(a:buffer, 'textlint', [
\ 'node_modules/.bin/textlint',
\ 'node_modules/textlint/bin/textlint.js',
\])

View File

@ -7,7 +7,7 @@ function! ale#handlers#tslint#InitVariables() abort
endfunction
function! ale#handlers#tslint#GetExecutable(buffer) abort
return ale#node#FindExecutable(a:buffer, 'typescript_tslint', [
return ale#path#FindExecutable(a:buffer, 'typescript_tslint', [
\ 'node_modules/.bin/tslint',
\])
endfunction

View File

@ -11,7 +11,7 @@ endfunction
call ale#handlers#writegood#ResetOptions()
function! ale#handlers#writegood#GetExecutable(buffer) abort
return ale#node#FindExecutable(a:buffer, 'writegood', [
return ale#path#FindExecutable(a:buffer, 'writegood', [
\ 'node_modules/.bin/write-good',
\ 'node_modules/write-good/bin/write-good.js',
\])

View File

@ -9,7 +9,7 @@ call ale#Set('typescript_xo_options', '')
function! ale#handlers#xo#GetExecutable(buffer) abort
let l:type = ale#handlers#xo#GetType(a:buffer)
return ale#node#FindExecutable(a:buffer, l:type . '_xo', [
return ale#path#FindExecutable(a:buffer, l:type . '_xo', [
\ 'node_modules/xo/cli.js',
\ 'node_modules/.bin/xo',
\])

View File

@ -41,7 +41,7 @@ let s:default_ale_linters = {
\ 'apkbuild': ['apkbuild_lint', 'secfixes_check'],
\ 'csh': ['shell'],
\ 'elixir': ['credo', 'dialyxir', 'dogma'],
\ 'go': ['gofmt', 'golint', 'go vet'],
\ 'go': ['gofmt', 'golint', 'gopls', 'govet'],
\ 'hack': ['hack'],
\ 'help': [],
\ 'inko': ['inko'],

View File

@ -3,38 +3,6 @@
call ale#Set('windows_node_executable_path', 'node.exe')
" Given a buffer number, a base variable name, and a list of paths to search
" for in ancestor directories, detect the executable path for a Node program.
"
" The use_global and executable options for the relevant program will be used.
function! ale#node#FindExecutable(buffer, base_var_name, path_list) abort
if ale#Var(a:buffer, a:base_var_name . '_use_global')
return ale#Var(a:buffer, a:base_var_name . '_executable')
endif
let l:nearest = ale#node#FindNearestExecutable(a:buffer, a:path_list)
if !empty(l:nearest)
return l:nearest
endif
return ale#Var(a:buffer, a:base_var_name . '_executable')
endfunction
" Given a buffer number, a base variable name, and a list of paths to search
" for in ancestor directories, detect the executable path for a Node program.
function! ale#node#FindNearestExecutable(buffer, path_list) abort
for l:path in a:path_list
let l:executable = ale#path#FindNearestFile(a:buffer, l:path)
if !empty(l:executable)
return l:executable
endif
endfor
return ''
endfunction
" Create a executable string which executes a Node.js script command with a
" Node.js executable if needed.
"

View File

@ -77,6 +77,42 @@ function! ale#path#ResolveLocalPath(buffer, search_string, global_fallback) abor
return l:path
endfunction
" Given a buffer number, a base variable name, and a list of paths to search
" for in ancestor directories, detect the executable path for a program.
function! ale#path#FindNearestExecutable(buffer, path_list) abort
for l:path in a:path_list
if ale#path#IsAbsolute(l:path)
let l:executable = filereadable(l:path) ? l:path : ''
else
let l:executable = ale#path#FindNearestFile(a:buffer, l:path)
endif
if !empty(l:executable)
return l:executable
endif
endfor
return ''
endfunction
" Given a buffer number, a base variable name, and a list of paths to search
" for in ancestor directories, detect the executable path for a program.
"
" The use_global and executable options for the relevant program will be used.
function! ale#path#FindExecutable(buffer, base_var_name, path_list) abort
if ale#Var(a:buffer, a:base_var_name . '_use_global')
return ale#Var(a:buffer, a:base_var_name . '_executable')
endif
let l:nearest = ale#path#FindNearestExecutable(a:buffer, a:path_list)
if !empty(l:nearest)
return l:nearest
endif
return ale#Var(a:buffer, a:base_var_name . '_executable')
endfunction
" Return 1 if a path is an absolute path.
function! ale#path#IsAbsolute(filename) abort
if has('win32') && a:filename[:0] is# '\'

View File

@ -194,12 +194,30 @@ g:ale_go_gometalinter_lint_package *g:ale_go_gometalinter_lint_package*
===============================================================================
gopls *ale-go-gopls*
gopls is the official Go language server, and is enabled for use with ALE by
default.
To install the latest stable version of `gopls` to your `$GOPATH`, try the
following command: >
GO111MODULE=on go get golang.org/x/tools/gopls@latest
<
If `$GOPATH` is readable by ALE, it should probably work without you having to
do anything else. See the `gopls` README file for more information:
https://github.com/golang/tools/blob/master/gopls/README.md
g:ale_go_gopls_executable *g:ale_go_gopls_executable*
*b:ale_go_gopls_executable*
Type: |String|
Default: `'gopls'`
Location of the gopls binary file.
See |ale-integrations-local-executables|
ALE will search for `gopls` in locally installed directories first by
default, and fall back on a globally installed `gopls` if it can't be found
otherwise.
g:ale_go_gopls_options *g:ale_go_gopls_options*
@ -229,6 +247,15 @@ g:ale_go_gopls_init_options *g:ale_go_gopls_init_options*
For a full list of supported analyzers, see:
https://github.com/golang/tools/blob/master/gopls/doc/analyzers.md
g:ale_go_gopls_use_global *g:ale_go_gopls_use_global*
*b:ale_go_gopls_use_global*
Type: |String|
Default: `get(g:, 'ale_use_global_executables', 0)`
See |ale-integrations-local-executables|
===============================================================================
govet *ale-go-govet*

View File

@ -1580,7 +1580,7 @@ g:ale_linters *g:ale_linters*
\ 'apkbuild': ['apkbuild_lint', 'secfixes_check'],
\ 'csh': ['shell'],
\ 'elixir': ['credo', 'dialyxir', 'dogma'],
\ 'go': ['gofmt', 'golint', 'go vet'],
\ 'go': ['gofmt', 'golint', 'gopls', 'govet'],
\ 'hack': ['hack'],
\ 'help': [],
\ 'inko': ['inko'],

View File

@ -192,7 +192,7 @@ formatting.
* [golangserver](https://github.com/sourcegraph/go-langserver) :warning:
* [golint](https://godoc.org/github.com/golang/lint)
* [gometalinter](https://github.com/alecthomas/gometalinter) :warning: :floppy_disk:
* [gopls](https://github.com/golang/go/wiki/gopls) :warning:
* [gopls](https://github.com/golang/go/wiki/gopls)
* [gosimple](https://github.com/dominikh/go-tools/tree/master/cmd/gosimple) :warning: :floppy_disk:
* [gotype](https://godoc.org/golang.org/x/tools/cmd/gotype) :warning: :floppy_disk:
* [revive](https://github.com/mgechev/revive) :warning: :floppy_disk:

View File

@ -1,5 +1,8 @@
Before:
Save g:ale_go_go111module
Save $GOPATH
let $GOPATH = '/non/existent/directory'
call ale#assert#SetUpLinterTest('go', 'gopls')
@ -14,16 +17,32 @@ After:
call ale#assert#TearDownLinterTest()
Execute(should set correct defaults):
Execute(The default command should be correct):
AssertLinter 'gopls', ale#Escape('gopls') . ' --mode stdio'
Execute(should configure gopls callback executable):
Execute(The executable should be configurable):
let b:ale_go_gopls_executable = 'boo'
let b:ale_go_gopls_options = ''
AssertLinter 'boo', ale#Escape('boo')
AssertLinter 'boo', ale#Escape('boo') . ' --mode stdio'
Execute(should set gopls options):
Execute(gopls should be found in GOPATH):
" This is a directory with a fake executable
let $GOPATH = ale#test#GetFilename('../test-files/go/gopath')
AssertLinter
\ ale#test#GetFilename('../test-files/go/gopath/bin/gopls'),
\ ale#Escape(ale#test#GetFilename('../test-files/go/gopath/bin/gopls'))
\ . ' --mode stdio'
Execute(Global settings should be preferre for gopls if use_global = 1):
" This is a directory with a fake executable
let $GOPATH = ale#test#GetFilename('../test-files/go/gopath')
let b:ale_go_gopls_executable = 'boo'
let b:ale_go_gopls_use_global = 1
AssertLinter 'boo', ale#Escape('boo') . ' --mode stdio'
Execute(Settings options should work):
call ale#test#SetFilename('../test-files/go/go1/prj1/file.go')
" let b:ale_completion_enabled = 1
let b:ale_go_gopls_options = ''
@ -39,18 +58,18 @@ Execute(should set gopls options):
let b:ale_go_gopls_init_options = {'ui.diagnostic.analyses': {'composites': v:false}}
AssertLSPOptions {'ui.diagnostic.analyses': {'composites': v:false}}
Execute(should support go environment variables):
Execute(Go environment variables should be passed on):
let b:ale_go_go111module = 'off'
AssertLinter 'gopls',
\ ale#Env('GO111MODULE', 'off') . ale#Escape('gopls') . ' --mode stdio'
Execute(Should return directory for 'go.mod' if found in parent directory):
Execute(Project directories should be detected based on 'go.mod' being present):
call ale#test#SetFilename('../test-files/go/test.go')
AssertLSPProject ale#path#Simplify(g:dir . '/../test-files/go')
Execute(Should return nearest directory with '.git' if found in parent directory):
Execute(Project directories with .git should be detected):
call ale#test#SetFilename('test.go')
if !isdirectory(g:dir . '/.git')
@ -59,7 +78,7 @@ Execute(Should return nearest directory with '.git' if found in parent directory
AssertLSPProject g:dir
Execute(Should ignore 'go.mod' and return '.git' dir if modules off):
Execute('go.mod' should be ignored if modules are off):
call ale#test#SetFilename('../test-files/go/test.go')
let b:ale_go_go111module = 'off'

View File

View File

@ -22,7 +22,7 @@ Execute(The defaults for the csh filetype should be correct):
AssertEqual [], GetLinterNames('csh')
Execute(The defaults for the go filetype should be correct):
AssertEqual ['gofmt', 'golint', 'govet'], GetLinterNames('go')
AssertEqual ['gofmt', 'golint', 'gopls', 'govet'], GetLinterNames('go')
let g:ale_linters_explicit = 1