1

I've succeeded in configuring a vim-c++ environment based on the plugin YCM and the plugin ale.

I use YCM to do the auto-completion and ALE to hint me errors and warnings.

I added the config as below to update the status line:

set statusline+=%#warningmsg#
function! LinterStatus() abort
    let l:counts = ale#statusline#Count(bufnr(''))
    let l:fst = ale#statusline#FirstProblem(bufnr(''), 'error')
    let l:all_errors = l:counts.error + l:counts.style_error
    let l:all_non_errors = l:counts.total - l:all_errors
    return l:counts.total == 0 ? 'OK' : printf(
    \   '%dW %dE(%d)',
    \   all_non_errors,
    \   all_errors,
    \   fst.lnum
    \)
endfunction
set statusline+=%{LinterStatus()}
set statusline+=%*

It worked as expected.

For example, the c++ code as below will show 0W 1E(3) at the status line.

int main()
{
    xxxx
}

Now I'm trying to configure a vim-golang environment with the plugin YCM and the plugin ALE.

I've built the YCM with the command ./install.py --go-completer. For ALE, I used the same config as above and I add one line to configure golang:

let g:ale_linters = {'go': ['gopls', 'golangci-lint', 'gofmt']}.

However, the status line always show me OK, meaning that there is no error, no matter how I create an error.

enter image description here

As you can see, there does exist an error but the status line shows me an OK.

:ALEInfo

 Current Filetype: go
Available Linters: ['bingo', 'gobuild', 'gofmt', 'golangci-lint', 'golint', 'gometalinter', 'gopls', 'gosimple', 'gotype', 'govet', 'golangserver', 'staticcheck']
   Linter Aliases:
'gobuild' -> ['go build']
'govet' -> ['go vet']
  Enabled Linters: ['gofmt', 'golangci-lint', 'gopls']
 Suggested Fixers:
  'gofmt' - Fix Go files with go fmt.
  'goimports' - Fix Go files imports with goimports.
  'remove_trailing_lines' - Remove all blank lines at the end of a file.
  'trim_whitespace' - Remove all trailing whitespace characters at the end of every line.
 Linter Variables:

let g:ale_go_go_executable = 'go'
let g:ale_go_golangci_lint_executable = 'golangci-lint'
let g:ale_go_golangci_lint_options = '--enable-all'
let g:ale_go_golangci_lint_package = 0
let g:ale_go_gopls_executable = 'gopls'
let g:ale_go_gopls_options = '--mode stdio'
let g:ale_go_langserver_executable = 'go-langserver'
let g:ale_go_langserver_options = ''
 Global Variables:

let g:ale_cache_executable_check_failures = v:null
let g:ale_change_sign_column_color = 0
let g:ale_command_wrapper = ''
let g:ale_completion_delay = v:null
let g:ale_completion_enabled = 0
let g:ale_completion_max_suggestions = v:null
let g:ale_echo_cursor = 1
let g:ale_echo_msg_error_str = 'Error'
let g:ale_echo_msg_format = '%code: %%s'
let g:ale_echo_msg_info_str = 'Info'
let g:ale_echo_msg_warning_str = 'Warning'
let g:ale_enabled = 1
let g:ale_fix_on_save = 0
let g:ale_fixers = {}
let g:ale_history_enabled = 1
let g:ale_history_log_output = 1
let g:ale_keep_list_window_open = 0
let g:ale_lint_delay = 200
let g:ale_lint_on_enter = 1
let g:ale_lint_on_filetype_changed = 1
let g:ale_lint_on_insert_leave = 1
let g:ale_lint_on_save = 1
let g:ale_lint_on_text_changed = 'normal'
let g:ale_linter_aliases = {}
let g:ale_linters = {'go': ['gopls', 'golangci-lint', 'gofmt']}
let g:ale_linters_explicit = 0
let g:ale_list_vertical = 0
let g:ale_list_window_size = 10
let g:ale_loclist_msg_format = '%code: %%s'
let g:ale_lsp_root = {}
let g:ale_max_buffer_history_size = 20
let g:ale_max_signs = -1
let g:ale_maximum_file_size = v:null
let g:ale_open_list = 0
let g:ale_pattern_options = v:null
let g:ale_pattern_options_enabled = v:null
let g:ale_set_balloons = 0
let g:ale_set_highlights = 1
let g:ale_set_loclist = 1
let g:ale_set_quickfix = 0
let g:ale_set_signs = 1
let g:ale_sign_column_always = 0
let g:ale_sign_error = '>>'
let g:ale_sign_info = '--'
let g:ale_sign_offset = 1000000
let g:ale_sign_style_error = '>>'
let g:ale_sign_style_warning = '--'
let g:ale_sign_warning = '--'
let g:ale_sign_highlight_linenrs = 0
let g:ale_statusline_format = v:null
let g:ale_type_map = {}
let g:ale_use_global_executables = v:null
let g:ale_virtualtext_cursor = 0
let g:ale_warn_about_trailing_blank_lines = 1
let g:ale_warn_about_trailing_whitespace = 1
  Command History:

(executable check - success) gofmt
(finished - exit code 0) ['/bin/bash', '-c', '''gofmt'' -e ''/tmp/vmCvq7C/1/test.go''']

<<<NO OUTPUT RETURNED>>>

(executable check - success) golangci-lint
(finished - exit code 3) ['/bin/bash', '-c', 'cd ''/home/zyh/tmp/src'' && ''golangci-lint'' run ''test.go'' --enable-all']

<<<NO OUTPUT RETURNED>>>
8
  • What put the sign there, ale or ycm?
    – D. Ben Knoble
    Mar 23, 2020 at 11:57
  • @D.BenKnoble it should be ycm.
    – Yves
    Mar 23, 2020 at 14:12
  • Ok. So what is :ALEInfo saying?
    – D. Ben Knoble
    Mar 23, 2020 at 14:51
  • @D.BenKnoble I put the output in the question.
    – Yves
    Mar 24, 2020 at 1:18
  • @D.BenKnoble In fact, I tried to use ALE without YCM, but it doesn't seem that ALE can do autocompletion, which means that I have to type <C-x><X-o> manually... So I mixed them up or what?
    – Yves
    Mar 24, 2020 at 1:56

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.