vim.diagnostic.config {
  virtual_text = false,
  virtual_lines = { only_current_line = true },
  float = {
    border = 'single',
    focus = false,
    focusable = false,
    source = 'always',
    format = function(d)
      return ('%s (%s) [%s]'):format(d.message, d.source, d.code or d.user_data.lsp.code)
    end,
  },
}

vim.fn.sign_define(
  'DiagnosticSignError',
  { text = ' ', texthl = 'DiagnosticSignError', linehl = 'LspDiagnosticsLineNrError' }
)
vim.fn.sign_define(
  'DiagnosticSignWarn',
  { text = ' ', texthl = 'DiagnosticSignWarn', linehl = 'LspDiagnosticsLineNrWarn' }
)
vim.fn.sign_define(
  'DiagnosticSignInfo',
  { text = ' ', texthl = 'DiagnosticSignInfo', linehl = 'LspDiagnosticsLineNrInfo' }
)
vim.fn.sign_define(
  'DiagnosticSignHint',
  { text = ' ', texthl = 'LspDiagnosticsLineNrHint', linehl = 'LspDiagnosticsLineNrHint' }
)

vim.keymap.set('n', '{d', vim.diagnostic.goto_prev, {desc ='Previous [D]iagnostic'})
vim.keymap.set('n', '}d', vim.diagnostic.goto_next, {desc ='Next [D]iagnostic'})
vim.keymap.set('n', '<leader>e', vim.diagnostic.open_float, {desc='View [E]rror'})
vim.keymap.set('n', '<leader>ll', vim.diagnostic.setloclist, {desc='View [L]ocal [L]ist'})
