vim-lsp
vim-lsp copied to clipboard
gopls: syntax:Error:expected declaration, found 'package'
vimrc:
set nocompatible
call plug#begin()
Plug 'prabirshrestha/vim-lsp'
Plug 'mattn/vim-lsp-settings'
call plug#end()
let g:lsp_settings = {
\ 'golangci-lint-langserver': {
\ 'initialization_options': {
\ 'command': [
\ 'golangci-lint', 'run', '--fast',
\ '--max-issues-per-linter', '0',
\ '--max-same-issues', '0',
\ '--out-format', 'json',
\ ],
\ }
\ }
\ }
let g:lsp_settings_filetype_go = ['gopls', 'golangci-lint-langserver']
Steps to reproduce:
- Open any Go file.
-
:bdelete
current buffer. - Press
CTRL+^
to reopen the file. -
:LspDocumentDiagnostics
This won't happen if I:
- Remove
golangci-lint-langserver
from vimrc:
set nocompatible
call plug#begin()
Plug 'prabirshrestha/vim-lsp'
Plug 'mattn/vim-lsp-settings'
call plug#end()
let g:lsp_settings_filetype_go = ['gopls']
- Or, just checkout the commit prior to a91419e and keep vimrc unchanged.
So I reverted following change introduced in a91419e, and it works:
diff --git a/autoload/lsp.vim b/autoload/lsp.vim
index 679636a..497dc8c 100644
--- a/autoload/lsp.vim
+++ b/autoload/lsp.vim
@@ -217,7 +217,7 @@ function! s:register_events() abort
autocmd TextChangedP * call s:on_text_document_did_change()
endif
if g:lsp_untitled_buffer_enabled
- autocmd FileType * call s:on_filetype_changed(bufnr(expand('<afile>')))
+ autocmd FileType * call s:on_filetype_changed(bufnr('<afile>'))
endif
augroup END
And then I noticed g:lsp_untitled_buffer_enabled
. Setting it to 0
also works.
It seems this is still an issue, so I'm not closing it.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
@b97tsk is this still an issue?
@prabirshrestha Yes, but feel free to close it. I don't mind to have let g:lsp_untitled_buffer_enabled = 0
in my vimrc. 😄
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.