diff --git a/test/capabilities.fnl b/test/capabilities.fnl index 786c9f4..3d6cdeb 100644 --- a/test/capabilities.fnl +++ b/test/capabilities.fnl @@ -13,21 +13,21 @@ :trace "off"}) (fn test-offset-encoding [] - (let [(self [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) - _ (self:open-file! "foo.fnl" text) - [response] (self:definition "foo.fnl" cursor)] + _ (client:open-file! "foo.fnl" text) + [response] (client:definition "foo.fnl" cursor)] (faith.= start response.result.range.start) (faith.= end response.result.range.end)) - (let [(self [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) - _ (self:open-file! "foo.fnl" text) - [response] (self:definition "foo.fnl" cursor)] + _ (client:open-file! "foo.fnl" text) + [response] (client:definition "foo.fnl" cursor)] (faith.= start response.result.range.start) (faith.= end response.result.range.end)) diff --git a/test/code-action.fnl b/test/code-action.fnl index cd5c3cf..ddc5e0b 100644 --- a/test/code-action.fnl +++ b/test/code-action.fnl @@ -6,8 +6,8 @@ (create-client-with-files "(print :hi)") (fn check [file-contents action-I-want-to-take desired-file-contents] - (let [{: self : uri :locations [range] : encoding : text} (create-client-with-files file-contents) - [{:result responses}] (self:code-action uri range.range) + (let [{: client : uri :locations [range] : encoding : text} (create-client-with-files file-contents) + [{:result responses}] (client:code-action uri range.range) action (accumulate [result nil _ action (ipairs responses) &until result] (if (= action.title action-I-want-to-take) @@ -21,8 +21,8 @@ edited-text (apply-edits text edits encoding)] (faith.= desired-file-contents edited-text)))) (fn check-negative [file-contents action-not-suggested] - (let [{: self : uri :locations [range]} (create-client-with-files file-contents) - [{:result responses}] (self:code-action uri range.range)] + (let [{: client : uri :locations [range]} (create-client-with-files file-contents) + [{:result responses}] (client:code-action uri range.range)] (each [_ action (ipairs responses)] (assert (not= action.title action-not-suggested) (.. "I found your action \"" action-not-suggested "\" in:\n" @@ -39,10 +39,10 @@ ; (fn test-fix-method-function [] ; (check "(local x {}) ; (fn x:y [a b c] -; (print self a b c))" +; (print client a b c))" ; "TO-BE-NAMED" ; "(local x {}) -; (fn x.y [self a b c] -; (print self a b c))")) +; (fn x.y [client a b c] +; (print client a b c))")) {: test-fix-op-no-arguments} diff --git a/test/completion.fnl b/test/completion.fnl index 3cbe8d0..4499461 100644 --- a/test/completion.fnl +++ b/test/completion.fnl @@ -43,8 +43,8 @@ i))) (fn check [file-contents expected unexpected ?client-options] - (let [{: self : uri : cursor : text} (create-client-with-files file-contents ?client-options) - [{:result ?result}] (self:completion uri + (let [{: client : uri : cursor : text} (create-client-with-files file-contents ?client-options) + [{:result ?result}] (client:completion uri (or cursor (position-past-end-of-text text))) completions (or ?result [])] diff --git a/test/goto-definition.fnl b/test/goto-definition.fnl index 2c2f4f2..bd53e93 100644 --- a/test/goto-definition.fnl +++ b/test/goto-definition.fnl @@ -4,8 +4,8 @@ (local {: view} (require :fennel)) (fn check [file-contents] - (let [{: self : uri : cursor :locations [location]} (create-client-with-files file-contents) - [message] (self:definition uri cursor)] + (let [{: client : uri : cursor :locations [location]} (create-client-with-files file-contents) + [message] (client:definition uri cursor)] (if location (faith.= location message.result (.. "Didn't go to location: \n" (view file-contents))) diff --git a/test/hover.fnl b/test/hover.fnl index 3f38059..eed7f8c 100644 --- a/test/hover.fnl +++ b/test/hover.fnl @@ -4,8 +4,8 @@ (local {: null} (require :fennel-ls.json.json)) (fn check [file-contents ?response-string] - (let [{: self : uri : cursor} (create-client-with-files file-contents) - [message] (self:hover uri cursor)] + (let [{: client : uri : cursor} (create-client-with-files file-contents) + [message] (client:hover uri cursor)] (if (= (type ?response-string) :string) (faith.= ?response-string (?. message :result :contents :value) (.. "Invalid hover message\nfrom: " (view file-contents))) diff --git a/test/misc.fnl b/test/misc.fnl index 9fd6b70..2de67bd 100644 --- a/test/misc.fnl +++ b/test/misc.fnl @@ -16,8 +16,8 @@ nil) (fn test-find-symbol [] - (let [{: self : uri} (create-client-with-files "(match [1 2 4] [1 2 sym-one] sym-one)") - file (. self.server.files uri) + (let [{: client : uri} (create-client-with-files "(match [1 2 4] [1 2 sym-one] sym-one)") + file (. client.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 [{: self : uri} (create-client-with-files "(match [1 2 4] [1 2 sym-one] sym-one)") - file (. self.server.files uri) + (let [{: client : uri} (create-client-with-files "(match [1 2 4] [1 2 sym-one] sym-one)") + file (. client.server.files uri) (symbol parents) (language.find-symbol file.ast 18)] (faith.= symbol nil) (faith.= diff --git a/test/references.fnl b/test/references.fnl index c8f5233..4a5ad25 100644 --- a/test/references.fnl +++ b/test/references.fnl @@ -16,8 +16,8 @@ (= a.range.end.character b.range.end.character))))))))))) (fn check [file-contents] - (let [{: self : uri : cursor : locations} (create-client-with-files file-contents) - [response] (self:references uri cursor)] + (let [{: client : uri : cursor : locations} (create-client-with-files file-contents) + [response] (client:references uri cursor)] (if (not= null response.result) (do (table.sort locations location-comparator) diff --git a/test/rename.fnl b/test/rename.fnl index 28c89e1..62870ab 100644 --- a/test/rename.fnl +++ b/test/rename.fnl @@ -4,8 +4,8 @@ (local {: apply-edits} (require :fennel-ls.utils)) (fn check [file-content new-name expected-file-content] - (let [{: self : uri : cursor : text : encoding} (create-client-with-files file-content) - [{: result}] (self:rename uri cursor new-name)] + (let [{: client : uri : cursor : text : encoding} (create-client-with-files file-content) + [{: result}] (client:rename uri cursor new-name)] (if (= null result) (faith.= expected-file-content text) (let [new-content (apply-edits text (. result.changes uri) encoding)] diff --git a/test/settings.fnl b/test/settings.fnl index 5524a03..f3a8d8a 100644 --- a/test/settings.fnl +++ b/test/settings.fnl @@ -4,14 +4,14 @@ (local {: create-client-with-files} (require :test.utils)) (fn test-path [] - (let [{: self : uri : cursor :locations [location]} + (let [{: client : uri : cursor :locations [location]} (create-client-with-files {:modname.fnl "{:this-is-in-modname {:this :one :isnt :on :the :path}}" :modname/modname/modname/modname.fnl "(fn ==this-is-in-modname== [] nil) {: this-is-in-modname}" :main.fnl "(local {: this-is-in-mod|name} (require :modname))"} {:settings {:fennel-ls {:fennel-path "./?/?/?/?.fnl"}}}) - [response] (self:definition uri cursor)] + [response] (client:definition uri cursor)] (faith.= location response.result "error message"))) @@ -29,7 +29,7 @@ ;; (it "recompiles modules if the macro files are modified)" ;; (it "can infer the macro path from fennel-path" - ;; (local self (doto [] ({:settings {:fennel-ls {:fennel-path "./?/?/?/?.fnl"}})))) + ;; (local client (doto [] ({:settings {:fennel-ls {:fennel-path "./?/?/?/?.fnl"}})))) (fn test-extra-globals [] (let [{:diagnostics good} (create-client-with-files "(foo-100 bar :baz)" {:settings {:fennel-ls {:extra-globals "foo-100 bar"}}}) @@ -39,10 +39,10 @@ nil) ;; (it "can turn off strict globals" - ;; (local self (doto [] (setup-server {:fennel-ls {:checks {:globals false}}})))) + ;; (local client (doto [] (setup-server {:fennel-ls {:checks {:globals false}}})))) ;; (it "can treat globals as a warning instead of an error" - ;; (local self (doto [] (setup-server {:fennel-ls {:diagnostics {:E202 "warning"}}}))))) + ;; (local client (doto [] (setup-server {:fennel-ls {:diagnostics {:E202 "warning"}}}))))) (fn test-lints [] (let [{:diagnostics good} (create-client-with-files "(local x 10)" {:settings {:fennel-ls {:checks {:unused-definition false}}}}) diff --git a/test/utils/client.fnl b/test/utils/client.fnl index 28f094f..d7bc2ab 100644 --- a/test/utils/client.fnl +++ b/test/utils/client.fnl @@ -14,7 +14,7 @@ (local mt {}) (fn create-client [?opts ?provide-root-uri] - (let [self (doto {:server [] :prev-id 1} (setmetatable mt)) + (let [client (doto {:server [] :prev-id 1} (setmetatable mt)) params (or (?. ?opts :params) {:capabilities {:general {:positionEncodings [default-encoding]}} :clientInfo {:name "Neovim" :version "0.7.2"} @@ -30,14 +30,14 @@ :jsonrpc "2.0" :method "initialize" : params} - result (dispatch.handle* self.server initialize)] + result (dispatch.handle* client.server initialize)] (case (?. ?opts :settings) settings - (dispatch.handle* self.server + (dispatch.handle* client.server {:jsonrpc "2.0" :method :workspace/didChangeConfiguration :params {: settings}})) - (values self result))) + (values client result))) (fn next-id! [self] (set self.prev-id (+ self.prev-id 1)) diff --git a/test/utils/init.fnl b/test/utils/init.fnl index e9ad63a..ef3735a 100644 --- a/test/utils/init.fnl +++ b/test/utils/init.fnl @@ -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)) - self (create-client ?client-options ?give-a-root-uri) + client (create-client ?client-options ?give-a-root-uri) locations []] (each [name marked (pairs file-contents)] (if (not= name :main.fnl) @@ -45,20 +45,20 @@ {: text : ranges} (get-markup marked)] (icollect [_ range (ipairs ranges) &into locations] {: range : uri}) - (self:pretend-this-file-exists! uri text)))) + (client:pretend-this-file-exists! uri text)))) (let [uri (.. ROOT-URI "/" :main.fnl) main-file-contents (. file-contents :main.fnl) {: text : ranges : cursor} (get-markup main-file-contents)] (icollect [_ range (ipairs ranges) &into locations] {: range : uri}) - (let [[{:params {: diagnostics}}] (self:open-file! uri text)] - {: self + (let [[{:params {: diagnostics}}] (client:open-file! uri text)] + {: client : diagnostics : cursor : locations : text : uri - :encoding self.server.position-encoding})))) + :encoding client.server.position-encoding})))) (fn position-past-end-of-text [text ?encoding] (utils.byte->position text (+ (length text) 1) (or ?encoding default-encoding)))