Skip to content

Commit c1005a0

Browse files
feat(treesitter): Compile parser using tree-sitter if available (#1062)
* feat(treesitter): Compile parser using tree-sitter if available * feat(treesitter): add missing args for some compilers
1 parent b525c77 commit c1005a0

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

lua/orgmode/utils/treesitter/install.lua

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ local Promise = require('orgmode.utils.promise')
22
local utils = require('orgmode.utils')
33
local uv = vim.uv
44
local M = {
5-
compilers = { vim.fn.getenv('CC'), 'cc', 'gcc', 'clang', 'cl', 'zig' },
5+
compilers = { 'tree-sitter', vim.fn.getenv('CC'), 'cc', 'gcc', 'clang', 'cl', 'zig' },
66
}
77

88
local required_version = '2.0.0'
@@ -150,6 +150,13 @@ function M.get_parser_path()
150150
end
151151

152152
function M.select_compiler_args(compiler)
153+
if compiler == 'tree-sitter' then
154+
return {
155+
'build',
156+
'-o',
157+
'parser.so',
158+
}
159+
end
153160
if string.match(compiler, 'cl$') or string.match(compiler, 'cl.exe$') then
154161
return {
155162
'/Fe:',
@@ -158,6 +165,8 @@ function M.select_compiler_args(compiler)
158165
'src/parser.c',
159166
'src/scanner.c',
160167
'-Os',
168+
'/std:c11',
169+
'/utf-8',
161170
'/LD',
162171
}
163172
elseif string.match(compiler, 'zig$') or string.match(compiler, 'zig.exe$') then
@@ -171,6 +180,7 @@ function M.select_compiler_args(compiler)
171180
'-Isrc',
172181
'-shared',
173182
'-Os',
183+
'-std=c11',
174184
}
175185
else
176186
local args = {
@@ -180,6 +190,7 @@ function M.select_compiler_args(compiler)
180190
'src/parser.c',
181191
'src/scanner.c',
182192
'-Os',
193+
'-std=c11',
183194
}
184195
if vim.fn.has('mac') == 1 then
185196
table.insert(args, '-bundle')

0 commit comments

Comments
 (0)