vala-lang / vala-language-server

Code Intelligence for Vala & Genie
GNU Lesser General Public License v2.1
287 stars 41 forks source link
coc genie gnome language-server neovim vala vim vls vscode

Vala Language Server

This is a language server for the Vala programming language.

Installation

We recommend using VSCode with the Vala plugin.

...and more. See below:

Packaging status

VLS with VSCode VLS with Vim with coc.nvim and vista plugins VLS with GNOME Builder

Table of Contents

Features

Dependencies

Install dependencies with Guix

If you're using Guix, to launch a shell with build dependencies satisfied:

guix environment vala-language-server

Building from Source

meson -Dprefix=/usr build
ninja -C build
sudo ninja -C build install

This will install vala-language-server to /usr/bin

Editors

An important note: VLS cannot know what arguments are used for the file you are editing unless it can locate a build script, compile commands list, or shebang to analyze. (This is generally true for most language servers of compiled languages.) Before making an issue, check whether you have a build script or shebang for your file.

vim and neovim

coc.nvim

  1. Make sure coc.nvim is installed.
  2. After successful installation, in Vim run :CocConfig and add a new entry for VLS to the languageserver property like below:
{
    "languageserver": {
        "vala": {
            "command": "vala-language-server",
            "filetypes": ["vala", "genie"]
        }
    }
}

vim-lsp

  1. Make sure vim-lsp is installed
  2. Add the following to your .vimrc:
if executable('vala-language-server')
  au User lsp_setup call lsp#register_server({
        \ 'name': 'vala-language-server',
        \ 'cmd': {server_info->[&shell, &shellcmdflag, 'vala-language-server']},
        \ 'whitelist': ['vala', 'genie'],
        \ })
endif

nvim-lspconfig

require'lspconfig'.vala_ls.setup {
  -- defaults, no need to specify these
  cmd = { "vala-language-server" },
  filetypes = { "vala", "genie" },
  root_dir = root_pattern("meson.build", ".git"),
  single_file_support = true,
}

Visual Studio Code

GNOME Builder

Kate

Emacs

Sublime Text

Specifying dependencies

If you're using meson, vala-language-server will automatically detect the packages you depend on.

If you just want to write a quick script without a build system, you can add a shebang line to the top of your .vala file:

#!/usr/bin/env -S vala --pkg gtk4

Contributing

Want to help out? Here are some helpful resources: