{ lib, pkgs, config, ... }: let cfg = config.presets.base.diagnostics; in { options.presets.base.diagnostics = { enable = lib.mkEnableOption "diagnostics"; }; config = lib.mkIf cfg.enable { extraConfigLua = # lua '' require("actions-preview").setup({}) local signs = { { name = "DiagnosticSignError", text = "" }, { name = "DiagnosticSignWarn", text = "" }, { name = "DiagnosticSignHint", text = "󰌵" }, { name = "DiagnosticSignInfo", text = "" }, } for _, sign in ipairs(signs) do vim.fn.sign_define(sign.name, { texthl = sign.name, text = sign.text, numhl = "" }) end vim.diagnostic.config({ virtual_text = true, signs = true, underline = true, update_in_insert = true, severity_sort = false, }) vim.lsp.handlers["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, { border = "rounded" }) ''; keymaps = [ { key = "sa"; mode = "n"; options.silent = true; lua = true; action = # lua "require('actions-preview').code_actions"; } { key = "sx"; mode = "n"; options.silent = true; lua = true; action = "vim.lsp.buf.format"; } { key = "sR"; mode = "n"; options.silent = true; action = ":LspRestart"; } { key = "sn"; mode = "n"; options.silent = true; action = "vim.lsp.buf.hover"; lua = true; } ]; plugins = { lsp.enable = true; telescope = { enable = true; keymaps = { "sr" = "lsp_references"; "sd" = "lsp_definitions"; "si" = "lsp_implementations"; "ss" = "lsp_document_symbols"; "sw" = "lsp_workspace_symbols"; "st" = "lsp_type_definitions"; "sh" = "diagnostics"; }; }; which-key.registrations."s" = { name = "LSP"; n = "Hover"; r = "References"; R = "Restart LSP"; d = "Definitions"; i = "Implementations"; s = "Document Symbols"; w = "Workspace Symbols"; t = "Type Definitions"; h = "Diagnostics"; a = "Code Actions"; x = "LSP Format"; }; }; extraPlugins = [ pkgs.vimPlugins.actions-preview-nvim ]; }; }