The PRs for nvim-lspconfig and mason-lspconfig.nvim are merged as well.
This means the Motoko-LSP can be installed in Neovim from the standard registries.
LSP
If you use something like kickstart.nvim for your configuration, you just have to add motko_lsp = {}
to your list of LSPs and register the filetype motoko:
-- init.lua
-- [...]
-- Enable the following language servers
-- Feel free to add/remove any LSPs that you want here. They will automatically be installed.
-- [..]
local servers = {
motoko_lsp = {}
}
-- [...]
vim.filetype.add { extension = { mo = 'motoko' } }
Formatter and syntax highlighting are not included in the above setup.
Formatter
I currently use conform with the prettier plugin (which is also used in the VSCode extension). I have prettier with the plugin installed globally, not sure if that is required or not.
{ -- Autoformat
'stevearc/conform.nvim',
lazy = false,
keys = {
{
'<leader>=',
function()
require('conform').format { async = true, lsp_fallback = false }
end,
mode = '',
desc = 'Format buffer',
},
},
opts = {
-- [...]
formatters_by_ft = {
-- [...]
motoko = { 'prettier' },
},
formatters = {
prettier = {
prepend_args = function(self, ctx)
return { '--plugin', 'prettier-plugin-motoko' }
end,
},
},
},
},
Syntax highlighting
The syntax file linked by @quint above could be a quick way to get started (Btw. thanks for the reply. It’s nice to know someone is interested in this as well).
I’m currently using tree-sitter with the grammar from polychromatist/tree-sitter-motoko, compiled locally. The next step is to make this easier to install and probably also update the grammar to support the newer Motoko features.