Skip to content

gopls: Invalid settings: invalid options type on first lint #4981

@cfebs

Description

@cfebs

Information

VIM version

NVIM v0.11.1
Build type: RelWithDebInfo
LuaJIT 2.1.1741730670

Operating System: Arch Linux

❯ pacman -Q gopls go
gopls 0.18.1-2
go 2:1.24.3-1
❯ go version; gopls version
go version go1.24.3 linux/amd64
golang.org/x/tools/gopls (devel)

Note: the (devel) version installed from official arch pkg should be 0.18.1 based on the PKGBUILD https://gitlab.archlinux.org/archlinux/packaging/packages/gopls/-/blob/22890b721f637386150cad812068f1523a5ab85e/PKGBUILD

What went wrong

gopls throws an initial "Invalid settings" message when linting a golang source file

LSP[gopls:/home/cfebs/src/gotest] Invalid settings: invalid options type []interface {} (want JSON null or object)

Image

The the repro steps below with minimal vimrc this happens on file load when the file is first linted.

Subsequent lints do not throw the message and gopls seems to work correctly.

Reproducing the bug

Here is a gist containing the full stripped down test case: https://gist.github.com/cfebs/1ec23c8da5362480ba1a3630b2d19f7f

It contains:

  • go.mod main.go - simple golang files
  • vimrc.aletest - stripped down vimrc loading ALE with Plugged

Repro steps:

  1. clone the test: git clone https://gist.github.com/1ec23c8da5362480ba1a3630b2d19f7f.git
  2. nvim -u ./vimrc.aletest main.go

Expected:

nvim loads, no warnings/errors from ALE

Actual:

gopls Invalid settings message is printed

:ALEInfo

Expand

Current Filetype: go
Available Linters: ['bingo', 'cspell', 'gobuild', 'gofmt', 'golangci-lint', 'gopls', 'gosimple', 'gotype', 'govet', 'golangserver', 'revive', 'staticcheck']
Linter Aliases:
'gobuild' -> ['go build']
'govet' -> ['go vet']
Enabled Linters: ['gofmt', 'golangci-lint', 'gopls', 'govet']
Ignored Linters: []
Suggested Fixers:
'gofmt' - Fix Go files with go fmt.
'gofumpt' - Fix Go files with gofumpt, a stricter go fmt.
'goimports' - Fix Go files imports with goimports.
'golangci_lint' - Fix Go files with golangci-lint.
'golines' - Fix Go file long lines with golines
'gopls' - Fix Go files with gopls.
'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:
" Press Space to read :help for a setting
let g:ale_go_go_executable = 'go'
let g:ale_go_golangci_lint_executable = 'golangci-lint'
let g:ale_go_golangci_lint_options = ''
let g:ale_go_golangci_lint_package = 1
let g:ale_go_gopls_executable = 'gopls'
let g:ale_go_gopls_init_options = {}
let g:ale_go_gopls_options = '--mode stdio'
let g:ale_go_gopls_use_global = 0
let g:ale_go_govet_options = ''
let g:ale_go_langserver_executable = 'go-langserver'
let g:ale_go_langserver_options = ''

Global Variables:
" Press Space to read :help for a setting
let g:ale_cache_executable_check_failures = v:null
let g:ale_change_sign_column_color = v:null
let g:ale_command_wrapper = ''
let g:ale_completion_delay = v:null
let g:ale_completion_enabled = v:false
let g:ale_completion_max_suggestions = v:null
let g:ale_disable_lsp = 'auto'
let g:ale_echo_cursor = v:true
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 = v:false
let g:ale_fixers = {}
let g:ale_history_enabled = v:true
let g:ale_info_default_mode = 'preview'
let g:ale_history_log_output = v:true
let g:ale_keep_list_window_open = 0
let g:ale_lint_delay = 200
let g:ale_lint_on_enter = v:true
let g:ale_lint_on_filetype_changed = v:true
let g:ale_lint_on_insert_leave = v:true
let g:ale_lint_on_save = v:true
let g:ale_lint_on_text_changed = 'normal'
let g:ale_linter_aliases = {}
let g:ale_linters = {}
let g:ale_linters_explicit = v:false
let g:ale_linters_ignore = {}
let g:ale_list_vertical = v:false
let g:ale_list_window_size = 10
let g:ale_loclist_msg_format = '%code: %%s'
let g:ale_max_buffer_history_size = 20
let g:ale_max_signs = v:null
let g:ale_maximum_file_size = v:null
let g:ale_open_list = v:false
let g:ale_pattern_options = v:null
let g:ale_pattern_options_enabled = v:null
let g:ale_root = {}
let g:ale_set_balloons = v:false
let g:ale_set_highlights = v:true
let g:ale_set_loclist = v:true
let g:ale_set_quickfix = v:false
let g:ale_set_signs = v:true
let g:ale_sign_column_always = v:null
let g:ale_sign_error = v:null
let g:ale_sign_info = v:null
let g:ale_sign_offset = v:null
let g:ale_sign_style_error = v:null
let g:ale_sign_style_warning = v:null
let g:ale_sign_warning = v:null
let g:ale_sign_highlight_linenrs = v:null
let g:ale_type_map = {}
let g:ale_use_neovim_diagnostics_api = v:true
let g:ale_use_global_executables = v:null
let g:ale_virtualtext_cursor = 'all'
let g:ale_warn_about_trailing_blank_lines = v:true
let g:ale_warn_about_trailing_whitespace = v:true

Command History:

(executable check - success) gofmt
(finished - exit code 0) ['/bin/bash', '-c', '''gofmt'' -e ''/tmp/nvim.cfebs/MNCv0W/0/main.go''']

<<>>

(executable check - success) golangci-lint
(finished - exit code 0) ['/bin/bash', '-c', 'cd ''/home/cfebs/src/gotest'' && ''golangci-lint'' --version']

<<>>
golangci-lint has version v1.39.1-0.20210503082938-96a7f62b2e13 built from (unknown, mod sum: "h1:iHpG/WyvVrVJxrOYzfyR+YR4CJmYz9FRdCbg0mNUYUg=") on (unknown)
<<>>

(executable check - success) gopls
(executable check - success) go
(finished - exit code 0) ['/bin/bash', '-c', 'cd ''/home/cfebs/src/gotest'' && ''go'' vet .']

<<>>

(finished - exit code 3) ['/bin/bash', '-c', 'cd ''/home/cfebs/src/gotest'' && ''golangci-lint'' run --out-format=json --show-stats=0']

<<>>

(started) ['/bin/bash', '-c', '''gopls'' --mode stdio']

Also thank you very much for ALE. I have been a user for years and appreciate the tool greatly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions