return both the server and client from create-client
This commit is contained in:
parent
9770e3eefd
commit
7194838132
@ -13,7 +13,7 @@
|
||||
:trace "off"})
|
||||
|
||||
(fn test-offset-encoding []
|
||||
(let [(client [response])
|
||||
(let [(client _ [response])
|
||||
(create-client {:params (params-with-encodings [:utf-16])})
|
||||
_ (faith.= :utf-16 (. response :result :capabilities :positionEncoding))
|
||||
{: text : cursor :ranges [{: start : end}]} (get-markup "(let [==𐐀𐐀== 100] 𐐀𐐀|)" :utf-16)
|
||||
@ -22,7 +22,7 @@
|
||||
(faith.= start response.result.range.start)
|
||||
(faith.= end response.result.range.end))
|
||||
|
||||
(let [(client [response])
|
||||
(let [(client _ [response])
|
||||
(create-client {:params (params-with-encodings [:utf-16 :utf-8])})
|
||||
_ (faith.= :utf-8 (. response :result :capabilities :positionEncoding))
|
||||
{: text : cursor :ranges [{: start : end}]} (get-markup "(let [==𐐀𐐀== 100] 𐐀𐐀|)" :utf-8)
|
||||
@ -32,13 +32,13 @@
|
||||
(faith.= end response.result.range.end))
|
||||
|
||||
;; utf-16 is the fallback
|
||||
(let [(_ [response]) (create-client {:params (params-with-encodings nil)})]
|
||||
(let [(_ _ [response]) (create-client {:params (params-with-encodings nil)})]
|
||||
(faith.= :utf-16 (. response :result :capabilities :positionEncoding)))
|
||||
|
||||
(let [(_ [response]) (create-client {:params (params-with-encodings [:random-encoding])})]
|
||||
(let [(_ _ [response]) (create-client {:params (params-with-encodings [:random-encoding])})]
|
||||
(faith.= :utf-16 (. response :result :capabilities :positionEncoding)))
|
||||
|
||||
(let [(_ [response]) (create-client {:params (params-with-encodings [:utf-8 :utf-16])})]
|
||||
(let [(_ _ [response]) (create-client {:params (params-with-encodings [:utf-8 :utf-16])})]
|
||||
(faith.= :utf-8 (. response :result :capabilities :positionEncoding)))
|
||||
|
||||
nil)
|
||||
|
||||
@ -16,8 +16,8 @@
|
||||
nil)
|
||||
|
||||
(fn test-find-symbol []
|
||||
(let [{: client : uri} (create-client-with-files "(match [1 2 4] [1 2 sym-one] sym-one)")
|
||||
file (. client.server.files uri)
|
||||
(let [{: server : uri} (create-client-with-files "(match [1 2 4] [1 2 sym-one] sym-one)")
|
||||
file (. server.files uri)
|
||||
(symbol parents) (language.find-symbol file.ast 23)]
|
||||
(faith.= symbol (fennel.sym :sym-one))
|
||||
(faith.=
|
||||
@ -25,8 +25,8 @@
|
||||
(fennel.view parents {:one-line? true})
|
||||
"bad parents"))
|
||||
|
||||
(let [{: client : uri} (create-client-with-files "(match [1 2 4] [1 2 sym-one] sym-one)")
|
||||
file (. client.server.files uri)
|
||||
(let [{: server : uri} (create-client-with-files "(match [1 2 4] [1 2 sym-one] sym-one)")
|
||||
file (. server.files uri)
|
||||
(symbol parents) (language.find-symbol file.ast 18)]
|
||||
(faith.= symbol nil)
|
||||
(faith.=
|
||||
|
||||
@ -14,7 +14,7 @@
|
||||
|
||||
(local mt {})
|
||||
(fn create-client [?opts ?provide-root-uri]
|
||||
(let [client (doto {:server [] :prev-id 1} (setmetatable mt))
|
||||
(let [server []
|
||||
params (or (?. ?opts :params)
|
||||
{:capabilities {:general {:positionEncodings [default-encoding]}}
|
||||
:clientInfo {:name "Neovim" :version "0.7.2"}
|
||||
@ -30,14 +30,15 @@
|
||||
:jsonrpc "2.0"
|
||||
:method "initialize"
|
||||
: params}
|
||||
result (dispatch.handle* client.server initialize)]
|
||||
initialize-response (dispatch.handle* server initialize)
|
||||
client (doto {: server :prev-id 1} (setmetatable mt))]
|
||||
(case (?. ?opts :settings)
|
||||
settings
|
||||
(dispatch.handle* client.server
|
||||
(dispatch.handle* server
|
||||
{:jsonrpc "2.0"
|
||||
:method :workspace/didChangeConfiguration
|
||||
:params {: settings}}))
|
||||
(values client result)))
|
||||
(values client server initialize-response)))
|
||||
|
||||
(fn next-id! [self]
|
||||
(set self.prev-id (+ self.prev-id 1))
|
||||
|
||||
@ -37,7 +37,7 @@
|
||||
(let [(?give-a-root-uri file-contents) (if (= (type file-contents) :string)
|
||||
(values nil {:main.fnl file-contents})
|
||||
(values true file-contents))
|
||||
client (create-client ?client-options ?give-a-root-uri)
|
||||
(client server) (create-client ?client-options ?give-a-root-uri)
|
||||
locations []]
|
||||
(each [name marked (pairs file-contents)]
|
||||
(if (not= name :main.fnl)
|
||||
@ -53,12 +53,13 @@
|
||||
{: range : uri})
|
||||
(let [[{:params {: diagnostics}}] (client:open-file! uri text)]
|
||||
{: client
|
||||
: server
|
||||
: diagnostics
|
||||
: cursor
|
||||
: locations
|
||||
: text
|
||||
: uri
|
||||
:encoding client.server.position-encoding}))))
|
||||
:encoding server.position-encoding}))))
|
||||
|
||||
(fn position-past-end-of-text [text ?encoding]
|
||||
(utils.byte->position text (+ (length text) 1) (or ?encoding default-encoding)))
|
||||
|
||||
Loading…
Reference in New Issue
Block a user