mirror of
https://github.com/neovim/neovim.git
synced 2024-12-23 20:55:18 -07:00
refactor(build): graduate libtreesitter features which are 1+ years old
This commit is contained in:
parent
1b3c1f6c06
commit
c002fd421e
@ -7,34 +7,3 @@ mark_as_advanced(TREESITTER_LIBRARY TREESITTER_INCLUDE_DIR)
|
|||||||
add_library(treesitter INTERFACE)
|
add_library(treesitter INTERFACE)
|
||||||
target_include_directories(treesitter SYSTEM BEFORE INTERFACE ${TREESITTER_INCLUDE_DIR})
|
target_include_directories(treesitter SYSTEM BEFORE INTERFACE ${TREESITTER_INCLUDE_DIR})
|
||||||
target_link_libraries(treesitter INTERFACE ${TREESITTER_LIBRARY})
|
target_link_libraries(treesitter INTERFACE ${TREESITTER_LIBRARY})
|
||||||
|
|
||||||
list(APPEND CMAKE_REQUIRED_INCLUDES "${TREESITTER_INCLUDE_DIR}")
|
|
||||||
list(APPEND CMAKE_REQUIRED_LIBRARIES "${TREESITTER_LIBRARY}")
|
|
||||||
check_c_source_compiles("
|
|
||||||
#include <tree_sitter/api.h>
|
|
||||||
int
|
|
||||||
main(void)
|
|
||||||
{
|
|
||||||
TSQueryCursor *cursor = ts_query_cursor_new();
|
|
||||||
ts_query_cursor_set_match_limit(cursor, 32);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
" TS_HAS_SET_MATCH_LIMIT)
|
|
||||||
if(TS_HAS_SET_MATCH_LIMIT)
|
|
||||||
target_compile_definitions(treesitter INTERFACE NVIM_TS_HAS_SET_MATCH_LIMIT)
|
|
||||||
endif()
|
|
||||||
check_c_source_compiles("
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <tree_sitter/api.h>
|
|
||||||
int
|
|
||||||
main(void)
|
|
||||||
{
|
|
||||||
ts_set_allocator(malloc, calloc, realloc, free);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
" TS_HAS_SET_ALLOCATOR)
|
|
||||||
if(TS_HAS_SET_ALLOCATOR)
|
|
||||||
target_compile_definitions(treesitter INTERFACE NVIM_TS_HAS_SET_ALLOCATOR)
|
|
||||||
endif()
|
|
||||||
list(REMOVE_ITEM CMAKE_REQUIRED_INCLUDES "${TREESITTER_INCLUDE_DIR}")
|
|
||||||
list(REMOVE_ITEM CMAKE_REQUIRED_LIBRARIES "${TREESITTER_LIBRARY}")
|
|
||||||
|
@ -152,9 +152,7 @@ void tslua_init(lua_State *L)
|
|||||||
build_meta(L, TS_META_QUERYCURSOR, querycursor_meta);
|
build_meta(L, TS_META_QUERYCURSOR, querycursor_meta);
|
||||||
build_meta(L, TS_META_TREECURSOR, treecursor_meta);
|
build_meta(L, TS_META_TREECURSOR, treecursor_meta);
|
||||||
|
|
||||||
#ifdef NVIM_TS_HAS_SET_ALLOCATOR
|
|
||||||
ts_set_allocator(xmalloc, xcalloc, xrealloc, xfree);
|
ts_set_allocator(xmalloc, xcalloc, xrealloc, xfree);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int tslua_has_language(lua_State *L)
|
int tslua_has_language(lua_State *L)
|
||||||
@ -1321,11 +1319,7 @@ static int node_rawquery(lua_State *L)
|
|||||||
} else {
|
} else {
|
||||||
cursor = ts_query_cursor_new();
|
cursor = ts_query_cursor_new();
|
||||||
}
|
}
|
||||||
// TODO(clason): API introduced after tree-sitter release 0.19.5
|
|
||||||
// remove guard when minimum ts version is bumped to 0.19.6+
|
|
||||||
#ifdef NVIM_TS_HAS_SET_MATCH_LIMIT
|
|
||||||
ts_query_cursor_set_match_limit(cursor, 64);
|
ts_query_cursor_set_match_limit(cursor, 64);
|
||||||
#endif
|
|
||||||
ts_query_cursor_exec(cursor, query, node);
|
ts_query_cursor_exec(cursor, query, node);
|
||||||
|
|
||||||
bool captures = lua_toboolean(L, 3);
|
bool captures = lua_toboolean(L, 3);
|
||||||
|
Loading…
Reference in New Issue
Block a user