This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-04-14
Channels
- # ai (24)
- # announcements (36)
- # babashka (15)
- # babashka-sci-dev (8)
- # beginners (18)
- # biff (4)
- # calva (24)
- # cider (13)
- # clj-kondo (1)
- # clj-on-windows (2)
- # clojars (15)
- # clojure (120)
- # clojure-dev (13)
- # clojure-europe (69)
- # clojure-nl (1)
- # clojure-norway (8)
- # clojure-uk (2)
- # clojurescript (4)
- # core-logic (2)
- # cursive (6)
- # datomic (193)
- # dev-tooling (4)
- # emacs (1)
- # hyperfiddle (57)
- # lsp (56)
- # malli (11)
- # missionary (15)
- # nbb (61)
- # off-topic (8)
- # polylith (8)
- # practicalli (2)
- # proletarian (1)
- # reitit (3)
- # releases (2)
- # remote-jobs (1)
- # shadow-cljs (13)
- # spacemacs (1)
- # specter (2)
- # sql (17)
- # tools-deps (3)
- # vim (38)
Hey.
How do I configure LSP to do less highlighting?
For instance I use nvim and when I disable the default highlighting that I
used all the time then LSP still highlights my buffer... but after 1-2
seconds. I want my highlighting to be instant because this is
distracting.
How can I tune this to disable variable and function
highlighting? Unused variables are ok to keep but I think it just does
too much work to be fast.
I have a really powerful laptop and it's still lagging so I think you have to remove something from your plugin.
The first screenshot shows how it highlights everything in the world. I don't need this. This is over the top.
The second screenshot shows what I have when I don't enable clojure_lsp
. Yes, the function name highlighting and unused function highlighting could be great but it highlights just too much stuff and it's too slow (the second screenshot has +
that is hardcoded in clojure.vim
highlighting plugin so it's highlighted in yellow).
My setup was to not use clojure_lsp
at all but for some reason something made it so that I can't disable it even if I use :syntax off
in nvim
. It does the highlighting even if I don't want to highlight anything in the buffer (but probably this isn't the issue with clojure_lsp
but with a plugin that loads the LSP server).
I mainly want to understand how to tune the highlighter to output less stuff because I don't need it.
The way i understand semantic tokens is for us to interpret/configure our colorscheme etc to handle them differently, not the lsp server to highlight less. Its just sending some extra data which is up for interpretation or ignoring etc. I think tuning how your colorscheme sees the highlight groups is more relevant/useful than tuning the lsp server here.
colorschemes like https://github.com/folke/tokyonight.nvim specifically supports the semantic tokens for example
Wouldn't it be less wasteful to not do the unneeded analysis in the first place? I understand that we live in an era where CPU and RAM are infinite. But what if I don't want to analyze what I don't need...? Especially if it takes 1-2 seconds to analyze it.
yeah can disable it then if its unneeded.
In my opinion it takes away from nvim's speediness and immediate startup because everything else is immediate in that editor. And by making things that take 1-2 seconds we get a distraction and then we're getting used to only open one IDE at all times because it will be the same as in Emacs where you're not supposed to exit a single instance of your IDE.
On emacs that's pretty fast, probably something to tune in vim side, even so, you can disable semantic tokens on client side or server side via semantic-tokens?
setting https://clojure-lsp.io/settings/
You should configure it in .lsp/config.edn, but keep in mind that feature should be configurable via nvim, it's part of the spec make that optional
I tried to configure that using command line using --settings
but even if the server was run using these parameters the IDE still received the highlighting information.
Maybe the docs are not clear but --settings
only work for clojure-lsp CLI commands, not when using via Editor
Why is this distinction useful?
via editor, what you want in this case, you have 2 options:
• change .lsp/config.edn
and add your setting there
• change your client to send the setting you want via https://clojure-lsp.io/settings/#initializationoptions
probably it's not useful, editor should consider that flag --settings
as well, it just doesn't do ATM, never anyone requested it
I tried to use nvim's plugins to load these settings and they didn't wire it correctly. Then I decided to simply use CLI but that didn't work either :thinking_face: I wanted to configure my LSP to not depend on copying files around. I wanted it to solely live in my nvim config. Of course this may prevent project-local settings but that wasn't my goal.
https://github.com/emacs-lsp/lsp-mode/blob/master/clients/lsp-clojure.el#L450-L451 doing that, I don't know how nvim does that though
I'll either do that or create a color scheme plugin that accomodates the new LSP changes.
I think nvim doesn't have a way to properly do it (or at least I use a broken plugin): https://clojurians.slack.com/archives/C0DF8R51A/p1681453494605029
This was what I wanted to do from the start but then I tried more and more but nothing worked. So now I also tried to nuke the highlighting from LSP via CLI options which didn't also work. So I think I'll instead change the colorscheme so that it would highlight correctly.
there are plenty of ways to debug if client is sending correct stuff, one way is get <https://clojure-lsp.io/troubleshooting/#client-server-log%7Cclient<->server logs>, and check what vim is sending in the initialize
request
I think I was wrong all this time: https://github.com/neovim/nvim-lspconfig/wiki/Understanding-setup-%7B%7D#init_options
This worked:
init_options = {
['semantic-tokens?'] = false
}
I think what actually helped is to take a break and take a walk.I guess... but before taking a break I found out how to make the highlighting work with correct colors. So now I'll have to make it work.
I tried to run this command and I think that the argument :semantic-tokens?
is not picked up:
/usr/bin/clojure-lsp --settings {:semantic-tokens? false}
I want my editor to not use the extended syntax highlighting and this option should disable it but for some reason it doesn't.
I start the LSP server using this command (it's started via my IDE). I forced the IDE to start it using that command.
Do you think there could be a bug with how the parameter is read?
Versions:
clojure-lsp 2023.02.27-13.12.12
NVIM v0.9.0@ericdallo Should I add a test for this somewhere? https://github.com/clojure-lsp/clojure-lsp/pull/1548/files Do you have tests with different clj-kondo configs?
Yes, I think a test https://github.com/clojure-lsp/clojure-lsp/blob/a841b46621b530b76923d16c34b7f754300d0e6d/lib/test/clojure_lsp/feature/diagnostics_test.clj would be nice, via f.diagnostic/find-diagnostics
A lot of tests are failing for me locally with bb test-lib
but they aren't failing on CI. any ideas?
when a single namespace is specified FAIL
when a single namespace is specified with dry option
when ns does not matches uri
when ns is already formatted FAIL FAIL
when single filename is specified FAIL FAIL
maybe because I have:
:clojure-lsp/unused-public-var {:level :off}
in my home lsp config?those tests are from api_test.clj right? things you are not touching, maybe ignore until we find the root cause
The issue was
:cljfmt {:remove-multiple-non-indenting-spaces? true
:sort-ns-references? true
:remove-consecutive-blank-lines? false}
in my configmaybe the tests can have something like: ignore the user's config? not sure what the best solution is, but I'll make an issue
I'm confused as to why this doesn't give me a proper error:
(h/load-code-and-locs "(ns cljc-ns) (let [x 1])" (h/file-uri "file:///cljc_ns.cljc"))
(testing "clj-kondo show langs in cljc file"
(swap! (h/db*) shared/deep-merge {:kondo-config {:output {:langs true}
:linters {:unused-binding {:level :warning}}}
:settings {:linters {:clj-kondo {:level :off}}}})
(h/assert-submaps
[{:a 1}]
(f.diagnostic/find-diagnostics (h/file-uri "file:///cljc_ns.cljc") (h/db))))
I added the test here but it still needs to be finished: https://github.com/clojure-lsp/clojure-lsp/pull/1548 can you give any pointers?