Coder Social home page Coder Social logo

clj-kondo / clj-kondo.lsp Goto Github PK

View Code? Open in Web Editor NEW
28.0 3.0 6.0 138 KB

Clj-kondo language server and VSCode extension: https://marketplace.visualstudio.com/items?itemName=borkdude.clj-kondo

License: Eclipse Public License 1.0

Clojure 82.18% TypeScript 17.82%
clojure linter language-server-protocol vscode-extension

clj-kondo.lsp's Introduction

clj-kondo.lsp

This repo contains the code for:

Prerequisites

To build the LSP server:

To use the LSP with Visual Studio Code:

  • Visual Studo Code
    • On Ubuntu Linux: sudo snap install code --classic
  • npm
    • On Ubuntu Linux: sudo apt install npm

Build

Project automation is done using babashka tasks.

Server

To build the server, run this script from the root directory of this repo:

bb vscode-server

This will copy the uberjar to the vscode-extension directory.

VSCode extension

Enter the vscode-extension directory:

cd vscode-extension

To intall the dependencies, run:

npm install

While still in the vscode-extension directory, start VSCode with the following command:

code .

In the VSCode window that appears, press F5 or choose menu item Run -> Start Debugging. This should cause another VSCode window to appear. The first VSCode window that appears does not have access to the clj-kondo.lsp LSP server, but the second one does.

In the second VSCode window, open a Clojure file with suffix .clj and you will get diagnostic feedback.

Near the bottom left of the window should appear two icons with numbers to the right of each one. The first icon looks like a circle with an X inside of it, indicating errors, and the second icon looks like a triangle with a ! inside of it, indicating warnings. If you click on one of these icons, it causes a separate window pane containing details of the errors and warnings to appear (clicking the icons when this window pane is visible causes the pane to disappear). Inside of that pane, clicking on a line describing a warning or error causes the main window pane containing your code to jump to the relevant line of code.

License

Copyright © 2019-2022 Michiel Borkent

Distributed under the EPL License, same as Clojure. See LICENSE.

clj-kondo.lsp's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

clj-kondo.lsp's Issues

IndexOutOfBoundsException with metadata tag lacking something to tag

A file with this contents produces an exception:

(def ^:foo)

(Note the newline after the borked form.)

The error:

[Error - 2:40:39 PM] java.lang.IndexOutOfBoundsException
	at clojure.lang.PersistentVector.arrayFor(PersistentVector.java:158)
	at clojure.lang.PersistentVector.nth(PersistentVector.java:162)
	at clojure.lang.RT.nth(RT.java:896)
	at clj_kondo.lsp_server.impl.server$finding__GT_Diagnostic.invokeStatic(server.clj:75)
	at clj_kondo.lsp_server.impl.server$lint_BANG_$fn__11576.invoke(server.clj:132)
	at clojure.core$mapv$fn__8445.invoke(core.clj:6912)
	at clojure.lang.PersistentVector.reduce(PersistentVector.java:343)
	at clojure.core$reduce.invokeStatic(core.clj:6827)
	at clojure.core$mapv.invokeStatic(core.clj:6903)
	at clj_kondo.lsp_server.impl.server$lint_BANG_.invokeStatic(server.clj:124)
	at clj_kondo.lsp_server.impl.server.LSPTextDocumentService.didChange(server.clj:153)
	at jdk.internal.reflect.GeneratedMethodAccessor1.invoke(Unknown Source)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:567)
	at org.eclipse.lsp4j.jsonrpc.services.GenericEndpoint.lambda$null$0(GenericEndpoint.java:65)
	at org.eclipse.lsp4j.jsonrpc.services.GenericEndpoint.notify(GenericEndpoint.java:152)
	at org.eclipse.lsp4j.jsonrpc.RemoteEndpoint.handleNotification(RemoteEndpoint.java:220)
	at org.eclipse.lsp4j.jsonrpc.RemoteEndpoint.consume(RemoteEndpoint.java:187)
	at org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer.handleMessage(StreamMessageProducer.java:194)
	at org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer.listen(StreamMessageProducer.java:94)
	at org.eclipse.lsp4j.jsonrpc.json.ConcurrentMessageProcessor.run(ConcurrentMessageProcessor.java:113)
	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
	at java.base/java.lang.Thread.run(Thread.java:835)

[Feature Request] Add false positive macro to config

clj-kondo complains about macros it doesn't know about, which is fine, because how should it know? 😄

It would be nice with some help to config away the linting complaints. Maybe as a quick-fix option: ”Lint macro as: ”, or some such. It can be a bit of work for the user to find the config info in the clj-kondo repro, understand it, and configure it correctly, by hand.

