Skip to content

Commit 180c629

Browse files
authored
Merge pull request #2312 from h-east/update-ft_hare
Update ft_hare.{txt,jax}
2 parents fba2ec5 + e49bc4e commit 180c629

File tree

2 files changed

+215
-97
lines changed

2 files changed

+215
-97
lines changed

doc/ft_hare.jax

Lines changed: 107 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,72 +1,133 @@
11
*ft_hare.txt* Hare プログラミング言語のサポート
22

33
==============================================================================
4-
☆内容 *hare*
4+
☆内容 *hare* *hare.vim*
55

6-
1. 前書き |hare-intro|
7-
2. ファイルタイププラグイン |hare-plugin|
8-
3. 設定 |hare-settings|
6+
1. 前書き |ft-hare-intro|
7+
2. ファイルタイププラグイン |ft-hare-plugin|
8+
3. Haredoc ファイルタイプ |ft-haredoc-plugin|
9+
4. インデント設定 |ft-hare-indent|
10+
5. コンパイラサポート |compiler-hare|
911

1012
==============================================================================
11-
☆前書き *hare-intro*
13+
☆前書き *ft-hare-intro*
1214

13-
このプラグインは、Hare プログラミング言語に構文のハイライト、インデント、その
14-
他の機能を提供する。Hare モジュール内の README ファイルのサポートも提供されて
15-
いるが、これは |g:filetype_haredoc| を設定して有効にする必要がある。
15+
このプラグインは、Hare プログラミング言語の構文のハイライト、インデント、およ
16+
びその他のサポート機能を提供する。
1617

17-
==============================================================================
18-
☆ファイルタイププラグイン *hare-plugin*
1918

20-
このプラグインは、HAREPATH 環境変数の内容を含むように 'path' の値を自動的に設
21-
定し、|gf| などのコマンドで標準ライブラリまたはサードパーティのモジュールを直
22-
接開くことができるようにする。HAREPATH が設定されていない場合、デフォルトで、
23-
ほとんどの Unix 系ファイルシステムの推奨パス、つまり /usr/src/hare/stdlib およ
24-
び /usr/src/hare/third-party が使用される。
19+
☆ファイルタイププラグイン *ft-hare-plugin*
2520

26-
==============================================================================
27-
☆設定 *hare-settings*
21+
このプラグインには、動作を微調整するために |vimrc| 内で定義できるいくつかの異
22+
なる変数がある。
2823

