ionide / Ionide-vim

F# Vim plugin based on FsAutoComplete and LSP protocol
MIT License
163 stars 20 forks source link

Cannot disable reference code lens (FSAC) #77

Open markusbrammer opened 4 months ago

markusbrammer commented 4 months ago

Describe the bug It doesn't seem possible to disable reference code lens for FSAutoComplete (FSAC). The FSAC setting FSharp.EnableReferenceCodeLens is included in the Ionide's list of FSAC configs/settings: https://github.com/ionide/Ionide-vim/blob/8435bae84b26b602dbb68399661b3989915cc4d3/autoload/fsharp.vim#L178 I am also using lspconfig.

To Reproduce NA, see expected behaviour

Expected behaviour I would expect to behave like disabling other FSAC settings:

vim.g['fsharp#unused_declarations_analyzer'] = 0 -- Works
vim.g['fsharp#unused_opens_analyzer'] = 0 -- Works 
vim.g['fsharp#enable_reference_code_lens'] = 0 -- Doesn't work

But it doesn't work, the reference counter is still there, see screenshot.

Screenshots Want to disable the 1 References part. image

Environment (please complete the following information):

Additional context This might not be a bug if it is not implemented.

greggyb commented 1 month ago

@cannorin , I dug into this a little bit, to the extent of changing the default to this in autoload/fsharp.vim, trying to implement the CodeLens property, which also mentions the reference count. I also removed all properties referencing this reference code lens. I tried these variations with each change:

  1. Change setting and :so $MYVIMRC
  2. Change+source and restart language server
  3. Change and close vim, then re-open.

If you have any pointers, I can continue digging on this one. I didn't have time yet, but my next step will be checking the LSP log when starting up and changing these options.

cannorin commented 1 month ago

@greggyb It should be enough to call :FSharpUpdateServerConfig to update the LSP server configuration, which calls workspace/didChangeConfiguration under the hood.

My concern is that CodeLens options may not work in workspace/didChangeConfiguration and have to be specified in initializationOptions (which is init_options in Neovim's LSP client). If that is the case, we would have to explicitly add it to initializationOptions as we do for AutomaticWorkspaceInit. https://github.com/ionide/Ionide-vim/blob/master/lua/ionide/init.lua#L38-L54

I'm going to take a look at this issue on this weekend (since I suspect that setting the CodeLenses option would fix this), but I really appreciate it if you can continue investigating it! Feel free to open a PR if you manage to fix it at your end before I do :)

joprice commented 2 weeks ago

According to the changelog, the setting was renamed from FSharp.EnableReferenceCodeLens to FSharp.codeLenses.references.enabled: https://github.com/ionide/FsAutoComplete/blob/edca0ecf0c081b80aec1a135d4fffddcf28fe449/CHANGELOG.md?plain=1#L420.

Here's where it's accessed: https://github.com/ionide/FsAutoComplete/blob/edca0ecf0c081b80aec1a135d4fffddcf28fe449/src/FsAutoComplete/LspServers/AdaptiveFSharpLspServer.fs#L1539