-
Notifications
You must be signed in to change notification settings - Fork 15
Always use popup instead of virtual text #29
Comments
You can easily do this with autocmd CursorHold * lua vim.lsp.util.show_line_diagnostics() |
Thank you! Def should be an option I'd say. Much better experience imo than the virtual text. |
Expanding with a more realistic example for anyone else coming here (i.e. add it to the local nvim_command = vim.api.nvim_command
local on_attach = function(client, bufnr)
nvim_command('autocmd CursorHold <buffer> lua vim.lsp.util.show_line_diagnostics()')
end
nvim_lsp.foobar.setup { on_attach = on_attach } |
So it works for me if I run My LSP configuration: function! s:lsp() abort
lua << EOF
local lsp = require 'nvim_lsp'
local diagnostic = require 'diagnostic'
local nvim_command = vim.api.nvim_command
lsp.gopls.setup{ on_attach = diagnostic.on_attach }
lsp.tsserver.setup{ on_attach = diagnostic.on_attach }
lsp.vimls.setup{ on_attach = diagnostic.on_attach }
EOF
inoremap <silent> <M-f> <C-x><C-f>
inoremap <silent> <M-g> <C-x><C-o>
set completeopt=menuone,longest,noselect
set pumheight=10
function! s:b_lsp() abort
nnoremap <silent> <buffer> gd <cmd>lua vim.lsp.buf.declaration()<CR>
nnoremap <silent> <buffer> <c-]> <cmd>lua vim.lsp.buf.definition()<CR>
nnoremap <silent> <buffer> K <cmd>lua vim.lsp.buf.hover()<CR>
nnoremap <silent> <buffer> gD <cmd>lua vim.lsp.buf.implementation()<CR>
nnoremap <silent> <buffer> <c-k> <cmd>lua vim.lsp.buf.signature_help()<CR>
nnoremap <silent> <buffer> 1gD <cmd>lua vim.lsp.buf.type_definition()<CR>
nnoremap <silent> <buffer> gr <cmd>lua vim.lsp.buf.references()<CR>
nnoremap <silent> <buffer> g0 <cmd>lua vim.lsp.buf.document_symbol()<CR>
nnoremap <silent> <buffer> gW <cmd>lua vim.lsp.buf.workspace_symbol()<CR>
setlocal omnifunc=v:lua.vim.lsp.omnifunc
endfunction
augroup nhooyr_lsp
autocmd!
autocmd FileType go,vim,typescript* call s:b_lsp()
autocmd CursorHold * lua vim.lsp.util.show_line_diagnostics()
augroup END
endfunction
call s:lsp() |
Are you sure though? Because |
Positive. My update time is 100ms |
Switched to:
I see the echo but no diagnostics. And manually running does show them. |
Try disabling diagnostic-nvim. Might be some conflict there. |
Oh my bad, I thought it was part of the plugin. |
Yup works now! How do I disable the virtual text now from native lsp? |
Guess the answer is somewhere in this plugin! |
Something like this maybe: do
local diagnostic_ns = vim.api.nvim_create_namespace('vim_lsp_diagnostics')
local default_callback = vim.lsp.callbacks['textDocument/publishDiagnostics']
vim.lsp.callbacks['textDocument/publishDiagnostics'] = function(...)
default_callback(...)
local _, _, result = ...
local bufnr = vim.uri_to_bufnr(result.uri)
api.nvim_buf_clear_namespace(bufnr, diagnostic_ns, 0, -1)
end
end You can use the default callback as inspiration: https://github.com/neovim/neovim/blob/60c581b35db439dd6b32cdc2ebe1a5aed933b44c/runtime/lua/vim/lsp/callbacks.lua#L67-L92 |
Works perfectly now. Not really sure what I did to fix it but must have been some user error. function! s:lsp() abort
lua << EOF
local lsp = require 'nvim_lsp'
local on_attach = function(client)
require'diagnostic'.on_attach()
require'completion'.on_attach()
end
lsp.gopls.setup{ on_attach = on_attach }
lsp.tsserver.setup{ on_attach = on_attach }
lsp.vimls.setup{ on_attach = on_attach }
EOF
inoremap <silent> <M-x> <C-x>
set completeopt=menuone,longest,noselect
set pumheight=10
let g:diagnostic_insert_delay = 1
let g:completion_enable_snippet = 'Neosnippet'
imap <C-k> <cmd>lua require'source'.nextCompletion()<CR>
function! s:b_lsp() abort
nnoremap <silent> <buffer> gd <cmd>lua vim.lsp.buf.declaration()<CR>
nnoremap <silent> <buffer> <C-]> <cmd>lua vim.lsp.buf.definition()<CR>
nnoremap <silent> <buffer> K <cmd>lua vim.lsp.buf.hover()<CR>
nnoremap <silent> <buffer> gD <cmd>lua vim.lsp.buf.implementation()<CR>
nnoremap <silent> <buffer> <C-k> <cmd>lua vim.lsp.buf.signature_help()<CR>
nnoremap <silent> <buffer> 1gD <cmd>lua vim.lsp.buf.type_definition()<CR>
nnoremap <silent> <buffer> gr <cmd>lua vim.lsp.buf.references()<CR>
nnoremap <silent> <buffer> g0 <cmd>lua vim.lsp.buf.document_symbol()<CR>
nnoremap <silent> <buffer> gW <cmd>lua vim.lsp.buf.workspace_symbol()<CR>
setlocal omnifunc=v:lua.vim.lsp.omnifunc
endfunction
augroup lsp
autocmd!
autocmd FileType go,vim,typescript* call s:b_lsp()
autocmd CursorHold * lua vim.lsp.util.show_line_diagnostics()
autocmd BufEnter * lua require'completion'.on_attach()
augroup END
endfunction
call s:lsp() |
Got it to work somehow. See nvim-lua/diagnostic-nvim#29
Got it to work somehow. See nvim-lua/diagnostic-nvim#29
Is it possible to show diagnostics window only if a popup isn't opened already? |
yes same concern as @desprit Looks like diag messages were originally geared toward virtual text and handling a "popup only" display of diag messages is kinda rought. Along with Desprit's concer, I use and to move around diag messages. This breaks if you begin to use CursorHold to have your messages pop up. Those key strokes will place you inside the actual pop-up menu, not allowing you to jump to the next diag message. |
This repository is deprecated by the way. For your concern of CursorHold placing you inside the pop-up menu @ldelossa , you can use : |
Would be nice to have an option for this.
At the moment the popup only shows up jump.
The text was updated successfully, but these errors were encountered: