FYI: simple lsp setup in LazyNvim

Just for reference setting up the Mojo Language Server in LazyVim is as trivial as creating a file in the lua/plugins folder, for example mojo,lua, with the following content

-- Load the LSP.
require("lspconfig").mojo.setup({})

I have also collected some good error format strings for mixed Python/Mojo projects: init.lua/lua/local/error_formats.lua at main · winding-lines/init.lua · GitHub

I am using these with an async runner and parsing in the quick fix list. My mojo.lua file that puts them all together is here: init.lua/lua/plugins/mojo.lua at main · winding-lines/init.lua · GitHub

This is my first neovim lua project and Claude.ai wrote a bunch of this so the code may not be idiomatic but seems to work.

I hope this helps,

Marius

2 Likes

It turns out you can also pass cli arguments. In the mini projects I’ve used so far the LSP was not doing well in tests but passing the current working directory as an include dir solved the problem.

require("lspconfig").mojo.setup({ cmd = { "mojo-lsp-server", "-I", "." } })