.config/nvim/lua/config/lsp.lua

Sun, 05 Mar 2023 15:14:39 -0500

author
Meredith Howard <mhoward@roomag.org>
date
Sun, 05 Mar 2023 15:14:39 -0500
changeset 1060
c20cb89a2ee9
parent 1059
dc0095e5bbc8
child 1061
8141190cc943
permissions
-rw-r--r--

Add "comment" parser

1032
b0497894f69b Customize LSP float diags further
Meredith Howard <mhoward@roomag.org>
parents: 1031
diff changeset
1 local diag_virtual_min_threshold = "WARN"
b0497894f69b Customize LSP float diags further
Meredith Howard <mhoward@roomag.org>
parents: 1031
diff changeset
2 local diag_float_max_threshold = "INFO"
1030
03d507b3c122 Customize LSP more - diag behavior and symbol HL
Meredith Howard <mhoward@roomag.org>
parents: 1022
diff changeset
3
1016
07d37da233ef Add lsp-specific config
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
4 vim.diagnostic.config({
1032
b0497894f69b Customize LSP float diags further
Meredith Howard <mhoward@roomag.org>
parents: 1031
diff changeset
5 severity_sort = true,
b0497894f69b Customize LSP float diags further
Meredith Howard <mhoward@roomag.org>
parents: 1031
diff changeset
6 underline = { severity = {min = diag_virtual_min_threshold} },
b0497894f69b Customize LSP float diags further
Meredith Howard <mhoward@roomag.org>
parents: 1031
diff changeset
7 virtual_text = { true, severity = {min = diag_virtual_min_threshold} },
b0497894f69b Customize LSP float diags further
Meredith Howard <mhoward@roomag.org>
parents: 1031
diff changeset
8 float = { source = "if_many" },
1030
03d507b3c122 Customize LSP more - diag behavior and symbol HL
Meredith Howard <mhoward@roomag.org>
parents: 1022
diff changeset
9 })
03d507b3c122 Customize LSP more - diag behavior and symbol HL
Meredith Howard <mhoward@roomag.org>
parents: 1022
diff changeset
10
03d507b3c122 Customize LSP more - diag behavior and symbol HL
Meredith Howard <mhoward@roomag.org>
parents: 1022
diff changeset
11 -- Some options are more chill in text mode, this unchills them if a LSP is in
03d507b3c122 Customize LSP more - diag behavior and symbol HL
Meredith Howard <mhoward@roomag.org>
parents: 1022
diff changeset
12 -- play. Note they're global
03d507b3c122 Customize LSP more - diag behavior and symbol HL
Meredith Howard <mhoward@roomag.org>
parents: 1022
diff changeset
13 vim.api.nvim_create_autocmd("LspAttach", {
03d507b3c122 Customize LSP more - diag behavior and symbol HL
Meredith Howard <mhoward@roomag.org>
parents: 1022
diff changeset
14 once = true,
03d507b3c122 Customize LSP more - diag behavior and symbol HL
Meredith Howard <mhoward@roomag.org>
parents: 1022
diff changeset
15 group = "lsp_attach",
03d507b3c122 Customize LSP more - diag behavior and symbol HL
Meredith Howard <mhoward@roomag.org>
parents: 1022
diff changeset
16 callback = function(args)
03d507b3c122 Customize LSP more - diag behavior and symbol HL
Meredith Howard <mhoward@roomag.org>
parents: 1022
diff changeset
17 vim.opt.number = true
03d507b3c122 Customize LSP more - diag behavior and symbol HL
Meredith Howard <mhoward@roomag.org>
parents: 1022
diff changeset
18 vim.opt.updatetime = 250
03d507b3c122 Customize LSP more - diag behavior and symbol HL
Meredith Howard <mhoward@roomag.org>
parents: 1022
diff changeset
19 end,
1016
07d37da233ef Add lsp-specific config
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
20 })
07d37da233ef Add lsp-specific config
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
21
07d37da233ef Add lsp-specific config
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
22 vim.api.nvim_create_autocmd("LspAttach", {
1030
03d507b3c122 Customize LSP more - diag behavior and symbol HL
Meredith Howard <mhoward@roomag.org>
parents: 1022
diff changeset
23 group = "lsp_attach",
1016
07d37da233ef Add lsp-specific config
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
24 callback = function(args)
1030
03d507b3c122 Customize LSP more - diag behavior and symbol HL
Meredith Howard <mhoward@roomag.org>
parents: 1022
diff changeset
25 local bufnr = args.buf
03d507b3c122 Customize LSP more - diag behavior and symbol HL
Meredith Howard <mhoward@roomag.org>
parents: 1022
diff changeset
26 local client = vim.lsp.get_client_by_id(args.data.client_id)
03d507b3c122 Customize LSP more - diag behavior and symbol HL
Meredith Howard <mhoward@roomag.org>
parents: 1022
diff changeset
27
03d507b3c122 Customize LSP more - diag behavior and symbol HL
Meredith Howard <mhoward@roomag.org>
parents: 1022
diff changeset
28 -- enable auto diags in message area for below threshold
03d507b3c122 Customize LSP more - diag behavior and symbol HL
Meredith Howard <mhoward@roomag.org>
parents: 1022
diff changeset
29 vim.api.nvim_create_augroup('lsp_diags', {clear = false})
1032
b0497894f69b Customize LSP float diags further
Meredith Howard <mhoward@roomag.org>
parents: 1031
diff changeset
30 vim.api.nvim_create_autocmd("CursorHold", {
1030
03d507b3c122 Customize LSP more - diag behavior and symbol HL
Meredith Howard <mhoward@roomag.org>
parents: 1022
diff changeset
31 group = "lsp_diags",
03d507b3c122 Customize LSP more - diag behavior and symbol HL
Meredith Howard <mhoward@roomag.org>
parents: 1022
diff changeset
32 buffer = bufnr,
03d507b3c122 Customize LSP more - diag behavior and symbol HL
Meredith Howard <mhoward@roomag.org>
parents: 1022
diff changeset
33 callback = function(opts, bufnr, line_nr, client_id)
1032
b0497894f69b Customize LSP float diags further
Meredith Howard <mhoward@roomag.org>
parents: 1031
diff changeset
34 vim.diagnostic.open_float(nil, {
b0497894f69b Customize LSP float diags further
Meredith Howard <mhoward@roomag.org>
parents: 1031
diff changeset
35 focusable = false,
b0497894f69b Customize LSP float diags further
Meredith Howard <mhoward@roomag.org>
parents: 1031
diff changeset
36 close_events = {"BufLeave", "CursorMoved", "InsertEnter", "FocusLost"},
b0497894f69b Customize LSP float diags further
Meredith Howard <mhoward@roomag.org>
parents: 1031
diff changeset
37 scope = "line",
b0497894f69b Customize LSP float diags further
Meredith Howard <mhoward@roomag.org>
parents: 1031
diff changeset
38 severity = {max = diag_float_max_threshold},
b0497894f69b Customize LSP float diags further
Meredith Howard <mhoward@roomag.org>
parents: 1031
diff changeset
39 })
1030
03d507b3c122 Customize LSP more - diag behavior and symbol HL
Meredith Howard <mhoward@roomag.org>
parents: 1022
diff changeset
40 end,
03d507b3c122 Customize LSP more - diag behavior and symbol HL
Meredith Howard <mhoward@roomag.org>
parents: 1022
diff changeset
41 })
03d507b3c122 Customize LSP more - diag behavior and symbol HL
Meredith Howard <mhoward@roomag.org>
parents: 1022
diff changeset
42 end
1016
07d37da233ef Add lsp-specific config
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
43 })
1059
dc0095e5bbc8 disable rubocop and formatting in solargraph, add standardrb glue
Meredith Howard <mhoward@roomag.org>
parents: 1032
diff changeset
44
dc0095e5bbc8 disable rubocop and formatting in solargraph, add standardrb glue
Meredith Howard <mhoward@roomag.org>
parents: 1032
diff changeset
45 -- This can be removed when mason-lspconfig gets support for standardrb
dc0095e5bbc8 disable rubocop and formatting in solargraph, add standardrb glue
Meredith Howard <mhoward@roomag.org>
parents: 1032
diff changeset
46 if vim.fn.executable("standardrb") == 1 then
dc0095e5bbc8 disable rubocop and formatting in solargraph, add standardrb glue
Meredith Howard <mhoward@roomag.org>
parents: 1032
diff changeset
47 local lsp_ruby = vim.api.nvim_create_augroup("lsp_ruby", {clear = true})
dc0095e5bbc8 disable rubocop and formatting in solargraph, add standardrb glue
Meredith Howard <mhoward@roomag.org>
parents: 1032
diff changeset
48
dc0095e5bbc8 disable rubocop and formatting in solargraph, add standardrb glue
Meredith Howard <mhoward@roomag.org>
parents: 1032
diff changeset
49 vim.api.nvim_create_autocmd("FileType", {
dc0095e5bbc8 disable rubocop and formatting in solargraph, add standardrb glue
Meredith Howard <mhoward@roomag.org>
parents: 1032
diff changeset
50 pattern = "ruby",
dc0095e5bbc8 disable rubocop and formatting in solargraph, add standardrb glue
Meredith Howard <mhoward@roomag.org>
parents: 1032
diff changeset
51 group = lsp_ruby,
dc0095e5bbc8 disable rubocop and formatting in solargraph, add standardrb glue
Meredith Howard <mhoward@roomag.org>
parents: 1032
diff changeset
52 once = true,
dc0095e5bbc8 disable rubocop and formatting in solargraph, add standardrb glue
Meredith Howard <mhoward@roomag.org>
parents: 1032
diff changeset
53 callback = function()
dc0095e5bbc8 disable rubocop and formatting in solargraph, add standardrb glue
Meredith Howard <mhoward@roomag.org>
parents: 1032
diff changeset
54 require("lspconfig").standardrb.setup({})
dc0095e5bbc8 disable rubocop and formatting in solargraph, add standardrb glue
Meredith Howard <mhoward@roomag.org>
parents: 1032
diff changeset
55 end,
dc0095e5bbc8 disable rubocop and formatting in solargraph, add standardrb glue
Meredith Howard <mhoward@roomag.org>
parents: 1032
diff changeset
56 })
dc0095e5bbc8 disable rubocop and formatting in solargraph, add standardrb glue
Meredith Howard <mhoward@roomag.org>
parents: 1032
diff changeset
57
dc0095e5bbc8 disable rubocop and formatting in solargraph, add standardrb glue
Meredith Howard <mhoward@roomag.org>
parents: 1032
diff changeset
58 vim.api.nvim_create_autocmd("FileType", {
dc0095e5bbc8 disable rubocop and formatting in solargraph, add standardrb glue
Meredith Howard <mhoward@roomag.org>
parents: 1032
diff changeset
59 pattern = "ruby",
dc0095e5bbc8 disable rubocop and formatting in solargraph, add standardrb glue
Meredith Howard <mhoward@roomag.org>
parents: 1032
diff changeset
60 group = lsp_ruby,
dc0095e5bbc8 disable rubocop and formatting in solargraph, add standardrb glue
Meredith Howard <mhoward@roomag.org>
parents: 1032
diff changeset
61 callback = function()
dc0095e5bbc8 disable rubocop and formatting in solargraph, add standardrb glue
Meredith Howard <mhoward@roomag.org>
parents: 1032
diff changeset
62 vim.cmd.LspStart("standardrb")
dc0095e5bbc8 disable rubocop and formatting in solargraph, add standardrb glue
Meredith Howard <mhoward@roomag.org>
parents: 1032
diff changeset
63 end,
dc0095e5bbc8 disable rubocop and formatting in solargraph, add standardrb glue
Meredith Howard <mhoward@roomag.org>
parents: 1032
diff changeset
64 })
dc0095e5bbc8 disable rubocop and formatting in solargraph, add standardrb glue
Meredith Howard <mhoward@roomag.org>
parents: 1032
diff changeset
65 end
dc0095e5bbc8 disable rubocop and formatting in solargraph, add standardrb glue
Meredith Howard <mhoward@roomag.org>
parents: 1032
diff changeset
66

mercurial