Awesome
⚠️ Warning (Please read this first) ⚠️
OFFICIAL EFFORTS ARE NOW LOCATED AT: https://github.com/vlang/v-analyzer
🔺 🔺 🔺 🔺 🔺 🔺 🔺 🔺 🔺 🔺 🔺 🔺 🔺 🔺 🔺 🔺 🔺 🔺 🔺 🔺 🔺 🔺 🔺 🔺 🔺 🔺 🔺 🔺 🔺 🔺 🔺 🔺 🔺 🔺 🔺 🔺 🔺 🔺 🔺 🔺 🔺 🔺 🔺 🔺
V Language Server
V Language Server (also known as "VLS") is a LSP v3.15-compatible language server for the V programming language.
Installation
You can get the V language server on a variety of methods.
Via V CLI (Recommended)
Starting with V 0.3.1, you can now install and update VLS via the V CLI by simply executing the following command:
v ls --install
Pre-built/Precompiled Binaries
Pre-built binaries for Windows (x64), MacOS (x64/M1), and Linux (x64) can be found here.
VSCode
The official V VSCode extension provides built-in support for VLS. To install VLS, go to the V section of your editor's settings and check the "Enable VLS" setting. This will look for any existing installation of VLS and will download a copy if there's none.
If you want to use an existing copy of VLS, please refer to this guide.
Build from Source
NOTE: TCC, the default compiler shipped with V, is not recommended ATM due to some issues in the Tree Sitter's output.
To build the language server from source, you need to have the following:
NOTE: If you are downloading V from Homebrew and other community-maintained packages, please do
v up
first before proceeding.
Afterwards, open your operating system's terminal and execute the following:
## Clone the project:
git clone https://github.com/vlang/vls && cd vls
## Build the project
## Use "v run build.vsh gcc" if you're compiling VLS with GCC.
v run build.vsh clang
# The binary will be created in the `bin` directory inside the vls folder.
Usage
To use the language server, you need to have an editor with LSP support. See this link for a full list of supported editors.
VSCode, VSCodium, and other derivatives
GitHub Web Editor and VSCode Online are not supported yet at this moment. See this issue comment.
For Visual Studio Code and other derivatives, all you need to do is to install 0.1.4 or above versions of the V VSCode extension. Afterwards, go to settings and scroll to the V extension section. From there, enable VLS by checking the "Enable VLS" box.
If you have VLS downloaded in a custom directory, you need to input the absolute path of the vls
language server executable to the "Custom Path" setting. If you cloned the repository and compiled it from source, the executable will be in the vls
root directory. So make sure to add vls/bin/vls
or vls/bin/vls.exe
(for Windows).
Sublime Text (3 and 4)
For Sublime Text, please install the LSP extension via Package Control. Afterwards, open the command palette, select Preferences: LSP Settings
, and add the following configuration:
{
"clients": {
"vls": {
"enabled": true,
"command": ["v", "ls", "--socket"], // or ["<path-to-vls>", "--socket"] if you downloaded / compiled it manually
"tcp_port": 5007,
"selector": "source.v"
}
}
}
Be sure to install the Sublime V Plugin first in order for the language server to start properly.
NeoVim
For NeoVim, install nvim-lspconfig and install vls on your system.
Then, you open your lsp configuration and add the following to enable the usage of the vls require('lspconfig').vls.setup{}
.
Afterwards, just paste the following line into your neovim configuration vim.cmd([[au BufNewFile,BufRead *.v set filetype=vlang]])
.
Vim
For Vim, please install vim-lsp and vim-lsp-settings. Afterwards, open any .v
file, and execute :LspInstallServer
.
Panic Nova
See the VLS extension for detailed instructions on how to install VLS on Panic Nova.
IntelliJ IDEA, GoLand, and other derivatives
VLS on JetBrains / IntelliJ-based IDEs does not work at this moment. See issue 52 for more details.
You can use IntelliJ V plugin instead: https://intellij-v.github.io
Other Editors
For other editors, please refer to the plugin's/editor's documentation for instructions on how to setup an LSP server connection.
Crash Reports
VLS generates a report and notifies the user by default when something is wrong. These crash reports are accessible which can be found inside C:\Users\<user_name\.vls\reports
for Windows and ~/.vls/reports
for both Linux and MacOS. The contents of the file can be then pasted into the issue tracker form.
Bugs that are not crashes however can still generate reports by passing the --generate-report
flag to the language server CLI.
Logging
VLS provides a log file (${workspacePath}/vls.log
) for debugging the language server incoming requests and outgoing responses / notifications. By default, this can only be saved and accessed on server crash. To save the log on every exit, pass the --debug
flag to the language server CLI.
Frequently Asked Questions
What is a language server?
A language server is a software that understands the code provided by the user and provides information to supported text editors and IDEs. Think of it as a compiler that does not emit an executable but a format that your text editor can use in order for you to work on a project better and faster.
Some of the commonly used features such as autocompletion / IntelliSense, go to definition, and diagnostics are directly handled by the language server itself and not by the dedicated language extensions.
What does it support?
Currently, VLS supports the following language features:
Feature Name | Supported? | Notes |
---|---|---|
Diagnostics | ✅ | Via v -check |
Completion | ✅ | Needs polish |
Hover | ✅ | |
Signature Help | ✅ | |
Go to Declaration | ❌ | |
Go to Definition | ✅ | |
Go to Implementation | ✅ | Limited to interfaces for now. |
References | ❌ | |
Document Highlight | ❌ | |
Code Lens | ✅ | Stub implementation |
Code Action | ❌ | |
Document Symbol / Outline | ✅ | |
Workspace Symbols | ✅ | Limited to opened documents. |
Document Link | ✅ | Stub implementation |
Formatting | ✅ | Via v fmt |
Range Formatting | ❌ | |
Type Formatting | ❌ | |
Rename | ❌ | |
Folding Range | ✅ |
For a full list of features/methods VLS supports, see CAPABILITIES.md.
Contributing
Submitting a pull request
- Fork it (https://github.com/vlang/vls/fork)
- Create your feature branch (git checkout -b my-new-feature)
- Commit your changes (git commit -am 'Add some feature')
- Push to the branch (git push origin my-new-feature)
- Create a new Pull Request
Contributors
- nedpals - creator and maintainer
- danieldaeschle - maintainer
- hungrybluedev - contributor
- streaksu - contributor
- ylluminarious - contributor
- yuyi98 - contributor