From 9602ae4d8582c3ccdb9e8c1561ad306491713be4 Mon Sep 17 00:00:00 2001 From: pommicket Date: Sun, 25 Dec 2022 21:55:42 -0500 Subject: global lsp-enabled setting --- config.c | 7 ++++--- main.c | 1 + ted.c | 5 ++++- ted.cfg | 7 +++++-- ted.h | 1 + 5 files changed, 15 insertions(+), 6 deletions(-) diff --git a/config.c b/config.c index 9cfad1e..c399ad6 100644 --- a/config.c +++ b/config.c @@ -251,6 +251,7 @@ static OptionBool const options_bool[] = { {"indent-with-spaces", &options_zero.indent_with_spaces, true}, {"trigger-characters", &options_zero.trigger_characters, true}, {"identifier-trigger-characters", &options_zero.identifier_trigger_characters, true}, + {"lsp-enabled", &options_zero.lsp_enabled, true}, }; static OptionU8 const options_u8[] = { {"tab-width", &options_zero.tab_width, 1, 100, true}, @@ -778,11 +779,11 @@ static void config_parse_line(ConfigReader *cfg, Settings *settings, const Confi bool const is_floating = *endptr == '\0'; bool is_bool = false; bool boolean = false; - #define BOOL_HELP "(should be yes/no/on/off)" - if (streq(value, "yes") || streq(value, "on")) { + #define BOOL_HELP "(should be yes/no/on/off/true/false)" + if (streq(value, "yes") || streq(value, "on") || streq(value, "true")) { is_bool = true; boolean = true; - } else if (streq(value, "no") || streq(value, "off")) { + } else if (streq(value, "no") || streq(value, "off") || streq(value, "false")) { is_bool = true; boolean = false; } diff --git a/main.c b/main.c index a1aa8e9..6bec271 100644 --- a/main.c +++ b/main.c @@ -34,6 +34,7 @@ FUTURE FEATURES: - plugins? - keyboard macros - ctrl+9/0 to inc/dec number would be useful here + - with macros we can really test performance of buffer_insert_text_at_pos, etc. (which should ideally be fast) */ #include "base.h" diff --git a/ted.c b/ted.c index 0a71227..637a592 100644 --- a/ted.c +++ b/ted.c @@ -92,6 +92,10 @@ Settings *ted_get_settings(Ted *ted, const char *path, Language language) { } LSP *ted_get_lsp(Ted *ted, const char *path, Language language) { + Settings *settings = ted_get_settings(ted, path, language); + if (!settings->lsp_enabled) + return NULL; + int i; for (i = 0; i < TED_LSP_MAX; ++i) { LSP *lsp = ted->lsps[i]; @@ -105,7 +109,6 @@ LSP *ted_get_lsp(Ted *ted, const char *path, Language language) { } if (i == TED_LSP_MAX) return NULL; // why are there so many LSP open??? - Settings *settings = ted_get_settings(ted, path, language); if (*settings->lsp) { // start up this LSP char *root_dir = settings_get_root_dir(settings, path); diff --git a/ted.cfg b/ted.cfg index df79a5f..e4a6b1b 100644 --- a/ted.cfg +++ b/ted.cfg @@ -33,6 +33,9 @@ restore-session = on trigger-characters = on # should all identifier characters (e.g. a-z) be treated as trigger characters? identifier-trigger-characters = off +# enable LSP support (for autocompletion, etc.) +# you can also set `lsp = ""` but this is a quick way to disable LSP servers for all langauges +lsp-enabled = yes # search depth for files to generate tags for. # if set to 0, tag generation/regeneration will do nothing @@ -40,7 +43,7 @@ tags-max-depth = 2 # regenerate tags if an identifier is not found (with Ctrl+click)? regenerate-tags-if-not-found = yes # this variable determines how ted finds the "root directory" of a project for -# running build commands and because LSPs need to know +# running build commands and because LSP servers need to know # FOR EXAMPLE: If you have the file /a/b/c/d.txt open, # ted will check each of the directories /, /a, /a/b, /a/b/c # and set the root to whichever one has one of these files, @@ -123,7 +126,7 @@ Ctrl+a = :select-all Tab = :tab Shift+Tab = :backtab Enter = :newline -# same as :newline for normal text insertion, but goes to the previous search result instead of the next one +# same as :newline for normal text insertion, but goes to the previous search result instead of the next one for find+replace Shift+Enter = :newline-back Keypad Enter = :newline Shift+Keypad Enter = :newline-back diff --git a/ted.h b/ted.h index 18defc4..13e3331 100644 --- a/ted.h +++ b/ted.h @@ -187,6 +187,7 @@ typedef struct { bool indent_with_spaces; bool trigger_characters; bool identifier_trigger_characters; + bool lsp_enabled; u8 tab_width; u8 cursor_width; u8 undo_save_time; -- cgit v1.2.3