diff --git a/src/treesit.c b/src/treesit.c
index 599a9b883ef..07d78626e6b 100644
--- a/src/treesit.c
+++ b/src/treesit.c
@@ -21,10 +21,10 @@ along with GNU Emacs. If not, see . */
#include "lisp.h"
#include "buffer.h"
-#if HAVE_TREE_SITTER
-
#include "treesit.h"
+#if HAVE_TREE_SITTER
+
/* Dynamic loading of libtree-sitter. */
diff --git a/src/treesit.h b/src/treesit.h
index 2d2a91cd366..1473126c5bc 100644
--- a/src/treesit.h
+++ b/src/treesit.h
@@ -20,6 +20,10 @@ along with GNU Emacs. If not, see . */
#ifndef EMACS_TREESIT_H
#define EMACS_TREESIT_H
+#include
+
+#ifdef HAVE_TREE_SITTER
+
#include
#include "lisp.h"
@@ -176,6 +180,8 @@ CHECK_TS_COMPILED_QUERY (Lisp_Object query)
Qtreesit_compiled_query_p, query);
}
+INLINE_HEADER_END
+
extern void treesit_record_change (ptrdiff_t, ptrdiff_t, ptrdiff_t);
extern Lisp_Object make_treesit_parser (Lisp_Object, TSParser *, TSTree *,
Lisp_Object);
@@ -187,8 +193,8 @@ extern void treesit_delete_parser (struct Lisp_TS_Parser *);
extern void treesit_delete_query (struct Lisp_TS_Query *);
extern bool treesit_named_node_p (TSNode);
+#endif /* HAVE_TREE_SITTER */
+
extern void syms_of_treesit (void);
-INLINE_HEADER_END
-
#endif /* EMACS_TREESIT_H */