29-
このプラグインは、vimrc で定義して動作を設定できる少数の変数を提供する。
24+
さらに、`{ }` ブロックの折り畳みもサポートされている。折り畳みを有効にするに
25+
は、|after-directory| 内のファイル (例えば、~/.vim/after/ftplugin/hare.vim) に
26+
以下のコードを追加する: >
3027
31-
*g:filetype_haredoc*
32-
このプラグインは、Hare モジュールを自動的に検出し、README ファイルに "haredoc"
33-
ファイルタイプを設定できる。ヒューリスティックとして使用される再帰的ディレクト
34-
リ検索はパフォーマンスに若干の影響を与えるため、この機能はデフォルトで無効に
35-
なっており、特別にオプトインする必要がある: >
36-
let g:filetype_haredoc = 1
37-
<
38-
検索動作を調整する方法については、|g:haredoc_search_depth| を参照。
28+
setlocal foldmethod=syntax
3929
40-
*g:hare_recommended_style*
41-
公式の Hare スタイルガイドに従って、次のオプションがデフォルトで設定される: >
30+
ブロックベースの折り畳みでは小さな折り畳みが多数作成される傾向があるため、
31+
'foldminlines''foldnestmax' などの関連するオプションをいくつか設定すること
32+
を検討すること。
33+
34+
*g:hare_recommended_style*
35+
Hare の公式スタイルガイドに従って、次のオプションがデフォルトで設定されている:
36+
>
4237
setlocal noexpandtab
4338
setlocal shiftwidth=0
4439
setlocal softtabstop=0
4540
setlocal tabstop=8
4641
setlocal textwidth=80
47-
<
48-
この動作を無効にするには: >
42+
43+
この動作を無効にするには、|vimrc| に次の行を追加する: >
44+
4945
let g:hare_recommended_style = 0
5046
<
51-
*g:hare_space_error*
52-
デフォルトでは、末尾の空白文字とスペース文字が前にあるタブはエラーとしてハイラ
53-
イトされる。挿入モードでは、これは自動的にオフになる。このハイライトを完全に無
54-
効にするには: >
55-
let g:hare_space_error = 0
56-
<
57-
*g:haredoc_search_depth*
58-
デフォルトでは、|g:filetype_haredoc| が有効な場合、カレントディレクトリとその
59-
直下のサブディレクトリのみ Hare ファイルが検索される。最大検索深度は以下のよう
60-
に調整する: >
61-
let g:haredoc_search_depth = 2
47+
*g:hare_symbol_operators*
48+
デフォルトでは、記号演算子は特別な構文ハイライト表示を受けない (`!``?``::`
49+
のみ例外)。他のほとんどの演算子の構文ハイライトを有効にするには、|vimrc| に以
50+
下の行を追加する: >
51+
52+
let g:hare_symbol_operators = 1
6253
<
54+
*g:hare_space_error*
55+
デフォルトでは、末尾の空白文字とスペースに続く <Tab> 文字はエラーとしてハイラ
56+
イト表示される。挿入モードでは、このハイライト表示は自動的に無効になる。このハ
57+
イライト表示を完全に無効にするには、|vimrc| に以下の行を追加する: >
58+
59+
let g:hare_space_error = 0
60+
61+
62+
☆Haredoc ファイルタイプ *ft-haredoc-plugin*
63+
64+
このプラグインは、ディレクトリの再帰検索を使用して、Hare モジュール内の README
65+
ファイルを自動検出し、"haredoc" ファイルタイプを付与する。これは非常に一般的な
66+
ファイル名であるため、このプラグインはデフォルトで同じディレクトリ内の Hare
67+
ソースファイルのみを検索する。
68+
69+
*g:filetype_haredoc*
70+
|g:filetype_haredoc| 変数を使用すると、この検索の深さを微調整したり、Hare ド
71+
キュメントファイルの検出を完全にバイパスしたりできる:
72+
6373
値 効果~
64-
0 カレントディレクトリのみ検索。
65-
1 カレントディレクトリと直下のサブディレクトリを検索。
66-
2 カレントディレクトリと 2 階層のサブディレクトリを検索。
74+
0 自動検出なし
75+
1 カレントディレクトリのみを検索 (これがデフォルト)
76+
2 サブディレクトリの 1 階層を検索
77+
3 サブディレクトリの 2 階層を検索
78+
79+
検索の深さは任意の正の整数にすることができるが、ほとんどの場合、 `2` より大き
80+
い値では目に見える利点が得られない可能性がある。
81+
82+
83+
☆インデント設定 *ft-hare-indent*
84+
85+
このプラグインの他のほとんどの設定とは異なり、インデント設定はバッファごとに設
86+
定でき、既存のグローバル設定を上書きできる。これを行うには、変数の先頭に |g:|
87+
ではなく |b:| を付ける。
88+
89+
*g:hare_indent_match_switch*
90+
デフォルトでは、"match" および "switch" 条件の継続行は 1 レベルだけインデント
91+
される: >hare
92+
93+
const file = match (os::create(path, 0o644,
94+
flag::WRONLY | flag::TRUNC)) {
95+
case let file: io::file =>
96+
yield file;
97+
// ...
98+
99+
代わりに 2 レベルインデントして、"if" 条件と "for" 条件に近づけたい場合
100+
は、|vimrc| に次の行を追加する: >
101+
102+
let g:hare_indent_match_switch = 2
103+
<
104+
*g:hare_indent_case*
105+
デフォルトでは、"match" 式と "switch" 式の場合の継続行は 2 レベルインデントさ
106+
れ、case 本体と視覚的に区別される: >hare
107+
108+
case ltok::I8, ltok::I16, ltok::I32,
109+
ltok::I64, ltok::INT =>
110+
// ...
111+
112+
インデント量を変更したい場合は、|g:hare_indent_case| を使って調整できる。有効
113+
な値は `0``1``2` である。
114+
115+
116+
☆コンパイラサポート *compiler-hare*
117+
118+
このプラグインは、カレントディレクトリに Makefile が存在することを検出した場
119+
合、ビルドシステムに `make` を使用することを想定し、'makeprg' はそのまま残す。
120+
それ以外の場合は、`hare build` が使用される。
121+
122+
*g:hare_makeprg_params*
123+
`hare build` を使用する場合、|g:hare_makeprg_params| 変数を使って 'makeprg'
124+
追加のコンパイラオプションを指定できる。また、バッファごとに設定することも可能
125+
である (|g:| の代わりに |b:| を使用)。その場合、既存のグローバル設定は上書きさ
126+
れる。例: >
127+
128+
let b:hare_makeprg_params = '-lc -t o'
67129
68-
最大検索深度は任意の整数に設定できるが、2 より大きい値を使用することは推奨され
69-
ず、ほとんどの状況で具体的なメリットは得られないだろう。
130+
グローバルのデフォルトは "-q" で、ビルド中に標準出力への書き込みを抑制する。
70131

71132
==============================================================================
72133
vim:tw=78:ts=8:noet:ft=help:norl:

en/ft_hare.txt

Lines changed: 108 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,77 +1,134 @@
11
*ft_hare.txt* Support for the Hare programming language
22

33
==============================================================================
4-
CONTENTS *hare*
4+
CONTENTS *hare* *hare.vim*
55

6-
1. Introduction |hare-intro|
7-
2. Filetype plugin |hare-plugin|
8-
3. Settings |hare-settings|
6+
1. Introduction |ft-hare-intro|
7+
2. Filetype plugin |ft-hare-plugin|
8+
3. Haredoc filetype |ft-haredoc-plugin|
9+
4. Indentation settings |ft-hare-indent|
10+
5. Compiler support |compiler-hare|
911

1012
==============================================================================
11-
INTRODUCTION *hare-intro*
13+
INTRODUCTION *ft-hare-intro*
1214

13-
This plugin provides syntax highlighting, indentation, and other functionality
14-
for the Hare programming language. Support is also provided for README files
15-
inside Hare modules, but this must be enabled by setting |g:filetype_haredoc|.
15+
This plugin provides syntax highlighting, indentation, and other supporting
16+
functionality for the Hare programming language.
1617

17-
==============================================================================
18-
FILETYPE PLUGIN *hare-plugin*
1918

20-
This plugin automatically sets the value of 'path' to include the contents of
21-
the HAREPATH environment variable, allowing commands such as |gf| to directly
22-
open standard library or third-party modules. If HAREPATH is not set, it
23-
defaults to the recommended paths for most Unix-like filesystems, namely
24-
/usr/src/hare/stdlib and /usr/src/hare/third-party.
19+
FILETYPE PLUGIN *ft-hare-plugin*
2520

26-
==============================================================================
27-
SETTINGS *hare-settings*
21+
This plugin has a few different variables that can be defined inside your
22+
|vimrc| to tweak its behavior.
2823

29-
This plugin provides a small number of variables that you can define in your
30-
vimrc to configure its behavior.
24+
Additionally, support is provided for folding `{ }` blocks. To enable folding,
25+
add the following to a file inside your |after-directory| (e.g.
26+
~/.vim/after/ftplugin/hare.vim): >
3127
32-
*g:filetype_haredoc*
33-
This plugin is able to automatically detect Hare modules and set the "haredoc"
34-
filetype for any README files. As the recursive directory search used as a
35-
heuristic has a minor performance impact, this feature is disabled by default
36-
and must be specifically opted into: >
37-
let g:filetype_haredoc = 1
38-
<
39-
See |g:haredoc_search_depth| for ways to tweak the searching behavior.
28+
setlocal foldmethod=syntax
4029
41-
*g:hare_recommended_style*
42-
The following options are set by default, in accordance with the official Hare
30+
Because block-based folding tends to create many small folds, consider setting
31+
a few related options, such as 'foldminlines' and 'foldnestmax'.
32+
33+
*g:hare_recommended_style*
34+
The following options are set by default, in accordance with Hare's official
4335
style guide: >
36+
4437
setlocal noexpandtab
4538
setlocal shiftwidth=0
4639
setlocal softtabstop=0
4740
setlocal tabstop=8
4841
setlocal textwidth=80
49-
<
50-
To disable this behavior: >
42+
43+
To disable this behavior, add the following to your |vimrc|: >
44+
5145
let g:hare_recommended_style = 0
5246
<
53-
*g:hare_space_error*
54-
By default, trailing whitespace and tabs preceded by space characters are
55-
highlighted as errors. This is automatically turned off when in insert mode.
56-
To disable this highlighting completely: >
57-
let g:hare_space_error = 0
58-
<
59-
*g:haredoc_search_depth*
60-
By default, when |g:filetype_haredoc| is enabled, only the current directory
61-
and its immediate subdirectories are searched for Hare files. The maximum
62-
search depth may be adjusted with: >
63-
let g:haredoc_search_depth = 2
47+
*g:hare_symbol_operators*
48+
By default, symbolic operators do not receive any special highlighting (with
49+
`!`, `?`, and `::` being the only exceptions). To enable syntax highlighting
50+
for most other operators, add the following to your |vimrc|: >
51+
52+
let g:hare_symbol_operators = 1
6453
<
54+
*g:hare_space_error*
55+
By default, trailing whitespace and spaces followed by <Tab> characters will
56+
be highlighted as errors. This is automatically disabled in Insert mode. To
57+
turn off this highlighting completely, add the following to your |vimrc|: >
58+
59+
let g:hare_space_error = 0
60+
61+
62+
HAREDOC FILETYPE *ft-haredoc-plugin*
63+
64+
This plugin will automatically detect README files inside Hare modules, using
65+
a recursive directory search, and give them the "haredoc" filetype. Because
66+
this is such a common filename, this plugin only searches for Hare source
67+
files within the same directory by default.
68+
69+
*g:filetype_haredoc*
70+
The |g:filetype_haredoc| variable can be used to tweak the depth of this
71+
search, or bypass the detection of Hare documentation files altogether:
72+
6573
Value Effect~
66-
0 Only search the current directory.
67-
1 Search the current directory and immediate
68-
subdirectories.
69-
2 Search the current directory and two levels of
70-
subdirectories.
71-
72-
The maximum search depth can be set to any integer, but using values higher
73-
than 2 is not recommended, and will likely provide no tangible benefit in most
74-
situations.
74+
0 No automatic detection
75+
1 Search current directory only (this is the default)
76+
2 Search one level of subdirectories
77+
3 Search two levels of subdirectories
78+
79+
The search depth may be any positive integer, but values higher than `2` are
80+
unlikely to provide a tangible benefit in most situations.
81+
82+
83+
INDENTATION SETTINGS *ft-hare-indent*
84+
85+
Unlike most other settings for this plugin, the indentation settings may also
86+
be set per-buffer, overriding any global configuration that exists. To do
87+
this, simply prefix the variable with |b:| instead of |g:|.
88+
89+
*g:hare_indent_match_switch*
90+
By default, continuation lines for "match" and "switch" conditions are
91+
indented only one level: >hare
92+
93+
const file = match (os::create(path, 0o644,
94+
flag::WRONLY | flag::TRUNC)) {
95+
case let file: io::file =>
96+
yield file;
97+
// ...
98+
99+
If you instead prefer indenting them two levels, to more closely resemble "if"
100+
and "for" conditions, add the following line to your |vimrc|: >
101+
102+
let g:hare_indent_match_switch = 2
103+
<
104+
*g:hare_indent_case*
105+
By default, continuation lines for cases in "match" and "switch" expressions
106+
are indented two levels, to visually distinguish them from the body of the
107+
case: >hare
108+
109+
case ltok::I8, ltok::I16, ltok::I32,
110+
ltok::I64, ltok::INT =>
111+
// ...
112+
113+
If you prefer a different amount of indentation, you can adjust it using
114+
|g:hare_indent_case|. Valid values include `0`, `1`, and `2`.
115+
116+
117+
COMPILER SUPPORT *compiler-hare*
118+
119+
If this plugin detects a Makefile in the current directory, it will assume you
120+
wish to use `make` for your build system, and will leave 'makeprg' untouched.
121+
Otherwise, `hare build` will be used.
122+
123+
*g:hare_makeprg_params*
124+
When `hare build` is used, additional compiler options may be appended to
125+
'makeprg' with the |g:hare_makeprg_params| variable. It may also be set on a
126+
per-buffer basis (using |b:| instead of |g:|), overriding any global
127+
configuration that exists. For example: >
128+
129+
let b:hare_makeprg_params = '-lc -t o'
130+
131+
The global default is "-q", to suppress writing to stdout while building.
75132

76133
==============================================================================
77134
vim:tw=78:ts=8:noet:ft=help:norl:

0 commit comments

Comments
 (0)