DAML for Neovim

Hi! I built a Neovim plugin for DAML: https://github.com/Sengoku11/daml.nvim

It’s easy to install and comes with:

  • LSP setup (diagnostics, autocompletion, go-to, hover, etc.)
  • Syntax highlighting (reuses Haskell grammar)
  • Filetype detection out of the box

Install is simple (e.g., via lazy.nvim):

{
  'Sengoku11/daml.nvim',
  ft = 'daml',
  opts = {},
  dependencies = {
    'nvim-treesitter/nvim-treesitter',
    'saghen/blink.cmp',
  },
}

Feedback and PRs welcome!

P.S. Here are some screenshots using daml-finance tutorials source.

Autocompletion:

Error checking:

3 Likes

That’s neat, thanks for the contribution to the ecosystem!

I’d recommend also posting on the GSF app dev Slack channel: #gsf-global-synchronizer-appdev

2 Likes

Thank you, @Batyr!

I needed to add an init function to my treesitter.lua plugin as follows:

EDIT: see later in the thread

return {
  {
    "nvim-treesitter/nvim-treesitter",
    build = ":TSUpdate",

    init = function()
      vim.treesitter.language.register('haskell', 'daml')
      vim.api.nvim_create_autocmd("FileType", {
        pattern = "daml",
        callback = function()
          vim.treesitter.start()
        end,
      })
    end,

    opts = {
      ensure_installed = { 
        "lua", "vim", "vimdoc", "query", 
        "javascript", "python", "scala",
        "haskell"
      },
      highlight = { enable = true },
      indent = { enable = true },
    },
  },
}

Did you find that you need a similar init function? Without it, I was not getting the color highlighting. But I’m wondering if that indicates I had something else wrong.

Hi @WallaceKelly , looks like the plugin wasn’t initialized properly. How do you install it? Also could be issue with a treesitter, did it work with other languages before?

Normally it should map automatically, and add extra syntax to highlighting (you mapped it directly so should miss some highlights on keywords like ensure, nonconsuming, etc.).

Here is my treesitter config: kickstart.nvim/lua/plugins/coding/treesitter.lua at 593d3006fc9ae11b8637adb9767ff407e71aff5a · Sengoku11/kickstart.nvim · GitHub

You are right, @Batyr. The init function in my previous post is not correct. I’ve moved this discussion to a GitHub issue.

1 Like

Hi @WallaceKelly, thanks for the heads-up! I hope my answers there were comprehensive, but let me know if anything doesn’t work on your end.

1 Like