Tblgen-lsp-server error in Sublime Text

the following is log, how should i fix it? @River707

1. :: --> tblgen-lsp-server initialize(1): {
2. 	'rootUri': 'file:///E:/Desktop/llvm-project', 
3. 	'rootPath': 'E:\\Desktop\\llvm-project', 
4. 	'capabilities': {
5. 		'textDocument': {
6. 			'implementation': {
7. 					'dynamicRegistration': True, 
8. 					'linkSupport': True
9. 				}, 
10. 			'documentLink': {
11. 					'tooltipSupport': True, 
12. 					'dynamicRegistration': True
13. 				}, 
14. 			'hover': {
15. 					'contentFormat': ['markdown', 'plaintext'], 
16. 					'dynamicRegistration': True
17. 				}, 
18. 			'definition': {
19. 				'dynamicRegistration': True, 
20. 				'linkSupport': True
21. 				}, 
22. 			'completion': {
23. 				'completionItem': {
24. 					'documentationFormat': ['markdown', 'plaintext'], 
25. 					'labelDetailsSupport': True, 
26. 					'insertTextModeSupport': {'valueSet': [2]}, 
27. 					'resolveSupport': {'properties': ['detail', 'documentation', 'additionalTextEdits']}, 
28. 					'deprecatedSupport': True, 
29. 					'tagSupport': {'valueSet': [1]}, 
30. 					'snippetSupport': True
31. 					}, 
32. 				'insertTextMode': 2, 
33. 				'completionItemKind': {'valueSet': [8, 7, 5, 25, 4, 14, 16, 10, 2, 12, 20, 18, 1, 13, 19, 23, 6, 24, 15, 9, 22, 21, 11, 3, 17]}, 
34. 				'dynamicRegistration': True
35. 				}, 
36. 			'references': {
37. 				'dynamicRegistration': True
38. 				}, 
39. 			'semanticTokens': {
40. 				'requests': {'full': {'delta': True}, 'range': True}, 
41. 				'tokenModifiers': ['deprecated', 'modification', 'abstract', 'readonly', 'static', 'defaultLibrary', 'async', 'documentation', 'definition', 'declaration'], 

42. 				'augmentsSyntaxTokens': True, 
43. 				'dynamicRegistration': True, 
44. 				'overlappingTokenSupport': False, 
45. 				'tokenTypes': ['interface', 'class', 'typeParameter', 'string', 'keyword', 'regexp', 'variable', 'property', 'method', 'type', 'comment', 'enumMember', 'macro', 'event', 'operator', 'decorator', 'struct', 'modifier', 'enum', 'number', 'parameter', 'function', 'namespace'], 

46. 				'formats': ['relative'], 
47. 				'multilineTokenSupport': True
48. 				}, 
49. 			'codeAction': {
50. 				'disabledSupport': True, 
51. 				'resolveSupport': {'properties': ['edit']}, 
52. 				'codeActionLiteralSupport': {
53. 					'codeActionKind': {
54. 						'valueSet': ['quickfix', 'refactor', 'refactor.extract', 'refactor.inline', 'refactor.rewrite', 'source.organizeImports']
55. 						}
56. 					},
57. 				'dynamicRegistration': True, 
58. 				'dataSupport': True
59. 				}, 
60. 			'inlayHint': {
61. 				'resolveSupport': {'properties': ['textEdits', 'label.command']}, 
62. 				'dynamicRegistration': True
63. 				}, 
64. 			'rename': {
65. 				'prepareSupport': True, 
66. 				'dynamicRegistration': True
67. 				}, 
68. 			'signatureHelp': {
69. 				'signatureInformation': {
70. 					'documentationFormat': ['markdown', 'plaintext'], 
71. 					'parameterInformation': {'labelOffsetSupport': True}, 
72. 					'activeParameterSupport': True
73. 					}, 
74. 				'contextSupport': True, 
75. 				'dynamicRegistration': True
76. 				}, 
77. 			'rangeFormatting': {
78. 				'dynamicRegistration': True
79. 				}, 
80. 			'selectionRange': {
81. 				'dynamicRegistration': True
82. 				}, 
83. 			'publishDiagnostics': {
84. 				'dataSupport': True, 
85. 				'codeDescriptionSupport': True, 
86. 				'tagSupport': {'valueSet': [2, 1]}, 
87. 				'relatedInformation': True, 
88. 				'versionSupport': True
89. 				}, 
90. 			'typeDefinition': {
91. 				'dynamicRegistration': True, 
92. 				'linkSupport': True
93. 				}, 
94. 			'declaration': {
95. 				'dynamicRegistration': True, 
96. 				'linkSupport': True
97. 				}, 
98. 			'colorProvider': {
99. 				'dynamicRegistration': True
100. 				}, 
101. 			'documentSymbol': {
102. 				'symbolKind': {'valueSet': [11, 18, 5, 8, 26, 17, 15, 9, 13, 19, 6, 3, 22, 4, 1, 10, 24, 25, 2, 23, 14, 20, 21, 7, 16, 12]}, 
103. 				'tagSupport': {'valueSet': [1]}, 
104. 				'hierarchicalDocumentSymbolSupport': True, 
105. 				'dynamicRegistration': True
106. 				}, 
107. 			'documentHighlight': {
108. 				'dynamicRegistration': True
109. 				}, 
110. 			'synchronization': {
111. 				'didSave': True, 
112. 				'willSaveWaitUntil': True, 
113. 				'willSave': True, 
114. 				'dynamicRegistration': True
115. 				}, 
116. 			'formatting': {
117. 				'dynamicRegistration': True
118. 				}, 
119. 			'codeLens': {
120. 				'dynamicRegistration': True
121. 				}
122. 			}, 
123. 		'window': {
124. 			'showMessage': {
125. 				'messageActionItem': {'additionalPropertiesSupport': True}
126. 				}, 
127. 			'showDocument': {
128. 				'support': True
129. 				}, 
130. 			'workDoneProgress': True
131. 			}, 
132. 		'general': {
133. 			'markdown': {
134. 				'parser': 'Python-Markdown', 
135. 				'version': '3.2.2'
136. 				}, 
137. 			'regularExpressions': {
138. 				'engine': 'ECMAScript'
139. 				}
140. 			}, 
141. 		'workspace': {
142. 			'applyEdit': True, 
143. 			'didChangeConfiguration': {'dynamicRegistration': True}, 
144. 			'configuration': True, 
145. 			'executeCommand': {}, 
146. 			'semanticTokens': {'refreshSupport': True}, 
147. 			'inlayHint': {'refreshSupport': True}, 
148. 			'workspaceEdit': {'failureHandling': 'abort', 'documentChanges': True}, 
149. 			'symbol': {
150. 				'symbolKind': {'valueSet': [11, 18, 5, 8, 26, 17, 15, 9, 13, 19, 6, 3, 22, 4, 1, 10, 24, 25, 2, 23, 14, 20, 21, 7, 16, 12]}, 
151. 				'tagSupport': {'valueSet': [1]}, 
152. 				'dynamicRegistration': True
153. 				}, 
154. 			'codeLens': {'refreshSupport': True}, 
155. 			'workspaceFolders': True
156. 			}
157. 		}, 
158. 	'processId': 9488, 
159. 	'clientInfo': {
160. 		'version': '1.18.0', 
161. 		'name': 'Sublime Text LSP'
162. 		}, 
163. 	'initializationOptions': {}, 
164. 	'workspaceFolders': [
165. 		{'uri': 'file:///E:/Desktop/llvm-project', 'name': 'llvm-project'}, 
166. 		{'uri': 'file:///E:/sublime_text/Data/Packages/Polang', 'name': 'Polang'}
167. 		]
168. 	}

