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