summaryrefslogtreecommitdiff
path: root/script/method/textDocument/didOpen.lua
blob: 732ddacfbdf0bad0bc42e2f6c0c103f034e09dc1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
local furi = require 'uri'

--- @param lsp LSP
--- @param params table
--- @return boolean
return function (lsp, params)
    local doc = params.textDocument
    if #lsp.workspaces == 0 then
        lsp:addWorkspace('root', furi.encode(furi.decode(doc.uri):parent_path()))
    end
    lsp:open(doc.uri, doc.version, doc.text)
    return true
end