Cannot disable reference code lens (FSAC)
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.
Environment (please complete the following information):
- OS: Linux Mint 21.3
- Neovim version: v0.9.5
- dotnet SDK version: 8.0.101
- FSAC version: 0.70.1
Additional context This might not be a bug if it is not implemented.
@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:
- Change setting and
:so $MYVIMRC - Change+source and restart language server
- 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.
@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 :)
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
Good catch! For anyone wanting to disable reference code lens, it is possible in Neovim using lspconfig. First, disable automatic FsAutoComplete setup with Ionide using:
vim.g["fsharp#lsp_auto_setup"] = 0
Then, manually set up FsAutoComplete using lspconfig with the setting disabled (where capabilities and on_attach are defined previously in my config):
require("ionide").setup({
capabilities = capabilities,
on_attach = on_attach,
settings = {
FSharp = {
codeLenses = {
references = {
enabled = false
}
}
}
},
})