Commit graph

173 commits

Author SHA1 Message Date
Maximilian Wolff 500e58341c
Defer loading of lsp servers up to when the buffer is visible 2021-06-06 22:26:31 +02:00
Maximilian Wolff e708f8dcaa
[go] Remove obsolete format statement and fix go-run-args passing 2021-05-29 22:33:59 +02:00
Dennis Mayr 627940d6d7
(format (concat go-run-command) modification
Changed `(format (concat go-run-command " %s %s .")` to `(format (concat go-run-command " .")`, to allow `main.go` running when functions are invoked from another file, as suggested here: https://github.com/microsoft/vscode-go/issues/3096

Correction: `concat go-run-command " ."` ->  `concat go-run-command " ." go-run-args`

Fixed as suggested
2021-05-29 22:30:56 +02:00
Lucius Hu 3bbc7a7d40
core-customization: improved SAFE variable handling (#14679)
* 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>
2021-04-19 21:34:09 +02:00
Maximilian Wolff 247d059289
[go] Switch layer variables to defcustoms
and fix wrong declaration of go-mode hooks
2021-04-17 23:56:05 +02:00
Lucius Hu bd3a7fb0b5
go: Fix local variables
- 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
2021-04-17 22:49:33 +02:00
Lucius Hu 0ef957b529 go: refactor
- 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
2021-04-04 12:48:21 +02:00
syl20bnr 97cd83e169 Apply GPLv3 terms explicitly to all elisp files 2021-03-25 22:59:32 -04:00
syl20bnr d55a9e2e67 Update header for year 2021 2021-03-25 22:59:32 -04:00
duianto 9375d6f54d Add missing space before defun args parens 2021-02-10 08:51:55 +01:00
emacspace 8fff0ea4ee documentation formatting: Sat Oct 3 18:54:32 UTC 2020 2020-10-03 22:24:57 +03:00
JAremko 8227686194 Fix links 2020-10-03 21:52:09 +03:00
Robert O'Connor 82ba73a1c0
update copyright to 2020 2020-09-23 21:25:01 +02:00
Maximilian Wolff 582e229704
[go] Deprecate =go-mode= and revise the layer documentation
In addition I have simplified the layer code a bit
to remove unnecessary indirection in the way LSP
is set up.
2020-09-20 23:51:28 +02:00
Fredrik Simón 85bef62e2d
[lsp] Fix lsp-diagnostics-provider name (#13956)
`lsp-diagnostic-package` was renamed to `lsp-diagnostics-provider` in
[LSP version 7.0.1](f23159a85f/CHANGELOG.org (release-701)).
2020-09-18 20:31:30 +02:00
Maximilian Wolff 15d93914f5
Fix "lsp is no valid syntax checker" error message
See #13841
2020-08-27 00:04:53 +02:00
Maximilian Wolff b82bc40b3c
Fix ignored popwin declarations
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.
2020-07-03 21:51:33 +02:00
Joel Pettersson 244b3f58a2 [go] Fix search for current test function to run
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.
2020-07-01 20:45:04 +02:00
Jay Z 34a446724f
Add Go command variables
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
2020-06-11 00:12:56 +02:00
Maximilian Wolff 23976ab799
[go] Remove duplicated code and run golangci-lint only if no errors are found
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.
2020-05-27 18:16:47 +02:00
Maximilian Wolff 1ec43e7262
[go] Next try to make golangci-lint support more stable 2020-05-26 00:19:38 +02:00
Maximilian Wolff c6c931bc1e
[go] Make golangci run all available checkers and backup with go-build
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.
2020-05-24 23:46:10 +02:00
Maximilian Wolff 1fd90fc1dc
Update instructions for dap integration and update existing layers
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.
2020-05-16 23:40:38 +02:00
Ivan Yonchovski c3f13d0391 Removed company-lsp in favour of company-capf
- Also removed some cquery artifacts which accidentally ended up in this PR
instead of in https://github.com/syl20bnr/spacemacs/pull/13446
2020-04-04 08:24:44 +02:00
emacspace 14881cac15
documentation formatting: Fri Mar 27 21:25:53 UTC 2020 2020-03-27 23:03:53 +01:00
Maximilian Wolff 9bd9151c7a
[go] Load dap when lsp is enabled
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.
2020-03-27 21:06:48 +01:00
Ljupcho Kotev e4eafe8324
Add dap-go integration 2020-03-27 21:05:55 +01:00
duianto dd8e611158
Replace obsolete lsp-prefer-flymake with lsp-diagnostic-package 2020-02-21 23:19:20 +01:00
pancho horrillo 1fa28b345c [go] Update build instructions for golangci-lint
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!
2019-12-28 20:29:01 +01:00
zhuoyikang 35de1f6db0
[go] Add missing linters to flycheck-disabled-checkers
I have added go-staticcheck and go-unconvert to list of
disabled checkers.
2019-12-15 15:28:53 +01:00
Seong Yong-ju 2e7a5c5929 Do not use go-eldoc for LSP backend 2019-11-17 16:45:39 +01:00
syl20bnr 584392bd92 [core] Fix layer dependencies based on layer variables
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)
2019-09-30 02:00:48 -04:00
syl20bnr ac30247811 [lsp] When used, make LSP the default backend for all supported lang
* Added a new function to each language to select the backend
* Use these new functions in all `pcase`.
2019-09-30 00:49:44 -04:00
emacspace 560b51c324 documentation formatting: Thu Sep 12 15:09:22 UTC 2019 2019-09-12 21:44:20 +02:00
Mathieu ab9acc0810 Fixed go-run-test-current-function for go test and gocheck 2019-09-12 15:25:57 +02:00
pancho horrillo a7e27370e6 [go] Cleanup README.org
- 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>
2019-09-12 14:25:51 +02:00
pancho horrillo 4c1245e8c5 [go] Drop support for deprecated gometalinter
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
2019-09-05 20:49:43 +02:00
pancho horrillo 877f577bab [go] Update doc on LSP setup.
`gopls` is Google’s upcoming Go language server; the other implementation
mentioned in the `lsp-mode` doc¹ has been discontinued².

So, I've added the recommended procedure³ to install `gopls`.

¹: https://github.com/emacs-lsp/lsp-mode/
²: https://github.com/saibing/bingo
³: https://github.com/golang/go/wiki/gopls
2019-08-26 17:58:51 +02:00
Mathieu 272c96d855 Add Testify support for layers/+lang/go 2019-08-21 21:25:49 +02:00
Robert Zaremba d642095380 layer/+lang/go: refactore go-linter setup 2019-07-11 19:22:18 +02:00
emacspace c7c348a676 documentation formatting: Sun May 26 20:58:52 UTC 2019 2019-05-27 01:23:35 +03:00
Anton-Latukha f6660f82d4
Switch to the new layers generator 2019-05-15 21:08:21 +03:00
Anton-Latukha ba074bc908 layers: lang: new structure: general: add pure, multi-paradigm (&js) 2019-05-15 21:04:48 +03:00
JAremko 77c680160e Add placeholder tags 2019-05-05 20:40:47 +03:00
Seong Yong-ju 610ecbbf70 Add godoc installation into go layer README 2019-04-17 15:37:52 +02:00
smile13241324 350dbf6373 Move go "generate" prefix declaration to "go-gen-test" init 2019-04-07 08:43:18 +02:00
Seong Yong-ju 9941c60b5c Add missing prefixes in go-mode 2019-04-05 23:21:15 +02:00
Enze Chi 21c442050a Add go-run-args to pass command line arguments to go run
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:
2019-04-05 22:59:17 +02:00
Tim Heckman e84bd90262 Set lsp-prefer-flymake to :none when Go layer is using LSP
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>
2019-04-04 12:46:49 +02:00
Enze Chi 004d407908 Add toggle control for verbose go test output 2019-04-04 12:17:53 +02:00