8000 GitHub - jpmcb/goland.nvim: πŸΉπŸŒ™ Jetbrains GoLand intelligence language server run under a native Neovim LSP client Β· GitHub
[go: up one dir, main page]

Skip to content

About

πŸΉπŸŒ™ Jetbrains GoLand intelligence language server run under a native Neovim LSP client

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

9 stars

Watchers

1 watching

Forks

Latest commit

Β 

History

13 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
< 8000 div class="react-directory-filename-cell">
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

πŸΉπŸŒ™ goland.nvim

Runs JetBrains' GoLand language server, the engine behind the Go by GoLand extension for VS Code and Cursor, under Neovim's built-in LSP client.

Features

  • :GolandInstall downloads the public JetBrains server for your platform and verifies its checksum. Nothing from JetBrains is bundled with this plugin.
  • Starts it through vim.lsp.config() and vim.lsp.enable(), so every built-in LSP mapping and any completion plugin works as with other servers.
  • Editors opened on the same project share one server, through the lsp-router that ships with it.
  • Shows the JetBrains license agreement. The server is not started until you accept it.
  • :GolandInstall moves to the latest build, which the preview needs every month.
  • :checkhealth goland reports the bundle, the agreement and the running clients.

Requirements

  • Neovim 0.12 or newer
  • curl, unzip and tar
  • shasum or sha256sum
  • Go, with go on your PATH
  • About 800 MB of disk space for the server and 2 GB of free memory while it runs

Install

With lazy.nvim:

{
  "jpmcb/goland.nvim",
  ft = { "go", "gomod", "gowork" },
  opts = {},
}

The plugin loads when you first open a Go file, and its commands exist from then on.

Without a plugin manager, put the plugin on your runtimepath and call setup():

require("goland").setup({})

Installation is explicit. Run :GolandInstall to download the server (about 280 MB) into stdpath("data")/goland, then run :GolandEula to read the agreement and press a to accept it. Once accepted, the server attaches to Go buffers, including ones already open. Nothing is downloaded until you run :GolandInstall, unless you set auto_install yourself.

Disable gopls for Go buffers first. Two language servers on one buffer answer everything twice, and the plugin warns when it sees both attached.

vim.lsp.enable("gopls", false)

Configuration

Every option with its default:

require("goland").setup({
  -- a bundle directory or its bin/intellij-server; nil uses the downloaded one
  server_path = nil,

  -- download the server on the first Go buffer when server_path is unset
  auto_install = false,

  -- africa|americas|apac|china|europe|middle_east|oceania; nil sends none
 
A5D4
 region = nil,

  -- usage statistics sent to JetBrains: "full"|"anonymous"|"none"
  data_sharing = "none",
  
  -- extra JVM options for the server, e.g. { "-Xmx4g" }
  jvm_args = {},

  -- Go SDK to analyze with; nil lets the server find `go` on PATH
  goroot = nil,

  -- e.g. "integration,linux"
  build_tags = nil,
  
  -- e.g. { "-tags=integration" }; only -tags is read
  build_flags = nil,
  filetypes = { "go", "gomod", "gowork" },

  -- warn when a module is not in the active go.work
  workspace_check = true,

  -- merged over the generated vim.lsp.config
  lsp = {},
})

The workspace root is the first of go.work, .git and go.mod found above the file. The server imports every Go module under that root, as it does for a folder opened in VS Code. Files under GOMODCACHE or GOROOT are not projects: jumping into a dependency or the standard library reuses the server of an open project, preferring the one you came from, instead of starting a second one. To root at the nearest module instead:

opts = {
  lsp = { root_markers = { "go.work", "go.mod" } },
}

lsp takes any vim.lsp.config() field, such as on_attach, capabilities or settings. The plugin's own before_init and on_exit run before yours. lsp.cmd is not supported; use server_path instead.

Commands

