vim

Martynas Maciulevičius 2023-04-14T06:24:54.605029Z

Did anyone manage to pass custom options to clojure_lsp when using lspconfig? I want to pass an option and there is simply no way it works for me:

lspconfig.clojure_lsp.setup({
...
    settings     = {
      -- 
      clojure_lsp = {
        ['semantic-tokens'] = false,
        ['semantic-tokens?'] = false
      },
      ['clojure-lsp'] = {
        ['semantic-tokens'] = false,
        ['semantic-tokens?'] = false
      },
      clojure = {
        ['semantic-tokens'] = false,
        ['semantic-tokens?'] = false
      },
      ['semantic-tokens'] = false,
      ['semantic-tokens?'] = false
    },
    ['semantic-tokens'] = false,
    ['semantic-tokens?'] = false
  })

lispyclouds 2023-04-14T06:30:23.404759Z

I think this cannot be configured from the client side. need to set {:semantic-tokens? false} in either .lsp/config.edn or ~/.config/clojure-lsp/config.edn i think

lispyclouds 2023-04-14T06:36:32.523079Z

root_dir is the only client side config that's passed to it as of now

Martynas Maciulevičius 2023-04-14T06:44:38.334779Z

My goal is to keep the config inside of nvim's config file so that I wouldn't have it all scattered around. I also tried this and it actually starts clojure_lsp with the right arg and clojure_lsp doesn't crash

cmd = {
      '/usr/bin/clojure-lsp', '--settings', '{:semantic-tokens? false :semantic-tokens false}'
    },
But then the LSP highlighting still works. I don't know what's going on 😕 Maybe it's a wrong option.

Martynas Maciulevičius 2023-04-14T06:54:04.271489Z

Alright. Using --settings worked the way I intended in my previous message.

lispyclouds 2023-04-14T06:54:47.415349Z

yeah this is the only way to configure it as of now

Martynas Maciulevičius 2023-04-14T06:56:07.266059Z

No, it didn't work. I submitted a bad config. semantic-tokens gets ignored. I don't know how to configure this anymore 🤔 The binary runs with the correct args and doesn't crash but the highlighting is still enabled:

>  ps aux | grep clojure-lsp
/usr/bin/clojure-lsp --settings {:semantic-tokens? false :semantic-tokens false}

lispyclouds 2023-04-14T06:57:24.366509Z

according to the clojure-lsp docs semantic-tokens? is the one: https://github.com/clojure-lsp/clojure-lsp/blob/master/docs/all-available-settings.edn#L34

Martynas Maciulevičius 2023-04-14T06:57:43.547279Z

I know but it's simply ignored. And I even passed one without ? too

lispyclouds 2023-04-14T06:58:22.076869Z

im assuming youre on nvim 0.9?

Martynas Maciulevičius 2023-04-14T06:58:45.579909Z

NVIM v0.9.0 clojure-lsp 2023.02.27-13.12.12 But this can't be nvim's issue because the command line is constructed by me. And then there is no other LSP server that could analyze that extended highlighting because I checked that there is only one clojure-lsp running with that specified arg. I'll ask in lsp channel.

lispyclouds 2023-04-14T07:05:11.517169Z

yeah im thinking of a way for nvim to ignore the lsp tokens

lispyclouds 2023-04-14T07:06:11.845189Z

try

vim.api.nvim_create_autocmd("LspAttach", {
  callback = function(args)
    local client = vim.lsp.get_client_by_id(args.data.client_id)
    client.server_capabilities.semanticTokensProvider = nil
  end,
});

lispyclouds 2023-04-14T07:08:48.279279Z

also vim.lsp.semantic_tokens.stop() should work too i think

lispyclouds 2023-04-14T07:09:13.156589Z

you can call this when the lsp attaches

Martynas Maciulevičius 2023-04-14T07:09:34.954909Z

If vim.lsp.semantic_tokens.stop() works then it could be better because it would be stopped from LSP's side and not from editor's side 🤔 But wait, wouldn't it stop tokens for all LSP sessions?

lispyclouds 2023-04-14T07:10:27.238699Z

its for the buffer i think

Martynas Maciulevičius 2023-04-14T07:10:57.201519Z

I'll try it.

lispyclouds 2023-04-14T07:11:59.818139Z

