1 local diag_virtual_min_threshold = "WARN" |
|
2 local diag_float_max_threshold = "INFO" |
|
3 |
|
4 vim.diagnostic.config({ |
1 vim.diagnostic.config({ |
|
2 float = { |
|
3 close_events = { "BufLeave", "CursorMoved", "InsertEnter", "FocusLost" }, |
|
4 focusable = false, |
|
5 header = "", |
|
6 max_width = 72, |
|
7 source = "if_many", |
|
8 style = "minimal", |
|
9 }, |
5 severity_sort = true, |
10 severity_sort = true, |
6 underline = { severity = { min = diag_virtual_min_threshold } }, |
11 underline = true, |
7 virtual_text = { true, severity = { min = diag_virtual_min_threshold } }, |
12 virtual_text = false, |
8 float = { source = "if_many" }, |
|
9 }) |
13 }) |
10 |
14 |
11 -- Some options are more chill in text mode, this unchills them if a LSP is in |
15 -- Some options are more chill in text mode, this unchills them if a LSP is in |
12 -- play. Note they're global |
16 -- play. Note they're global |
13 vim.api.nvim_create_autocmd("LspAttach", { |
17 vim.api.nvim_create_autocmd("LspAttach", { |
20 }) |
24 }) |
21 |
25 |
22 vim.api.nvim_create_autocmd("LspAttach", { |
26 vim.api.nvim_create_autocmd("LspAttach", { |
23 group = "lsp_attach", |
27 group = "lsp_attach", |
24 callback = function(args) |
28 callback = function(args) |
25 local bufnr = args.buf |
|
26 local client = vim.lsp.get_client_by_id(args.data.client_id) |
|
27 |
|
28 -- enable auto diags in message area for below threshold |
|
29 vim.api.nvim_create_autocmd("CursorHold", { |
29 vim.api.nvim_create_autocmd("CursorHold", { |
30 group = vim.api.nvim_create_augroup("lsp_buf_diags", { clear = true }), |
30 group = vim.api.nvim_create_augroup("lsp_buf_diags", { clear = true }), |
31 buffer = bufnr, |
31 buffer = args.buf, |
32 callback = function(opts, bufnr, line_nr, client_id) |
32 callback = vim.diagnostic.open_float, |
33 vim.diagnostic.open_float(nil, { |
|
34 focusable = false, |
|
35 close_events = { "BufLeave", "CursorMoved", "InsertEnter", "FocusLost" }, |
|
36 scope = "line", |
|
37 severity = { max = diag_float_max_threshold }, |
|
38 }) |
|
39 end, |
|
40 }) |
33 }) |
41 end, |
34 end, |
42 }) |
35 }) |
43 |
36 |
44 -- Format on write, but only certain languages |
37 -- Format on write, but only certain languages |