whoissethdaniel / toggle-lsp-diagnostics.nvim Goto Github PK
View Code? Open in Web Editor NEWNeovim plugin for toggling the LSP diagnostics.
License: MIT License
Neovim plugin for toggling the LSP diagnostics.
License: MIT License
Maybe you can think about this realization?
Default config, LSP attached and operational:
E5108: Error executing lua ...ggle-lsp-diagnostics.nvim/lua/toggle_lsp_diagnostics.lua:90: attempt to index a nil value
stack traceback:
...ggle-lsp-diagnostics.nvim/lua/toggle_lsp_diagnostics.lua:90: in function 'toggle_diagnostic'
...ggle-lsp-diagnostics.nvim/lua/toggle_lsp_diagnostics.lua:109: in function 'toggle_virtual_text'
[string ":lua"]:1: in main chunk
A simple question, with which option could I disable lsp by default? I want to toggle it on when I need it. Thanks!
I came across this plugin but it didn't quite solve my desires. However, it was a helpful starting point, and I think the results I got might be useful to share here (either to incorporate or for others to copy).
This will automatically grab a user's existing configuration, and toggle between that config and everything off (in contrast to this plugin currently, which ignores the existing config).
DiagnosticsConfig = vim.diagnostic.config()
DiagnosticsEnabled = true
function ToggleDiagnostics()
if not DiagnosticsEnabled then
vim.diagnostic.config(DiagnosticsConfig)
DiagnosticsEnabled = true
else
DiagnosticsConfig = vim.diagnostic.config()
vim.diagnostic.config({
virtual_text = false,
sign = false,
float = false,
update_in_insert = false,
severity_sort = false,
underline = false,
})
DiagnosticsEnabled = false
end
end
vim.keymap.set("n", "yod", ToggleDiagnostics, { noremap=true, silent=true })
Hi, thank you for this nice package.
When toggling the diagnostics, there is a final message M.display_status('All diagnostics are', M.settings.all)
.
However, in the case of toggling the diagnostics on, there is already a message printed vim.api.nvim_echo({ { 'all diagnostics are at default' } }, false, {})
. This causes the output of the toggle call to be a multiline string, which requires to tap enter before being able to continue using nvim.
Wouldn't it be preferable to delete line 68?
E5108: Error executing lua ...ggle-lsp-diagnostics.nvim/lua/toggle_lsp_diagnostics.lua:44: attempt to index a nil value
stack traceback:
...ggle-lsp-diagnostics.nvim/lua/toggle_lsp_diagnostics.lua:44: in function 'current_settings'
...ggle-lsp-diagnostics.nvim/lua/toggle_lsp_diagnostics.lua:133: in function 'configure_diagnostics'
...ggle-lsp-diagnostics.nvim/lua/toggle_lsp_diagnostics.lua:57: in function 'turn_off_diagnostics'
[string ":lua"]:1: in main chunk
nvim --version shows
NVIM v0.9.0-dev-1291+gbad218cd6
Build type: RelWithDebInfo
LuaJIT 2.1.0-beta3
Compilation: /usr/bin/gcc-10 -O2 -g -Og -g -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wvla -Wdouble-promotion -Wmissing-noreturn -Wmissing-format-attribute -Wmissing-prototypes -fno-common -Wno-unused-result -Wimplicit-fallthrough -fdiagnostics-color=always -fstack-protector-strong -DUNIT_TESTING -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -I/__w/neovim/neovim/.deps/usr/include/luajit-2.1 -I/usr/include -I/__w/neovim/neovim/.deps/usr/include -I/__w/neovim/neovim/build/src/nvim/auto -I/__w/neovim/neovim/build/include -I/__w/neovim/neovim/build/cmake.config -I/__w/neovim/neovim/src -I/usr/include -I/__w/neovim/neovim/.deps/usr/include -I/__w/neovim/neovim/.deps/usr/include -I/__w/neovim/neovim/.deps/usr/include -I/__w/neovim/neovim/.deps/usr/include -I/__w/neovim/neovim/.deps/usr/include -I/__w/neovim/neovim/.deps/usr/include
system vimrc file: "$VIM/sysinit.vim"
fall-back for $VIM: "/__w/neovim/neovim/build/nvim.AppDir/usr/share/nvim"
Run :checkhealth for more info
even when I set config to true it doesn't turn on and I have to manually toggle-lsp-diag-default
require'toggle_lsp_diagnostics'.init({ start_on = true }})
When I <Plug>(toggle-lsp-diag)
they turn off fine, but when I do that again the diagnostics lose any of the settings I have assigned. If I do <Plug>(toggle-lsp-diag-default)
my customization is back again. This is unexpected behavior. I would like to toggle on/off without it changing any settings. Pressing two keys to turn them back on [properly] is also unacceptable.
When trying any Toggle command, I get the following error
E5108: Error executing lua Vim:E158: Invalid buffer name: 1 โ
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.