internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: sublimelsp/LSP

Issue:
Some servers provide tooltips for ignored scopes
The vscode-json-languageserver provides tooltips for json keys, but the `string` scope is ignored
https://github.com/tomv564/LSP/blob/1836426c85826f20de73e50ab285a948eebbeba4/plugin/hover.py#L21



Discussion:
Sure, we can remove the string scope from there, but we probably also want to remove the default "no hover content available" popup then? Want to open a PR?
I was thinking maybe just ignore json keys from `NO_HOVER_SCOPES`
 ```python
NO_HOVER_SCOPES = 'comment, string - string.quoted.double.json'
```
if not maybe introduce an optional setting for servers like `"no_hover_scopes"`.

Resolving patch:
diff --git a/plugin/hover.py b/plugin/hover.py
--- a/plugin/hover.py
+++ b/plugin/hover.py
@@ -18,7 +18,6 @@
 from .core.settings import client_configs
 
 SUBLIME_WORD_MASK = 515
-NO_HOVER_SCOPES = 'comment, string'
 
 
 class HoverHandler(sublime_plugin.ViewEventListener):
@@ -71,7 +70,7 @@ def __init__(self, view):
 
     def is_likely_at_symbol(self, point):
         word_at_sel = self.view.classify(point)
-        return word_at_sel & SUBLIME_WORD_MASK and not self.view.match_selector(point, NO_HOVER_SCOPES)
+        return word_at_sel & SUBLIME_WORD_MASK
 
     def run(self, edit, point=None):
         if point is None:
@@ -101,11 +100,14 @@ def handle_response(self, response: 'Optional[Any]', point) -> None:
             all_content += self.diagnostics_content(point_diagnostics)
 
         all_content += self.hover_content(point, response)
-        all_content += self.symbol_actions_content()
+        if all_content:
+            all_content += self.symbol_actions_content()
 
         _test_contents.clear()
         _test_contents.append(all_content)  # for testing only
-        self.show_hover(point, all_content)
+
+        if all_content:
+            self.show_hover(point, all_content)
 
     def symbol_actions_content(self):
         actions = []
@@ -139,10 +141,8 @@ def diagnostics_content(self, diagnostics):
         return "".join(formatted)
 
     def hover_content(self, point, response: 'Optional[Any]') -> str:
-        contents = ["No description available."]
+        contents = []  # type: List[Any]
         if isinstance(response, dict):
-            # Flow returns None sometimes
-            # See: https://github.com/flowtype/flow-language-server/issues/51
             response_content = response.get('contents')
             if response_content:
                 if isinstance(response_content, list):
@@ -164,7 +164,10 @@ def hover_content(self, point, response: 'Optional[Any]') -> str:
             else:
                 formatted.append(value)
 
