Repository: sublimelsp/LSP

Issue:
Feature request: allowing passthrough of sublime snippets in "only_show_lsp_completions" mode
* OS and language server
- Mac OS X Mojave
- Any language server (general LSP package feature request)

Hi there, this is a feature request as mentioned on Discord chat, being moved here. My set-up is Sublime Text 4, however I think this applies to all versions of ST and ST-LSP.

ST-LSP has the feature `only_show_lsp_completions`, which, when enabled, show only LSP completions. This drastically improves the ST autocomplete, which has never been worth much on its own.

However, there is one feature that lots of people use via autocomplete as the main interface — the sublime snippets. Enabling `only_show_lsp_completions` disables snippet completion.

The feature request is to make sublime snippets either by default passed through LSP in the case `only_show_lsp_completions` is enabled, or make this snippet passthrough a flag in the settings. My vote would be towards passing snippets through by default, since it is unlikely for a person to attempt disabling sublime snippets by enabling `only_show_lsp_completions` in LSP. 

Thanks for making this package — this is quite possibly the best ST package in existence in terms of usefulness.


Discussion:
maybe deprecate `only_show_lsp_completions`
in favor of a more dynamic setting?

```
// smart_completions - show lsp completions 
// explicit_completions - show completions based on .sublime-completions files
// word_completions - show completions based on the contents of the view 
"auto_complete_includes": ["smart_completions", "explicit_completions", "word_completions"]
```
Yes, that would be better. But any extra code written is a maintenance burden to the maintainers, especially if not many people use it, so I was going for the minimum workable configuration.

It also makes me think that would be much better served as a Sublime Text core feature rather than LSP, your kind of 'list of subscriptions' for autocomplete providers sound quite useful outside of LSP as well.
Just exposing `sublime.INHIBIT_WORD_COMPLETIONS` and `sublime.INHIBIT_EXPLICIT_COMPLETIONS` as `"inhibit_word_completions"` and `"inhibit_snippet_completions"` would work. The translation would be straightforward.
Thanks! If you need QA on this, happy to help out — already have LSP `git clone`'d. in place.

Resolving patch:
diff --git a/plugin/core/types.py b/plugin/core/types.py
--- a/plugin/core/types.py
+++ b/plugin/core/types.py
@@ -131,6 +131,8 @@ class Settings:
     disabled_capabilities = None  # type: List[str]
     document_highlight_scopes = None  # type: Dict[str, str]
     document_highlight_style = None  # type: str
+    inhibit_snippet_completions = None  # type: bool
+    inhibit_word_completions = None  # type: bool
     log_debug = None  # type: bool
     log_max_size = None  # type: int
     log_server = None  # type: List[str]
@@ -199,6 +201,15 @@ def r(name: str, default: Union[bool, int, str, list, dict]) -> None:
         else:
             self.auto_show_diagnostics_panel = "always"
 
+        # Backwards-compatible with "only_show_lsp_completions"
+        only_show_lsp_completions = s.get("only_show_lsp_completions")
+        if isinstance(only_show_lsp_completions, bool):
+            self.inhibit_snippet_completions = only_show_lsp_completions
+            self.inhibit_word_completions = only_show_lsp_completions
+        else:
+            r("inhibit_snippet_completions", False)
+            r("inhibit_word_completions", True)
+
     def show_diagnostics_panel_always(self) -> bool:
         return self.auto_show_diagnostics_panel == "always"
 
diff --git a/plugin/documents.py b/plugin/documents.py
--- a/plugin/documents.py
+++ b/plugin/documents.py
@@ -544,10 +544,11 @@ def _on_complete_result(self, response: Optional[Union[dict, List]], completion_
                             can_resolve_completion_items: bool) -> None:
         response_items = []  # type: List[Dict]
         flags = 0
-        if userprefs().only_show_lsp_completions:
-            flags |= sublime.INHIBIT_WORD_COMPLETIONS
+        prefs = userprefs()
+        if prefs.inhibit_snippet_completions:
             flags |= sublime.INHIBIT_EXPLICIT_COMPLETIONS
-            flags |= sublime.INHIBIT_REORDER
+        if prefs.inhibit_word_completions:
+            flags |= sublime.INHIBIT_WORD_COMPLETIONS
         if isinstance(response, dict):
             response_items = response["items"] or []
             if response.get("isIncomplete", False):
@@ -558,6 +559,8 @@ def _on_complete_result(self, response: Optional[Union[dict, List]], completion_
         LspResolveDocsCommand.completions = response_items
         items = [format_completion(response_item, index, can_resolve_completion_items)
                  for index, response_item in enumerate(response_items)]
+        if items:
+            flags |= sublime.INHIBIT_REORDER
         resolve(completion_list, items, flags)
 
     def _on_complete_error(self, error: dict, completion_list: sublime.CompletionList) -> None:


Test patch: