A very fast neovim config :D
at master 132 lines 4.8 kB view raw
1local M = { 2 { 3 "folke/trouble.nvim", 4 config = true, 5 dependencies = { "nvim-tree/nvim-web-devicons" }, 6 keys = { 7 { 8 "<leader>xx", 9 "<cmd>Trouble diagnostics toggle<cr>", 10 desc = "Diagnostics (Trouble)", 11 }, 12 { 13 "<leader>xX", 14 "<cmd>Trouble diagnostics toggle filter.buf=0<cr>", 15 desc = "Buffer Diagnostics (Trouble)", 16 }, 17 { 18 "<leader>cs", 19 "<cmd>Trouble symbols toggle<cr>", 20 desc = "Symbols (Trouble)", 21 }, 22 { 23 "<leader>cl", 24 "<cmd>Trouble lsp toggle win.position=right<cr>", 25 desc = "LSP Definitions / references / ... (Trouble)", 26 }, 27 { 28 "<leader>xL", 29 "<cmd>Trouble loclist toggle<cr>", 30 desc = "Location List (Trouble)", 31 }, 32 { 33 "<leader>xQ", 34 "<cmd>Trouble qflist toggle<cr>", 35 desc = "Quickfix List (Trouble)", 36 }, 37 }, 38 opts = { 39 auto_close = true, 40 focus = true, 41 }, 42 }, 43 { 44 "j-hui/fidget.nvim", 45 event = "BufReadPost", -- LspAttach would be ideal but we use as vim notify override 46 opts = { 47 notification = { 48 override_vim_notify = true, 49 }, 50 }, 51 }, 52 { 53 "neovim/nvim-lspconfig", 54 event = "BufReadPre", 55 config = function() 56 vim.diagnostic.config({ 57 float = { 58 focusable = true, 59 style = "minimal", 60 border = "rounded", 61 source = "always", 62 header = "", 63 prefix = "", 64 severity_sort = true, 65 }, 66 virtual_text = { spacing = 4, prefix = "󰊠" }, 67 signs = true, 68 underline = true, 69 update_in_insert = true, 70 severity_sort = true, 71 }) 72 73 local on_attach = function(_, bufnr) 74 local function map(modes, keys, command, desc) 75 vim.keymap.set(modes, keys, command, { 76 noremap = true, 77 silent = true, 78 buffer = bufnr, 79 desc = desc, 80 }) 81 end 82 83 map("n", "gr", "<cmd>Telescope lsp_references<CR>", "LSP References") 84 map("n", "gd", "<cmd>Telescope lsp_definitions<CR>", "LSP Definitions") 85 map("n", "gD", vim.lsp.buf.declaration, "LSP Declarations") 86 map("n", "gi", "<cmd>Telescope lsp_implementations<CR>", "LSP Implementations") 87 map("n", "<leader>D", "<cmd>Telescope diagnostics bufnr=0<CR>", "LSP Diagnostics") 88 map("n", "<leader>d", vim.diagnostic.open_float, "Inline Diagnostics") 89 map("n", "[d", vim.diagnostic.goto_prev, "Previous Diagnostic") 90 map("n", "]d", vim.diagnostic.goto_next, "Next Diagnostic") 91 map("n", "K", vim.lsp.buf.hover, "Symbol Info") 92 map({ "n", "v" }, "<leader>ca", vim.lsp.buf.code_action, "Code Actions") 93 map("n", "<leader>rn", vim.lsp.buf.rename, "Smart Rename") 94 map("i", "<C-h>", vim.lsp.buf.signature_help, "Lsp signature help") 95 map("n", "<leader>fm", vim.lsp.buf.format, "Format Document") 96 end 97 98 local capabilities = require("blink.cmp").get_lsp_capabilities() 99 local servers = { 100 tinymist = { 101 root_markers = { ".git", ".jj", "flake.nix" }, 102 }, 103 nil_ls = { 104 settings = { 105 ["nil"] = { 106 formatting = { 107 command = { "nixfmt" }, 108 }, 109 }, 110 }, 111 }, 112 } 113 114 local lsp_server_env = os.getenv("LSP_SERVER") 115 if lsp_server_env and not servers[lsp_server_env] then 116 servers[lsp_server_env] = { 117 root_markers = { ".git", ".jj", "flake.nix" }, 118 } 119 end 120 121 for server, config in pairs(servers) do 122 vim.lsp.enable(server) 123 vim.lsp.config[server] = vim.tbl_extend("force", { 124 capabilities = capabilities, 125 on_attach = on_attach, 126 }, config) 127 end 128 end, 129 }, 130} 131 132return M