ionide / tree-sitter-fsharp

F# grammar for treesitter
MIT License
81 stars 18 forks source link

Possibly Incorrect Path for F# Parser in Readme #89

Open caelchristian opened 1 week ago

caelchristian commented 1 week ago

I'm not sure if others have had this problem when installing this grammar or if I did not read the install instructions correctly.

With the default code config (same as in the readme), I got the following errors after running :TSInstall fsharp

local parser_config = require('nvim-treesitter.parsers').get_parser_configs()
parser_config.fsharp = {
  install_info = {
    url = 'https://github.com/ionide/tree-sitter-fsharp',
    branch = 'main',
    files = { 'src/scanner.c', 'src/parser.c' },
    location = "fsharp"
  },
  requires_generate_from_grammar = false,
  filetype = 'fsharp',
}
nvim-treesitter[fsharp]: Error during compilation
clang: error: no such file or directory: 'src/parser.c'
clang: error: no such file or directory: 'src/scanner.c'
clang: error: no input files

Once I checked the file structure I figured out I had to add fsharp to the beginning of the path for scanner and parser files: 'fsharp/src/scanner.c' and 'fsharp/src/parser.c'.

Is this something particular about this code tree compared to other custom grammars? I just wanted to point this out to anyone who might also have this issue.

As I try to reproduce this error I am getting the following (which I wish I had the time to further debug):

nvim-treesitter[fsharp]: Error during compilation
In file included from fsharp/src/scanner.c:1:
fsharp/src/../../common/scanner.h:4:10: fatal error: 'tree_sitter/alloc.h' file not found
#include "tree_sitter/alloc.h"
         ^~~~~~~~~~~~~~~~~~~~~
1 error generated.

Here is my full plugins/init.lua config:

return {
  {
    "stevearc/conform.nvim",
    opts = require "configs.conform",
  },
  -- nvim-lspconfig
  {
    "neovim/nvim-lspconfig",
    config = function()
      require "configs.lspconfig"
    end,
  },
  -- mason
  {
    "williamboman/mason.nvim",
    config = function()
      require("mason").setup()
    end,
  },
  -- mason-lspconfig
  {
    "williamboman/mason-lspconfig.nvim",
    config = function()
      require("mason-lspconfig").setup {
        ensure_installed = { "fsautocomplete" },
      }
    end,
  },
  -- nvim-treesitter
  {
    "nvim-treesitter/nvim-treesitter",
    opts = {
      ensure_installed = {
        "vim",
        "lua",
        "html",
        "css",
      },
      highlight = {
        enable = true,
      },
      parser_install_dir = "~/.config/nvim/treesitter-parsers",
    },
    config = function()
      local parser_config = require('nvim-treesitter.parsers').get_parser_configs()
      parser_config.fsharp = {
        install_info = {
          url = "~/projects/tree-sitter-fsharp",
          files = { "fsharp/src/parser.c", "fsharp/src/scanner.c" },
          branch = "main",
          generate_requires_npm = false,
          requires_generate_from_grammar = false,
          includes = { "fsharp/src/tree_sitter" }
        },
        filetype = "fsharp",
      }
      require'nvim-treesitter.configs'.setup {
        ensure_installed = { "fsharp" },
        highlight = {
          enable = true,
          additional_vim_regex_highlighting = false,
        },
      }
    end,
    build = ":TSUpdate",
  },
}

Huge thanks to the maintainers of this grammar <3

M1 Macbook Air on Somoma 14.5 Repo commit number 711d8f9 Editor: Nvchad/NVIM v0.10.1 Release Up to date treesitter nvim plugin and cli

Nsidorenco commented 1 week ago

Hi, Thanks for reporting šŸ™šŸ»

What is your version of nvim-treesitter? I'm unable to reproduce this error when installing the grammar on the latest version of nvim-treesitter.