@@ -20,72 +20,71 @@ require('nvim-treesitter').setup({
2020})
2121
2222print (' Starting parser installation...' )
23- local ok , result = pcall (function ()
24- return require (' nvim-treesitter' ).install (parsers , { force = true }):wait (1800000 )
25- end )
2623
27- if not ok then
28- print (' Installation failed: ' .. tostring (result ))
29- os.exit (1 )
24+ -- Use synchronous install and capture output
25+ local install = require (' nvim-treesitter.install' )
26+ for _ , parser in ipairs (parsers ) do
27+ print (' Installing parser: ' .. parser )
28+ local success , err = pcall (function ()
29+ install .update (parser )
30+ end )
31+ if not success then
32+ print (' Installation error: ' .. tostring (err ))
33+ end
3034end
3135
36+ -- Wait a bit for compilation to complete
37+ vim .wait (5000 , function () return false end )
38+
3239print (' Installation completed, searching for go parser...' )
3340
34- -- Check the build directory specifically for go parser
35- local build_locations = {
36- vim .fn .stdpath (' cache' ) .. ' /nvim-treesitter/tree-sitter-go ' ,
37- vim .fn .stdpath (' data' ) .. ' /nvim-treesitter/tree-sitter-go ' ,
38- install_dir .. ' /parser ' ,
39- ' /tmp/tree-sitter-go ' ,
41+ -- Check all possible locations
42+ local all_locations = {
43+ vim .fn .stdpath (' cache' ) .. ' /nvim-treesitter' ,
44+ vim .fn .stdpath (' data' ) .. ' /nvim-treesitter' ,
45+ vim . fn . stdpath ( ' data ' ) .. ' /site ' ,
46+ ' /tmp' ,
4047}
4148
42- local go_parser_found = false
43-
44- for _ , location in ipairs (build_locations ) do
45- local expanded = vim .fn .expand (location )
46- print (' Checking: ' .. expanded )
47- if vim .fn .isdirectory (expanded ) == 1 then
48- print (' Directory exists, listing contents:' )
49- local files = vim .fn .glob (expanded .. ' /*' , false , true )
50- for _ , file in ipairs (files ) do
51- print (' ' .. file )
52- end
53-
54- -- Look for go.so specifically
55- local go_so = vim .fn .glob (expanded .. ' /**/go.so' , false , true )
56- if # go_so > 0 then
57- print (' Found go.so: ' .. vim .inspect (go_so ))
58- for _ , so_file in ipairs (go_so ) do
49+ for _ , root in ipairs (all_locations ) do
50+ print (' \n Searching in: ' .. root )
51+ if vim .fn .isdirectory (root ) == 1 then
52+ -- Use find command to locate go.so
53+ local result = vim .fn .system (string.format (' find "%s" -name "go.so" 2>/dev/null' , root ))
54+ if result ~= ' ' then
55+ print (' Found go.so via find: ' .. result )
56+ local files = vim .split (result , ' \n ' , { trimempty = true })
57+ for _ , file in ipairs (files ) do
5958 local dest = install_dir .. ' /parser/go.so'
60- print (' Copying ' .. so_file .. ' to ' .. dest )
61- vim .fn .system (string.format (' cp "%s" "%s"' , so_file , dest ))
62- go_parser_found = true
59+ print (' Copying ' .. file .. ' to ' .. dest )
60+ vim .fn .system (string.format (' cp "%s" "%s"' , file , dest ))
6361 end
6462 end
65- end
66- end
67-
68- -- If not found, search everywhere
69- if not go_parser_found then
70- print (' \n Searching entire filesystem for go.so...' )
71- local search_roots = {
72- vim .fn .stdpath (' cache' ),
73- vim .fn .stdpath (' data' ),
74- vim .fn .stdpath (' state' ),
75- ' /tmp' ,
76- }
77-
78- for _ , root in ipairs (search_roots ) do
79- local go_files = vim .fn .glob (root .. ' /**/go.so' , false , true )
80- if # go_files > 0 then
81- print (' Found go.so files: ' .. vim .inspect (go_files ))
82- for _ , so_file in ipairs (go_files ) do
83- local dest = install_dir .. ' /parser/go.so'
84- print (' Copying ' .. so_file .. ' to ' .. dest )
85- vim .fn .system (string.format (' cp "%s" "%s"' , so_file , dest ))
86- go_parser_found = true
63+
64+ -- Also check for the build directory
65+ local build_result = vim .fn .system (string.format (' find "%s" -type d -name "tree-sitter-go" 2>/dev/null' , root ))
66+ if build_result ~= ' ' then
67+ print (' Found tree-sitter-go directories: ' .. build_result )
68+ local dirs = vim .split (build_result , ' \n ' , { trimempty = true })
69+ for _ , dir in ipairs (dirs ) do
70+ print (' Contents of ' .. dir .. ' :' )
71+ local ls_result = vim .fn .system (string.format (' ls -la "%s" 2>/dev/null' , dir ))
72+ print (ls_result )
73+
74+ -- Try to manually compile if source exists
75+ if vim .fn .filereadable (dir .. ' /src/parser.c' ) == 1 then
76+ print (' Found parser.c, attempting manual compilation...' )
77+ local compile_cmd = string.format (
78+ ' cc -o "%s/go.so" -I"%s/src" "%s/src/parser.c" -shared -Os -lstdc++ -fPIC 2>&1' ,
79+ install_dir .. ' /parser' ,
80+ dir ,
81+ dir
82+ )
83+ print (' Compile command: ' .. compile_cmd )
84+ local compile_result = vim .fn .system (compile_cmd )
85+ print (' Compile result: ' .. compile_result )
86+ end
8787 end
88- break
8988 end
9089 end
9190end
0 commit comments