* core-customization: improved SAFE variable handling
- SAFE can either be a function or t.
- When it's t, use a default validation function
`(lambda (val) (validate-value val TYPE t))`
- When it's a function, use the supplied function.
* Fixed bugs in go and groovy layer
In almost any cases, it's better to supply `t` instead of a function, to
`SAFE` argument of `spacemacs|defc`.
For example,
```elisp
(spacemacs|defc go-use-gocheck-for-testing nil
"If using gocheck for testing when running the tests -check.f will be used instead of -run to specify the test that will be ran. Gocheck is mandatory for testing suites."
'boolean nil #'booleanp)
```
If its value is nil, it evaluate to `nil`, which means that `nil` is not
a safe value for `go-use-gocheck-for-testing` local variable.
But clearly it is.
* core-customization: improved SAFE variable handling
- Added a function `spacemacs-customization//get-variable-validator`.
This function is designed to be used with `safe-local-variable`
property of spacemacs custom variables.
See details in the docstring.
```elisp
(put 'FOO 'safe-local-variable
(apply-partially 'spacemacs-customization//get-variable-validator
'FOO))
```
- This is better than a lambda since `apply-partially` returns a compiled
function. (Though the performace gain may be tiny.)
- This is better than simply calling `validate-value`, because it returns
nil when value is nil. But sometimes nil is a valid value.
Co-authored-by: Lucius Hu <lebensterben@users.noreply.github.com>
- Labelled `go-backend` and `go-format-on-save` as safe local variable.
- Added local variable hooks of go mode:
- `spacemacs//go-setup-backend`
- `spacemacs//go-setup-eldoc`
- `spacemacs//go-setup-format`
See: https://github.com/syl20bnr/spacemacs/issues/14653
- Moved backend determination to `config.el`
- Replaced `pcase` form with only one-arm with `when` or `unless` form
- Replaced unnecessary backquote construct with simple quotation
Popwin automatically configures pupo purposes
if properly configured. While I was checking
the existing configs I have found that the
settings will be ignored if the config is not
done via a post-config hook.
A quick search revealed a lot of popwin configs
which never had any effect.
This commit fixes these and with this also
restores the missing pupo configs.
spacemacs/go-run-test-current-function() previously failed when point was
anywhere but at the end of the line on the first line of the test function to
run.
This is a squash commit, it includes:
* Add go run and go test command variables
* Update go README for go-run-command and go-test-command
* Update CHANGELOG
Before the decision which linter to run before golangci-lint has been
taken by the layer. However this can also directly be done by the
checkers.
Also golangci-lint did run even when the previous checker still reported
errors. With this it is only called if the previous checker is satisfied.
All thanks goes to Tommi Komulainen.
Flycheck-golangci was not properly conigured which resulted in
not replacing disabled standard linters like go-test.
In addition there seems to be an issue in the current golangci
build causing the linter to fail. In this case spacemacs now
shows at least basic errors from go-build. When they are fixed
the linter should be able to work normally again.
The previous way of adding dap to a layer did add the mode
unconditionally to `spacemacs--dap-supported-modes` causing
dap bindings to be added also when no lsp backend was used.
Go layer now supports dap, therefore when lsp is selected the layer
will load dap which in turn will load lsp to enable debugging capabilities
for all lsp users.
See #10825.
Try to match more closely the build process followed upstream:
- Force module build mode, which builds the latest stable release (not master),
and takes care of module replacements.
- Disable cgo.
- The -trimpath argument to go get requires go >= 1.13, which is also needed
because go <= 1.12 has a bug that causes problems with golangci-lint², as
explained in the golangci-lint installation instructions².
Note that the only thing that is missing to exactly match the upstream build
process is the addition of some -X variables, which only affect the data
reported by golangci-lint version.
¹: https://github.com/golang/go/issues/29612
²: https://github.com/golangci/golangci-lint#install
Thanks to @dbriemann and @seriousben for reporting and clarifying this issue!
There was a edge case with the declaration of the `lsp` layer in `layers.el`
files.
The `hy` layer depends on the `python` layer which in turn depends on the `lsp`
layer if and only if the `python-backend` layer variable is set to `lsp`.
When the `hy` layer was declared first then it declares the `python` layer
without its layer variables, thus the `lsp` layer was not declared because the
`python-backend` variable was not set.
The fix is to gather all the layer dependencies and resolve them only after all
the used layers have been declared.
* new function `configuration-layer/declare-layer-dependencies`
* replace all calls to `configuration-layer/declare-layer` by the new function
except for distribution layers (we declare layer dependencies right away in
distribution layers)
- Consolidate pre-requisites
- Revise document structure
- Clarify setup instructions
- Link key bindings to their supporting tools
- Remove ancient notes on go-oracle
- Fix typos
- Style fixes
- Apply suggestions from code review by @duianto
Thanks to @duianto for the comprehensive review!
Co-Authored-By: duianto <otnaiud@gmail.com>
gometalinter¹ was deprecated on 2019-02-28, in favor of the more advanced
golangci-lint.
. Drop references to gometalinter from README.org
. Update reference to available meta-linter (golangci-lint) in LAYERS.org
. Add attribution in CHANGELOG.develop
¹: https://github.com/alecthomas/gometalinter
When executing the main function which requires command line arguments, user can
set `go-run-args` to pass command line arguments to compiled binary.
The example below demonstrates how to pass command line arguments by setting
`go-run-args` as file local variable:
package main
import (
"fmt"
"os"
"strconv"
)
func main() {
//Atoi converts a string to an int
fmt.Println("Arguments:", os.Args)
a, _ := strconv.Atoi(os.Args[1])
b, _ := strconv.Atoi(os.Args[2])
result := sum(a, b)
fmt.Printf("The sum of %d and %d is %d\n", a, b, result)
}
func sum(a, b int) int {
return a + b
}
// Local Variables:
// go-run-args: "10 5"
// End:
When switching the Go layer to use the LSP backend with `golangci-lint`, I
noticed that none of my linter errors were being rendered with my source code.
Digging in further, I eventually learned it was due to `lsp-prefer-flymake`
being set to `nil` and not `:none`.
This change updates the Go layer, when using LSP and golangci-lint, to set
`lsp-prefer-flymake` to `:none`. If this is not set, the golangci-lint errors
will not be reported.
This is an alternative to #12043.
Fixes#11680
Signed-off-by: Tim Heckman <t@heckman.io>