local M = { "nvimtools/none-ls.nvim" } local f = require("funcs") M.event = { "BufReadPre", "BufNewFile" } M.dependencies = { "mason-null-ls.nvim" } local lsp_maps = function(client, bufnr) local lsp_mappings = f.empty_map_table() -- TODO: CONDITIONALLY GATE THIS lsp_mappings.n["lf"] = { function() vim.lsp.buf.format() end, desc = "Format" } lsp_mappings.n["ld"] = { function() vim.diagnostic.open_float() end, desc = "Hover diagnostics" } lsp_mappings.n["[d"] = { function() vim.diagnostic.goto_prev() end, desc = "Previous diagnostic" } lsp_mappings.n["]d"] = { function() vim.diagnostic.goto_next() end, desc = "Next diagnostic" } lsp_mappings.n["gl"] = { function() vim.diagnostic.open_float() end, desc = "Hover diagnostics" } if f.is_available("telescope.nvim") then lsp_mappings.n["lD"] = { function() require("telescope.builtin").diagnostics() end, desc = "Search diagnostics", } end if f.is_available "mason-lspconfig.nvim" then lsp_mappings.n["li"] = { "LspInfo", desc = "LSP information" } end if f.is_available "null-ls.nvim" then lsp_mappings.n["lI"] = { "NullLsInfo", desc = "Null-ls information" } end if client.supports_method "textDocument/codeAction" then lsp_mappings.n["la"] = { function() vim.lsp.buf.code_action() end, desc = "LSP code action", } lsp_mappings.v["la"] = lsp_mappings.n["la"] end end M.opts = function() local nls = require("null-ls") return { root_dir = require("null-ls.utils").root_pattern(".null-ls-root", "Makefile", ".git"), sources = { -- shell nls.builtins.formatting.shfmt, nls.builtins.code_actions.shellcheck, -- python nls.builtins.formatting.black, -- perl nls.builtins.formatting.perltidy, -- Various (yaml, markdown, json among others) nls.builtins.formatting.prettierd, }, on_attach = lsp_maps } end return M