Closed Astisme closed 1 year ago
not sure if you still have the problem, I get it working in nvim https://github.com/xixiaofinland/dotfiles/blob/main/.config/nvim/lua/plug-settings.lua#L42
@Astisme, @xixiaofinland has been doing a lot of work on this and was able to get Apex, SOQL, and SOSL registered correctly into the regular nvim-treesitter repo. You should be able to engage with Apex like you would any other properly supported language now.
Please take a look at see if you're able to get that working now.
@aheber I can create a md
to record how to configure in nvim to get it up and running. Shall I create a new md file in this repo and you link it from README, part of README, or in a different repo?
@xixiaofinland please submit as a separate MD file. We can add a link from the README to the other doc so people are aware of it. If there are existing nvim-treesitter docs please link out to them as much as is reasonable. This will help to make sure our docs don't fall out of date.
Thanks!
Well it's now working. I'd like to report what is the solution as of right now.
First you should clone the repo in $CONFIG/nvim-data/tree-sitter-sfapex ($CONFIG is ~/AppData/Local)
This is the new nvim-treesitter.lua I use atm.
require 'nvim-treesitter.install'.compilers = { "clang" }
local parser_config = require "nvim-treesitter.parsers".get_parser_configs()
local installation_path = "$CONFIG\\nvim-data\\tree-sitter-sfapex" --$CONFIG from C:\\
parser_config.apex = {
install_info = {
url = installation_path .. "\\apex", -- the next comment will explain why not to use link here
files = {"src/parser.c"},
branch = "main", -- default branch in case of git repo if different from master
generate_requires_npm = false, -- if stand-alone parser without npm dependencies
requires_generate_from_grammar = false, -- if folder contains pre-generated src/parser.c
}
}
parser_config.soql= {
install_info = {
url = installation_path .. "\\soql",
files = {"src/parser.c"},
branch = "main", -- default branch in case of git repo if different from master
generate_requires_npm = false, -- if stand-alone parser without npm dependencies
requires_generate_from_grammar = false, -- if folder contains pre-generated src/parser.c
}
}
parser_config.sosl= {
install_info = {
url = installation_path .. "\\sosl",
files = {"src/parser.c"},
branch = "main", -- default branch in case of git repo if different from master
generate_requires_npm = false, -- if stand-alone parser without npm dependencies
requires_generate_from_grammar = false, -- if folder contains pre-generated src/parser.c
}
}
require 'nvim-treesitter.configs'.setup {
ensure_installed = {"apex", "soql","sosl"},
sync_install = false;
highlight = {
enable = true,
additional_vim_regex_highlighting = false,
},
}
Then restart nvim to install or use :TSInstall apex
, :TSInstall soql
and :TSInstall sosl
.
This works without any issues and successfully highlights the apex code (but not the SOQL or SOSL queries) in .cls
and .apex
files.
Here's a screenshot of the files downloaded. The first is the folder created by tree-sitter; the last is from a git clone. As you can see from this picture, as of right now, if you give tree-sitter the link to the repo, the files downloaded are less then the ones actually available.
I believe it should only be a release problem which could be fixed later, right?
No, you don't need to do anything other than telling nvim-treesitter to get apex
parser installed, like here in my dotfile.
Also, the built-in version has query issue you mentioned resolved for nvim.
Speaking of the file discrepancy, nvim-treesitter technically needs only parser.c
, as long as it works, it doesn't matter.
I have an instruction readme PR to be merged: https://github.com/aheber/tree-sitter-sfapex/pull/17/files
@Astisme
@xixiaofinland please submit as a separate MD file. We can add a link from the README to the other doc so people are aware of it. If there are existing nvim-treesitter docs please link out to them as much as is reasonable. This will help to make sure our docs don't fall out of date.
Thanks!
I made a PR, get the chance to review?
I didn't realize I had left it open. I just merged it.
@xixiaofinland ok, it is working actually without all the parser_config rows I wrote before. Case closed!
Prework
I followed the steps in #5 to make the apex, soql and sosl highlighting available. Here's my file tree (on Windows 11):
This is my nvim-treesitter.lua
Research
Checked health on nvim-treesitter
Software version
Problem
With this setup, I've run
:TSInstall apex
(and the others) and the output is onlyand it stays stuck at this spot forever.
Tldr
On Windows 11, I cannot make this repo work even though I followed the steps described in #5. nvim-treesitter gets stuck at "generating source files from grammar.js"