Make it easier to determine project root for gopls
ale/ale_linters/go/gopls.vim
Add following lines after line 26:
if empty(l:project_root)
let l:project_root = getcwd()
endif
Note that depending on the language server this may result on multiple language server instances being spawn for every file opened.
The suggestion isn't right, and we won't be doing it, but there may be something we can do to make gopls work with more projects. Go project structure is even more rigid than most other languages. Could you tell us more about which files you are editing?
A singel .go file is often used to make a simple command tool, because go can be used as a scripting language. Please refer to https://github.com/erning/gorun I think the right judgement sequence is go.work, go.mod, single file.
@FlashIvano Could we set the project root to the cwd if we detect ^#! as the first line? (A regular expression) Would that be enough?
@FlashIvano Could we set the project root to the cwd if we detect
^#!as the first line? (A regular expression) Would that be enough?
Maybe not appropriate. Because the solution still does not support GOPATH mode.
What is "GOPATH mode?"
This looks kind of similar to #3845, albeit for golang rather than C.
A similar workaround of adding let b:ale_root = getcwd() to the user's personal configuration might be applicable here too. Might not be the proper fix, but maybe something which gets the desired result without breaking ale?
How to configure the project root might be inconsistent between different language servers at the moment, and I'm not sure how it currently works with golang. Maybe #4993 is relevant?