This repository has been archived by the owner on Sep 24, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhls.py
86 lines (69 loc) · 2.73 KB
/
hls.py
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#!/usr/bin/env python3
# hls.py
# Copyright 2022 JCWasmx86 <[email protected]>
#
# Based on: ts_language_server_plugin.py
# Copyright 2021 Georg Vienna <[email protected]>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# SPDX-License-Identifier: GPL-3.0-or-later
import gi
import os
from gi.repository import GLib
from gi.repository import Gio
from gi.repository import GObject
from gi.repository import Ide
class HLSService(Ide.LspService):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.set_inherit_stderr(True)
self.set_search_path([os.path.expanduser("~/.ghcup/bin")])
self.set_program("haskell-language-server-wrapper")
def do_configure_launcher(self, pipeline, launcher):
launcher.push_argv("--lsp")
launcher.push_argv("--debug")
launcher.push_argv("--logfile")
launcher.push_argv(os.path.expanduser("~/.cache") + "/hls.log")
launcher.setenv("PATH", os.path.expanduser("~/.ghcup/bin") + ":" + "/app/bin/:/usr/bin/" + os.getenv("PATH"), True);
def do_configure_client(self, client):
client.add_language("haskell")
class HLSDiagnosticProvider(Ide.LspDiagnosticProvider, Ide.DiagnosticProvider):
def do_load(self):
HLSService.bind_client(self)
class HLSCompletionProvider(Ide.LspCompletionProvider, Ide.CompletionProvider):
def do_load(self, context):
HLSService.bind_client(self)
def do_get_priority(self, context):
return -1000
class HLSSymbolResolver(Ide.LspSymbolResolver, Ide.SymbolResolver):
def do_load(self):
HLSService.bind_client(self)
class HLSHighlighter(Ide.LspHighlighter, Ide.Highlighter):
def do_load(self):
HLSService.bind_client(self)
class HLSFormatter(Ide.LspFormatter, Ide.Formatter):
def do_load(self):
HLSService.bind_client(self)
class HLSHoverProvider(Ide.LspHoverProvider, Ide.HoverProvider):
def do_prepare(self):
self.props.category = "Haskell Language Server"
self.props.priority = 200
HLSService.bind_client(self)
class HLSRenameProvider(Ide.LspRenameProvider, Ide.RenameProvider):
def do_load(self):
HLSService.bind_client(self)
class HLSCodeActionProvider(Ide.LspCodeActionProvider, Ide.CodeActionProvider):
def do_load(self):
HLSService.bind_client(self)