Skip to content

Commit cfa6a9d

Browse files
fix statusbar when showing the model in the Copilot
1 parent 5d3240d commit cfa6a9d

File tree

4 files changed

+38
-23
lines changed

4 files changed

+38
-23
lines changed

lua/pieces/copilot/init.lua

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,15 @@ end
7373

7474
local function update_status_bar()
7575
if split ~= nil and type(split.winid) == "number" and vim.api.nvim_win_is_valid(split.winid) == true then
76-
vim.api.nvim_win_set_option(split.winid, 'statusline', 'Pieces Model: '.. vim.fn.PiecesGetModel())
76+
local success, model_name = pcall(vim.fn.PiecesGetModel)
77+
if success and model_name then
78+
local status_success, _ = pcall(vim.api.nvim_win_set_option, split.winid, 'statusline', 'Pieces Model: ' .. model_name)
79+
if not status_success then
80+
print("Failed to set statusline option")
81+
end
82+
end
83+
else
84+
print("Failed to get model name")
7785
end
7886
end
7987

plugin/pieces.lua

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
require("pieces.copilot")
2-
require("pieces.assets")
3-
require("pieces.copilot.slash_commands")
4-
require("pieces.onboarding")
5-
require("pieces.feedback")
6-
require("pieces.tutor")
1+
require("pieces.copilot")
2+
require("pieces.assets")
3+
require("pieces.copilot.slash_commands")
4+
require("pieces.onboarding")
5+
require("pieces.feedback")
6+
require("pieces.tutor")

rplugin/python3/pieces_python/__init__.py

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,31 @@
22
import pynvim
33
import pip
44

5+
56
def update_sdks():
6-
pip.main(["install","pieces_os_client","--upgrade"])
7+
pip.main(["install", "pieces_os_client", "--upgrade"])
8+
79

8-
MIN_SDKS_VERSION = "4.4.0"
10+
MIN_SDKS_VERSION = "4.4.1"
911
try:
10-
from pieces_os_client import __version__ as pieces_os_client_version
12+
from pieces_os_client import __version__ as pieces_os_client_version
13+
14+
try: # If there is any issue in the version checker then it is outdated
15+
from pieces_os_client.wrapper.version_compatibility import VersionChecker
1116

12-
try: # If there is any issue in the version checker then it is outdated
13-
from pieces_os_client.wrapper.version_compatibility import VersionChecker
14-
VersionChecker.compare("1.0.0","1.0.0") # Check also that the compare is working too
15-
except (AttributeError, ModuleNotFoundError):
16-
update_sdks()
17-
raise ModuleNotFoundError
17+
VersionChecker.compare(
18+
"1.0.0", "1.0.0"
19+
) # Check also that the compare is working too
20+
except (AttributeError, ModuleNotFoundError):
21+
update_sdks()
22+
raise ModuleNotFoundError
1823

19-
if VersionChecker.compare(pieces_os_client_version,MIN_SDKS_VERSION) < 0: # We need to be above 4.0.0
20-
update_sdks()
21-
raise ModuleNotFoundError
22-
from .main import Pieces
24+
if (
25+
VersionChecker.compare(pieces_os_client_version, MIN_SDKS_VERSION) < 0
26+
): # We need to be above 4.0.0
27+
update_sdks()
28+
raise ModuleNotFoundError
29+
from .main import Pieces
2330
except ModuleNotFoundError:
24-
pip.main(["install","pieces_os_client"])
25-
from .main import Pieces
31+
pip.main(["install", "pieces_os_client"])
32+
from .main import Pieces
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "1.5.1"
1+
__version__ = "1.5.2"

0 commit comments

Comments
 (0)