169. tblgen-lsp-server: I[10:18:19.358] --> initialize(1)
170. tblgen-lsp-server: I[10:18:19.358] --> reply:(1)

171. :: <<< tblgen-lsp-server 1: {
172. 	'serverInfo': {'version': '0.0.1', 'name': 'tblgen-lsp-server'}, 
173. 	'capabilities': {
174. 		'documentLinkProvider': {'resolveProvider': False}, 
175. 		'textDocumentSync': {'didOpen': {}, 'save': {}, 'didClose': {}, 'change': {'syncKind': 2}}, 
176. 		'definitionProvider': True, 
177. 		'referencesProvider': True, 
178. 		'hoverProvider': True
179. 		}
180. 	}

181. ::  -> tblgen-lsp-server initialized: {}
182. tblgen-lsp-server: I[10:18:19.359] --> initialized
183. tblgen-lsp-server: I[10:18:19.364] --> textDocument/didOpen
184. tblgen-lsp-server: I[10:18:19.364] --> textDocument/publishDiagnostics
185. tblgen-lsp-server: I[10:18:19.364] --> textDocument/documentLink(2)
186. tblgen-lsp-server: I[10:18:19.364] --> reply:(2)

187. ::  -> tblgen-lsp-server textDocument/didOpen: <params with 47069 characters>
188. :: --> tblgen-lsp-server textDocument/documentLink(2): {'textDocument': {'uri': 'file:///E:/Desktop/llvm-project/mlir/include/mlir/Dialect/Arithmetic/IR/ArithmeticOps.td'}}
189. :: <-  tblgen-lsp-server textDocument/publishDiagnostics: {
190. 	'version': 0, 
191. 	'uri': 'file:///E:/Desktop/llvm-project/mlir/include/mlir/Dialect/Arithmetic/IR/ArithmeticOps.td', 
192. 	'diagnostics': [{
193. 			'source': 'tablegen', 
194. 			'category': 'Parse Error', 
195. 			'message': "Could not find include file 'mlir/Dialect/Arithmetic/IR/ArithmeticBase.td'",
196. 			'severity': 1, 
197. 			'range': {'start': {'line': 11, 'character': 8}, 'end': {'line': 11, 'character': 54}}
198. 		}, 
199. 		{
200. 			'source': 'tablegen', 
201. 			'category': 'Parse Error', 
202. 			'message': 'Unexpected token at top level', 
203. 			'severity': 1, 
204. 			'range': {'start': {'line': 11, 'character': 8}, 'end': {'line': 11, 'character': 54}}
205. 		}]
206. 	}

