Skip to content

Commit b73717e

Browse files
Merge pull request #1128 from jiacai2050/fix-python13
fix version function for python 3.13
2 parents 2031e6d + 3f8f190 commit b73717e

File tree

3 files changed

+49
-54
lines changed

3 files changed

+49
-54
lines changed

.github/workflows/test.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,15 @@ jobs:
4545
run: |
4646
# sudo apt-get install clangd-12
4747
# sudo update-alternatives --install /usr/bin/clangd clangd /usr/bin/clangd-12 100
48-
pip install epc six basedpyright sexpdata watchdog
48+
pip install epc six basedpyright sexpdata watchdog packaging
4949
go install golang.org/x/tools/gopls@latest
5050
curl https://raw.githubusercontent.com/eruizc-dev/jdtls-launcher/master/install.sh | bash
5151
if: matrix.os == 'ubuntu-latest'
5252

5353
- name: Install Dependencies (Windows)
5454
run: |
5555
# choco install llvm
56-
python -m pip install epc six basedpyright sexpdata watchdog
56+
python -m pip install epc six basedpyright sexpdata watchdog packaging
5757
go install golang.org/x/tools/gopls@latest
5858
if: matrix.os == 'windows-latest'
5959

README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
<a href="https://github.com/manateelazycat/lsp-bridge/actions/workflows/test.yml"><img src="https://github.com/manateelazycat/lsp-bridge/actions/workflows/test.yml/badge.svg"/></a> <a href ="https://github.com/manateelazycat/lsp-bridge/blob/master/README.zh-CN.md"><img src="https://img.shields.io/badge/README-%E7%AE%80%E4%BD%93%E4%B8%AD%E6%96%87-555555.svg"/></a>
33

44
<hr>
5-
<a href="https://github.com/manateelazycat/lsp-bridge?tab=readme-ov-file#installation"><strong>Installation</strong></a> •
6-
<a href="https://github.com/manateelazycat/lsp-bridge?tab=readme-ov-file#supported-language-servers"><strong>Support languages</strong></a> •
5+
<a href="https://github.com/manateelazycat/lsp-bridge?tab=readme-ov-file#installation"><strong>Installation</strong></a> •
6+
<a href="https://github.com/manateelazycat/lsp-bridge?tab=readme-ov-file#supported-language-servers"><strong>Support languages</strong></a> •
77
<a href="https://github.com/manateelazycat/lsp-bridge?tab=readme-ov-file#keymap"><strong>Keymaps</strong></a> •
88
<a href="https://github.com/manateelazycat/lsp-bridge?tab=readme-ov-file#lsp-server-options"><strong>Customize options</strong></a> •
9-
<a href="https://github.com/manateelazycat/lsp-bridge?tab=readme-ov-file#join-development"><strong>Join development</strong></a>
9+
<a href="https://github.com/manateelazycat/lsp-bridge?tab=readme-ov-file#join-development"><strong>Join development</strong></a>
1010
<hr>
1111

1212

@@ -32,7 +32,7 @@ Advantages of lsp-bridge:
3232
## Installation
3333