Open VSX Listing: Signing the Publisher Agreement

Thank you for being part of the Open VSX community by adding your extensions to the Open VSX Registry. Please note that the service was recently transferred to the Eclipse Foundation and urgent action on your part is needed so we can continue to list your extensions. To ensure uninterrupted service, please sign the Eclipse Publisher Agreement on or before January 8, 2021. If not signed by that date, your extensions will be delisted and will no longer appear on the site nor be available via the API. If you sign at a later date, your extensions will then be re-activated. The signing process is explained in the Wiki (steps 1 and 2).

Please also note that all extensions MUST have a license in order to be listed.

More details are in these recent blog posts:
https://blogs.eclipse.org/post/brian-king/open-vsx-registry-under-new-management
https://blogs.eclipse.org/post/brian-king/new-era-open-vsx-registry

If you are the project maintainer, we urge you to claim the namespace for your extension(s). To find out how to do this, see:
https://github.com/eclipse/openvsx/wiki/Namespace-Access

Today, there’s growing momentum around open source tools and technologies that support Visual Studio (VS) Code extensions. Leading global organizations are adopting these tools and technologies. This momentum has spurred demand for a marketplace without restrictions and limitations. Thanks for joining us on this journey as we continue to build the Open VSX community. We look forward to continued innovation from you in 2021!

vscode clj-kondo extention throws NullPointerException

Hi, thank you very much for building clj-kondo. It's an awesome tool!

A small issue.

When editing shadow-cljs style ns :default, e.g. below snippet.

(ns lambda
  (:require
   ["aws-sdk" :default AWS]))

Stacktrace from vscode output window, and output window pops up every time there is another exception thrown (same stracktrace). I have to disable the extension because of this.

-- Welcome to clj-kondo v2020.12.12.
--
-- To configure clj-kondo, create a .clj-kondo directory in the root of your workspace and place a config.edn file in it.
-- Check out the configuration documentation here: https://github.com/borkdude/clj-kondo/blob/master/doc/config.md.
--
-- If you have questions, join the #clj-kondo channel on Clojurians slack.
-- Report issues at: https://github.com/borkdude/clj-kondo.
--
-- Happy linting!

[Info  - 3:16:05 PM] Clj-kondo language server loaded. Please report any issues to https://github.com/borkdude/clj-kondo.
[Error - 3:16:05 PM] java.lang.NullPointerException
	at clojure.lang.Numbers.ops(Numbers.java:1068)
	at clojure.lang.Numbers.dec(Numbers.java:145)
	at clj_kondo.lsp_server.impl.server$finding__GT_Diagnostic.invokeStatic(server.clj:73)
	at clj_kondo.lsp_server.impl.server$lint_BANG_$fn__11709.invoke(server.clj:137)
	at clojure.core$mapv$fn__8445.invoke(core.clj:6912)
	at clojure.lang.PersistentVector.reduce(PersistentVector.java:343)
	at clojure.core$reduce.invokeStatic(core.clj:6827)
	at clojure.core$mapv.invokeStatic(core.clj:6903)
	at clj_kondo.lsp_server.impl.server$lint_BANG_.invokeStatic(server.clj:126)
	at clj_kondo.lsp_server.impl.server.LSPTextDocumentService.didOpen(server.clj:149)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at org.eclipse.lsp4j.jsonrpc.services.GenericEndpoint.lambda$null$0(GenericEndpoint.java:65)
	at org.eclipse.lsp4j.jsonrpc.services.GenericEndpoint.notify(GenericEndpoint.java:152)
	at org.eclipse.lsp4j.jsonrpc.RemoteEndpoint.handleNotification(RemoteEndpoint.java:220)
	at org.eclipse.lsp4j.jsonrpc.RemoteEndpoint.consume(RemoteEndpoint.java:187)
	at org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer.handleMessage(StreamMessageProducer.java:194)
	at org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer.listen(StreamMessageProducer.java:94)
	at org.eclipse.lsp4j.jsonrpc.json.ConcurrentMessageProcessor.run(ConcurrentMessageProcessor.java:113)
	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
	at java.base/java.lang.Thread.run(Thread.java:834)

README mention non-existent script script/build-server

Thanks for publishing this. I am able to create an uberjar of the server and run it that way, but wanted to mention this minor issue with the README instructions where it mentions a script script/build-server that does not exist in the repo.

Missplaced docstring warning on a defmethod that shouldn't be there

I don't know if anyone still maintains this repo but I've got an issue:

For a defmethod that looks something like this;
(defmethod defmethod-name :default [args] "some docstring string." (defmethod-body)

clj-kondo gives a warning: Missplaced docstring

I do not think this is a missplaced docstring.

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.