|
1 | 1 | *ft_hare.txt* Support for the Hare programming language
|
2 | 2 |
|
3 | 3 | ==============================================================================
|
4 |
| -CONTENTS *hare* |
| 4 | +CONTENTS *hare* *hare.vim* |
5 | 5 |
|
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| |
9 | 11 |
|
10 | 12 | ==============================================================================
|
11 |
| -INTRODUCTION *hare-intro* |
| 13 | +INTRODUCTION *ft-hare-intro* |
12 | 14 |
|
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. |
16 | 17 |
|
17 |
| -============================================================================== |
18 |
| -FILETYPE PLUGIN *hare-plugin* |
19 | 18 |
|
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* |
25 | 20 |
|
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. |
28 | 23 |
|
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): > |
31 | 27 |
|
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 |
40 | 29 |
|
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 |
43 | 35 | style guide: >
|
| 36 | +
|
44 | 37 | setlocal noexpandtab
|
45 | 38 | setlocal shiftwidth=0
|
46 | 39 | setlocal softtabstop=0
|
47 | 40 | setlocal tabstop=8
|
48 | 41 | setlocal textwidth=80
|
49 |
| -< |
50 |
| -To disable this behavior: > |
| 42 | +
|
| 43 | +To disable this behavior, add the following to your |vimrc|: > |
| 44 | +
|
51 | 45 | let g:hare_recommended_style = 0
|
52 | 46 | <
|
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 |
64 | 53 | <
|
| 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 | + |
65 | 73 | 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. |
75 | 132 |
|
76 | 133 | ==============================================================================
|
77 | 134 | vim:tw=78:ts=8:noet:ft=help:norl:
|
0 commit comments