Code Monkey home page Code Monkey logo

zen-lsp's Issues

Create zen-lsp MVP server

Created the initial setup for the zen-lsp server.

@niquola Let's create some more issues to work on next. We could start with some simple linting for single files or index a project (need more info how this should work) first and then do some linting.

Github Actions config

  • build and release lsp uberjar
  • publish automatically the vscode plugin to the vscode marketplace

Autocomplete

We can start here:

  • zen ctx contains key called :ns and :symbols and this can be used for autocompletions
  • call this function from lsp mode

Possible improvements:

  • zen-core will provide a function that returns autocompletions, given the last valid zen edn file and location and/or path like [:foo bar baz] into the EDN

Autocompletion: implement smart autocompletion

We need more smart-autocompletion, depending on context.

  • complete keys for schema, bassed on current type
  • complete keys for schema, based on current type confirmation (zen/vector confirms zen/coll)
  • complete symbols from current ns, imported ns, zen.edn
  • complete tags when cursor in :zen/tags #{}
  • complete schemas when cursor in :confirms #{}

Tests

@niquola I'd like to write some unit tests for this part of the code:

(defn error->finding [edn-node error]
(let [message (:message error)
;; path (:path error)
resource (:resource error)
resource-path (some-> resource name symbol)
path (cons resource-path (:path error))
key? (str/includes? message "unknown key")
loc (get-location edn-node path key?)
finding (assoc loc :message message :level :warning)]
finding))
(defn lint! [text uri]
(when-not (str/ends-with? uri ".calva/output-window/output.calva-repl")
(let [_lang (uri->lang uri)
path (-> (java.net.URI. uri)
(.getPath))
edn (e/parse-string text)
ctx (zen/new-context {:unsafe true})
_ (store/load-ns ctx edn {:zen/file path})
errors (:errors @ctx)
edn-node (p/parse-string text)
findings (map #(error->finding edn-node %) errors)
{:keys [:findings]} {:findings findings}
lines (str/split text #"\r?\n")
diagnostics (vec (keep #(finding->Diagnostic lines %) findings))]
(debug "publishing diagnostics")
(.publishDiagnostics ^LanguageClient @proxy-state
(PublishDiagnosticsParams.
uri
diagnostics)))))

In the tests we can capture the correct behavior given a path + text (EDN string) and the expected lint warnings (and expected locations).

Currently I've been experimenting with this bit of code:

Screen Shot 2021-09-09 at 10 09 32

which seems to work well, but as we make changes, tests will ensure that it will remain working.

Therefore I need more test cases + expected outputs.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.