diff --git a/init.vim b/init.vim index 2bd6ca4..e0c815f 100644 --- a/init.vim +++ b/init.vim @@ -423,5 +423,10 @@ augroup END "----------------------------------------------------------------------------}}} " +" +" require lua init +lua <lua vim.diagnostic.goto_prev({float = {...}})', opts) - buf_set_keymap('n', ']d', 'lua vim.diagnostic.goto_next({float = {...}})', opts) + buf_set_keymap('n', '[d', 'lua vim.diagnostic.goto_prev({float = false})', opts) + buf_set_keymap('n', ']d', 'lua vim.diagnostic.goto_next({float = false})', opts) buf_set_keymap('n', 'gd', 'lua vim.lsp.buf.definition()', opts) buf_set_keymap('n', 'gD', 'lua vim.lsp.buf.declaration()', opts) buf_set_keymap('n', 'gi', 'lua vim.lsp.buf.implementation()', opts) @@ -101,6 +87,16 @@ local on_attach = function(client, bufnr) vim.cmd [[autocmd BufWritePre :lua vim.lsp.buf.formatting_seq_sync({}, 3000)]] vim.cmd [[augroup END]] end + + if client.resolved_capabilities.document_highlight then + vim.cmd [[ + augroup lsp_document_highlight + autocmd! * + autocmd CursorHold lua vim.lsp.buf.document_highlight() + autocmd CursorMoved lua vim.lsp.buf.clear_references() + augroup END + ]] + end end local capabilities = vim.lsp.protocol.make_client_capabilities() diff --git a/lua/init.lua b/lua/init.lua new file mode 100644 index 0000000..a433464 --- /dev/null +++ b/lua/init.lua @@ -0,0 +1,40 @@ +vim.diagnostic.config({ + virtual_text = false, + signs = true, + underline = false, + update_in_insert = false, + severity_sort = true, + float = { + source = "always", -- Or "if_many" + }, +}) + +vim.cmd [[ + augroup diagnostic_on_hover + autocmd CursorHold,CursorHoldI * lua vim.diagnostic.open_float(nil, {focus=false}) + augroup END +]] + +local signs = { Error = "● ", Warn = "● ", Hint = "● ", Info = "● " } +for type, icon in pairs(signs) do + local hl = "DiagnosticSign" .. type + vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = hl }) +end + +local border = { + {"┌", "FloatBorder"}, + {"─", "FloatBorder"}, + {"┐", "FloatBorder"}, + {"│", "FloatBorder"}, + {"┘", "FloatBorder"}, + {"─", "FloatBorder"}, + {"└", "FloatBorder"}, + {"│", "FloatBorder"}, +} + +local orig_util_open_floating_preview = vim.lsp.util.open_floating_preview +function vim.lsp.util.open_floating_preview(contents, syntax, opts, ...) + opts = opts or {} + opts.border = opts.border or border + return orig_util_open_floating_preview(contents, syntax, opts, ...) +end