-        return mdpopups.md2html(self.view, "\n".join(formatted))
+        if formatted:
+            return mdpopups.md2html(self.view, "\n".join(formatted))
+
+        return ""
 
     def show_hover(self, point, contents):
         mdpopups.show_popup(


Test patch:
Repository: sublimelsp/LSP

Issue:
Option to hide links in hover
Currently the hover looks like this:
![screenshot from 2018-12-14 17-03-08](https://user-images.githubusercontent.com/22029477/50014040-1b81d800-ffc3-11e8-8dc4-13cbd907d572.png)

But I would at least appreciate a flag to remove the links, so it would look like:
![screenshot from 2018-12-14 17-04-24](https://user-images.githubusercontent.com/22029477/50014091-3e13f100-ffc3-11e8-8907-6ce55da0046c.png)


Discussion:

Resolving patch:
diff --git a/plugin/core/settings.py b/plugin/core/settings.py
--- a/plugin/core/settings.py
+++ b/plugin/core/settings.py
@@ -66,6 +66,7 @@ def update_settings(settings: Settings, settings_obj: sublime.Settings) -> None:
                                                            settings.document_highlight_scopes)
     settings.diagnostics_gutter_marker = read_str_setting(settings_obj, "diagnostics_gutter_marker", "dot")
     settings.show_code_actions_bulb = read_bool_setting(settings_obj, "show_code_actions_bulb", False)
+    settings.show_symbol_action_links = read_bool_setting(settings_obj, "show_symbol_action_links", False)
     settings.only_show_lsp_completions = read_bool_setting(settings_obj, "only_show_lsp_completions", False)
     settings.complete_all_chars = read_bool_setting(settings_obj, "complete_all_chars", True)
     settings.completion_hint_type = read_str_setting(settings_obj, "completion_hint_type", "auto")
diff --git a/plugin/core/types.py b/plugin/core/types.py
--- a/plugin/core/types.py
+++ b/plugin/core/types.py
@@ -30,6 +30,7 @@ def __init__(self) -> None:
         }
         self.diagnostics_gutter_marker = "dot"
         self.show_code_actions_bulb = False
+        self.show_symbol_action_links = False
         self.complete_all_chars = False
         self.completion_hint_type = "auto"
         self.prefer_label_over_filter_text = False
diff --git a/plugin/hover.py b/plugin/hover.py
--- a/plugin/hover.py
+++ b/plugin/hover.py
@@ -103,7 +103,7 @@ def handle_response(self, response: 'Optional[Any]', point: int) -> None:
             all_content += self.diagnostics_content(point_diagnostics)
 
         all_content += self.hover_content(point, response)
-        if all_content:
+        if all_content and settings.show_symbol_action_links:
             all_content += self.symbol_actions_content()
 
         _test_contents.clear()


Test patch:
Repository: sublimelsp/LSP

Issue:
Send `null` when a setting doesn't match in workspace/configuration request
We currently send an empty dictionary, but we should send null instead, as per spec.

https://microsoft.github.io/language-server-protocol/specification#workspace_configuration

discussed here: https://github.com/sublimelsp/LSP/pull/906



Discussion:

Resolving patch:
diff --git a/plugin/core/sessions.py b/plugin/core/sessions.py
--- a/plugin/core/sessions.py
+++ b/plugin/core/sessions.py
@@ -104,6 +104,16 @@ def diff_folders(old: List[WorkspaceFolder],
     return added, removed
 
 
+def get_dotted_value(current: Any, dotted: str) -> Any:
+    keys = dotted.split('.')
+    for key in keys:
+        if isinstance(current, dict):
+            current = current.get(key)
+        else:
+            return None
+    return current
+
+
 class InitializeError(Exception):
 
     def __init__(self, session: 'Session') -> None:
@@ -279,7 +289,14 @@ def _handle_request_workspace_configuration(self, params: Dict[str, Any], reques
         items = []  # type: List[Any]
         requested_items = params.get("items") or []
         for requested_item in requested_items:
-            items.append(self.config.settings)  # ???
+            if 'section' in requested_item:
+                section = requested_item['section']
+                if section:
+                    items.append(get_dotted_value(self.config.settings, section))
+                else:
+                    items.append(self.config.settings)
+            else:
+                items.append(self.config.settings)
         self.client.send_response(Response(request_id, items))
 
     def end(self) -> None:


Test patch:
Repository: sublimelsp/LSP

Issue:
Improve handling of missing project folders
I am using LSP plugin installed on Windows 10 through package control.

When I have a project file that contains folder paths that do not exist on the file system, I get the following error, and LSP disables clangd.

This could potentially be improved. LSP could either ignore missing folders (this is what sublime text seems to do). Or LSP could give a more informative error to the user. Since LSP is reading a user edited file, something more informative than an assert should be implemented.

```
LSP: global configs ['phpls=False', 'gopls=False', 'rls=False', 'dart=False', 'cquery=False', 'metals=False', 'flow=False', 'rlang=False', 'ocaml=False', 'lsp-tsserver=False', 'clangd=False', 'typescript-language-server=False', 'javascript-typescript-langserver=False', 'elixir-ls=False', 'ra-lsp=False', 'polymer-ide=False', 'reason=False', 'bashls=False', 'ruby=False', 'intelephense-ls=False', 'vscode-css=False', 'golsp=False', 'jdtls=False', 'pyls=False', 'eslint=False', 'haskell-ide-engine=False']
LSP: window has override for clangd {'enabled': True}
LSP: window 2 starting 1 initial views
LSP: window has override for clangd {'enabled': True}
LSP: window 2 requests clangd for C:\somedir\myfile.cpp
LSP: window has override for clangd {'enabled': True}
Could not start clangd



Server will be disabled for this window
Traceback (most recent call last):
  File "C:\Users\sfield\AppData\Roaming\Sublime Text 3\Installed Packages\LSP.sublime-package\plugin/core/windows.py", line 471, in _start_client
    self._workspace.all(),         # workspace_folders
  File "C:\Users\sfield\AppData\Roaming\Sublime Text 3\Installed Packages\LSP.sublime-package\plugin/core/workspace.py", line 19, in all
    return [WorkspaceFolder.from_path(f) for f in self.folders]
  File "C:\Users\sfield\AppData\Roaming\Sublime Text 3\Installed Packages\LSP.sublime-package\plugin/core/workspace.py", line 19, in <listcomp>
    return [WorkspaceFolder.from_path(f) for f in self.folders]
  File "C:\Users\sfield\AppData\Roaming\Sublime Text 3\Installed Packages\LSP.sublime-package\plugin/core/protocol.py", line 427, in from_path
    assert os.path.isdir(path)
AssertionError


```


Discussion:
Yes, I would love to remove all occurrences of `assert` in favour of proper error handling where needed. Maybe it's useful while debugging but this is one example where we needlessly break the user experience.

Resolving patch:
diff --git a/plugin/core/protocol.py b/plugin/core/protocol.py
--- a/plugin/core/protocol.py
+++ b/plugin/core/protocol.py
@@ -419,13 +419,9 @@ class WorkspaceFolder:
     def __init__(self, name: str, path: str) -> None:
         self.name = name
         self.path = path
-        assert self.name
-        assert self.path
 
     @classmethod
     def from_path(cls, path: str) -> 'WorkspaceFolder':
-        assert os.path.isdir(path)
-        assert os.path.isabs(path)
         return cls(os.path.basename(path) or path, path)
 
     def __repr__(self) -> str:


Test patch:
Repository: sublimelsp/LSP

Issue:
Empty initializationOptions is not sent
# Problem

If the `initializationOptions` is an empty dict, it won't be sent to the server.
```js
// this is not sent
"initializationOptions": {},
```

Some servers (such as [vscode-css-languageserver](https://github.com/vscode-langservers/vscode-css-languageserver)) need `initializationOptions` to be set even if a empty one or a useless one (as a workaround) such as the following.

```js
// this will be sent
"initializationOptions": {"just_an_useless_key": 1},
```


# Reference

- https://github.com/sublimelsp/LSP-css/pull/2#discussion_r393881421


Discussion:

Resolving patch:
diff --git a/plugin/core/sessions.py b/plugin/core/sessions.py
--- a/plugin/core/sessions.py
+++ b/plugin/core/sessions.py
@@ -85,7 +85,7 @@ def get_initialize_params(workspace_folders: List[WorkspaceFolder], designated_f
             }
         }
     }
-    if config.init_options:
+    if config.init_options is not None:
         initializeParams['initializationOptions'] = config.init_options
 
     return initializeParams


Test patch:
diff --git a/tests/test_session.py b/tests/test_session.py
--- a/tests/test_session.py
+++ b/tests/test_session.py
@@ -1,6 +1,6 @@
 from LSP.plugin.core.protocol import TextDocumentSyncKindFull, TextDocumentSyncKindNone, TextDocumentSyncKindIncremental
 from LSP.plugin.core.protocol import WorkspaceFolder
-from LSP.plugin.core.sessions import create_session, Session, InitializeError
+from LSP.plugin.core.sessions import create_session, Session, InitializeError, get_initialize_params
 from LSP.plugin.core.settings import settings as global_settings
 from LSP.plugin.core.types import ClientConfig
 from LSP.plugin.core.types import Settings
@@ -44,6 +44,20 @@ def make_session(self, bootstrap_client, on_pre_initialize=None, on_post_initial
                 on_post_initialize=on_post_initialize,
                 on_post_exit=on_post_exit))
 
+    def test_initialize_params(self) -> None:
+        wf = WorkspaceFolder.from_path("/foo/bar/baz")
+        params = get_initialize_params(
+            [wf], wf, ClientConfig(name="test", binary_args=[""], tcp_port=None, init_options=None))
+        self.assertNotIn("initializationOptions", params)
+        params = get_initialize_params(
+            [wf], wf, ClientConfig(name="test", binary_args=[""], tcp_port=None, init_options={}))
+        self.assertIn("initializationOptions", params)
+        self.assertEqual(params["initializationOptions"], {})
+        params = get_initialize_params(
+            [wf], wf, ClientConfig(name="test", binary_args=[""], tcp_port=None, init_options={"foo": "bar"}))
+        self.assertIn("initializationOptions", params)
+        self.assertEqual(params["initializationOptions"], {"foo": "bar"})
+
     # @unittest.skip("need an example config")
     def test_can_create_session(self):
         config = ClientConfig(
Repository: sublimelsp/LSP

Issue:
View synchronization issue when modifying file during LSP initialization
1. Install `lsp-eslint` (you might also need proper eslint configuration...)
2. Restart ST with such document open
```js
const a = 1;
const b = 2;
const c = 3;
```
3. While LSP is initializing, join all three lines with `cmd+j` (or equivalent on non-macs).
4. Wait for LSP to initialize fully
5. Undo changes with cmd+z (or equivalent).

The diagnostics will be messed up.
Log:
 - `textDocument/didOpen`:
```const a = 1; const b = 2; const c = 3;\n```
 - `textDocument/didChange`:
```
  "contentChanges": [
    {
      "rangeLength": 1,
      "range": {
        "start": {
          "line": 0,
          "character": 25
        },
        "end": {
          "line": 1,
          "character": 0
        }
      },
      "text": ""
    },
    {
      "rangeLength": 0,
      "range": {
        "start": {
          "line": 0,
          "character": 25
        },
        "end": {
          "line": 0,
          "character": 25
        }
      },
      "text": " "
    }
  ]
```

This is already wrong as replies changes that no longer apply for the view that was sent in `didOpen`.

(Issue found by @predragnikolic )


Discussion:
Maybe `on_text_changed` should also include a "document version" (`view.change_count()`) so that we can discard changes that are for past versions of the view.

Resolving patch:
diff --git a/plugin/core/windows.py b/plugin/core/windows.py
--- a/plugin/core/windows.py
+++ b/plugin/core/windows.py
@@ -214,6 +214,8 @@ def handle_did_open(self, view: ViewLike) -> None:
 
     def _notify_did_open(self, view: ViewLike, session: Session) -> None:
         language_id = self._view_language(view, session.config.name)
+        # There might be pending, no longer valid changes when restoring session.
+        self._pending_buffer_changes.pop(view.buffer_id(), None)
         # mypy: expected sublime.View, got ViewLike
         session.send_notification(did_open(view, language_id))  # type: ignore
 


Test patch:
Repository: sublimelsp/LSP

Issue:
Double requests for documentHighlight
I've noticed that setting a cursor on some symbol makes the `documentHighlight` underline blink once.

Checked logs and saw the request being made twice on each cursor movement:
```
:: --> pyls textDocument/documentHighlight(12): {'textDocument': {'uri': 'file:////LSP/plugin/highlights.py'}, 'position': {'character': 8, 'line': 38}}
:: --> pyls textDocument/documentHighlight(13): {'textDocument': {'uri': 'file:////LSP/plugin/highlights.py'}, 'position': {'character': 8, 'line': 38}}
```

Then added log in `DocumentHighlightListener` class, inside `on_selection_modified_async` method and that listener seems to be triggered twice on cursor movement. Tested with `print(self.view.file_name())`.


Discussion:

Resolving patch:
diff --git a/plugin/highlights.py b/plugin/highlights.py
--- a/plugin/highlights.py
+++ b/plugin/highlights.py
@@ -43,9 +43,11 @@ def on_selection_modified_async(self) -> None:
                 current_point = self.view.sel()[0].begin()
             except IndexError:
                 return
-            self._stored_point = current_point
             self._clear_regions()
-            debounced(self._on_document_highlight, 500, lambda: self._stored_point == current_point, async_thread=True)
+            if self._stored_point != current_point:
+                self._stored_point = current_point
+                debounced(self._on_document_highlight, 500, lambda: self._stored_point == current_point,
+                          async_thread=True)
 
     def _initialize(self) -> None:
         self._initialized = True


Test patch:
Repository: sublimelsp/LSP

Issue:
Don't send workspace/didChangeConfiguration before initialized
LSP (master branch) sends a `workspace/didChangeConfiguration` ([here](https://github.com/sublimelsp/LSP/blob/099381ca3bc0301b6c7413caa05e0e4ba40aec38/plugin/core/sessions.py#L362)) before `initialized` notification. This is a violation of the [specs](https://microsoft.github.io/language-server-protocol/specifications/specification-current/#initialized) (emphasis by me):
> The initialized notification is sent from the client to the server after the client received the result of the initialize request **but before the client is sending any other request or notification** to the server.




Discussion:

Resolving patch:
diff --git a/plugin/core/sessions.py b/plugin/core/sessions.py
--- a/plugin/core/sessions.py
+++ b/plugin/core/sessions.py
@@ -358,12 +358,8 @@ def _handle_initialize_result(self, result: Any) -> None:
         self.on_request("workspace/configuration", self._handle_request_workspace_configuration)
         self.on_request("client/registerCapability", self._handle_register_capability)
         self.on_request("client/unregisterCapability", self._handle_unregister_capability)
-        if self.config.settings:
-            self.client.send_notification(Notification.didChangeConfiguration({'settings': self.config.settings}))
-
         if self._on_post_initialize:
             self._on_post_initialize(self)
-
         execute_commands = self.get_capability('executeCommandProvider.commands')
         if execute_commands:
             debug("{}: Supported execute commands: {}".format(self.config.name, execute_commands))
diff --git a/plugin/core/windows.py b/plugin/core/windows.py
--- a/plugin/core/windows.py
+++ b/plugin/core/windows.py
@@ -560,7 +560,8 @@ def _handle_post_initialize(self, session: Session) -> None:
         self._handlers.on_initialized(session.config.name, self._window, session.client)
 
         session.client.send_notification(Notification.initialized())
-
+        if session.config.settings:
+            session.client.send_notification(Notification.didChangeConfiguration({'settings': session.config.settings}))
         if session.has_capability("textDocumentSync"):
             self.documents.add_session(session)
         self._window.status_message("{} initialized".format(session.config.name))


Test patch:
Repository: sublimelsp/LSP

Issue:
"show_view_status" is not working
I've set `show_view_status` to `false`, but still can see `LSP-json` prefix

***

* OS and language server: Windows
* How you installed LSP (Package Control or from git?): Package Control



Discussion:

Resolving patch:
diff --git a/plugin/core/types.py b/plugin/core/types.py
--- a/plugin/core/types.py
+++ b/plugin/core/types.py
@@ -133,7 +133,6 @@ def document_highlight_style_to_add_regions_flags(self) -> int:
         return _settings_style_to_add_regions_flag(self.document_highlight_style)
 
     def diagnostics_highlight_style_to_add_regions_flag(self) -> int:
-        # TODO: Unused for now
         return _settings_style_to_add_regions_flag(self.diagnostics_highlight_style)
 
 
@@ -199,8 +198,9 @@ def __init__(self,
         self.status_key = "lsp_{}".format(self.name)
 
     def set_view_status(self, view: sublime.View, message: str) -> None:
-        status = "{}: {}".format(self.name, message) if message else self.name
-        view.set_status(self.status_key, status)
+        if sublime.load_settings("LSP.sublime-settings").get("show_view_status"):
+            status = "{}: {}".format(self.name, message) if message else self.name
+            view.set_status(self.status_key, status)
 
     def erase_view_status(self, view: sublime.View) -> None:
         view.erase_status(self.status_key)


Test patch:
Repository: sublimelsp/LSP

Issue:
Server is being shutdown on server sending empty stderr line
When server triggers stderr output that is an empty string (or becomes an empty string after `rstrip` then LSP closes the transports and thus the server.

Issue found when analyzing https://github.com/sublimelsp/LSP-angular/issues/1


Discussion:

Resolving patch:
diff --git a/plugin/core/transports.py b/plugin/core/transports.py
--- a/plugin/core/transports.py
+++ b/plugin/core/transports.py
@@ -158,8 +158,6 @@ def _stderr_loop(self) -> None:
         try:
             while self._stderr:
                 message = self._stderr.readline().decode('utf-8', 'replace').rstrip()
-                if not message:
-                    break
                 callback_object = self._callback_object()
                 if callback_object:
                     callback_object.on_stderr_message(message)


Test patch:
Repository: sublimelsp/LSP

Issue:
Server is being shutdown on server sending empty stderr line
When server triggers stderr output that is an empty string (or becomes an empty string after `rstrip` then LSP closes the transports and thus the server.

Issue found when analyzing https://github.com/sublimelsp/LSP-angular/issues/1


Discussion:

Resolving patch:
diff --git a/plugin/core/transports.py b/plugin/core/transports.py
--- a/plugin/core/transports.py
+++ b/plugin/core/transports.py
@@ -157,9 +157,9 @@ def _write_loop(self) -> None:
     def _stderr_loop(self) -> None:
         try:
             while self._stderr:
-                message = self._stderr.readline().decode('utf-8', 'replace').rstrip()
-                if not message:
+                if self._closed:
                     break
+                message = self._stderr.readline().decode('utf-8', 'replace').rstrip()
                 callback_object = self._callback_object()
                 if callback_object:
                     callback_object.on_stderr_message(message)


Test patch: