Giter VIP home page Giter VIP logo

Comments (7)

clason avatar clason commented on June 16, 2024

You probably have the parser open in a different Neovim instance, in which case Windows locks it. We have fixed that on main but will not make any changes on master.

Make sure to close all Neovim instances, manually clear out the target dir, and try again.

from nvim-treesitter.

cjhillbrand avatar cjhillbrand commented on June 16, 2024

Thanks for the help on this issue and the previous issue @clason!
Closed down all my windows and went in and manually removed the old so. Opening nvim and running TSInstall PowerShell resulted in the successful install of the PowerShell parser.

When running:
:checkhealth nvim-treesitter I get the following results:

Check health results.
nvim-treesitter: require("nvim-treesitter.health").check()

Installation ~
- OK `tree-sitter` found 0.22.6 (b40f342067a89cd6331bf4c27407588320f3c263) (parser generator, only needed for :TSInstallFromGrammar)
- OK `node` found v20.13.1 (only needed for :TSInstallFromGrammar)
- OK `git` executable found.
- OK `zig` executable found. Selected from { "zig" }
  Version: info: Usage: zig [command] [options]
- OK Neovim was compiled with tree-sitter runtime ABI version 14 (required >=13). Parsers must be compatible with runtime ABI.

OS Info:
{
  machine = "x86_64",
  release = "10.0.22631",
  sysname = "Windows_NT",
  version = "Windows 11 Enterprise"
} ~

Parser/Features         H L F I J
  - c                   ✓ ✓ ✓ ✓ ✓
  - c_sharp             ✓ ✓ ✓ . ✓
  - gitcommit           ✓ . . . ✓
  - gitignore           ✓ . . . .
  - java                ✓ ✓ ✓ ✓ ✓
  - javascript          ✓ ✓ ✓ ✓ ✓
  - json                ✓ ✓ ✓ ✓ .
  - jsonc               ✓ ✓ ✓ ✓ ✓
  - lua                 ✓ ✓ ✓ ✓ ✓
  - markdown            ✓ . ✓ ✓ ✓
  - powershell          . . . . .
  - query               ✓ ✓ ✓ ✓ ✓
  - sql                 ✓ . . ✓ ✓
  - vim                 ✓ ✓ ✓ . ✓
  - vimdoc              ✓ . . . ✓
  - xml                 ✓ ✓ ✓ ✓ ✓
  - yaml                ✓ ✓ ✓ ✓ ✓

  Legend: H[ighlight], L[ocals], F[olds], I[ndents], In[j]ections
         +) multiple parsers found, only one will be used
         x) errors found in the query, try to run :TSUpdate {lang} ~

