Skip to content

Instantly share code, notes, and snippets.

@aviatesk
Created August 25, 2020 10:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aviatesk/43dfd10f31e3b853cb36d9aab0b2e12c to your computer and use it in GitHub Desktop.
Save aviatesk/43dfd10f31e3b853cb36d9aab0b2e12c to your computer and use it in GitHub Desktop.
# %%
using LanguageServer, CSTParser, StaticLint, SymbolServer
using LanguageServer: Range, TextDocumentIdentifier, TextDocumentPositionParams
const LS = LanguageServer
const SS = SymbolServer
server = let
pi = IOBuffer()
po = IOBuffer()
env = normpath(@__DIR__, "..", "scripts", "environments", "development")
depot = normpath(@__DIR__, "ls_depot")
server = LanguageServerInstance(pi, po, env, depot)
@async run(server)
init_str = read(joinpath(@__DIR__, "ls_init_str.json"), String)
init_params = LS.InitializeParams(LS.JSON.parse(init_str)["params"])
LanguageServer.initialize_request(init_params, server, nothing)
server
end
function str_to_lsdoc(text; uri = "none", server = server)
doc = LS.Document(uri, text, true, server)
LS.setdocument!(server, LS.URI2(uri), doc)
LS.parse_all(doc, server)
return doc
end
# %%
server.env_path
server.symbol_store
server.symbol_server
server.symbol_server.process
server.depot_path
# %%
@time SS.getstore(server.symbol_server, server.env_path)
@time SS.load_project_packages_into_store!(server.symbol_server, server.env_path, SS.recursive_copy(SS.stdlibs))
@time wait(LS.trigger_symbolstore_reload(server))
server.symbol_store
# %%
using LanguageServer: get_offset, Position
doc = str_to_lsdoc("""
a = sincos(1)
s = "jυλια"
""")
get_offset(doc, Position(0, 30))
@aviatesk
Copy link
Author

ls_init_str.json

{
  "jsonrpc": "2.0",
  "id": 0,
  "method": "initialize",
  "params": {
    "processId": 0,
    "clientInfo": {
      "name": "vscode",
      "version": "1.42.0"
    },
    "rootPath": null,
    "rootUri": null,
    "capabilities": {
      "workspace": {
        "applyEdit": true,
        "workspaceEdit": {
          "documentChanges": true,
          "resourceOperations": [
            "create",
            "rename",
            "delete"
          ],
          "failureHandling": "textOnlyTransactional"
        },
        "didChangeConfiguration": {
          "dynamicRegistration": true
        },
        "didChangeWatchedFiles": {
          "dynamicRegistration": true
        },
        "symbol": {
          "dynamicRegistration": true,
          "symbolKind": {
            "valueSet": [
              1,
              2,
              3,
              4,
              5,
              6,
              7,
              8,
              9,
              10,
              11,
              12,
              13,
              14,
              15,
              16,
              17,
              18,
              19,
              20,
              21,
              22,
              23,
              24,
              25,
              26
            ]
          }
        },
        "executeCommand": {
          "dynamicRegistration": true
        },
        "configuration": true,
        "workspaceFolders": true
      },
      "textDocument": {
        "publishDiagnostics": {
          "relatedInformation": true,
          "versionSupport": false,
          "tagSupport": {
            "valueSet": [
              1,
              2
            ]
          }
        },
        "synchronization": {
          "dynamicRegistration": true,
          "willSave": true,
          "willSaveWaitUntil": true,
          "didSave": true
        },
        "completion": {
          "dynamicRegistration": true,
          "contextSupport": true,
          "completionItem": {
            "snippetSupport": true,
            "commitCharactersSupport": true,
            "documentationFormat": [
              "markdown",
              "plaintext"
            ],
            "deprecatedSupport": true,
            "preselectSupport": true,
            "tagSupport": {
              "valueSet": [
                1
              ]
            }
          },
          "completionItemKind": {
            "valueSet": [
              1,
              2,
              3,
              4,
              5,
              6,
              7,
              8,
              9,
              10,
              11,
              12,
              13,
              14,
              15,
              16,
              17,
              18,
              19,
              20,
              21,
              22,
              23,
              24,
              25
            ]
          }
        },
        "hover": {
          "dynamicRegistration": true,
          "contentFormat": [
            "markdown",
            "plaintext"
          ]
        },
        "signatureHelp": {
          "dynamicRegistration": true,
          "signatureInformation": {
            "documentationFormat": [
              "markdown",
              "plaintext"
            ],
            "parameterInformation": {
              "labelOffsetSupport": true
            }
          },
          "contextSupport": true
        },
        "definition": {
          "dynamicRegistration": true,
          "linkSupport": true
        },
        "references": {
          "dynamicRegistration": true
        },
        "documentHighlight": {
          "dynamicRegistration": true
        },
        "documentSymbol": {
          "dynamicRegistration": true,
          "symbolKind": {
            "valueSet": [
              1,
              2,
              3,
              4,
              5,
              6,
              7,
              8,
              9,
              10,
              11,
              12,
              13,
              14,
              15,
              16,
              17,
              18,
              19,
              20,
              21,
              22,
              23,
              24,
              25,
              26
            ]
          },
          "hierarchicalDocumentSymbolSupport": true
        },
        "codeAction": {
          "dynamicRegistration": true,
          "isPreferredSupport": true,
          "codeActionLiteralSupport": {
            "codeActionKind": {
              "valueSet": [
                "",
                "quickfix",
                "refactor",
                "refactor.extract",
                "refactor.inline",
                "refactor.rewrite",
                "source",
                "source.organizeImports"
              ]
            }
          }
        },
        "codeLens": {
          "dynamicRegistration": true
        },
        "formatting": {
          "dynamicRegistration": true
        },
        "rangeFormatting": {
          "dynamicRegistration": true
        },
        "onTypeFormatting": {
          "dynamicRegistration": true
        },
        "rename": {
          "dynamicRegistration": true,
          "prepareSupport": true
        },
        "documentLink": {
          "dynamicRegistration": true,
          "tooltipSupport": true
        },
        "typeDefinition": {
          "dynamicRegistration": true,
          "linkSupport": true
        },
        "implementation": {
          "dynamicRegistration": true,
          "linkSupport": true
        },
        "colorProvider": {
          "dynamicRegistration": true
        },
        "foldingRange": {
          "dynamicRegistration": true,
          "rangeLimit": 5000,
          "lineFoldingOnly": true
        },
        "declaration": {
          "dynamicRegistration": true,
          "linkSupport": true
        },
        "selectionRange": {
          "dynamicRegistration": true
        },
        "callHierarchy": {
          "dynamicRegistration": true
        },
        "semanticTokens": {
          "dynamicRegistration": true,
          "tokenTypes": [
            "comment",
            "keyword",
            "number",
            "regexp",
            "operator",
            "namespace",
            "type",
            "struct",
            "class",
            "interface",
            "enum",
            "typeParameter",
            "function",
            "member",
            "macro",
            "variable",
            "parameter",
            "property",
            "label"
          ],
          "tokenModifiers": [
            "declaration",
            "documentation",
            "static",
            "abstract",
            "deprecated",
            "async",
            "readonly"
          ]
        }
      },
      "window": {
        "workDoneProgress": true
      }
    },
    "trace": "verbose"
  }
}

@aviatesk
Copy link
Author

@reportdef

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment