chore(nerd_icons): updated codepoints after v3.0.0
[edyt.git] / lua / lsp / init.lua
blobab0f93fefb3662a0d911528f966159570eadcde3
1 local M = {}
3 -- Global mappings.
4 -- See `:help vim.diagnostic.*` for documentation on any of the below functions
5 M.setup = function() --<--
6 require("lsp.mappings").setup.default()
7 require("lsp.mappings").setup.lspsaga()
9 -- Signs <--
10 local signs = {
11 { name = "DiagnosticSignError", text = "" },
12 { name = "DiagnosticSignWarn", text = "" },
13 { name = "DiagnosticSignHint", text = "" },
14 { name = "DiagnosticSignInfo", text = "" },
17 for _, sign in ipairs(signs) do
18 vim.fn.sign_define(sign.name, { texthl = sign.name, text = sign.text, numhl = "" })
19 end -->--
21 vim.diagnostic.config({ --<--
22 virtual_text = false,
23 signs = { active = signs },
24 update_in_insert = false,
25 underline = false,
26 severity_sort = true,
27 float = {
28 focusable = false,
29 style = "minimal",
30 border = "rounded",
31 source = "always",
32 header = "",
33 prefix = "",
34 format = require("lsp.fn.float_text").format,
36 }) -->--
38 local handlers = vim.lsp.handlers
39 local with = vim.lsp.with
40 handlers["textDocument/hover"] = with(handlers.hover, { silent = true, border = "rounded" })
41 handlers["textDocument/signatureHelp"] = with(handlers.signature_help, { border = "rounded" })
43 require("lsp.fn.list_capabilities")
45 vim.api.nvim_create_user_command("ClearLspLog", function()
46 vim.fn.delete(require("vim.lsp.log").get_filename())
47 end, { desc = "Delete LSP log file." })
48 end -->--
50 M.mappings = function(buf) --<--
51 for _, f in pairs(require("lsp.mappings").on_attach) do
52 f(buf)
53 end
54 end -->--
56 M.buffer_options = function(buf) --<--
57 -- Enable completion triggered by <c-x><c-o>
58 vim.bo[buf].omnifunc = "v:lua.vim.lsp.omnifunc"
59 end -->--
61 M.capabilities = function(client, buf) --<--
62 if client.server_capabilities.documentHighlightProvider then
63 local group = vim.api.nvim_create_augroup("lsp_document_highlight", {})
64 local autocmds = {
65 CursorHold = vim.lsp.buf.document_highlight,
66 CursorMoved = vim.lsp.buf.clear_references,
68 for event, callback in pairs(autocmds) do
69 vim.api.nvim_create_autocmd(event, { group = group, buffer = buf, callback = callback })
70 end
71 end
72 end -->--
74 M.on_attach = function(client, buf) --<--
75 M.mappings(buf)
76 M.buffer_options(buf)
77 M.capabilities(client, buf)
78 end -->--
80 return M