3434
1. Install Emacs 28 or higher version
35-
2. Install Python dependencies: `pip3 install epc orjson sexpdata six setuptools paramiko rapidfuzz watchdog` (orjson is optional, orjson is based on Rust, providing faster JSON parsing performance)
35+
2. Install Python dependencies: `pip3 install epc orjson sexpdata six setuptools paramiko rapidfuzz watchdog packaging` (orjson is optional, orjson is based on Rust, providing faster JSON parsing performance)
3636
3. Install Elisp dependencies: [markdown-mode](https://github.com/jrblevin/markdown-mode), [yasnippet](https://github.com/joaotavora/yasnippet)
3737

3838
4. Download this repository using git clone, and replace the load-path path in the configuration below.
@@ -268,8 +268,8 @@ lsp-bridge provides support for more than two language servers for many language
268268
- `lsp-bridge-csharp-lsp-server`: C# language server, you can choose `omnisharp-mono`, `omnisharp-dotnet` or `csharp-ls`, note that you need to give **execute permissions** to the OmniSharp file
269269
- `lsp-bridge-python-multi-lsp-server`: Python multi-language servers, you can choose `basedpyright_ruff`, `pyright_ruff`, `jedi_ruff`, `python-ms_ruff`, `pylsp_ruff`
270270
- `lsp-bridge-nix-lsp-server`: Nix language server, you can choose `rnix-lsp`, `nixd` or `nil`
271-
- `lsp-bridge-markdown-lsp-server`: Markdown language server, you can choose `vale-ls` or `marksman`
272-
- `lsp-bridge-lua-lsp-server`: Lua language server, you can choose `sumneko` or `lua-lsp`
271+
- `lsp-bridge-markdown-lsp-server`: Markdown language server, you can choose `vale-ls` or `marksman`
272+
- `lsp-bridge-lua-lsp-server`: Lua language server, you can choose `sumneko` or `lua-lsp`
273273
- `lsp-bridge-verilog-lsp-server`: Verilog language server, you can choose `verible`, or `svls`
274274
- `lsp-bridge-xml-lsp-server`: XML language server, you can choose `lemminx`, or `camells`
275275

@@ -393,7 +393,7 @@ If your language supports mixed multi-language servers, it is recommended to che
393393
| Futhark | [futhark-lsp](https://futhark-lang.org) | |
394394
| Fuzion | [fuzion-lsp-server](https://github.com/tokiwa-software/fuzion-lsp-server) | |
395395
| F# | [fsautocomplete](https://github.com/fsharp/FsAutoComplete) | |
396-
| Gleam | [gleam lsp](https://gleam.run/news/v0.21-introducing-the-gleam-language-server/) |
396+
| Gleam | [gleam lsp](https://gleam.run/news/v0.21-introducing-the-gleam-language-server/) |
397397
| GLSL | [glsl-language-server](https://github.com/svenstaro/glsl-language-server) | |
398398
| Go | [gopls](https://github.com/golang/tools/tree/master/gopls) | Make sure install [go-mode](https://github.com/dominikh/go-mode.el) and `gopls` in PATH, please do `ln -s ~/go/bin/gopls ~/.local/bin`, and do `go mod init` first |
399399
| GraphQL | [graphql-lsp](https://github.com/graphql/graphiql/tree/main/packages/graphql-language-service-cli) | |

core/tabnine.py

100644100755
Lines changed: 40 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,20 @@
22
# -*- coding: utf-8 -*-
33

44
# Copyright (C) 2022 Andy Stewart
5-
#
5+
#
66
# Author: Andy Stewart <[email protected]>
77
8-
#
8+
#
99
# This program is free software: you can redistribute it and/or modify
1010
# it under the terms of the GNU General Public License as published by
1111
# the Free Software Foundation, either version 3 of the License, or
1212
# any later version.
13-
#
13+
#
1414
# This program is distributed in the hope that it will be useful,
1515
# but WITHOUT ANY WARRANTY; without even the implied warranty of
1616
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1717
# GNU General Public License for more details.
18-
#
18+
#
1919
# You should have received a copy of the GNU General Public License
2020
# along with this program. If not, see <http://www.gnu.org/licenses/>.
2121

@@ -27,14 +27,9 @@
2727

2828
from core.utils import *
2929
from subprocess import PIPE
30-
from sys import stderr,version_info
31-
32-
if version_info[1] < 12 :
33-
from distutils.version import StrictVersion
34-
version_function = StrictVersion
35-
else:
36-
from pkg_resources import parse_version
37-
version_function = parse_version
30+
from sys import stderr
31+
from packaging.version import Version
32+
version_function = Version
3833

3934
TABNINE_PROTOCOL_VERSION = "1.0.14"
4035
TABNINE_EXECUTABLE = "TabNine.exe" if get_os_name() == "windows" else "TabNine"
@@ -45,20 +40,20 @@ class TabNine:
4540
def __init__(self):
4641
self.process = None
4742
self.path = None
48-
43+
4944
self.receiver = None
5045
self.sender = None
5146
self.dispatcher = None
52-
47+
5348
self.try_completion_timer = None
54-
49+
5550
[self.tabnine_binaries_folder] = get_emacs_vars(["tabnine-bridge-binaries-folder"])
56-
51+
5752
def complete(self, before, after, filename, region_includes_beginning, region_includes_end, max_num_results):
5853
if self.is_tabnine_exist() and isinstance(filename, str):
5954
if self.try_completion_timer is not None and self.try_completion_timer.is_alive():
6055
self.try_completion_timer.cancel()
61-
56+
6257
self.message = {
6358
"version": TABNINE_PROTOCOL_VERSION,
6459
"request": {
@@ -75,10 +70,10 @@ def complete(self, before, after, filename, region_includes_beginning, region_in
7570

7671
self.try_completion_timer = threading.Timer(0.5, self.do_complete)
7772
self.try_completion_timer.start()
78-
73+
7974
def do_complete(self):
8075
self.sender.send_request(self.message) # type: ignore
81-
76+
8277
def get_tabnine_path(self):
8378
if os.path.exists(self.tabnine_binaries_folder):
8479
try:
@@ -96,46 +91,46 @@ def get_tabnine_path(self):
9691
return None
9792

9893
return None
99-
94+
10095
def is_tabnine_exist(self):
10196
if self.path is None:
10297
self.path = self.get_tabnine_path()
103-
98+
10499
if isinstance(self.path, str) and os.path.exists(self.path):
105100
if self.process is None:
106101
self.process = subprocess.Popen(
107-
[self.path, "--client", "emacs"],
108-
bufsize=DEFAULT_BUFFER_SIZE,
109-
stdin=PIPE,
110-
stdout=PIPE,
102+
[self.path, "--client", "emacs"],
103+
bufsize=DEFAULT_BUFFER_SIZE,
104+
stdin=PIPE,
105+
stdout=PIPE,
111106
stderr=stderr)
112-
107+
113108
self.receiver = TabNineReceiver(self.process)
114109
self.receiver.start()
115-
110+
116111
self.sender = TabNineSender(self.process)
117112
self.sender.start()
118-
113+
119114
self.dispatcher = threading.Thread(target=self.message_dispatcher)
120115
self.dispatcher.start()
121-
116+
122117
log_time("Start TabNine server ({})".format(self.path))
123-
118+
124119
return self.process is not None
125120
else:
126121
return False
127-
122+
128123
def message_dispatcher(self):
129124
try:
130125
while True:
131126
message = self.receiver.get_message() # type: ignore
132-
127+
133128
completion_candidates = []
134-
129+
135130
if "results" in message:
136131
for result in message["results"]:
137132
label = result["new_prefix"]
138-
133+
139134
candidate = {
140135
"key": label,
141136
"icon": "tabnine",
@@ -146,37 +141,37 @@ def message_dispatcher(self):
146141
"new_suffix": result["new_suffix"],
147142
"old_suffix": result["old_suffix"]
148143
}
149-
144+
150145
completion_candidates.append(candidate)
151-
146+
152147
completion_candidates = sorted(completion_candidates, key=lambda candidate: candidate["annotation"], reverse=True)
153-
148+
154149
eval_in_emacs("lsp-bridge-search-backend--record-items", "tabnine", completion_candidates)
155150
except:
156151
logger.error(traceback.format_exc())
157-
152+
158153
class TabNineSender(MessageSender):
159-
154+
160155
def send_message(self, message):
161156
data = json.dumps(message) + "\n"
162-
157+
163158
self.process.stdin.write(data.encode("utf-8")) # type: ignore
164159
self.process.stdin.flush() # type: ignore
165-
160+
166161
log_time("Send TabNine complete request for project {}".format(message["request"]["Autocomplete"]["filename"]))
167-
162+
168163
logger.debug(json.dumps(message, indent=3))
169-
164+
170165
def run(self):
171166
try:
172167
while self.process.poll() is None:
173168
message = self.queue.get()
174169
self.send_message(message)
175170
except:
176171
logger.error(traceback.format_exc())
177-
172+
178173
class TabNineReceiver(MessageReceiver):
179-
174+
180175
def run(self):
181176
try:
182177
while self.process.poll() is None:

0 commit comments

Comments
 (0)