Giter Site home page Giter Site logo

diagnostic-nvim's Introduction

diagnostic-nvim (DEPRECATED)

After the creation of vim.lsp.diagnostic (See: neovim/neovim#12655) nvim-lua/diagnostic.nvim is deprecated. To find out how to migrate, checkout the migration guide.

You should uninstall diagnostic-nvim if you are on latest master.

diagnostic-nvim's People

Contributors

chmln avatar ckipp01 avatar el-iot avatar erw7 avatar haorenw1025 avatar iron-e avatar kosayoda avatar ndreas avatar tjdevries avatar yaegassy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

diagnostic-nvim's Issues

option to disable all passive lint highlighting

I've been banging my head against the wall for quite a while now trying to disable ONLY the passive text highlighting.

2020-06-11-103100_465x106_scrot

Like in this example, I don't want any of these highlights and underlines, but I do want the pop-ups to work when I ask for them with proper highlighting.

2020-06-11-103227_491x76_scrot
(e.g. I do want the above, only in the pop-up).

For the life of me I can't seem to get this to happen with neovim-lsp. The closest I can get is turning off all LSP-related highlighting by setting, e.g.

hi! LspDiagnosticsUnderline ctermbg=none
hi! LspDiagnosticsInformation ctermbg=none
hi! LspDiagnosticsHint ctermbg=none
hi! LspDiagnosticsError ctermbg=none
hi! LspDiagnosticsWarning ctermbg=none
hi! LspDiagnosticsUnderlineError ctermbg=none
hi! LspDiagnosticsUnderlineHint ctermbg=none
hi! LspDiagnosticsUnderlineInformation ctermbg=none
hi! LspDiagnosticsUnderlineWarning ctermbg=none

but this also turns off just about every form of highlighting in the pop-ups, which is not what I want.

Any idea if there's any way of doing this? Can an option be added in this package?

just to mention

just wanted to mention that these 2 items have been merged on neovim master already see neovim/neovim#11668:

  • Option to change sign text.
  • Support different signs for different diagnosis level.

Discussion: Might be able to re-use more built-in logic now

Hey, just drive-by issue of saying you might be able to re-use more of the built-in stuff for diagnostics now as we have exposed more stuff in master.

Also wondering if there was more stuff we could expose that would be helpful to you in this plugin.

Thanks.

Virtual text not always displaying

From #36:

Hmm… one thing I am noticing is that g:diagnostic_enable_virtual_text isn't doing anything for me right now (no virtual text is shown, only things in the sign column. Is this happening for you too?

Seems to be happening only on certain language servers. sumneko_lua and bashls are two of them, but interestingly enough omnisharp and gopls work but the diagnostics stay on screen after they should disappear.

I'll add that currently omnisharp is one of the more troubled language servers with nvim_lsp, so it's odd that it's working there.

Popups work on all servers I've tried, and so do items in the sign column.

Virtual text does not appear and/or disappears when cursor is on line

Virtual text does not appear and/or disappears when cursor is on a line with an entry in the diagnostic list.

Demonstration of the behavior:

out

The virtual text, when displayed, does not conform to the defined LSP diagnostic highlighting. Text is black when it should be light grey inline with Comment style. Should these settings be within the on_attach_callback?

Diagnostic configuration
local api = vim.api
local fn = vim.fn

api.nvim_command('packadd! nvim-lspconfig')  -- If installed as a Vim "package".
api.nvim_command('packadd! diagnostic-nvim')
api.nvim_command('packadd! completion-nvim')

local nvim_lsp = require'nvim_lsp'
local diagnostic_nvim = require'diagnostic'
local completion_nvim = require'completion'

-- Setup Nvim LSP configuration(s) with default values. Configure buffer(s)
-- omnifunc handler to consume LSP completion for each filetype, configuring
-- diagnostic-nvim in the process.
--
local on_attach_callback = function(_, bufnr)
  api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc')
  diagnostic_nvim.on_attach(_)
  completion_nvim.on_attach(_)
end

local servers = {'pyls_ms', 'sumneko_lua', 'tsserver', 'vimls', 'ocamllsp', 'html', 'sqlls'}
for _, lsp in ipairs(servers) do
  nvim_lsp[lsp].setup {
    on_attach = on_attach_callback,
  }
end

-- Configure diagnostic-nvim -------------------------
--
-- Change default signcolumn signs for LSP diagnostic. Note that the first
-- line is done this way as a reminder of the different ways to
-- interact with the nvim api from lua
--
api.nvim_call_function('sign_define', {"LspDiagnosticsErrorSign", {text = "", texthl = "LspDiagnosticsError"}})
fn.sign_define("LspDiagnosticsWarningSign", {text = "", texthl = "LspDiagnosticsWarning"})
fn.sign_define("LspDiagnosticsInformationSign", {text = "", texthl = "LspDiagnosticsInformation"})
fn.sign_define("LspDiagnosticsHintSign", {text = "", texthl = "LspDiagnosticsHint"})

-- api.nvim_command('highlight link LspDiagnosticsError Comment')
api.nvim_command('highlight link LspDiagnosticsWarning Comment')
api.nvim_command('highlight link LspDiagnosticsInformation Comment')
api.nvim_command('highlight link LspDiagnosticsHint Comment')


api.nvim_set_var('diagnostic_enable_virtual_text', 1)
api.nvim_set_var('diagnostic_virtual_text_prefix', '')
api.nvim_set_var('diagnostic_trimmed_virtual_text', '32')
api.nvim_set_var('diagnostic_sign_priority', 20)
api.nvim_set_var('diagnostic_enable_underline', 0)
api.nvim_set_var('space_before_virtual_text', 2)
api.nvim_set_var('diagnostic_insert_delay', 1)

Version Details

Neovim

NVIM v0.5.0-nightly-88-gc5ceefca7
Build type: Release
LuaJIT 2.0.5

Health check

health#targets#check
========================================================================
  - OK: No conflicting mappings found

health#completion_nvim#check
========================================================================
  - ERROR: Failed to run healthcheck for "completion_nvim" plugin. Exception:
    function health#check[21]..health#completion_nvim#check, line 1
    Vim(lua):E5108: Error executing lua ...tart/completion-nvim/lua/completion/chain_completion.lua:60: attempt to index local 'syntax_regex' (a number value)

health#nvim_lsp#check
========================================================================
## Checking language server protocol configuration
  - INFO: pyls_ms: configuration checked.
  - INFO: sqlls: configuration checked.
  - INFO: tsserver: configuration checked.
  - INFO: vimls: configuration checked.
  - INFO: ocamllsp: configuration checked.
  - ERROR: html: The given command "html-languageserver" is not executable.
  - INFO: sumneko_lua: configuration checked.

health#nvim_treesitter#check
========================================================================
## Installation
  - OK: `git` executable found.
  - OK: `cc` executable found.

## elm parser healthcheck
  - OK: elm parser found.
  - WARNING: No `highlights.scm` query found for elm
    - ADVICE:
      - Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
  - WARNING: No `locals.scm` query found for elm
    - ADVICE:
      - Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
  - WARNING: No `textobjects.scm` query found for elm
    - ADVICE:
      - Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
  - WARNING: No `folds.scm` query found for elm
    - ADVICE:
      - Open an issue at https://github.com/nvim-treesitter/nvim-treesitter

## c parser healthcheck
  - OK: c parser found.
  - OK: `highlights.scm` found.
  - OK: `locals.scm` found.
  - OK: `textobjects.scm` found.
  - OK: `folds.scm` found.

## java parser healthcheck
  - OK: java parser found.
  - OK: `highlights.scm` found.
  - OK: `locals.scm` found.
  - WARNING: No `textobjects.scm` query found for java
    - ADVICE:
      - Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
  - WARNING: No `folds.scm` query found for java
    - ADVICE:
      - Open an issue at https://github.com/nvim-treesitter/nvim-treesitter

## python parser healthcheck
  - OK: python parser found.
  - OK: `highlights.scm` found.
  - OK: `locals.scm` found.
  - OK: `textobjects.scm` found.
  - OK: `folds.scm` found.

## dart parser healthcheck
  - OK: dart parser found.
  - OK: `highlights.scm` found.
  - OK: `locals.scm` found.
  - WARNING: No `textobjects.scm` query found for dart
    - ADVICE:
      - Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
  - WARNING: No `folds.scm` query found for dart
    - ADVICE:
      - Open an issue at https://github.com/nvim-treesitter/nvim-treesitter

## lua parser healthcheck
  - OK: lua parser found.
  - OK: `highlights.scm` found.
  - OK: `locals.scm` found.
  - OK: `textobjects.scm` found.
  - OK: `folds.scm` found.

## ocaml parser healthcheck
  - OK: ocaml parser found.
  - OK: `highlights.scm` found.
  - OK: `locals.scm` found.
  - WARNING: No `textobjects.scm` query found for ocaml
    - ADVICE:
      - Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
  - OK: `folds.scm` found.

## go parser healthcheck
  - OK: go parser found.
  - OK: `highlights.scm` found.
  - OK: `locals.scm` found.
  - OK: `textobjects.scm` found.
  - WARNING: No `folds.scm` query found for go
    - ADVICE:
      - Open an issue at https://github.com/nvim-treesitter/nvim-treesitter

## nix parser healthcheck
  - OK: nix parser found.
  - WARNING: No `highlights.scm` query found for nix
    - ADVICE:
      - Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
  - WARNING: No `locals.scm` query found for nix
    - ADVICE:
      - Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
  - WARNING: No `textobjects.scm` query found for nix
    - ADVICE:
      - Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
  - WARNING: No `folds.scm` query found for nix
    - ADVICE:
      - Open an issue at https://github.com/nvim-treesitter/nvim-treesitter

## yaml parser healthcheck
  - OK: yaml parser found.
  - WARNING: No `highlights.scm` query found for yaml
    - ADVICE:
      - Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
  - WARNING: No `locals.scm` query found for yaml
    - ADVICE:
      - Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
  - WARNING: No `textobjects.scm` query found for yaml
    - ADVICE:
      - Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
  - WARNING: No `folds.scm` query found for yaml
    - ADVICE:
      - Open an issue at https://github.com/nvim-treesitter/nvim-treesitter

## json parser healthcheck
  - OK: json parser found.
  - OK: `highlights.scm` found.
  - WARNING: No `locals.scm` query found for json
    - ADVICE:
      - Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
  - WARNING: No `textobjects.scm` query found for json
    - ADVICE:
      - Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
  - WARNING: No `folds.scm` query found for json
    - ADVICE:
      - Open an issue at https://github.com/nvim-treesitter/nvim-treesitter

## jsdoc parser healthcheck
  - OK: jsdoc parser found.
  - WARNING: No `highlights.scm` query found for jsdoc
    - ADVICE:
      - Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
  - WARNING: No `locals.scm` query found for jsdoc
    - ADVICE:
      - Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
  - WARNING: No `textobjects.scm` query found for jsdoc
    - ADVICE:
      - Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
  - WARNING: No `folds.scm` query found for jsdoc
    - ADVICE:
      - Open an issue at https://github.com/nvim-treesitter/nvim-treesitter

## markdown parser healthcheck
  - OK: markdown parser found.
  - WARNING: No `highlights.scm` query found for markdown
    - ADVICE:
      - Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
  - WARNING: No `locals.scm` query found for markdown
    - ADVICE:
      - Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
  - WARNING: No `textobjects.scm` query found for markdown
    - ADVICE:
      - Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
  - WARNING: No `folds.scm` query found for markdown
    - ADVICE:
      - Open an issue at https://github.com/nvim-treesitter/nvim-treesitter

## julia parser healthcheck
  - OK: julia parser found.
  - WARNING: No `highlights.scm` query found for julia
    - ADVICE:
      - Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
  - WARNING: No `locals.scm` query found for julia
    - ADVICE:
      - Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
  - WARNING: No `textobjects.scm` query found for julia
    - ADVICE:
      - Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
  - WARNING: No `folds.scm` query found for julia
    - ADVICE:
      - Open an issue at https://github.com/nvim-treesitter/nvim-treesitter

## html parser healthcheck
  - OK: html parser found.
  - OK: `highlights.scm` found.
  - OK: `locals.scm` found.
  - WARNING: No `textobjects.scm` query found for html
    - ADVICE:
      - Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
  - WARNING: No `folds.scm` query found for html
    - ADVICE:
      - Open an issue at https://github.com/nvim-treesitter/nvim-treesitter

## typescript parser healthcheck
  - OK: typescript parser found.
  - OK: `highlights.scm` found.
  - OK: `locals.scm` found.
  - OK: `textobjects.scm` found.
  - OK: `folds.scm` found.

## fennel parser healthcheck
  - OK: fennel parser found.
  - OK: `highlights.scm` found.
  - OK: `locals.scm` found.
  - WARNING: No `textobjects.scm` query found for fennel
    - ADVICE:
      - Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
  - WARNING: No `folds.scm` query found for fennel
    - ADVICE:
      - Open an issue at https://github.com/nvim-treesitter/nvim-treesitter

## swift parser healthcheck
  - OK: swift parser found.
  - WARNING: No `highlights.scm` query found for swift
    - ADVICE:
      - Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
  - WARNING: No `locals.scm` query found for swift
    - ADVICE:
      - Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
  - WARNING: No `textobjects.scm` query found for swift
    - ADVICE:
      - Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
  - WARNING: No `folds.scm` query found for swift
    - ADVICE:
      - Open an issue at https://github.com/nvim-treesitter/nvim-treesitter

## query parser healthcheck
  - OK: query parser found.
  - OK: `highlights.scm` found.
  - OK: `locals.scm` found.
  - WARNING: No `textobjects.scm` query found for query
    - ADVICE:
      - Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
  - WARNING: No `folds.scm` query found for query
    - ADVICE:
      - Open an issue at https://github.com/nvim-treesitter/nvim-treesitter

## cpp parser healthcheck
  - OK: cpp parser found.
  - OK: `highlights.scm` found.
  - OK: `locals.scm` found.
  - OK: `textobjects.scm` found.
  - OK: `folds.scm` found.

## ruby parser healthcheck
  - OK: ruby parser found.
  - OK: `highlights.scm` found.
  - OK: `locals.scm` found.
  - WARNING: No `textobjects.scm` query found for ruby
    - ADVICE:
      - Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
  - WARNING: No `folds.scm` query found for ruby
    - ADVICE:
      - Open an issue at https://github.com/nvim-treesitter/nvim-treesitter

## vue parser healthcheck
  - OK: vue parser found.
  - WARNING: No `highlights.scm` query found for vue
    - ADVICE:
      - Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
  - WARNING: No `locals.scm` query found for vue
    - ADVICE:
      - Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
  - WARNING: No `textobjects.scm` query found for vue
    - ADVICE:
      - Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
  - WARNING: No `folds.scm` query found for vue
    - ADVICE:
      - Open an issue at https://github.com/nvim-treesitter/nvim-treesitter

## regex parser healthcheck
  - OK: regex parser found.
  - OK: `highlights.scm` found.
  - WARNING: No `locals.scm` query found for regex
    - ADVICE:
      - Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
  - WARNING: No `textobjects.scm` query found for regex
    - ADVICE:
      - Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
  - WARNING: No `folds.scm` query found for regex
    - ADVICE:
      - Open an issue at https://github.com/nvim-treesitter/nvim-treesitter

## scala parser healthcheck
  - OK: scala parser found.
  - WARNING: No `highlights.scm` query found for scala
    - ADVICE:
      - Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
  - WARNING: No `locals.scm` query found for scala
    - ADVICE:
      - Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
  - WARNING: No `textobjects.scm` query found for scala
    - ADVICE:
      - Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
  - WARNING: No `folds.scm` query found for scala
    - ADVICE:
      - Open an issue at https://github.com/nvim-treesitter/nvim-treesitter

## toml parser healthcheck
  - OK: toml parser found.
  - OK: `highlights.scm` found.
  - OK: `locals.scm` found.
  - WARNING: No `textobjects.scm` query found for toml
    - ADVICE:
      - Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
  - WARNING: No `folds.scm` query found for toml
    - ADVICE:
      - Open an issue at https://github.com/nvim-treesitter/nvim-treesitter

## rust parser healthcheck
  - OK: rust parser found.
  - OK: `highlights.scm` found.
  - OK: `locals.scm` found.
  - OK: `textobjects.scm` found.
  - WARNING: No `folds.scm` query found for rust
    - ADVICE:
      - Open an issue at https://github.com/nvim-treesitter/nvim-treesitter

## bash parser healthcheck
  - OK: bash parser found.
  - OK: `highlights.scm` found.
  - OK: `locals.scm` found.
  - WARNING: No `textobjects.scm` query found for bash
    - ADVICE:
      - Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
  - WARNING: No `folds.scm` query found for bash
    - ADVICE:
      - Open an issue at https://github.com/nvim-treesitter/nvim-treesitter

## ocaml_interface parser healthcheck
  - OK: ocaml_interface parser found.
  - OK: `highlights.scm` found.
  - OK: `locals.scm` found.
  - WARNING: No `textobjects.scm` query found for ocaml_interface
    - ADVICE:
      - Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
  - OK: `folds.scm` found.

## rst parser healthcheck
  - OK: rst parser found.
  - OK: `highlights.scm` found.
  - OK: `locals.scm` found.
  - OK: `textobjects.scm` found.
  - WARNING: No `folds.scm` query found for rst
    - ADVICE:
      - Open an issue at https://github.com/nvim-treesitter/nvim-treesitter

## css parser healthcheck
  - OK: css parser found.
  - OK: `highlights.scm` found.
  - WARNING: No `locals.scm` query found for css
    - ADVICE:
      - Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
  - WARNING: No `textobjects.scm` query found for css
    - ADVICE:
      - Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
  - WARNING: No `folds.scm` query found for css
    - ADVICE:
      - Open an issue at https://github.com/nvim-treesitter/nvim-treesitter

## c_sharp parser healthcheck
  - OK: c_sharp parser found.
  - OK: `highlights.scm` found.
  - WARNING: No `locals.scm` query found for c_sharp
    - ADVICE:
      - Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
  - OK: `textobjects.scm` found.
  - WARNING: No `folds.scm` query found for c_sharp
    - ADVICE:
      - Open an issue at https://github.com/nvim-treesitter/nvim-treesitter

## javascript parser healthcheck
  - OK: javascript parser found.
  - OK: `highlights.scm` found.
  - OK: `locals.scm` found.
  - OK: `textobjects.scm` found.
  - OK: `folds.scm` found.

## php parser healthcheck
  - OK: php parser found.
  - OK: `highlights.scm` found.
  - OK: `locals.scm` found.
  - WARNING: No `textobjects.scm` query found for php
    - ADVICE:
      - Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
  - OK: `folds.scm` found.

## haskell parser healthcheck
  - OK: haskell parser found.
  - WARNING: No `highlights.scm` query found for haskell
    - ADVICE:
      - Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
  - WARNING: No `locals.scm` query found for haskell
    - ADVICE:
      - Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
  - WARNING: No `textobjects.scm` query found for haskell
    - ADVICE:
      - Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
  - WARNING: No `folds.scm` query found for haskell
    - ADVICE:
      - Open an issue at https://github.com/nvim-treesitter/nvim-treesitter

## tsx parser healthcheck
  - OK: tsx parser found.
  - OK: `highlights.scm` found.
  - OK: `locals.scm` found.
  - OK: `textobjects.scm` found.
  - OK: `folds.scm` found.

health#nvim#check
========================================================================
## Configuration
  - OK: no issues found

## Performance
  - OK: Build type: Release

## Remote Plugins
  - OK: Up to date

## terminal
  - INFO: key_backspace (kbs) terminfo entry: key_backspace=^H
  - INFO: key_dc (kdch1) terminfo entry: key_dc=\E[3~
  - INFO: $TERM_PROGRAM='iTerm.app'
  - INFO: $COLORTERM='truecolor'

## tmux
  - OK: escape-time: 10
  - INFO: Checking stuff
  - OK: focus-events: on
  - INFO: $TERM: tmux-256color

health#provider#check
========================================================================
## Clipboard (optional)
  - OK: Clipboard tool found: pbcopy

## Python 2 provider (optional)
  - INFO: Using: g:python_host_prog = "/usr/local/anaconda3/envs/nvim-py2/bin/python"
  - INFO: Executable: /usr/local/anaconda3/envs/nvim-py2/bin/python
  - INFO: Python version: 2.7.17
  - INFO: pynvim version: 0.4.1 (outdated; from /usr/local/anaconda3/envs/nvim-py2/lib/python2.7/site-packages/neovim)
  - WARNING: Latest pynvim is NOT installed: 0.4.2

## Python 3 provider (optional)
  - INFO: Using: g:python3_host_prog = "/usr/local/anaconda3/envs/nvim-py3/bin/python"
  - INFO: Executable: /usr/local/anaconda3/envs/nvim-py3/bin/python
  - INFO: Python version: 3.8.1
  - INFO: pynvim version: 0.4.1 (outdated; from /usr/local/anaconda3/envs/nvim-py3/lib/python3.8/site-packages/neovim)
  - WARNING: Latest pynvim is NOT installed: 0.4.2

## Python virtualenv
  - OK: no $VIRTUAL_ENV

## Ruby provider (optional)
  - INFO: Ruby: ruby 2.7.1p83 (2020-03-31 revision a0c7c23c9c) [x86_64-darwin19]
  - INFO: Host: /Users/tkolleh/.rbenv/shims/neovim-ruby-host
  - WARNING: Gem "neovim" is out-of-date. Installed: 0.8.0, latest: 0.8.1
    - ADVICE:
      - Run in shell: gem update neovim

## Node.js provider (optional)
  - INFO: Node.js: v14.11.0
  - WARNING: Missing "neovim" npm (or yarn) package.
    - ADVICE:
      - Run in shell: npm install -g neovim
      - Run in shell (if you use yarn): yarn global add neovim

## Perl provider (optional)
  - ERROR: perl provider error:
    - ADVICE:
      - Perl version is too old, 5.22+ required

Trying to run in command-line window

When opening the command line window with q: the following error is printed:

Error executing vim.schedule lua callback: .../.config/nvim/plugged/diagnostic-nvim/lua/diagnostic.lua:74: Vim(lexpr):E11: Invalid in command-line window; <CR> executes, CTRL-C quits

diagnostic-nvim is being loaded using on_attach in my configuration, but this error occurs even when I haven't loaded a file yet.

diagnostic-nvim version is latest from git.
nvim version:

NVIM v0.5.0-523-g04a0486c6
Build type: Debug
LuaJIT 2.1.0-beta3
Compilation: /usr/bin/cc -g -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wmissing-prototypes -Wimplicit-fallthrough -Wvla -fstack-protector-strong -fno-common -fdiagnostics-color=always -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -DMIN_LOG_LEVEL=1 -I/home/gecko/build/neovim/build/config -I/home/gecko/build/neovim/src -I/home/gecko/build/neovim/.deps/usr/include -I/usr/include -I/home/gecko/build/neovim/build/src/nvim/auto -I/home/gecko/build/neovim/build/include
Compiled by gecko@mortred

Features: +acl +iconv +tui
See ":help feature-compile"

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "/usr/local/share/nvim"

Run :checkhealth for more info

Triggering diagnostics in a new file not on disk spams error messages

Hi,

This bug might be in neovim, however I can't get it reproduced without your plugin as I'm failing to navigate the undocumented vim.api.lsp calls. If you can figure it out I'd be very grateful!

Test steps I used:

  1. Make sure sumneko_lsp server is set up and working
  2. Edit a new file: :e mytestfile.lua
  3. Insert some text to trigger a diagnostic: local foo (should trigger a variable not used Hint)

The messages bar will then show:

Error executing vim.schedule lua callback: /usr/local/share/nvim/runtime/lua/vim/lsp/util.lua:1018: bad argument #1 to 'lines' (/home/gecko/.config/nvim/mytestfile.lua: No such file or directory)

Unfortunately this error is very aggressive and can make editing, or even controlling nvim, impossible.

Using up to date nightly nvim and this repo.

diagnostic appears as message before being displayed as a popup

There is a strange issue when I use successive Prev/NextDiagnostic. Sometimes the diagnostic is displayed next to the statusline right before being displayed as a popup, see the bottom of the screenshot:

2020-03-28-173343_636x719_scrot

Maybe it's something in my config but I am not sure what.

virtual text lose position when using this plugin.

When attaching this plugin, virtual text doesn't follow errors and get lost.

minimal vimrc

call plug#begin('~/.local/share/nvim/plugged')
    Plug 'neovim/nvim-lsp'
    Plug 'nvim-lua/diagnostic-nvim'
    Plug 'nvim-lua/completion-nvim'
call plug#end()
" lua require'nvim_lsp'.gopls.setup{on_attach=require'completion'.on_attach}
lua << EOF
local on_attach_vim = function()
  require'completion'.on_attach()
  require'diagnostic'.on_attach()
end
require'nvim_lsp'.gopls.setup{on_attach=on_attach_vim}
EOF
au Filetype lua setl omnifunc=v:lua.vim.lsp.omnifunc
" Use <Tab> and <S-Tab> to navigate through popup menu
inoremap <expr> <Tab>   pumvisible() ? "\<C-n>" : "\<Tab>"
inoremap <expr> <S-Tab> pumvisible() ? "\<C-p>" : "\<S-Tab>"

" " Set completeopt to have a better completion experience
set completeopt=menuone,noinsert,noselect

let g:diagnostic_enable_virtual_text = 1

let g:completion_chain_complete_list = {
    \ 'default': [
    \    {'complete_items': ['lsp', 'snippet', 'tabnine']},
    \    {'mode': '<c-p>'},
    \    {'mode': '<c-n>'}
    \]
\}

image

Wrong diagnostics appearing on locationlist

Using rust_analyzer and NVIM v0.5.0-583-g7b529e791
This just seems very odd behavior.

My first asciinema

On start everything seems correct. After opening locationlist using :lopen it contains some arbitrary points in the file (they are always the same). Diagnostic signs disappear after a while on the locationlist. When the file buffer is refocused all of the signs and locationlist restore to normal. Removing any character or writing anything on the file buffer gets the arbitrary points back to location list.

Also on top of this is there a way to make locationlist report the error itself?

diagnostic-nvim configuration:

let g:diagnostic_insert_delay = 1
local nvim_lsp = require('nvim_lsp')

local on_attach = function(client, bufnr)
    require'diagnostic'.on_attach(client)

    vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc')
    vim.api.nvim_command('setlocal signcolumn=yes')

    -- Mappings.
    local opts = { noremap=true, silent=true }
    vim.api.nvim_buf_set_keymap(bufnr , 'n' , 'gD'        , '<cmd>lua vim.lsp.buf.declaration()<CR>'            , opts)
    vim.api.nvim_buf_set_keymap(bufnr , 'n' , 'gd'        , '<cmd>lua vim.lsp.buf.definition()<CR>'             , opts)
    vim.api.nvim_buf_set_keymap(bufnr , 'n' , 'K'         , '<cmd>lua vim.lsp.buf.hover()<CR>'                  , opts)
    vim.api.nvim_buf_set_keymap(bufnr , 'n' , 'gi'        , '<cmd>lua vim.lsp.buf.implementation()<CR>'         , opts)
    vim.api.nvim_buf_set_keymap(bufnr , 'n' , 'gy'        , '<cmd>lua vim.lsp.buf.type_definition()<CR>'        , opts)
    vim.api.nvim_buf_set_keymap(bufnr , 'n' , 'gR'        , '<cmd>lua vim.lsp.buf.rename()<CR>'                 , opts)
    vim.api.nvim_buf_set_keymap(bufnr , 'n' , 'gr'        , '<cmd>lua vim.lsp.buf.references()<CR>'             , opts)
    vim.api.nvim_buf_set_keymap(bufnr , 'n' , '<leader>f' , '<cmd>lua vim.lsp.buf.formatting()<CR>'             , opts)
    vim.api.nvim_buf_set_keymap(bufnr , 'n' , '<leader>e' , '<cmd>lua vim.lsp.util.show_line_diagnostics()<CR>' , opts)
    vim.api.nvim_buf_set_keymap(bufnr , 'n' , '<leader>a' , '<cmd>lua vim.lsp.buf.code_action()<CR>' , opts)
    -- vim.api.nvim_buf_set_keymap(bufnr    , 'n' , '<C-k>'     , '<cmd>lua vim.lsp.buf.signature_help()<CR>'         , opts)
end

local servers = {'bashls', 'tsserver', 'pyls', 'rust_analyzer'}
for _, lsp in ipairs(servers) do
    nvim_lsp[lsp].setup {
        on_attach = on_attach,
    }
end

The plugin always sets the locations list overwiting an existing one

  • nvim --version: NVIM v0.5.0-634-g161cdba1e
  • language server name/version: ?
  • Operating system/version: Linux Debian Buster
nvim -c ":checkhealth nvim nvim_lsp"
health#nvim#check
========================================================================
## Configuration
  - OK: no issues found

## Performance
  - OK: Build type: RelWithDebInfo

## Remote Plugins
  - OK: Up to date

## terminal
  - INFO: key_backspace (kbs) terminfo entry: key_backspace=\177
  - INFO: key_dc (kdch1) terminfo entry: key_dc=\E[3~
  - INFO: $VTE_VERSION='5402'
  - INFO: $COLORTERM='truecolor'

health#nvim_lsp#check
========================================================================
## Checking language server protocol configuration
lsp.log

The lsp log remains empty.

Actual behaviour

I set the location list to the list of changes in the working tree with this function:

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Function: git#to_qfix
" Fill the locations list window with git diff hunks
" From GitGutter plugin.
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
""
function! git#to_qfix()
  " {{{1
  silent! Gcd
  let locations = []
  let cmd = 'git --no-pager diff --no-ext-diff --no-color -U0'
  if exists('g:gitgutter_diff_base')
    let cmd .= ' ' . g:gitgutter_diff_base
  endif
  let diff = systemlist(cmd)
  let lnum = 0
  for line in diff
    if line =~ '^diff --git [^"]'
      let paths = line[11:]
      let mid = (len(paths) - 1) / 2
      let [fnamel, fnamer] = [paths[:mid-1], paths[mid+1:]]
      let fname = fnamel ==# fnamer ? fnamel : fnamel[2:]
    elseif line =~ '^diff --git "'
      let [_, fnamel, _, fnamer] = split(line, '"')
      let fname = fnamel ==# fnamer ? fnamel : fnamel[2:]
    elseif line =~ '^@@'
      let lnum = matchlist(line, '+\(\d\+\)')[1]
    elseif lnum > 0
      call add(locations, {'filename': fname, 'lnum': lnum, 'text': line})
      let lnum = 0
    endif
  endfor
  if !empty(locations)
    call setloclist(0, locations)
    lopen
    ll
  else
    echo '[git.vim] no changes'
  endif
endfunction "}}}

Initially the location list is set (it's not empty and I can see it if I print it with echomsg), but as soon as it switches to a buffer with a lsp client (sumneko_lua in this case) it is replaced by the LSP locations list (it says so in the window statusline). You can see it in this asciicast:

asciicast

Expected behaviour

Well if I set a location list I don't want LSP to mess with it...

Plugin working without calling on_attach

Hello! Thanks for this nice plugin.

Currently, I have this small wrapper:

local vim = vim
local api = vim.api
-- local compl = require'completion'
-- local diagnostic = require'diagnostic'
local nvim_lsp = require'nvim_lsp'
local M = {}

local function on_attach()
    -- compl.on_attach()
    -- diagnostic.on_attach()
    api.nvim_command [[augroup LspAttachments]]
      api.nvim_command("autocmd! * <buffer>")
      -- api.nvim_command("autocmd CursorHold <buffer> lua vim.lsp.buf.hover()")
    api.nvim_command [[augroup end]]
    api.nvim_command("command! -buffer -nargs=0 LspRename call RenameSymbol()")
    api.nvim_command("command! -buffer -nargs=0 LspFormat lua vim.lsp.buf.formatting()")
end

function M.register_servers()
  -- Go
  nvim_lsp.gopls.setup{on_attach=on_attach}
  -- JavaScript & TypeScript
  nvim_lsp.tsserver.setup{on_attach=on_attach}
end

return M

And in my init.vim:

" ...
Plug 'haorenW1025/diagnostic-nvim'
" Plug 'haorenW1025/completion-nvim'
"...

lua require'lsp_config'.register_servers()

As you can see, I have commented the calls to diagnostic.on_attach, and am only importing the plugin itself via vim-plug. I was testing it by toggling comments in that call. However, even with it disabled, it still works. The on_attach call has no effect whatsover. It would be nice if the plugin only got activated when I call the on_attach function.

Error executing vim.schedule lua callback diagnostic/util.lua:149 Index out of bounds

I keep getting this error especially when I open a .lua file

So this is my setup (and also if I open the file I get these errors) https://github.com/ahmedelgabri/dotfiles/blob/26f32ba6aae362a20095523b180f5f06d74f5bcb/roles/vim/files/.vim/lua/lsp.lua

And the error seems to be coming from this line

local line = api.nvim_buf_get_lines(0, row, row+1, true)[1]

Error executing vim.schedule lua callback: ...ack/minpac/start/diagnostic-nvim/lua/diagnostic/util.lua:149: Index out of bounds
Error executing vim.schedule lua callback: ...ack/minpac/start/diagnostic-nvim/lua/diagnostic/util.lua:149: Index out of bounds
Error executing vim.schedule lua callback: ...ack/minpac/start/diagnostic-nvim/lua/diagnostic/util.lua:149: Index out of bounds

Here is a recording of the issue, I only opened the file and moved the cursor up/down.

asciicast

Error executing vim.schedule lua callback using R language server

I got the following error message:

Error executing vim.schedule lua callback: ...ael/.vim/plugged/diagnostic-nvim/lua/diagnostic/util.lua:185: attempt to compare string with number

Plugins:

- SimpylFold: OK
- fzf: OK
- vimwiki: OK
- fzf.vim: OK
- vim-slime: OK
- nord-vim: OK
- vim-snippets: OK
- completion-nvim: OK
- vim-devicons: OK
- black: OK
- vim-toml: OK
- diagnostic-nvim: OK
- ultisnips: OK
- wmgraphviz.vim: OK
- vim-fugitive: OK
- nvim-lspconfig: OK
- csv.vim: OK
- previm: OK
- nerdtree: OK
- julia-vim: OK
- vim-airline: OK
- vimtex: OK
- stan.vim: OK

Updated to the latest versions today 2020-09-29. Neovim version

NVIM v0.5.0-709-g4f8d98e58
Build type: RelWithDebInfo
LuaJIT 2.1.0-beta3
Compilation: /usr/bin/gcc-5 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -O2 -g -Og -g -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wmissing-prototypes -Wvla -fstack-protector-strong -fno-common -fdiagnostics-color=auto -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -DMIN_LOG_LEVEL=3 -I/home/travis/build/neovim/bot-ci/build/neovim/build/config -I/home/travis/build/neovim/bot-ci/build/neovim/src -I/home/travis/build/neovim/bot-ci/build/neovim/.deps/usr/include -I/usr/include -I/home/travis/build/neovim/bot-ci/build/neovim/build/src/nvim/auto -I/home/travis/build/neovim/bot-ci/build/neovim/build/include
Compiled by travis@travis-job-6c0c5b42-8f4c-41ab-9dd7-cb182e87f565

Features: +acl +iconv +tui
See ":help feature-compile"

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "
/home/travis/build/neovim/bot-ci/build/neovim/build/nvim.AppDir/usr/share/nvim

Inlay Hints

Rust Analyzer is has support for a LSP extension, Inlay Hints. Rust Analyzer group is working to push upstream this extension.

Would this be something this plugin would be interested in supporting?

The implementation would be to use virtual text to put the inlay hints.

By including it into this package, we can use the same diagnostic variables, virtual text. But it might not work with how diagnostics work.

My attempt so far that describes the flow that replicates diagnostics.lua flow (sort of)

local vim = vim
local M = {}

-- Range
-- {
--     start: { line: 5, character: 23 },
--     end : { line: 6, character: 0 }
-- }
--
--

-- InlayHint
-- -- kind: "TypeHint" | "ParameterHint" | "ChainingHint"
-- -- range: LSP.Range
-- -- label: string
--
-- results: InlayHint[]
local callback = function(_, _, results, _)
	if not results then
		return
	end

	for _, result in pairs(results) do
		-- We need to apply the text across the Range{start, end}
		-- vim.api.nvim_buf_set_virtual_text(bufnr, -1, line, {{ result.label, "comment" }}, {})
		print("Set label ", result.label)
	end

	print("callbacked")
end

-- file: LSP.TextDocumentIdentifier
local fetch_hints = function(file)
	local request = {{ "textDocument": file }}

	vim.lsp.buf_request(bufnr, 'rust-analyzer/inlayHints', request)
end

function M.attach_callback()
	vim.lsp.callbacks['rust-analyzer/inlayHints'] = callback
	vim.lsp.callbacks['experimental/inlayHints'] = callback
end

function M.refresh_hints(file)
	fetch_hints(file)
end

function M.on_attach(_, _)
	M.attach_callbacks()
	vim.api.nvim_command("autocmd! * <buffer>")
	vim.api.nvim_command("autocmd BufEnter,BufWinEnter,TabEnter <buffer> lua require'inlay_hint'.refresh_hints(expand(\"%p\"))")

end

return M

Note: This is my first time using Lua so any suggestions would be appreciated.

Inlay Hint Specs:

https://github.com/rust-analyzer/rust-analyzer/blob/master/docs/dev/lsp-extensions.md#inlay-hints

CoC implmentation:
https://github.com/fannheyward/coc-rust-analyzer/blob/master/src/inlay_hints.ts

You can thank @tjdevries as he suggested I work with this plugin.

Error or segfault when using location list with diagnostics

Steps to reproduce:

  • Open the location list with diagnostics using :OpenDiagnostic.
  • Place cursor on one of the lines in the location list.
  • Press enter to navigate to that location in your source code buffer.

What happens instead is either:

  • the cursor jumps to a different location in the source buffer
  • or this error occurs: E92: Buffer 168430090 not found
  • or a segfault happens

Details: The buffer number in E92 is not always the same, it tends to grow as you make more attempts to navigate from the location list, or maybe simply as you go down the list (not entirely sure which at this point). At any rate, once it gets big enough, a segfault is triggered. So the number is probably used as an invalid pointer at some point?

I'm seeing this in Rust files with rust-analyzer as the language server. AFAICS, the location list as shown in the appropriate Neovim buffer looks alright -- the filenames, line and column numbers match the highlights in the source code.

Let me know if I can provide additional details!

Incorrect virtual text display for some diagnostics

image

Sample screenshot from a piece of lua (and a language server which isn't fully set up yet, ahem).

As you can see, the multiple warnings that vim is not defined seem to work as expected, but the warning for the unused function is using incorrect highlighting and a doubled up diagnostic_virtual_text_prefix.

Possible reasons that I could think of are:

  1. There are two errors on this line, see next screenshot:
    image

    • Note: the highlighting in the Hover popup here is also incorrect, since the highlighting for popups on later lines matches the virtual text:

    image

  2. The highlighting for diagnostic type "Hint" is different to type "Warning".

Settings from init.vim (screenshotted to include NerdFont glyphs)

image

no diagnostic at all

This is an exiting time for neovim with builtin lsp, treesitter coming soon.
Thanks for this project.

Unfortunately, while the completion plugin is working out of the box, this one is not.
With this init.nvim I can see no floating windows with diagnostics. Not even with the following code full of mistakes:

import thiisnot as np
import numba as nb


de pipppp(suppp):
pass

I'm using last nightly, and last commits from your project.

feature request: add wrap commands

Everything works great but when comparing with ale, I'm missing at least 2 commands:

:PrevWrapDiagnostic
:NextWrapDiagnostic

These variants would wrap arround a buffer, making warning navigation more seamless.

Another nice-to-have that maybe it's outside the scope of this plugin would be OpenDiagnosticToggle so that it would be easier to open-close the quickfix diagnostics window without needing to navigate to it and close it manually.

The ability to specify style

Could you add the ability to specify signs colors? It would be nice to have warnings in yellow color, error in red etc.
And I suggest to add the ability to specify different highlighting groups for warnings and errors inside text. For example, let user replace underline with something like this in yellow color for warnings and red for errors:
изображение

Hover behavior: {Prev,Next}Diagnostic vs jumping to location list

This plugin is great! I've removed some of my own custom overrides of nvim callbacks in favor of this. One thing I've noticed is that the location list is populated with diagnostics, however, the behavior is different if one jumps to a location list item vs using the built-in {Prev, Next}Diagnostic functions. I'm wondering if this is intentional, as only the latter triggers the hover (with printing of the diagnostics in a floating window).

Auto pop up does not work

Thanks for making this plugin!

I have the following in my .vimrc:

let g:diagnostic_auto_popup_while_jump = 1
let g:diagnostic_enable_virtual_text = 0

When I hover over this line, I get the following:

Screen Shot 2020-05-26 at 4 04 53 PM

This shows the error in the gutter but doesn't show the pop up with the diagnostics.

If I call :lua vim.lsp.util.show_line_diagnostics()<CR> I get the following:

Screen Shot 2020-05-26 at 4 05 22 PM

Do you happen to know what might be going on?

display diagnostic in location list instead of line content

OpenDiagnostic doesn't show the diagnostic in location list but the content of the line where there is a diagnostic.
I would much prefer to see the error in location list.
Neovim used to show the diagnostics thanks to neovim/neovim#11777 but this was changed later on because it was not the desired behavior to display references IIRC.

NextDiagnostic won't work if an error is at the end of the row

Minimal example:

int main() {
  int a = 0
  int b = 0;

  return 0
}

This produces 2 diagnostics of missing semicolon:

test.c|2 col 12| int a = 0
test.c|5 col 11| return 0

Expected behavior:

:NextDiagnostic<CR>
:NextDiagnostic<CR>

will put the cursor at the end of return statement.

Actual behavior:
The cursor stays at the end of the second row.

not working with gopls and rust_analyzer

I was really excited to try this out in my nvim. Unfortunately it is not working. It is not showing any kind of diagnostic at all with gopls and rust_analyzer

NVIM --

NVIM v0.5.0-521-gc6dc39780
Build type: Debug
LuaJIT 2.1.0-beta3

inti.vim ---

call plug#begin(expand('~/.config/nvim/plugged'))
Plug 'neovim/nvim-lsp'
Plug 'haorenW1025/diagnostic-nvim'
call plug#end()

lua require'nvim_lsp'.gopls.setup{on_attach=require'diagnostic'.on_attach}
lua require'nvim_lsp'.rust_analyzer.setup{on_attach=require'diagnostic'.on_attach}

statusline and generic namespacing

Thanks for the plugin. I was about to attempt a lsp diagnostic statusline with Error and Warn count.
The nvim vim.lsp help has an example, but since I am using diagnostic,
I thought I would see what was available, and found

print(vim.inspect(require('util').buf_diagnostics_count('Hint')))

This will do the trick, but it highlights the namespace problem.
'util' is pretty generic module name and I see the completions plugin has a 'utilty' module

I think these lua modules should be namespaced to their main module,
either by renaming util.lua => diagnostic_util.lua or like 'neovim/nvim-lsp'
a child 'diagnostic' dir so you can go require('diagnostic.util')

Diagnostics disappear on :e

I'm using rust_analyzer, diagnostics work when opening files. However if I execute :e everything disappears from loclist and signs and wont come back until I edit a file.

Feature request: per-buffer/window options

I'd like to be able to set the virtual text prefix to the current filetype's comment string, so I can copy stuff out of the terminal and e.g. paste it into a REPL.

Thanks for this addon, it's great :)

ALE Integration

ALE is a great plugin for showing linting errors. It also has an API exposed for providing diagnostics from other plugins or tools for it to display (see section 3.2, ale-lint-other-sources)

I've been playing around with integrating diagnostic-nvim with ALE through this API, and have gotten pretty promising results. Would this be a feature that you'd be interested in merging? I'm also happy to split this functionality out into a separate plugin, since ALE duplicates many of the features already provided by diagnostic-nvim.

`diagnostic-nvim` changes the statusline when using `lightline.vim`

Thank you for writing this plugin! It works great!

I have a .vimrc file below:

call plug#begin('~/.local/share/nvim/plugged')
Plug '~/gitrepos/nvim-lsp'
Plug 'haorenW1025/diagnostic-nvim'          " better diagnostic
Plug 'itchyny/lightline.vim' 				" status bar
Plug 'JuliaEditorSupport/julia-vim'
Plug '~/gitrepos/vim-one'
call plug#end()

set shortmess+=c
set shortmess+=I
set completeopt=menuone,noinsert,noselect
set laststatus=2
set noshowmode

colorscheme one
set background=light

let g:diagnostic_show_sign = 0

lua << EOF
  local nvim_lsp = require'nvim_lsp'
  local on_attach = function(_, bufnr)
    vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc')
    require'diagnostic'.on_attach()
  end

  nvim_lsp.julials.setup{
    on_attach=on_attach;
  }
EOF

If require'diagnostic'.on_attach() is commented, everything works as expected.

However, if require'diagnostic'.on_attach() is not commented, then when LanguageServer.jl sends textDocument/publishDiagnostics, the status line changes.

Before textDocument/publishDiagnostics:

After textDocument/publishDiagnostics:

I looked through the package and I don't see why using this package would have any effect on the statusline. I wanted to check if you have any idea what might be going on? This seems to only be an issue when using lightline.vim and diagnostic-nvim. I'm not having this issue if I use airline.vim and diagnostic-nvim.

No Warnings

Using nvim lsp + completion + diagnostics, things seem to work fine expect for warnings from diagnostics. For example, when using rust-analyzer and importing something I don't use, I get no warning. I can't seem to find the issue. I'm using ubuntu with most recent neovim nightly and plugins.

Lua settings:

local nvim_lsp = require('nvim_lsp')

function preview_location(location, context, before_context)
  -- location may be LocationLink or Location (more useful for the former)
  context = context or 10
  before_context = before_context or 5
  local uri = location.targetUri or location.uri
  if uri == nil then
    return
  end
  local bufnr = vim.uri_to_bufnr(uri)
  if not vim.api.nvim_buf_is_loaded(bufnr) then
    vim.fn.bufload(bufnr)
  end
  local range = location.targetRange or location.range
  local contents =
    vim.api.nvim_buf_get_lines(bufnr, range.start.line - before_context, range["end"].line + 1 + context, false)
  local filetype = vim.api.nvim_buf_get_option(bufnr, "filetype")
  return vim.lsp.util.open_floating_preview(contents, filetype)
end

function preview_location_callback(_, method, result)
  local context = 10
  if result == nil or vim.tbl_isempty(result) then
    print("No location found: " .. method)
    return nil
  end
  if vim.tbl_islist(result) then
    floating_buf, floating_win = preview_location(result[1], context)
  else
    floating_buf, floating_win = preview_location(result, context)
  end
end

function peek_definition()
  if vim.tbl_contains(vim.api.nvim_list_wins(), floating_win) then
    vim.api.nvim_set_current_win(floating_win)
  else
    local params = vim.lsp.util.make_position_params()
    return vim.lsp.buf_request(0, "textDocument/definition", params, preview_location_callback)
  end
end

local on_attach = function(_, bufnr)
  vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc')
  require'diagnostic'.on_attach()
  require'completion'.on_attach()

  local opts = { noremap=true, silent=true }
  vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gd', '<cmd>lua vim.lsp.buf.definition()<CR>', opts)
  vim.api.nvim_buf_set_keymap(bufnr, 'n', 'K',  '<cmd>lua vim.lsp.buf.hover()<CR>', opts)
  vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gr', '<cmd>lua vim.lsp.buf.references()<CR>', opts)
  vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gD', '<cmd>lua vim.lsp.util.show_line_diagnostics()<CR>', opts)
  vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gi', '<cmd>lua vim.lsp.buf.implementation()<CR>', opts)
  vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gs', '<cmd>lua vim.lsp.buf.signature_help()<CR>', opts)
  vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gt', '<cmd>lua vim.lsp.buf.type_definition()<CR>', opts)
  vim.api.nvim_buf_set_keymap(bufnr, 'n', 'g0', '<cmd>lua vim.lsp.buf.document_symbol()<CR>', opts)
  vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gW', '<cmd>lua vim.lsp.buf.workspace_symbol()<CR>', opts)
  vim.api.nvim_buf_set_keymap(bufnr, 'n', '<Leader>de', '<cmd>lua vim.lsp.buf.declaration()<CR>', opts)
  vim.api.nvim_buf_set_keymap(bufnr, 'n', '<Leader>rn', '<cmd>lua vim.lsp.buf.rename()<CR>', opts)
  vim.api.nvim_buf_set_keymap(bufnr, 'n', 'pd', '<cmd>lua peek_definition()<CR>', opts)
  vim.api.nvim_buf_set_keymap(bufnr, 'n', '[d', ':PrevDiagnostic<CR>', opts)
  vim.api.nvim_buf_set_keymap(bufnr, 'n', ']d', ':NextDiagnostic<CR>', opts)
  vim.api.nvim_buf_set_keymap(bufnr, 'n', '[D', ':PrevDiagnosticCycle<CR>', opts)
  vim.api.nvim_buf_set_keymap(bufnr, 'n', ']D', ':NextDiagnosticCycle<CR>', opts)
end

nvim_lsp.rust_analyzer.setup{ on_attach = on_attach }

Init vim settings:

call plug#begin('~/.config/nvim/plugged')
Plug 'mhinz/vim-startify'
Plug 'https://github.com/joshdick/onedark.vim.git'
Plug 'itchyny/lightline.vim'

Plug 'nvim-lua/completion-nvim'
Plug 'neovim/nvim-lsp'
Plug 'nvim-lua/diagnostic-nvim'
call plug#end()

" SWAP AND UNDOFILE SETUP
set noswapfile
set nobackup
set nowritebackup
set undodir=~/.config/nvim/undodir
set undofile

" CORE CHANGES
set hidden
set tabstop=8
set softtabstop=4
set shiftwidth=4
set expandtab
set nowrap
set number relativenumber
set autoindent
set termguicolors
set mouse=a

" Make sure clipboard works
set clipboard=unnamedplus

" Hide netrw banner
let g:netrw_banner=0

" REMAPPING
let mapleader = " "
nnoremap <leader>y "*y
vnoremap <leader>y "*y
nnoremap <leader>p "*p
vnoremap <leader>p "*p
nnoremap <leader>P "*P

" Remove highlight when esc is pressed
nmap <silent><ESC> :noh<CR>

" LSP CONFIG
lua require 'lsp'
set signcolumn=yes
set completeopt-=menu
set completeopt-=longest    " Don't insert the longest common text
set completeopt-=preview    " Hide the documentation preview window
set completeopt+=menuone    " Show the completions UI even with only 1 item
set completeopt+=noinsert   " Don't insert text automatically
set completeopt+=noselect   " Do not select a match in the menu

" Lightline config
let g:lightline = {
            \ 'colorscheme': 'onedark',
            \ 'active': {
            \   'left': [ [ 'mode', 'paste' ],
            \             [ 'readonly', 'filename', 'modified' ] ]
            \ },
            \ }

" Startify config
let g:startify_custom_header = [
\ '  __     ___            ',
\ '  \ \   / (_)_ __ ___   ',
\ '   \ \ / /| | ''_ ` _ \ ',
\ '    \ V / | | | | | | | ',
\ '     \_/  |_|_| |_| |_| ',
\ '',
\ '',
\ ]

" COLORS, SYNTAX, AND LATE CHANGES
"let g:onedark_terminal_italics=1
let g:onedark_hide_endofbuffer=1
colorscheme onedark

PrevDiagnostic / NextDiagnostic don't jump into Hints

Hey, first at all, great plugin. Thanks a lot.

This is more a question: It happens to me that I have hints in the buffer but these commands don't jump there. Is this intended? if that's the case, would be possible to add an option to make Hints "jumpable".

Please let me know, I would be happy to send a PR with this.

Question: Virtual text styling

Hello @haorenW1025,

Thank you for creating this great plugin, I love it!

I have a question about the virtual text feature: how can one change the text color (guifg) of the virtual text?

Sorry to ask it here, I was unable to find any info in it anywhere.

attempt to index field 'diagnostics_by_buf' (a nil value)

I'm only using

lua require'nvim_lsp'.pyls.setup{on_attach=require'diagnostic'.on_attach}

but I'm getting the following error message:

Error executing vim.schedule lua callback: ...al/share/nvim/plugged/diagnostic-nvim/lua/diagnostic.lua:75: attempt to index field 'diag
nostics_by_buf' (a nil value)

Almost everything related to LSP stopped working.

Cannot change styles

Hi @haorenW1025 ,

I am trying to have either Floating / Virtual text styling work properly, but nothing I tried worked yet.

I've set all highlight groups like this (tried a lot of configurations, but nothing works) :

        hi! LspDiagnosticsErrorSign cterm=bold ctermfg=196 ctermbg=235
        hi! LspDiagnosticsError cterm=italic ctermfg=196 ctermbg=235
        hi! LspDiagnosticsErrorFloating cterm=italic ctermfg=196 ctermbg=235

Checking that the values are properly set looks good :

:hi LspDiagnosticsErrorFloating
LspDiagnosticsErrorFloating xxx cterm=italic ctermfg=196 ctermbg=235

However, everything (signs, virtual text, floating, etc...) seems to use an autogenerated style based on my current colorscheme.

Maybe linked to #43

Add the option to show diagnostics in the echo area

Hi,

Great work with this plugin, your plugins have quickyl become an essential part of my setup! :)

Would it be possible to add the ability to show diagnostics in the echo area, ala https://github.com/Shougo/echodoc.vim ?

I find popups annoying because they obstruct my code and get in the way, and virtual text is also quite jarring and looks silly when chatty languages like Rust attempt to show errors that are 50-70 characters long and they end up going off screen. Especially when I have splits open, the error messages can be quite useless because they show nothing of use before getting cut off.

The echo area seems like the ideal place to show diagnostics to me, and I'm surprised more plugins don't use it.

Thanks.

How do I map a key to open up the diagnostics popup?

Thanks so much for this plugin. It really fixes a bunch of issues with the default lsp config.

I'd like the equivalent of

nnoremap <silent> gh    <cmd>lua vim.lsp.util.show_line_diagnostics()<CR>

since this doesn't appear to work any more. Is there a way to do this?

Feature Request: Workspace diagnostics

Hello! I was wondering if it would be possible for diagnostic-nvim to also offer an option to show all workspace diagnostics instead of the buffer that it was opened from. I know for myself when I'm doing larger refactorings it's extremely helpful to see diagnostics in other places in my codebase.

Another issue I often come across is that I will have a buffer open, OpenDiagnostics, which will show me my diagnostics for the current buffer, and then I will split and open something else to fix something etc. Then I may close the original, which leaves the list open showing diagnostics for my previous buffer.

There is actually a pr for this in the nvim-metals repo, but it's a very simple implementation.

I'd love to hear your thoughts on whether or not this is something you'd consider adding to diagnostic-nvim. Thanks!

[FeatureRequest] Toggle command

It would be great if there was a command provided to toggle the execution of the plugin at runtime. Something like :ToggleDiagnostics.
Sometimes, especially during reshuffling code the amount of diagnostics can be quite overwhelming and easy toggle for either the total plugin or at least the virtualtext (g:diagnostic_enable_virtual_text does not have an effect when changed at runtime [as expected]).

I just wanted to throw this out there in case someone else also finds this useful 🙂

Regression: custom signs no longer work

It seems commit f88b35a has introduced a bug which disables setting custom diagnostic symbols signs. I checked out every commit between my last version and the regression, and that commit is the culprit.

Hide ellipsis when g:diagnostic_trimmed_virtual_text is zero

This is just my opinion, so feel free to close it if you don't agree. I think when g:diagnostic_trimmed_virtual_text equals 0, the ellipsis should be hidden and only the symbols should be shown. Without any text the ellipsis doesn't have any value, since we already know there are error messages only by seeing the error symbols.

Hints are not displayed

After activating this plugin, I stopped seeing hints in my JavaScript code, only errors (and possibly warnings).

It would be nice if this plugin still showed everything the default diagnostics showed, like errors, warnings, hints and information.

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.