diff options
author | pommicket <pommicket@gmail.com> | 2023-01-03 18:36:05 -0500 |
---|---|---|
committer | pommicket <pommicket@gmail.com> | 2023-01-03 18:36:05 -0500 |
commit | 874d7d0c6555642b06c6d2c3e75c6eddf1c94bd0 (patch) | |
tree | 3760b3aa26466c1a6e3355a18f11e456a6f84d4a /lsp.c | |
parent | a648291509aa3b0f91a4b3032b780f1f688379d2 (diff) |
don't start up multiple LSP servers with the same command
Diffstat (limited to 'lsp.c')
-rw-r--r-- | lsp.c | 14 |
1 files changed, 8 insertions, 6 deletions
@@ -167,8 +167,8 @@ static bool lsp_supports_request(LSP *lsp, const LSPRequest *request) { case LSP_REQUEST_EXIT: return true; case LSP_REQUEST_JDTLS_CONFIGURATION: - // @TODO: check if this is actually jdtls - return lsp->language == LANG_JAVA; + // not perfect but whatever + return strstr(lsp->command, "jdtls") != 0; case LSP_REQUEST_COMPLETION: return cap->completion_support; case LSP_REQUEST_SIGNATURE_HELP: @@ -444,7 +444,7 @@ const char *lsp_document_path(LSP *lsp, LSPDocumentID document) { return path; } -LSP *lsp_create(const char *root_dir, Language language, const char *analyzer_command) { +LSP *lsp_create(const char *root_dir, const char *analyzer_command) { LSP *lsp = calloc(1, sizeof *lsp); if (!lsp) return NULL; @@ -454,13 +454,14 @@ LSP *lsp_create(const char *root_dir, Language language, const char *analyzer_co static LSPID curr_id = 1; lsp->id = curr_id++; + #if DEBUG - printf("Starting up LSP %p `%s` for language %s in %s\n", - (void *)lsp, analyzer_command, language_to_str(language), root_dir); + printf("Starting up LSP %p `%s` in %s\n", + (void *)lsp, analyzer_command, root_dir); #endif str_hash_table_create(&lsp->document_ids, sizeof(u32)); - lsp->language = language; + lsp->command = str_dup(analyzer_command); lsp->quit_sem = SDL_CreateSemaphore(0); lsp->error_mutex = SDL_CreateMutex(); lsp->messages_mutex = SDL_CreateMutex(); @@ -564,6 +565,7 @@ void lsp_free(LSP *lsp) { arr_free(lsp->completion_trigger_chars); arr_free(lsp->signature_help_trigger_chars); arr_free(lsp->signature_help_retrigger_chars); + free(lsp->command); memset(lsp, 0, sizeof *lsp); free(lsp); } |