@@ -8,6 +8,8 @@ local getLabel = require 'core.hover.label'
88local jsonb = require ' json-beautify'
99local util = require ' utility'
1010local markdown = require ' provider.markdown'
11+ local fs = require ' bee.filesystem'
12+ local furi = require ' file-uri'
1113
1214--- @alias doctype
1315--- | ' doc.alias'
@@ -55,13 +57,14 @@ local markdown = require 'provider.markdown'
5557local export = {}
5658
5759function export .getLocalPath (uri )
58- -- remove uri root (and prefix)
59- local local_file_uri = uri
60- local i , j = local_file_uri :find (DOC )
61- if not j then
62- return ' [FOREIGN] ' .. uri
60+ local file_canonical = fs .canonical (furi .decode (uri )):string ()
61+ local doc_canonical = fs .canonical (DOC ):string ()
62+ local relativePath = fs .relative (file_canonical , doc_canonical ):string ()
63+ if relativePath == " " or relativePath :sub (1 , 2 ) == ' ..' then
64+ -- not under project directory
65+ return ' [FOREIGN] ' .. file_canonical
6366 end
64- return local_file_uri : sub ( j + 1 )
67+ return relativePath
6568end
6669
6770function export .positionOf (rowcol )
@@ -214,10 +217,6 @@ export.makeDocObject['local'] = function(source, obj, has_seen)
214217 obj .name = source [1 ]
215218end
216219
217- export .makeDocObject [' luals.config' ] = function (source , obj , has_seen )
218-
219- end
220-
221220export .makeDocObject [' self' ] = export .makeDocObject [' local' ]
222221
223222export .makeDocObject [' setfield' ] = export .makeDocObject [' doc.class' ]
@@ -284,17 +283,25 @@ end
284283--- @param callback fun ( i , max )
285284function export .makeDocs (globals , callback )
286285 local docs = {}
287-
288286 for i , global in ipairs (globals ) do
289287 table.insert (docs , export .documentObject (global ))
290288 callback (i , # globals )
291289 end
292-
290+ docs [ # docs + 1 ] = export . getLualsConfig ()
293291 table.sort (docs , export .sortDoc )
294-
295292 return docs
296293end
297294
295+ function export .getLualsConfig ()
296+ return {
297+ name = ' LuaLS' ,
298+ type = ' luals.config' ,
299+ DOC = fs .canonical (fs .path (DOC )):string (),
300+ defines = {},
301+ fields = {}
302+ }
303+ end
304+
298305--- takes the table from `makeDocs`, serializes it, and exports it
299306--- @async
300307--- @param docs table
0 commit comments