Command Description
:GolandInstall Install or update the server; restarts the shared server when attached
:GolandEula Read the JetBrains license agreement; a accepts, q closes
:GolandStart Attach this editor's clients; starts a server if none runs
:GolandStop Detach this editor's clients; shared servers keep running
:GolandServerStop Stop the shared servers; requires an attached client
:GolandServerRestart Restart the shared servers; requires an attached client
:GolandUninstall Remove the server and the license acceptance; ! skips the question
:GolandLog Show the project import and build output

From Lua, require("goland") exposes .install(), .start(), .stop(), .server_stop(), .server_restart() and .uninstall().

:GolandStart and :GolandStop attach and detach every goland client in this editor, across projects, and leave the shared servers running.

The Server commands talk to the shared daemon through an attached client. When this editor is detached they warn and do nothing, so run :GolandStart first. They affect every editor on the workspace: other editors lose the old server and must restart or reopen their clients. :GolandInstall uses the same shared restart when it switches builds and a client is attached.

:GolandUninstall removes everything the plugin stored: the downloaded server in stdpath("data")/goland and the recorded license acceptance in stdpath("state")/goland. It first stops the shared servers this editor is attached to, then stays idle until you run :GolandInstall again, which also means accepting the agreement again. A server that only another editor is attached to cannot be reached, so stop it there first. The index under the JetBrains cache directory belongs to the server and is left in place.

The plugin fires a User autocommand with the pattern GolandImport when a project import ends. Its data.phase is FINISHED, CANCELLED or FAILED.

License agreement

The server is a JetBrains product with its own license, the EULA.txt inside the bundle. It refuses to start until the program that launches it passes a hash of that file, and passing the hash is the acceptance.

The plugin only passes it after you ran :GolandEula and pressed a. There is no option that accepts the agreement for you. A new build with a changed agreement asks again.

During the preview the server needs no license. JetBrains has said that licensing arrives with the 1.0 release.

Updating

Each preview build expires 30 days after its release. When that happens the server exits and the plugin tells you to run :GolandInstall, which fetches the latest build and restarts. :checkhealth goland warns when the installed build is close to that age.

How it works

:GolandInstall asks Open VSX for the latest Go by GoLand extension of your platform. That extension holds a server-bundle.json naming the matching server archive on download.jetbrains.com and its SHA-256. The plugin downloads the archive, checks it and unpacks it.

The server is then started the way the VS Code extension starts it:

bin/lsp-router --server-launcher bin/intellij-server -- --eula <hash>

lsp-router speaks LSP on stdio. It reads the workspaceId initialization option, attaches to the server that already serves that workspace, and starts one when none does. A Go file outside any project gets a private intellij-server --stdio instead.

A self-built server can pair with its own router by exporting INTELLIJ_LSP_ROUTER, as the VS Code extension allows.

The region and data sharing options reach the server as the INTELLIJ_REGION and INTELLIJ_DATA_SHARING environment variables, and jvm_args as IJ_JAVA_OPTIONS.

What Where Default path
Server bundle stdpath("data")/goland/servers/<build>/ ~/.local/share/nvim/goland/servers/271.4062.0/
Which build is current stdpath("data")/goland/current.json ~/.local/share/nvim/goland/current.json
EULA text EULA.txt inside the bundle ~/.local/share/nvim/goland/servers//EULA.txt
EULA acceptance stdpath("state")/goland/eula-accepted ~/.local/state/nvim/goland/eula-accepted

Troubleshooting

  • :checkhealth goland shows what is installed and what is running.
  • :checkhealth vim.lsp shows whether the goland client attached, and where the LSP log is when it did not start.
  • :GolandLog shows why a project import failed.
  • If a checkout is not listed in the active go.work, the plugin warns that the server will index the workspace's other modules instead. Update the workspace, or start Neovim with GOWORK=off for a standalone checkout. Set workspace_check = false to silence it.
  • The server keeps its index under ~/Library/Caches/JetBrains on macOS and ~/.cache/JetBrains on Linux.

Contributing

See the contributing guide for the development environment, checks, tests, and pull request guidance.

Related

About

πŸΉπŸŒ™ Jetbrains GoLand intelligence language server run under a native Neovim LSP client

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

9 stars

Watchers

1 watching

Forks

Releases

Contributors

Languages

0