Geany

Geany 用户指引

Geany 是最快的 X11 编辑器,如果管理员需要以 UI 方式编辑服务器文件,Geany 是第一选择。

远程运行服务器端 Geany 时,客户端需要安装 X Window 服务。Windows 用户考虑安装 VcXsrv,macOS 用户可以安装 XQuartz,都能完美远程运行 Geany。

安装

Geany 依赖 yaru-theme-icon 包,需要同时安装避免图标错误。

sudo apt install yaru-theme-icon
sudo apt-get install -y mesa-utils libgl1-mesa-glx

常用配置

通过菜单栏 Tools > Configuration Files > filetypes.common 编辑配置文件,保存后配置即刻生效。

[styling]

以下配置项目需要在 [styling] 段落下,末尾分号代表最末配置值为空:

项目 说明
line_height=5;5; 行高前后添加 50% 空间
current_line=default 取消当前行高亮

添加扩展高亮配色

Geany 提供了额外的语法高亮配色,需要访问 geany-themes 单独安装。

wget https://codeload.github.com/geany/geany-themes/zip/master
unzip master
cd master
./install.sh

自定义语言高亮

Geany 支持为新的语法增加自定义的高亮规则,但是自定义的语言必须通过 lexer_filetype 绑定预定义的某种语言加亮规则,否则无法生效。

自定义的语言需要在 filetype_extensions.conf 文件中绑定扩展名及文件名(如果有),还可以指定一个 geany 预定义的语言种类,用于收纳自定义的语言到相应到菜单下。然后按照 filetypes.<语言名称>.conf 的命名规则,提供具体的语法规则。

Dockerfile

配置完后的效果:

vim ~/.config/geany/filetype_extensions.conf


[Extensions]
# <自定义的语言名称>=<文件名或*.扩展名>;<文件名或*.扩展名>;
Dockerfile=Dockerfile;*.dockerfile;

# 定义新添加的语言种类
[Groups]
Programming=
Script=
Markup=
Misc=Dockerfile;
None=
# For complete documentation of this file, please see Geany's main documentation
[styling=Sh]
operator=comment
commentline=number
number=0xff0000
operator=type

[keywords]
primary=FROM MAINTAINER RUN COPY ENTRYPOINT WORKDIR EXPOSE ENV VOLUME CMD EXEC

[settings]
# default extension used when saving files
extension=dockerfile
lexer_filetype=Sh

# MIME type
mime_type=text/Dockerfile

# the following characters are these which a "word" can contains, see documentation
wordchars=_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789

# these comments are used for PHP, the comments used in HTML are in filetypes.xml
# single comments, like # in this file
comment_single=#

# set to false if a comment character/string should start at column 0 of a line, true uses any
# indentation of the line, e.g. setting to true causes the following on pressing CTRL+d
	#command_example();
# setting to false would generate this
#	command_example();
# This setting works only for single line comments
comment_use_indent=false

# context action command (please see Geany's main documentation for details)
context_action_cmd=

# if this setting is set to true, a new line after a line ending with an
# unclosed tag will be automatically indented
xml_indent_tags=true

[indentation]
width=4
# 0 is spaces, 1 is tabs, 2 is tab & spaces
type=0

[build_settings]
# %f will be replaced by the complete filename
# %e will be replaced by the filename without extension
# (use only one of it at one time)
# use a syntax checker and ignore the formatted output
compiler=docker build -f "%f" -t "%e" .

用 Geany 开发 docker 时,可以通过 Build > Set Build Commands 添加以下命令以提高开发效率:

标签 命令
status docker ps -a && docker images
clean docker stop run_%e && docker rm -v run_%e  && docker rmi %e
Start docker run -d --restart=always --name run_%e %e
Restart docker stop run_%e; docker start run_%e
Interact docker exec -it run_%e bash

参考 

https://github.com/codebrainz/geany-themes

Author: njun
njun's picture
Updated: 2022/05/29