Code Monkey home page Code Monkey logo

toggle-lsp-diagnostics.nvim's Introduction

Description

A Neovim plugin for toggling the LSP diagnostics. Turn all diagnostics on/off or turn on/off individual features of diagnostics (virtual text, underline, signs, etc...).

Compatibility

Neovim >= 0.5.0

Installation

Install using your favorite plugin manager.

If you use vim-plug:

Plug 'WhoIsSethDaniel/toggle-lsp-diagnostics.nvim'

Or if you use Vim 8 style packages:

cd <plugin dir>
git clone https://github.com/WhoIsSethDaniel/toggle-lsp-diagnostics.nvim

Configuration

Somwhere in your config you should have this:

require('toggle_lsp_diagnostics').init()

If you are using Vimscript for configuration:

lua <<EOF
require'toggle_lsp_diagnostics'.init()
EOF

To preserve the current diagnostic configuration upon initializing this module you can do the following (assuming your Neovim is at least 0.7):

vim.diagnostic.config { ...some config... }
require('toggle_lsp_diagnostics').init(vim.diagnostic.config())

You can pass an initial configuration for each of the diagnostic settings:

require('toggle_lsp_diagnostics').init { underline = false, virtual_text = { prefix = 'XXX', spacing = 5 } }

The above turns off underlining by default and configures the virtual text with a prefix of 'XXX' and five spaces prior to the virtual text being printed. The complete list of settings may be found in lsp help page.

You can configure diagnostics so that they are off when you first start Neovim:

require'toggle_lsp_diagnostics'.init({ start_on = false })

Simply toggle them back on when you want to see them.

Behavior

The toggling is currently done globally. When you turn off all diagnostics you do so for all buffers / clients both now and in the future. When you turn diagnostics back on the same applies.

You can change the default settings by passing a configuration to the init() method (see the 'Configuration' section above).

Mappings

The following mappings are available.

<Plug>(toggle-lsp-diag-underline) Toggle underlining diagnostic information.

<Plug>(toggle-lsp-diag-signs) Toggle displaying signs in the sign column.

<Plug>(toggle-lsp-diag-vtext) Toggle displaying virtual text in your code.

<Plug>(toggle-lsp-diag-update_in_insert) Toggle updating diagnostic information while in insert mode.

<Plug>(toggle-lsp-diag) Toggle all diagnostics. Turn them all off / or back to what was passed to init().

<Plug>(toggle-lsp-diag-default) Set all diagnostics to their default. The default is everything is on, unless other values were passed to init().

<Plug>(toggle-lsp-diag-on) Turn all diagnostics on.

<Plug>(toggle-lsp-diag-off) Turn all diagnostics off.

An example configuration:

nmap <leader>tlu <Plug>(toggle-lsp-diag-underline)
nmap <leader>tls <Plug>(toggle-lsp-diag-signs)
nmap <leader>tlv <Plug>(toggle-lsp-diag-vtext)
nmap <leader>tlp <Plug>(toggle-lsp-diag-update_in_insert)

nmap <leader>tld  <Plug>(toggle-lsp-diag)
nmap <leader>tldd <Plug>(toggle-lsp-diag-default)
nmap <leader>tldo <Plug>(toggle-lsp-diag-off)
nmap <leader>tldf <Plug>(toggle-lsp-diag-on)

Commands

The following commands are available:

:ToggleDiag Toggle ALL diagnostics on/off

:ToggleDiagDefault Toggle ALL diagnostics to their default

:ToggleDiagOn Turn ALL diagnostics on

:ToggleDiagOff Turn ALL diagnostics off

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.