Comments (7)
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.
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.
Yes, obviously you need to put the corresponding queries on runtimepath. The parser is useless without them.
from nvim-treesitter.
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.
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.
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.
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)
- Opening multiple files with -p with nightly neovim has different tabstop & expandtab values on second tab HOT 2
- `Makefile` highlighting some values and arguments as text HOT 8
- Bug: vim.tbl_flatten is deprecated in latest Neovim HOT 4
- Issuing Installing tree-sitter for PowerShell in nvim HOT 2
- Error (freezes nvim) when opening markdown with code block name in different case (e.g. "Python", "JSON", "R"): `no such language: R` HOT 13
- `ocaml` and `ocaml_interface` could not be compiled on Windows HOT 20
- java query error with vim.lsp.buf.signature_help() HOT 1
- Treesitter crashes when opening a buffer HOT 14
- New `compat.flatten` replacement in-compatible HOT 8
- zig not working for treesitter build after update to neovim nightly and lazyvim rewrite HOT 8
- :TSInstall not install parsers to parser_install_dir HOT 2
- Wrong indentation with elixir HOT 1
- Failed to load parser for language 'lua' : uv_dlopen : no error (on windows) HOT 19
- crash: segfault due to trying to free() an invalid pointer during TreeSitter HTML parsing HOT 1
- TreeSitter fails to load parser HOT 2
- Treesitter error when opening cpp file HOT 1
- Luau variables are highlighted as type
- Failed to open .gitconfig HOT 1
- Support google/zx HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nvim-treesitter.