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

Hey everyone! If you’ve migrated from the default Daml assistant to dpm, you’ll need to pass this specific cmd override in your opts:

{
  ‘Sengoku11/daml.nvim’,
  ft = ‘daml’,
  opts = {
    lsp = {
      cmd = { ‘dpm’, ‘damlc’, ‘multi-ide’ }, -- override daml assistant with dpm
    },
  },
}

Also, please make sure are updated to the latest version of the plugin!

2 Likes

daml.nvim now supports Script Results directly in the IDE!

It works exactly like in VS Code, except I tweaked the rendering (HTML → Markdown) so it fits your terminal perfectly. You can have instant results faster than ever, check this out!

3 Likes