vim-lsp icon indicating copy to clipboard operation
vim-lsp copied to clipboard

Toggling g:lsp_diagnostics_float_cursor has no effect when initial value is set to 0

Open brianjamesquinn1 opened this issue 2 years ago • 3 comments

In my .vimrc I have the following:

function! Diagnostic_Toggle()
    if g:lsp_diagnostics_float_cursor
        let g:lsp_diagnostics_float_cursor = 0
    else
        let g:lsp_diagnostics_float_cursor = 1
    endif
:endfunction

nnoremap <silent> <leader>e :call Diagnostic_Toggle()<CR>

I use this because I prefer the error to be echoed via let g:lsp_diagnostics_echo_cursor = 1, but when the diagnostic is too long for the entire message to be read, I like to hit \e to float the diagnostic message. Then I hide it again after I am done addressing it. This works fine as long as I have let g:lsp_diagnostics_float_cursor = 1 in my .vimrc, but I have to turn it off to begin with. If I start with let g:lsp_diagnostics_float_cursor = 0 in my .vimrc, then toggling g:lsp_diagnostics_float_cursor will never float the window.

brianjamesquinn1 avatar Mar 01 '22 19:03 brianjamesquinn1

This is currently expected since if the feature is disabled we don't even want to listen for the events. This is useful since vimscript is slow so small optimizations like this helps. It is also helps when there are bugs in some parts of the code that can be prevented temporarily by disabling the flag.

Few options.

  1. Add lsp_setup_post (feel free to suggest better name) user event such that it allows you enable it by default but as soon as the events are registered you disable it and this will allow dynamic turning on and off.
  2. Add another flag such as g:lsp_diagnostics_float_cursor_ignore = 1

I'm leaning for 1 as 2 would mean we introduce a lot of new flags and could be avoided in the future if vim supports neovim's dictionary notification api.

prabirshrestha avatar Mar 02 '22 01:03 prabirshrestha

I would lean toward 1 as well. I think lsp_setup_post is a little vague. Would prefer lsp_post_setup_settings. Post usually comes before a verb so I think post alone is confusing, but it may be better for grepping/naming conventions for setup to come immediately after lsp so maybe something like lsp_setup_after_overrides, lsp_setup_post_settings or something along those line may be better.

brianjamesquinn1 avatar Mar 14 '22 20:03 brianjamesquinn1

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Jun 11 '22 04:06 stale[bot]

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Aug 12 '22 06:08 stale[bot]