local puk = require 'std.puk' local project = require 'std.project' local dbg = require 'std.dbg' local icon = require 'std.icon' local map = require 'std.map' local auto = require 'std.auto' local table = require 'std.table' local localrc = require 'std.localrc' if dbg.get() then vim.lsp.set_log_level('debug') end local settings_override = project_local_lsp_settings[language_server_name] if settings_override then return settings_override end end end end local language_servers = { lua_ls = { root_dir = project.find_lua_project_root, settings = { Lua = { hint = { enable = true, setType = true, }, telemetry = { enable = false, }, }, }, }, -- TODO: take some config from clients/ int here jdtls = { root_dir = project.find_java_project_root, }, zls = { root_dir = project.find_zig_project_root, }, ziggy = { root_dir = project.find_vcs_project_root, }, ziggy_schema = { root_dir = project.find_vcs_project_root, }, asm_lsp = { root_dir = project.find_vcs_project_root, }, clangd = { root_dir = project.find_vcs_project_root, }, denols = { root_dir = project.find_vcs_project_root, }, dotls = { root_dir = project.find_vcs_project_root, }, docker_compose_language_service = { root_dir = project.find_vcs_project_root, }, dockerls = { root_dir = project.find_vcs_project_root, }, ast_grep = { root_dir = project.find_vcs_project_root, }, cssls = { root_dir = project.find_vcs_project_root, }, css_variables = { root_dir = project.find_vcs_project_root, }, emmet_language_server = { root_dir = project.find_vcs_project_root, }, gopls = { root_dir = project.find_vcs_project_root, }, gradle_ls = { root_dir = project.find_vcs_project_root, }, harper_ls = { root_dir = project.find_vcs_project_root, }, html = { root_dir = project.find_vcs_project_root, }, htmx = { root_dir = project.find_vcs_project_root, }, hyprls = { root_dir = project.find_vcs_project_root, }, jsonls = { root_dir = project.find_vcs_project_root, }, lemminx = { root_dir = project.find_vcs_project_root, }, lsp_ai = { root_dir = project.find_vcs_project_root, }, ltex = { root_dir = project.find_vcs_project_root, }, marksman = { root_dir = project.find_vcs_project_root, }, markdown_oxide = { root_dir = project.find_vcs_project_root, }, nil_ls = { root_dir = project.find_vcs_project_root, }, nixd = { root_dir = project.find_vcs_project_root, }, nushell = { root_dir = project.find_vcs_project_root, }, ocamllsp = { root_dir = project.find_vcs_project_root, }, protols = { root_dir = project.find_vcs_project_root, }, roc_ls = { root_dir = project.find_vcs_project_root, }, rust_analyzer = { root_dir = project.find_vcs_project_root, }, statix = { root_dir = project.find_vcs_project_root, }, superhtml = { root_dir = project.find_vcs_project_root, }, tabby_ml = { root_dir = project.find_vcs_project_root, }, taplo = { root_dir = project.find_vcs_project_root, }, ts_ls = { root_dir = project.find_vcs_project_root, }, zk = { root_dir = project.find_vcs_project_root, }, } puk.defer 'lspconfig' (function(lspconfig) for server, config in pairs(language_servers) do local capabilities = vim.lsp.protocol.make_client_capabilities() config.capabilities = require('blink.cmp').get_lsp_capabilities(config.capabilities) capabilities = table.extend('force', capabilities, config.capabilities) local settings = config.settings or {} local settings_override = local_settings(server) or {} config.settings = table.extend('force', settings, settings_override) lspconfig[server].setup(config) end end) local lsp_attach = function(args) local bufnr = args.buf local client_id = args.data.client_id local client = vim.lsp.get_client_by_id(client_id) if not client then return end vim.lsp.completion.enable(true, client_id, bufnr) if client.server_capabilities.inlayHintProvider then map.normal { description = 'Toggle inlay hints', category = 'lsp', buffer = bufnr, keys = 'ti', command = function() vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled()) end, } end end auto 'lsp' { description = 'lsp: client attached to buffer', events = 'LspAttach', command = lsp_attach, } local completion_icons = { Class = icon.class, Color = icon.color, Constant = icon.constant, Constructor = icon.constructor, Enum = icon.enum, EnumMember = icon.enum_member, Field = icon.field, File = icon.file, Folder = icon.folder, Function = icon['function'], Interface = icon.interface, Keyword = icon.keyword, Method = icon.method, Module = icon.module, Property = icon.property, Snippet = icon.snippet, Struct = icon.struct, Text = icon.text, Unit = icon.unit, Value = icon.value, Variable = icon.variable, } local completion_kinds = vim.lsp.protocol.CompletionItemKind for i, kind in ipairs(completion_kinds) do completion_kinds[i] = completion_icons[kind] or kind end