Skip to content

The @vlang language server, for all your editing needs like go-to-definition, code completion, type hints, and more.

License

Notifications You must be signed in to change notification settings

vlang/v-analyzer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

v-analyzer

Bring IDE features for the V programming language to VS Code, Vim, and other editors.

The features provided by v-analyzer include:

  • code completion/IntelliSense
  • go to definition, type definition
  • find all references, document symbol, symbol renaming
  • types and documentation on hover
  • inlay hints for types and some construction like or block
  • semantic syntax highlighting
  • formatting
  • signature help

Installation

Linux, macOS, Windows

Note: the following command will download install.vsh to the current directory, then run it, and then delete it. If there is a pre-existing file with this name, make sure it is safe, when it is overwritten/deleted, or change the current directory (the script itself can be run from anywhere).

v download -RD https://raw.githubusercontent.com/vlang/v-analyzer/main/install.vsh

Pre-built binaries

You can download pre-built binaries from the release page. Currently, we provide binaries for Linux (x64), macOS (x64 and ARM), and Windows (x64).

Building from source

Note

This repository uses Git submodules. In practice, this means that you either have to:

git clone --filter=blob:none --recursive --shallow-submodules https://github.com/vlang/v-analyzer

... or, if you used just git clone https://github.com/vlang/v-analyzer, you can execute below inside your local v-analyzer clone:

git submodule init && git submodule update

If you do not do either, the symptom is that when you try to build v-analyzer, you will get a C compiler message, about lib.c not found

Tip

On Windows, use GCC for building, as TCC can run into some issues.

Update V to the latest version:

v up

You can build a debug or release version of the binary. The debug version will be slower, but faster to compile.

v build.vsh debug
v build.vsh release

The compiled binary will be located in the bin/ folder.

Setup

Add the bin/ folder to your $PATH environment variable to make the v-analyzer command easily accessible.

You can also specify the path to the binary in your VS Code settings:

{
	"v-analyzer.serverPath": "/path/to/v-analyzer/bin/v-analyzer"
}

Note Restart VS Code after changing the settings or PATH.

Config

v-analyzer is configured using global or local config. The global config is located in ~/.config/v-analyzer/config.toml, changing it will affect all projects.

A local config can be created with the v-analyzer init command at the root of the project. Once created, it will be in ./.v-analyzer/config.toml. Each setting in the config has a detailed description.

Pay attention to the custom_vroot setting, if v-analyzer cannot find where V was installed, then you will need to specify the path to it manually in this field.

Updating

To update v-analyzer to the latest version, run:

v-analyzer up

You can also update to a nightly version:

v-analyzer up --nightly

Note In the nightly version you will get the latest changes, but they may not be stable!

VS Code extension

The VS Code extension is available via the VS Code Marketplace. The source code for extension is contained in the editors/code folder of this repository.

NVIM LSP / Mason

For Neovim users, v-analyzer is available via nvim-lspconfig plugin. It is part of the mason registry and could be installed with both Neovim plugins:

Authors

  • jsonrpc, lsp, tree_sitter_v modules written initially by VLS authors and after that in 2023 it was modified by the VOSCA.

Thanks

License

This project is under the MIT License. The full license text can be found in the LICENSE file.