修复导入错误
This commit is contained in:
104
CodeSnippetDaemon/pom.xml
Normal file
104
CodeSnippetDaemon/pom.xml
Normal file
@@ -0,0 +1,104 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>work.slhaf</groupId>
|
||||
<artifactId>CodeSnippetDaemon</artifactId>
|
||||
<version>1.0</version>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>25</maven.compiler.source>
|
||||
<maven.compiler.target>25</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>1.18.40</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.commonmark</groupId>
|
||||
<artifactId>commonmark</artifactId>
|
||||
<version>0.26.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
<version>2.0.17</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ch.qos.logback</groupId>
|
||||
<artifactId>logback-classic</artifactId>
|
||||
<version>1.5.18</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.xerial</groupId>
|
||||
<artifactId>sqlite-jdbc</artifactId>
|
||||
<version>3.50.3.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cn.hutool</groupId>
|
||||
<artifactId>hutool-all</artifactId>
|
||||
<version>5.8.36</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<version>3.2.0</version>
|
||||
<configuration>
|
||||
<archive>
|
||||
<manifest>
|
||||
<mainClass>work.slhaf.snippet.App</mainClass>
|
||||
</manifest>
|
||||
</archive>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<!-- 添加 maven-shade-plugin 插件 -->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
<version>3.4.1</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>shade</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<transformers>
|
||||
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
|
||||
<mainClass>work.slhaf.snippet.App</mainClass>
|
||||
</transformer>
|
||||
</transformers>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.11.0</version>
|
||||
<configuration>
|
||||
<source>${maven.compiler.source}</source>
|
||||
<target>${maven.compiler.target}</target>
|
||||
<annotationProcessorPaths>
|
||||
<path>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>1.18.40</version>
|
||||
</path>
|
||||
</annotationProcessorPaths>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
||||
@@ -191,9 +191,7 @@ def _create_tmp(content: str) -> str:
|
||||
|
||||
def _open_with_nvim(file_path: str) -> None:
|
||||
# 获取终端环境变量,默认为xterm
|
||||
term = os.environ.get('TERMINAL', '')
|
||||
if not term:
|
||||
term = 'xterm'
|
||||
term = os.getenv('TERMINAL', 'xterm')
|
||||
|
||||
# 获取终端名称
|
||||
name = os.path.basename(term)
|
||||
|
||||
@@ -8,16 +8,16 @@ class DeleteMenu:
|
||||
self._r = r
|
||||
|
||||
def run(self):
|
||||
try:
|
||||
result = run_search("")
|
||||
except Exception as e:
|
||||
print(f"Error: {e}")
|
||||
self._r.error(str(e))
|
||||
return
|
||||
if result.status != "SUCCESS":
|
||||
self._r.error(result.data)
|
||||
return
|
||||
while True:
|
||||
try:
|
||||
result = run_search("")
|
||||
except Exception as e:
|
||||
print(f"Error: {e}")
|
||||
self._r.error(str(e))
|
||||
return
|
||||
if result.status != "SUCCESS":
|
||||
self._r.error(result.data)
|
||||
return
|
||||
if len(result.data) == 0:
|
||||
self._r.select("删除", ["未找到Snippet记录"])
|
||||
break
|
||||
|
||||
55
README.md
55
README.md
@@ -11,7 +11,7 @@
|
||||
- rofi
|
||||
- nc
|
||||
- nvim
|
||||
- 推荐装有 Markdown 相关插件
|
||||
- 推荐装有 Markdown 相关插件
|
||||
- python3
|
||||
- python-rofi
|
||||
|
||||
@@ -32,35 +32,36 @@
|
||||
### 安装
|
||||
1. 下载RELEASE
|
||||
2. 下载所需库
|
||||
- `pip install python-rofi`
|
||||
2. 解压,目录结构如下:
|
||||
> 
|
||||
- `pip install python-rofi`
|
||||
3. 安装Java 25(守护进程使用Java 25, 如有需要, 可以自行clone并重新打包)
|
||||
4. 解压,目录结构如下:
|
||||
> 
|
||||
|
||||
### 使用
|
||||
1. 设置环境变量
|
||||
- CODE_SNIPPET_CONF
|
||||
- 配置文件目录
|
||||
- CODE_SNIPPET_DIR
|
||||
- 文件存储目录
|
||||
- CODE_SNIPPET_PORT
|
||||
- TCP服务器端口
|
||||
- CODE_SNIPPET_API_KEY
|
||||
- AI服务商提供的的 api_key
|
||||
- CODE_SNIPPET_BASE_URL
|
||||
- AI服务商提供的 base_url
|
||||
- CODE_SNIPPET_MODEL
|
||||
- 所用模型名称
|
||||
- CODE_SNIPPET_EDITOR (可选,若未指定则使用nvim)
|
||||
- 所用的编辑器,默认使用nvim
|
||||
- Typora 好像也可以编辑,只是会额外打开一个终端窗口
|
||||
- 其他编辑器未测试
|
||||
- CODE_SNIPPET_ROFI (可选,若未指定则使用默认 rofi)
|
||||
- 指定的 rofi 脚本,可以添加参数,比如: `rofi -theme ~/.config/rofi/launchers/type-4/style-1.rasi`
|
||||
- CODE_SNIPPET_CONF
|
||||
- 配置文件目录
|
||||
- CODE_SNIPPET_DIR
|
||||
- 文件存储目录
|
||||
- CODE_SNIPPET_PORT
|
||||
- TCP服务器端口
|
||||
- CODE_SNIPPET_API_KEY
|
||||
- AI服务商提供的的 api_key
|
||||
- CODE_SNIPPET_BASE_URL
|
||||
- AI服务商提供的 base_url
|
||||
- CODE_SNIPPET_MODEL
|
||||
- 所用模型名称
|
||||
- CODE_SNIPPET_EDITOR (可选,若未指定则使用nvim)
|
||||
- 所用的编辑器,默认使用nvim
|
||||
- Typora 好像也可以编辑,只是会额外打开一个终端窗口
|
||||
- 其他编辑器未测试
|
||||
- CODE_SNIPPET_ROFI (可选,若未指定则使用默认 rofi)
|
||||
- 指定的 rofi 脚本,可以添加参数,比如: `rofi -theme ~/.config/rofi/launchers/type-4/style-1.rasi`
|
||||
|
||||
2. 启动 Java 守护进程
|
||||
- `java -jar daemon/CodeSnippetDaemon-1.0.jar`
|
||||
- `java -jar daemon/CodeSnippetDaemon-1.0.jar`
|
||||
3. 启动 rofi 脚本
|
||||
- `python rofi/launcher.py`
|
||||
- `python rofi/launcher.py`
|
||||
|
||||
> 已将打开的编辑器窗口的class属性设置为`code_snippet_editor`,如果使用的是 Hyprland 等 wm,可以据此对打开的编辑器窗口设置所需规则
|
||||
>
|
||||
@@ -70,9 +71,9 @@
|
||||
## 说明
|
||||
### rofi 菜单说明
|
||||
- 搜索
|
||||
- 编辑
|
||||
- 编辑并复制
|
||||
- 删除
|
||||
- 编辑
|
||||
- 编辑并复制
|
||||
- 删除
|
||||
- 添加
|
||||
- 编辑
|
||||
- 删除
|
||||
|
||||
Reference in New Issue
Block a user