local utilities = require("sherlock5512.utilities") local log = require("tjdevries.log") local required = {'mason','mason-lspconfig','lspconfig','cmp_nvim_lsp','fidget','neodev','mason-null-ls','mason-nvim-dap','dap','dapui'} local modules = utilities.require_modules(required) if not modules then log.error("some modules could not be loaded") return end local capabilities = modules['cmp_nvim_lsp'].default_capabilities() modules['neodev'].setup() modules["mason"].setup() modules["mason-lspconfig"].setup { ensure_installed = {"lua_ls"} } modules["mason-lspconfig"].setup_handlers { function (server_name) modules["lspconfig"][server_name].setup { capabilities = capabilities } end, ["omnisharp"] = function () modules["lspconfig"]["omnisharp"].setup { capabilities = capabilities, on_attach = function (_,_) local gr = vim.api.nvim_create_augroup("CS-OnAttach",{}) vim.api.nvim_create_autocmd({"BufWritePre"}, { group = gr, pattern = {"*.cs"}, desc = "(C#) Format before write", callback = function () vim.lsp.buf.format() end } ) end } end } modules['mason-null-ls'].setup({ ensure_installed = {}, automatic_installation = false, automatic_setup = true, }) modules['fidget'].setup{ text = { spinner = "dots" } } -- Built in diagnostic settings are also configured here vim.diagnostic.config({ virtual_text = true, signs = true, underline = true, update_in_insert = true, severity_sort = false, }) local signs = { Error = " ", Warn = " ", Hint = " ", Info = " " } for type, icon in pairs(signs) do local hl = "DiagnosticSign" .. type vim.fn.sign_define(hl, {text = icon, texthl = hl, numhl = hl}) end local auGroupDiagHover = vim.api.nvim_create_augroup("Diagnostic_hover",{clear = true}) vim.api.nvim_create_autocmd("CursorHold",{ pattern = {"*"}, callback = function () vim.diagnostic.open_float(nil, {focus=false, scope="cursor"}) end, group = auGroupDiagHover }) -- ## DAP ## warning: here be dragons modules['mason-nvim-dap'].setup({ automatic_setup = true, }) modules['dapui'].setup({ icons = { expanded = "", collapsed = "", current_frame = "", }, expand_lines = vim.fn.has("nvim-0.7") == 1, layouts = { { elements = { -- Elements can be strings or table with id and size keys. { id = "scopes", size = 0.25 }, "breakpoints", "stacks", "watches", }, size = 40, -- 40 columns position = "left", }, { elements = { "repl", "console", }, size = 0.25, -- 25% of total lines position = "bottom", }, }, controls = { -- Requires Neovim nightly (or 0.8 when released) enabled = true, -- Display controls in this element element = "repl", icons = { pause = "", play = "", step_into = "", step_over = "", step_out = "", step_back = "", run_last = "", terminate = "", }, }, floating = { max_height = nil, -- These can be integers or a float between 0 and 1. max_width = nil, -- Floats will be treated as percentage of your screen. border = "single", -- Border style. Can be "single", "double" or "rounded" mappings = { close = { "q", "" }, }, }, windows = { indent = 1 }, render = { max_type_length = nil, -- Can be integer or nil. max_value_lines = 100, -- Can be integer or nil. } }) modules['dap'].listeners.after.event_initialized["dapui_config"] = function() modules['dapui'].open() end modules['dap'].listeners.before.event_terminated["dapui_config"] = function() modules['dapui'].close() end modules['dap'].listeners.before.event_exited["dapui_config"] = function() modules['dapui'].close() end -- Also configure lspsaga here. -- Separate require check since we don't NEED lspsaga local ok,lspsaga = pcall(require,"lspsaga") if not ok then return end -- Wrapping since some distros still don't ship nvim 0.8 if vim.fn.exists('+winbar') ~= 0 then lspsaga.setup({ symbol_in_winbar = { in_custom = false, enable = true, seperator = '>', show_file = true, click_support = false }, diagnostic_header = { " ", " ", " ", "ﴞ " }, }) else lspsaga.setup({ diagnostic_header = { " ", " ", " ", "ﴞ " }, }) end