tree-sitter / tree-sitter-haskell

Haskell grammar for tree-sitter.
MIT License
152 stars 36 forks source link

`undefined symbol: tree_sitter_haskell_external_scanner_create` #43

Closed ocharles closed 3 years ago

ocharles commented 3 years ago

I think I've followed instructions correctly:

Now, when I open a Haskell file, I get:

E5108: Error executing lua Failed to load parser: uv_dlopen: /home/ollie/.local/share/nvim/site/pack/packer/start/nvim-treesitter/parser/haskell.so: undefined symbol: tree_sitter_haskell_external_scanner_create

I'm not really sure what's up at this point. The generated .so certainly has tree_sitter_haskell_external_scanner_create when I lookup strings haskell.so

ocharles commented 3 years ago

Ok, I think I got this working. I needed:

local parser_config = require "nvim-treesitter.parsers".get_parser_configs()

parser_config.haskell = {
  install_info = {
    url = "~/work/tree-sitter-haskell", -- local path or git repo
    files = {"src/parser.c", "src/scanner.cc"}
  },
  filetype = "haskell"
}

require'nvim-treesitter.configs'.setup {
  highlight = {
    enable = true,
    -- custom_captures = {
    --   -- Highlight the @foo.bar capture group with the "Identifier" highlight group.
    --   ["foo.bar"] = "Identifier",
    -- },
    -- Setting this to true will run `:h syntax` and tree-sitter at the same time.
    -- Set this to `true` if you depend on 'syntax' being enabled (like for indentation).
    -- Using this option may slow down your editor, and you may see some duplicate highlights.
    -- Instead of true it can also be a list of languages
    additional_vim_regex_highlighting = false,
  },
}

require'nvim-treesitter.install'.compilers = { "clang++" }

What I missed was:

  1. Mentioning 'scanner.cc'
  2. Setting compilers = { "clang++" }
tek commented 3 years ago

I'll add the nvim config snippet to the readme.

ocharles commented 3 years ago

Great idea!

tek commented 3 years ago

wait, you had to set clang++? did it not work with clang?

ocharles commented 3 years ago

No, clang didn't work. I ran into this:

nvim-treesitter[haskell]: Error during compilation                                                                                                                                                                                                             
src/scanner.cc:2:10: fatal error: 'vector' file not found                                                                                                                                                                                                      
#include <vector>                                                                                                                                                                                                                                              
         ^~~~~~~~                                                                                                                                                                                                                                              
1 error generated.

This goes away if I use clang++.

tek commented 3 years ago

added this as well :+1: