Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possibly Incorrect Path for F# Parser in Readme #89

Open
caelchristian opened this issue Sep 2, 2024 · 1 comment
Open

Possibly Incorrect Path for F# Parser in Readme #89

caelchristian opened this issue Sep 2, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@caelchristian
Copy link

caelchristian commented Sep 2, 2024

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

@caelchristian caelchristian added the bug Something isn't working label Sep 2, 2024
@Nsidorenco
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants