Skip to content

v0.5.0

Choose a tag to compare

@nmfirdausw nmfirdausw released this 20 Oct 06:18
· 19 commits to main since this release
1535ddc

What's Changed

Features

LSP

  • Add language server setup with inlay hints, code lenses and toggle keymaps by @nmfirdausw in #5

Highlights

  • Language servers. A new lsp option enables servers through Neovim's native vim.lsp.config() and vim.lsp.enable().
  • Bring your own configs. Use nvim-lspconfig, which Batu can install for you, or write your own in lsp/<name>.lua.
  • Inlay hints and code lenses. Each turns on in buffers whose server supports it.
  • Toggle keymaps. grh and grl toggle inlay hints and code lenses per buffer.
  • Native. Batu installs no servers and adds no dependencies beyond the optional nvim-lspconfig.

Usage

require("batu").setup({
  lsp = {
    lspconfig = true,
    servers = {
      lua_ls = true,                                             -- use the config Neovim finds
      gopls = { settings = { gopls = { staticcheck = true } } }, -- merge on top of it
      pyright = false,                                           -- skip
    },
    inlay_hints = true,
    codelens = true,
  },
})
Option Value Effect
lsp false (default) Do nothing
a table Set up language servers with the options below
lsp.lspconfig false (default) Leave server configs to you, in lsp/<name>.lua
true Install and load nvim-lspconfig with vim.pack
lsp.servers a table Servers to enable, by name. true uses the config Neovim finds, a table is merged on top of it, false skips the server
lsp.inlay_hints false (default) Don't enable inlay hints
true Enable them where the server supports it
lsp.codelens false (default) Don't enable code lenses
true Enable them where the server supports it
lsp.keymaps true (default) Set the toggle keymaps below
false Set none

Keymaps

Mode Key Action
n grh Toggle inlay hints in the buffer
n grl Toggle code lenses in the buffer

Both are set only in buffers whose server supports the feature. Neither clashes with Neovim's own gr* maps, and grx still runs the code lens on the current line.

How it works

Batu enables a feature when the server attaches, after checking that the server supports it. A server table such as lua_ls = require("lsp.lua_ls") is passed to vim.lsp.config() and then enabled.

Batu sets no diagnostic config, which is left for a later release.

Upgrading

Nothing changes for existing configs. lsp is off by default, so setup() does not enable any server or set any keymap until you pass an lsp table.

Full Changelog: v0.4.0...v0.5.0