2024-01-02 19:42:41 +01:00
|
|
|
local M = { "nvimtools/none-ls.nvim" }
|
2024-01-24 00:48:37 +01:00
|
|
|
local f = require("funcs")
|
2023-11-23 21:27:17 +01:00
|
|
|
|
|
|
|
M.event = { "BufReadPre", "BufNewFile" }
|
|
|
|
|
2024-01-24 00:48:37 +01:00
|
|
|
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["<leader>lf"] = { function() vim.lsp.buf.format() end, desc = "Format" }
|
|
|
|
|
|
|
|
lsp_mappings.n["<leader>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["<leader>lD"] = {
|
|
|
|
function() require("telescope.builtin").diagnostics() end,
|
|
|
|
desc = "Search diagnostics",
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
if f.is_available "mason-lspconfig.nvim" then
|
|
|
|
lsp_mappings.n["<leader>li"] = { "<cmd>LspInfo<cr>", desc = "LSP information" }
|
|
|
|
end
|
|
|
|
|
|
|
|
if f.is_available "null-ls.nvim" then
|
|
|
|
lsp_mappings.n["<leader>lI"] = { "<cmd>NullLsInfo<cr>", desc = "Null-ls information" }
|
|
|
|
end
|
|
|
|
|
|
|
|
if client.supports_method "textDocument/codeAction" then
|
|
|
|
lsp_mappings.n["<leader>la"] = {
|
|
|
|
function() vim.lsp.buf.code_action() end,
|
|
|
|
desc = "LSP code action",
|
|
|
|
}
|
|
|
|
lsp_mappings.v["<leader>la"] = lsp_mappings.n["<leader>la"]
|
|
|
|
end
|
|
|
|
end
|
2023-11-23 21:27:17 +01:00
|
|
|
|
|
|
|
M.opts = function()
|
|
|
|
local nls = require("null-ls")
|
|
|
|
return {
|
2024-01-02 19:42:41 +01:00
|
|
|
root_dir = require("null-ls.utils").root_pattern(".null-ls-root", "Makefile", ".git"),
|
2023-11-23 21:27:17 +01:00
|
|
|
sources = {
|
2024-01-02 19:42:41 +01:00
|
|
|
-- shell
|
2023-11-23 21:27:17 +01:00
|
|
|
nls.builtins.formatting.shfmt,
|
2024-01-02 19:42:41 +01:00
|
|
|
nls.builtins.code_actions.shellcheck,
|
|
|
|
-- python
|
2023-11-23 21:27:17 +01:00
|
|
|
nls.builtins.formatting.black,
|
2024-01-02 19:42:41 +01:00
|
|
|
-- perl
|
|
|
|
nls.builtins.formatting.perltidy,
|
|
|
|
-- Various (yaml, markdown, json among others)
|
|
|
|
nls.builtins.formatting.prettierd,
|
2023-11-23 21:27:17 +01:00
|
|
|
},
|
2024-01-24 00:48:37 +01:00
|
|
|
on_attach = lsp_maps
|
2023-11-23 21:27:17 +01:00
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
return M
|