Skip to content

Commit

Permalink
3379 lsp config documentation and gowork 2 (#3397)
Browse files Browse the repository at this point in the history
* chore(3379): added go.work and go.work.sum to .gitignore

* chore(3379): updated readme
  • Loading branch information
kaanyalti authored Mar 25, 2024
1 parent 85bcc6a commit e19e701
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 1 deletion.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ dev-tools/cloud/terraform/.terraform
dev-tools/cloud/terraform/terraform.tfstate*
dev-tools/cloud/terraform/*.tfvars*

go.work
go.work.sum

# editor swap files
*.swp
*.swo
Expand All @@ -28,4 +31,4 @@ dev-tools/cloud/terraform/*.tfvars*


# direnv
.envrc*
.envrc*
74 changes: 74 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,80 @@ The following are notes to help developers onboarding to the project to quickly

When developing features for Fleet, it may become necessary to run both Fleet Server and Kibana from source in order to implement features end-to-end. To faciliate this, we've created a separate guide hosted [here](https://github.com/elastic/kibana/blob/main/x-pack/plugins/fleet/dev_docs/developing_kibana_and_fleet_server.md).

## IDE config

When using the gopls language server you may run into the following errors in
the `testing` package:

```bash
error while importing github.com/elastic/fleet-server/testing/e2e/scaffold: build constraints exclude all Go files in <path to fleet-server>/fleet-server/testing/e2e/scaffold
```
```bash
/<path to fleet-server>/fleet-server/testing/e2e/agent_install_test.go.
This file may be excluded due to its build tags; try adding "-tags=<build tag>" to your gopls "buildFlags" configuration
See the documentation for more information on working with build tags:
https://github.com/golang/tools/blob/master/gopls/doc/settings.md#buildflags-string
```
In order to resolve the first issue you can add a `go.work` file to the root of
this repo. Copy and paste the following into `go.work`:
```go
go 1.21

use (
.
./testing
./pkg/api
)

```
Solution for the second error depends on the ide and the package manager you are using.
### neovim
#### lazyvim package manager
##### nvim-lspconfig plugin
Add the following to your config files
```lua
{
"neovim/nvim-lspconfig",
opts = {
servers = {
gopls = {
settings = {
gopls = {
buildFlags = { "-tags=e2e integration cloude2e" },
},
},
},
},
},
}
```
After these changes if you are still running into issues with code suggestions,
autocomplete, you may have to clear your go mod cache and restart your lsp
clients.
Run the following command to clear your go mod cache
```bash
go clean -modcache
```
restart your vim session and run the following command to restart your lsp
clients
```vim
:LspRestart
```
### Changelog
The changelog for fleet-server is generated and maintained using the [elastic-agent-changelog-tool](https://github.com/elastic/elastic-agent-changelog-tool).
Expand Down

0 comments on commit e19e701

Please sign in to comment.