The only issue is that PowerShell has no features installed :(. As well when opening a ps1 file (checked w/ echo &filetype) no advanced highlighting is provided.
I understand that this is now technically a separate issue, so please let me know if I should create a new issue. Although Im hoping to still get a little bit of help on how I can further debug this.

Im reading through this section of documentation. My interpretation is that since the so is generated and installed the config for the parser is more or less correct. Although there is a section on queries but I couldn't piece together exactly how to investigate the queries files to see if this could be causing my issues.

So my main question - why does the plugin not recognize the highlighting capabilities of the powershell parser.

from nvim-treesitter.

clason avatar clason commented on June 16, 2024

Yes, obviously you need to put the corresponding queries on runtimepath. The parser is useless without them.

from nvim-treesitter.

cjhillbrand avatar cjhillbrand commented on June 16, 2024

Ah I am still fairly new to treesitter so unfortunately that wasn't obvious to me :( But I'm glad it was obvious to you, as it let me try some things out!

So I couldn't find where nvim-treesitter downloads the source from the remote url, so I went ahead and cloned directly into my data folder, re-installed to make sure parser is generated and copied over appropriately, and finally added the queries to the runtime path.

Here is my updated configuration:

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

-- This requires the manual cloning of the repo here: https://github.com/airbus-cert/tree-sitter-powershell
local data_path = vim.fn.stdpath("data")
local ps_location = data_path .. "\\tree-sitter-powershell"

parser_config.powershell = {
    install_info = {
        url = ps_location,
        branch = "main",
        files = { "src/parser.c", "src/scanner.c" }
    },
    filetype = "ps1",
    used_by = { "psm1", "psd1", "pssc", "psxml", "cdxml" }
}

vim.opt.runtimepath:append(ps_location .. "\\queries")

Checking my runtime path shows that the path is added appropriately:
:lua print(vim.inspect(vim.api.nvim_list_runtime_paths()))

{
    "C:\\Users\\cjhillbrand.NORTHAMERICA\\AppData\\Local\\nvim",
    ...
    ...
    "C:\\Users\\cjhillbrand.NORTHAMERICA\\AppData\\Local\\nvim\\after",
    "C:\\Users\\cjhillbrand.NORTHAMERICA\\AppData\\Local\\nvim-data\\tree-sitter-powershell\\queries"
}

Contents of the directory tree-sitter-powrshell\queries directory:

PS C:\Users\cjhillbrand.NORTHAMERICA\AppData\Local\nvim-data\tree-sitter-powershell> ls .\queries\

    Directory: C:\Users\cjhillbrand.NORTHAMERICA\AppData\Local\nvim-data\tree-sitter-powershell\queries

Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
-a---           5/18/2024 11:33 AM           2346 highlights.scm

I went ahead and closed nvim, reopened and ran TSUpdate, TSUpdate powershell, and finally ran checkhealth nvim-treesitter the features for powershell still show nothing present, as well no highlighting is available when opening a ps1 script.

Check health for tree sitter output.
nvim-treesitter: require("nvim-treesitter.health").check()

Installation ~
- OK `tree-sitter` found 0.22.6 (b40f342067a89cd6331bf4c27407588320f3c263) (parser generator, only needed for :TSInstallFromGrammar)
- OK `node` found v20.13.1 (only needed for :TSInstallFromGrammar)
- OK `git` executable found.
- OK `zig` executable found. Selected from { "zig" }
  Version: info: Usage: zig [command] [options]
- OK Neovim was compiled with tree-sitter runtime ABI version 14 (required >=13). Parsers must be compatible with runtime ABI.

OS Info:
{
  machine = "x86_64",
  release = "10.0.22631",
  sysname = "Windows_NT",
  version = "Windows 11 Enterprise"
} ~

Parser/Features         H L F I J
  - c                   ✓ ✓ ✓ ✓ ✓
  - c_sharp             ✓ ✓ ✓ . ✓
  - gitcommit           ✓ . . . ✓
  - gitignore           ✓ . . . .
  - java                ✓ ✓ ✓ ✓ ✓
  - javascript          ✓ ✓ ✓ ✓ ✓
  - json                ✓ ✓ ✓ ✓ .
  - jsonc               ✓ ✓ ✓ ✓ ✓
  - lua                 ✓ ✓ ✓ ✓ ✓
  - markdown            ✓ . ✓ ✓ ✓
  - powershell          . . . . .
  - query               ✓ ✓ ✓ ✓ ✓
  - sql                 ✓ . . ✓ ✓
  - vim                 ✓ ✓ ✓ . ✓
  - vimdoc              ✓ . . . ✓
  - xml                 ✓ ✓ ✓ ✓ ✓
  - yaml                ✓ ✓ ✓ ✓ ✓

  Legend: H[ighlight], L[ocals], F[olds], I[ndents], In[j]ections
         +) multiple parsers found, only one will be used
         x) errors found in the query, try to run :TSUpdate {lang} ~

I read all the query definitions get combined at runtime, but im curious if there is a way to check if the query defined in this new/custom runtime path is being considered by the plugin? Would you happen to have any suggestions on how to check that. Or do you suspect the .scm file is being loaded, but something else may be amiss.

Thanks again for all of the help so far!

from nvim-treesitter.

clason avatar clason commented on June 16, 2024

Queries are not downloaded as these are editor specific; you will need to provide your own.

The parser table only concerns the parser itself.

from nvim-treesitter.

cjhillbrand avatar cjhillbrand commented on June 16, 2024

I noticed that, so I downloaded the github repo of the PowerShell parser which contained an additional highlights.scm file, and added this to the vim runtime path.

Assuming the plugin now has visibility to the PowerShell-specific queries, Im lost on what the missing link here is. Parser is installed, queries are visible, what else is required?

from nvim-treesitter.

clason avatar clason commented on June 16, 2024

First, upstream queries are not (guaranteed to be) compatible with Neovim; the queries in this repo are hand-crafted specifically for Neovim.

Second, queries are expected in a specific place (like parsers): queries/powershell/highlights.scm etc. -- the queries directory is the one that must be in runtimepath.

from nvim-treesitter.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.