as for the lsp config, not quite sure why it doesnt pick up the settings from the command line arg, have only used the edn file configs. the clojure-lsp maintainers would know better

Martynas Maciulevičius 2023-04-14T07:13:08.971019Z

I wrote it in the chat. Maybe something is wrong. This is the second time I try some config that nobody tried before and it doesn't work.

lispyclouds 2023-04-14T07:20:15.043749Z

ah yeah, you need to pass the buffer number and client id to stop:

stop({bufnr}, {client_id})                    *vim.lsp.semantic_tokens.stop()*
    Stop the semantic token highlighting engine for the given buffer with the
    given client.

    NOTE: This is automatically called by a |LspDetach| autocmd that is set up
    as part of `start()`, so you should only need this function to manually
    disengage the semantic token engine without fully detaching the LSP client
    from the buffer.

    Parameters: ~
      • {bufnr}      (integer)
      • {client_id}  (integer)
never used it, reading the help now

lispyclouds 2023-04-14T07:26:40.653789Z

clojure-lsp has been sending these tokens for a while now i think, nvim from 0.9 started to use them now

Martynas Maciulevičius 2023-04-14T07:29:45.772889Z

Well for me vim.lsp.semantic_tokens.stop() doesn't work to disable the tokens. I think they didn't expect that some random guy would want this stupid feature.

lispyclouds 2023-04-14T07:30:26.293499Z

well like i said, your colorscheme needs to handle these in a way that you want

lispyclouds 2023-04-14T07:30:44.429649Z

i think you have regex based highlighting too

lispyclouds 2023-04-14T07:30:55.506829Z

these two are at odds

Martynas Maciulevičius 2023-04-14T07:31:36.782349Z

Regex-based highlighting is very fast. And also there will be a treesitter highlighting at some point which in theory should be faster and better. And this LSP one... it's good but I want to keep it simple. Three highlighting providers is quite much.

lispyclouds 2023-04-14T07:33:20.673869Z

yes, you need to stick to either regex or the semantic/treesitter ones. combining both isnt good as they approch the issue with very different and incompatible perspectives

lispyclouds 2023-04-14T07:34:02.582509Z

having both on would have issues like this

Martynas Maciulevičius 2023-04-14T07:34:33.169959Z

The problem with LSP highlighting is that when I type :syntax off it doesn't turn off. It doesn't care whether I want highlighting at all or not.

lispyclouds 2023-04-14T07:34:59.023519Z

that maybe coming from tressiter too

Martynas Maciulevičius 2023-04-14T07:36:07.574519Z

> that maybe coming from tressiter too I disabled treesitter because it wasn't highlighting parts of keywords and for other cases I didn't need any highlighting. LSP highlights unused vars correctly but it's intrusive to the point that it highlights everything where it's actually harming the readability. And I already can find unused vars using clj-kondo and LSP messages. Which means that LSP highlighting only gets in the way and lags for no reason.

lispyclouds 2023-04-14T07:36:30.613259Z

> Regex-based highlighting is very fast. it has issues in things like very long lines etc, hence the other methods

lispyclouds 2023-04-14T07:38:02.020499Z

id wanna say you see the laggy ones more due to the regex one doing it first, then the lsp changing it. but yes if its an annoyance you can turn it off. it there for other reasons, which may not be yours

Martynas Maciulevičius 2023-04-14T07:38:32.065239Z

I use LSP for jumping around in the code and for that it works very well. But I only want the jumping part and not highlighting one. Of course it would be good if it can highlight functions and macros correctly but I want to understand what it does first instead of letting myself into the 1-2s lag. For now I don't think it's useful to have it.

lispyclouds 2023-04-14T07:40:40.087029Z

id just say again, lsp is just sending some data, your colorscheme is interpreting this differently now. the longer term fix should be to adapt the colorscheme and not turn the tokens off

Martynas Maciulevičius 2023-04-14T08:44:51.637569Z

I can't run nvim with syntax off and LSP. LSP just doesn't highlight parens and everything. And then it also breaks existing themes too because now it colors things as it wants. For instance when I turn :syntax off then I can't have :syntax command which would display why a token is colored the way it is. So the only way I try to debug it is to find a colorscheme that colors the thing I want and override it.

Martynas Maciulevičius 2023-04-14T09:24:12.542369Z

Turns out this is the syntax variable that I was looking for: @lsp.type.keyword Oh my.