207. :: <<< tblgen-lsp-server 2: []

208. tblgen-lsp-server: I[10:18:20.794] --> textDocument/hover(3)
209. tblgen-lsp-server: I[10:18:20.794] --> reply:(3)
210. :: --> tblgen-lsp-server textDocument/hover(3): {'position': {'line': 46, 'character': 18}, 'textDocument': {'uri': 'file:///E:/Desktop/llvm-project/mlir/include/mlir/Dialect/Arithmetic/IR/ArithmeticOps.td'}}
211. :: <<< tblgen-lsp-server 3: None

212. :: --> tblgen-lsp-server textDocument/references(4): {'position': {'line': 46, 'character': 18}, 'textDocument': {'uri': 'file:///E:/Desktop/llvm-project/mlir/include/mlir/Dialect/Arithmetic/IR/ArithmeticOps.td'}, 'workDoneToken': 'wd4', 'context': {'includeDeclaration': False}}
213. :: <<< tblgen-lsp-server 4: []
214. tblgen-lsp-server: I[10:18:23.849] --> textDocument/references(4)
215. tblgen-lsp-server: I[10:18:23.849] --> reply:(4)

216. tblgen-lsp-server: I[10:20:25.009] --> textDocument/hover(5)
217. tblgen-lsp-server: I[10:20:25.009] --> reply:(5)
218. :: --> tblgen-lsp-server textDocument/hover(5): {'position': {'line': 22, 'character': 11}, 'textDocument': {'uri': 'file:///E:/Desktop/llvm-project/mlir/include/mlir/Dialect/Arithmetic/IR/ArithmeticOps.td'}}
219. :: <<< tblgen-lsp-server 5: None

The log is telling you that it couldn’t parse one of the include files. To be able to process includes, the language server needs you to provide a compilation database for that file. There should be a tablegen_compile_commands.yml at the root of your build directory (that gets generated for things using mlir_tablegen). Compilation databases can be passed to the server via the --tablegen-compilation-database option. I’m assuming that sublime let’s you pass arguments in to the server? (I’m familiar with sublime, but not how it handles LSP stuff).

I fixed the problem about include. but server always reply None, is it normal at line 44 “‘overlappingTokenSupport’: False” ?

@River707 is there any way to automatically generate the tablegen_compile_commands.yml if we’re not using MLIR’s cmake flow? For example would it be possible to get mlir-tblgen itself to generate that file?

The compile commands is something that really needs to be orchestrated by the build system, given that even if mlir-tblgen could create it, the location would need to be orchestrated by whatever build system is invoking it. The setup for building it in cmake is fairly trivial: llvm-project/AddMLIR.cmake at 90a004b4a14b27ba83a17734d439cfd8624db4b5 · llvm/llvm-project · GitHub
Adding similar stuff to a different CMake workflow is trivial, adding to another build system I’m not sure (I’m only familiar enough with CMake to be dangerous).

– River

Okay yeah that makes sense. Thanks for the quick response.