From 89a223e8d38c70bfa3af6fc103f6aedae8ca5e3d Mon Sep 17 00:00:00 2001 From: TJ DeVries Date: Fri, 6 Nov 2020 12:11:16 -0500 Subject: [PATCH] Deprecate --- README.md | 155 ++-------------------------------------- lua/diagnostic.lua | 11 +++ lua/diagnostic/util.lua | 5 +- 3 files changed, 19 insertions(+), 152 deletions(-) diff --git a/README.md b/README.md index 48d6bfd..358cda5 100644 --- a/README.md +++ b/README.md @@ -1,153 +1,6 @@ -# diagnostic-nvim +# diagnostic-nvim (DEPRECATED) -The built- in Nvim language server support is amazing, but the diagnostics setting -that it shipped with it by default may not be as great as other LSP plugins. -Fortunately, it's very customizable with changing the default callback function -with lua. This plugin tries to focus on wrapping the diagnostics setting up to -make it a more user friendly without adding too much to it. +After the creation of `vim.lsp.diagnostic` (See: https://github.com/neovim/neovim/pull/12655) +`nvim-lua/diagnostic.nvim` is deprecated. To find out how to migrate, checkout the [migration guide](https://github.com/nvim-lua/diagnostic-nvim/issues/73). -## Features - -- Options to disable/enable virtual text. -- Pipe diagnostic information into location list. -- Jump to next/previous diagnostic under your cursor. -- Automatically open pop up window that shows line diagnostic while jumping. -- Show error sign in columns. -- Show error underline in symbols. -- Delay diagnostic when you're in insert mode. - -## Demo -![Demo](https://user-images.githubusercontent.com/35623968/75627012-6824f380-5c07-11ea-8f25-59ce1751e902.gif) - -## Prerequisites - -- Neovim nightly -- You should set up your language server of choice with the help of [nvim-lsp](https://github.com/neovim/nvim-lsp) - -## Install - -- Install with any plugin manager by using the path on GitHub. - -```vim -Plug 'nvim-lua/diagnostic-nvim' -``` - -## Setup - -- Diagnostic-nvim requires several autocommands set up to work properly. You should - set it up using the `on_attach` function like this. - -```vim -lua require'nvim_lsp'.pyls.setup{on_attach=require'diagnostic'.on_attach} -``` - -- Change `pyls` to whichever language server you're using. - -## Commands - -- Use `PrevDiagnostic` and `NextDiagnostic` to jump to the previous and next diagnostic - under your cursor. -- `PrevDiagnosticCycle` and `NextDiagnosticCycle` not only jump to the previous and next diagnostic but also -cycle through the diagnostic if you're at the first or last diagnostic. -- `OpenDiagnostic` will open a location list and jump back to previous window. - -## Options - -### Enable/Disable virtual text - -- Diagnostic-nvim has an option that lets you toggle the virtual text. Virtual text - is disabled by default. You can enable it by - -```vim -let g:diagnostic_enable_virtual_text = 1 -``` - -### Change virtual text prefix - -- Diagnostic-nvim provides an option to change the virtual text prefix, the - default prefix is '■', but if you have nerd font or other power line font - support, you can make it a little more fancy by adding something like: - -```vim -let g:diagnostic_virtual_text_prefix = ' ' -``` - -### Trimming virtual text - -- Sometimes you can be working with language which has long virtual text, - Diagnostic-nvim provides an option to trim the virtual text to fit your usage by - -```vim -let g:diagnostic_trimmed_virtual_text = '20' -``` - -- If the virtual text exceeds the value that you set, `...` will be displayed in the end. -- Note that setting this option to `0` means that it will only show the prefix. -- By default, this value is set to `v:null`, which means it's not trimmed at all. - -### Spaces before virtual text -- By default, there will be only a space before virtual text. You can add more spaces by - -```vim -let g:space_before_virtual_text = 5 -``` - -### Enable/Disable Sign - -- By default, the build-in Nvim LSP will show a sign on every line that you have - a diagnostic message on. You can turn this off by - -```vim -let g:diagnostic_show_sign = 0 -``` - -- The default priority of the diagnostic sign is 20. You can customize it by - -```vim -let g:diagnostic_sign_priority = 20 -``` - -- Make sure to use the latest branch of Neovim which has sign support. - -- If you want to change the symbols of sign, use `sign_define` to change it - -```vim -call sign_define("LspDiagnosticsErrorSign", {"text" : "E", "texthl" : "LspDiagnosticsError"}) -call sign_define("LspDiagnosticsWarningSign", {"text" : "W", "texthl" : "LspDiagnosticsWarning"}) -call sign_define("LspDiagnosticsInformationSign", {"text" : "I", "texthl" : "LspDiagnosticsInformation"}) -call sign_define("LspDiagnosticsHintSign", {"text" : "H", "texthl" : "LspDiagnosticsHint"}) -``` - -### Enable/Disable Underline - -- By default, the build-in Nvim LSP will show a underline on every symbol that - you have a diagnostic message on. You can turn this off by - -```vim -let g:diagnostic_enable_underline = 0 -``` - -### Enable/Disable auto popup window - -- When you jump to next or previous diagnostic, line diagnostic message will popup - in a popup window, you can disable it by - -```vim -let g:diagnostic_auto_popup_while_jump = 0 -``` - -### Enable/Disable insert delay - -- Neovim's built-in LSP support will keep sending diagnostic messages when you're - in insert mode. Sometimes this can be kind of distraction especially when you have - virtual text enabled. If you don't want to show diagnostics while in insert mode, - set the following - -```vim -let g:diagnostic_insert_delay = 1 -``` - -## WARNING - -- This plugin is in the early stages and might have unexpected issues. -- Feel free to post issues on any unexpected behavior or open a feature request! +You should uninstall diagnostic-nvim if you are on latest master. diff --git a/lua/diagnostic.lua b/lua/diagnostic.lua index b5d87aa..fa2fc0b 100644 --- a/lua/diagnostic.lua +++ b/lua/diagnostic.lua @@ -121,7 +121,18 @@ function M.getDiagnosticCount(level, bufnr) end +local warned = false M.on_attach = function(_, _) + if not warned and vim.lsp.diagnostic then + warned = true + vim.api.nvim_err_write([['vim.lsp.diagnostic' is now builtin. 'nvim-lua/diagnostic-nvim' is now deprecated. +To migrate from 'nvim-lua/diagnostic-nvim' to builtin, + See: https://github.com/nvim-lua/diagnostic-nvim/issues/73 +For more information about new features, + See: https://github.com/neovim/neovim/pull/12655 +]]) + end + -- Setup autocmd M.modifyCallback() vim.api.nvim_command [[augroup DiagnosticRefresh]] diff --git a/lua/diagnostic/util.lua b/lua/diagnostic/util.lua index cd6a7fb..0c76452 100644 --- a/lua/diagnostic/util.lua +++ b/lua/diagnostic/util.lua @@ -175,7 +175,10 @@ function M.buf_diagnostics_signs(bufnr, diagnostics) [protocol.DiagnosticSeverity.Information] = "LspDiagnosticsInformationSign"; [protocol.DiagnosticSeverity.Hint] = "LspDiagnosticsHintSign"; } - vim.fn.sign_place(0, sign_ns, diagnostic_severity_map[diagnostic.severity], bufnr, {lnum=(diagnostic.range.start.line+1), priority=vim.g.diagnostic_sign_priority}) + pcall( + vim.fn.sign_place, + 0, sign_ns, diagnostic_severity_map[diagnostic.severity], bufnr, {lnum=(diagnostic.range.start.line+1), priority=vim.g.diagnostic_sign_priority} + ) end end