Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

3379 lsp config documentation and gowork 2 #3397

Merged
merged 2 commits into from
Mar 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading