<commit_before>local my_utils = require('local.utils')
local my_signs = my_utils.signs

-- You've something like this your config.
-- ```lua
--   {'diagnostics', sources = {'nvim_lsp'}}
-- ```
-- It needs to be updated to:
-- ```lua
--   {'diagnostics', sources = {'nvim_diagnostic'}}
-- ```

local Border = {
 {"╭", "FloatBorder"},
 {"─", "FloatBorder"},
 {"╮", "FloatBorder"},
 {"│", "FloatBorder"},
 {"╯", "FloatBorder"},
 {"─", "FloatBorder"},
 {"╰", "FloatBorder"},
 {"│", "FloatBorder"},
}

vim.diagnostic.open_float(
  0,
  {
    border = Border,
    focusable = false,
    scope = "line",
  }
)

-- https://github.com/neovim/nvim-lspconfig/wiki/Autocompletion
vim.lsp.handlers["textDocument/hover"] = vim.lsp.with(
  vim.lsp.handlers.hover, {
    border = Border,
    focusable = false,
  }
)

vim.lsp.handlers["textDocument/signatureHelp"] = vim.lsp.with(
 vim.lsp.handlers.signature_help, {
     border = Border
   }
 )


-- https://neovim.io/doc/user/lsp.html
vim.lsp.handlers["textDocument/publishDiagnostics"] = vim.lsp.with(
  vim.lsp.diagnostic.on_publish_diagnostics, {
    underline = true,
    virtual_text = false,
    signs = true,
    update_in_insert = false,
    severity_sort = true,
    source = 'always',
  }
)


local signs = {
    Error = my_signs.error .. " ",
    Warning = my_signs.warning .. " ",
    Warn = my_signs.warning .. " ",
    Hint = my_signs.hint .. " ",
    Information = my_signs.information .. " ",
    Info = my_signs.information .. " ",
}

for type, icon in pairs(signs) do
  local hl = "LspDiagnosticsSign" .. type
  vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = hl })

  local hl = "DiagnosticSign" .. type
  vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = hl })
end


-- Use an on_attach function to only map the following keys
-- after the language server attaches to the current buffer
local on_attach = function(client, bufnr)
  local function buf_set_keymap(...) vim.api.nvim_buf_set_keymap(bufnr, ...) end
  local function buf_set_option(...) vim.api.nvim_buf_set_option(bufnr, ...) end

  -- Enable completion triggered by <c-x><c-o><commit_msg>Update diagnostics config so it shows source<commit_after>local my_utils = require('local.utils')
local my_signs = my_utils.signs

-- You've something like this your config.
-- ```lua
--   {'diagnostics', sources = {'nvim_lsp'}}
-- ```
-- It needs to be updated to:
-- ```lua
--   {'diagnostics', sources = {'nvim_diagnostic'}}
-- ```

local Border = {
 {"╭", "FloatBorder"},
 {"─", "FloatBorder"},
 {"╮", "FloatBorder"},
 {"│", "FloatBorder"},
 {"╯", "FloatBorder"},
 {"─", "FloatBorder"},
 {"╰", "FloatBorder"},
 {"│", "FloatBorder"},
}

vim.diagnostic.open_float(
  0,
  {
    border = Border,
    focusable = false,
    scope = "line",
  }
)

-- https://github.com/neovim/nvim-lspconfig/wiki/Autocompletion
vim.lsp.handlers["textDocument/hover"] = vim.lsp.with(
  vim.lsp.handlers.hover, {
    border = Border,
    focusable = false,
  }
)

vim.lsp.handlers["textDocument/signatureHelp"] = vim.lsp.with(
 vim.lsp.handlers.signature_help, {
     border = Border
   }
 )


-- https://neovim.io/doc/user/lsp.html
-- vim.lsp.handlers["textDocument/publishDiagnostics"] = vim.lsp.with(
--   vim.lsp.diagnostic.on_publish_diagnostics, {
--     underline = true,
--     virtual_text = false,
--     signs = true,
--     update_in_insert = false,
--     severity_sort = true,
--     source = 'always',
--   }
-- )

vim.diagnostic.config({
    underline = true,
    virtual_text = false,
    signs = true,
    float = {
        show_header = true,
        source = 'always',
        border = 'rounded',
        focusable = false,
        severity_sort = true, -- default to false
    },
    update_in_insert = false, -- default to false
    severity_sort = true, -- default to false
})


local signs = {
    Error = my_signs.error .. " ",
    Warning = my_signs.warning .. " ",
    Warn = my_signs.warning .. " ",
    Hint = my_signs.hint .. " ",
    Information = my_signs.information .. " ",
    Info = my_signs.information .. " ",
}

for type, icon in pairs(signs) do
  local hl = "LspDiagnosticsSign" .. type
  vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = hl })

  local hl = "DiagnosticSign" .. type
  vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = hl })
end


-- Use an on_attach function to only map the following keys
-- after the language server attaches to the current buffer
local on_attach = function(client, bufnr)
  local function buf_set_keymap(...) vim.api.nvim_buf_set_keymap(bufnr, ...) end
  local function buf_set_option(...) vim.api.nvim_buf_set_option(bufnr, ...) end

  -- Enable completion triggered by <c-x><c-o>
{'fraction_non_alphanumeric': 0.1707941929974381, 'fraction_numerical': 0.0004269854824935952, 'mean_word_length': 3.03184165232358, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1517988', 'n_tokens_mistral': 1722, 'n_tokens_neox': 1683, 'n_words': 360}