diff --git a/doc/syntax.jax b/doc/syntax.jax index 84e6914db..3c78ddfc6 100644 --- a/doc/syntax.jax +++ b/doc/syntax.jax @@ -1,4 +1,4 @@ -*syntax.txt* For Vim バージョン 8.2. Last change: 2021 Aug 16 +*syntax.txt* For Vim バージョン 8.2. Last change: 2021 Nov 20 VIMリファレンスマニュアル by Bram Moolenaar @@ -775,7 +775,7 @@ g:html_font を使って1つないしは複数のフォントを変換された 5. 構文ファイルの覚書 *:syn-file-remarks* *b:current_syntax-variable* -Vimはロードした構文の名前を変数 "b:current_syntax" に記憶している。ある構文が +Vimは読み込んだ構文の名前を変数 "b:current_syntax" に記憶している。ある構文が 有効な場合だけある設定を行うにはこの変数が利用できる。例: > :au BufReadPost * if b:current_syntax == "csh" :au BufReadPost * do-some-things @@ -1056,32 +1056,45 @@ ChangeLogでは行頭のスペースのハイライトできる。これをオ CLOJURE *ft-clojure-syntax* -デフォルト構文グループは、変数 *g:clojure_syntax_keywords* や -*b:clojure_syntax_keywords* を用いて追加できる。値には構文グループの名前をキー -とし、値にカスタム識別子の|List|を持つ|Dictionary|を指定する: + *g:clojure_syntax_keywords* + +"clojure.core" 内の公開変数のシンタックスハイライトはデフォルトで提供されるが、 +|g:clojure_syntax_keywords| 変数にシンボルを追加することによって、追加のシンボ +ルをハイライトすることができる。値は、それぞれが識別子の |List| を含む構文グ +ループ名の |Dictionary| である必要がある。 > let g:clojure_syntax_keywords = { - \ 'clojureMacro': ["defproject", "defcustom"], - \ 'clojureFunc': ["string/join", "string/replace"] + \ 'clojureMacro': ["defproject", "defcustom"], + \ 'clojureFunc': ["string/join", "string/replace"] \ } < 有効な構文グループについては、Clojure 構文スクリプトを参照。 -バッファ変数(|buffer-variable|) *b:clojure_syntax_without_core_keywords* がセッ -トされると、言語定数と特定のフォームにのみマッチする。 +そしてまたプラグイン作者が動的にシンボルをハイライトする意図で使用するための +バッファローカル版として変数 *b:clojure_syntax_keywords* もある。 + +変数 *b:clojure_syntax_without_core_keywords* への設定で、"clojure.core" の変 +数をデフォルトでハイライトしなくなる。これは `(:refer-clojure :only [])` で設 +定される名前空間に便利である。 + + *g:clojure_fold* + +|g:clojure_fold| を `1` に設定すると、Clojureコードの折り畳みが有効になる。複 +数行にまたがる任意の list, vector または map は、標準のVimの |fold-commands| を +使用して折り畳むことができる。 -*g:clojure_fold* を設定するとシンタックスエンジンに基づいた Clojure コードの折 -り畳みが有効化される。複数行に渡るリスト、ベクタ、マップなどを標準の Vim を -使って折り畳みできる |fold-commands|。 -このオプションは rainbow-parentheses プラグインのような、角カッコの構文範囲を -変更するようなスクリプトを使っているときは機能しない。 + *g:clojure_discard_macro* -このオプションは初期設定でオフになっている。 +この変数を `1` に設定すると Clojure の "discard リーダーマクロ" の基本的なハイ +ライトを有効にする。 > - " 初期設定 - let g:clojure_fold = 0 + #_(defn foo [x] + (println x)) < +Note このオプションは、スタックされたdiscardマクロが正しくハイライトされない +(例 `#_#_`)。 + COBOL *cobol.vim* *ft-cobol-syntax* @@ -1486,6 +1499,13 @@ FORM用の既定の拡張カラーモードではヘッダー命令とFORMプロ る。 +FORTH *forth.vim* *ft-forth-syntax* + +"*.fs" にマッチするファイルのタイプは F# か Forth である。自動判別がうまく機能 +しない場合、または F# ファイルを一切編集しない場合は、vimrcでこれを使用する: > + :let filetype_fs = "forth" + + FORTRAN *fortran.vim* *ft-fortran-syntax* デフォルトのハイライトと方言 ~ @@ -1628,14 +1648,6 @@ FVWM CONFIGURATION FILES *fvwm.vim* *ft-fvwm-syntax* :au! BufNewFile,BufRead /etc/X11/fvwm2/* let b:fvwm_version = 2 | \ set filetype=fvwm -全ての有効な色の名前をVimにハイライトさせるには、システムの色データベース -(rgb.txt)の位置を知らせる必要がある。これには変数 "rgb_file" にその場所を設定 -する。色データベースが/usr/X11/lib/X11/にあるとすれば: > - - :let rgb_file = "/usr/X11/lib/X11/rgb.txt" - -このような内容をファイル.vimrcに追加する。 - GSP *gsp.vim* *ft-gsp-syntax* @@ -3066,6 +3078,14 @@ SQLにはANSI標準があるのだが、ほとんどのデータベースエン より詳しい説明は|ft_sql.txt|を参照。 +SQUIRREL *squirrel.vim* *ft-squirrel-syntax* + +Squirrel はハイレベルな命令型オブジェクト指向プログラミング言語であり、ビデオ +ゲームなどのアプリケーションのサイズ、メモリ帯域幅、リアルタイム性の要件に適す +る軽量なスクリプト言語として設計されている。次の拡張子のファイルは、Squirrel +ファイルとして認識される: .nut + + TCSH *tcsh.vim* *ft-tcsh-syntax* これは "tcsh" という名前のシェルをカバーしている。これはcshのスーパーセットで @@ -4326,7 +4346,7 @@ skipパターンも "\n" を含んでよい。ただし次の行の最初の文 "\(\I\i*\)" をexternalとしてマークする。endパターンでは\z1によってstartパターン 中の最初のマークされた部分への外部参照とする。外部参照はskipパターン中でも使え る: > - :syn region foo start="start \(\I\i*\)" skip="not end \z1" end="end \z1" + :syn region foo start="start \z(\I\i*\)" skip="not end \z1" end="end \z1" 通常のマークとexternalなマークはまったく独立であり、別々に番号が振られる。例え ば、文字列 "aabb" に対してパターン "\z(..\)\(..\)" を適用すると、\1は "bb" を @@ -4650,17 +4670,29 @@ Note: "*/" を含む文字列で行をまたぐものがあると、Cコメン 再帰的な読み込みはされない。つまりカラースキームスクリ プト中で ":colorscheme" を使うことはできない。 - カラースキームをカスタマイズするには異なる名前を使い、 - 例えば "~/.vim/colors/mine.vim"、`:runtime`を用いてオ - リジナルのカラースキームを読み込む: > + カラースキームのカスタマイズには2つの選択肢がある。 + 特定の色の見栄えを変えるため、カラースキームを読み込む + 前にカラー名を再定義することができる。desert スキーム + は、カーソルに khaki 色が使用されている。同じ色のより + 暗いバリエーションを使用する場合: > + + let v:colornames['khaki'] = '#bdb76b' + colorscheme desert +< + |:highlight-link| の関連付けを変更するなど、さらにカス + タマイズするには、別の名前を使用する。例えば、 + "~/.vim/colors/mine.vim" と `:runtime` を使用してオリ + ジナルのカラースキームを読み込む: > runtime colors/evening.vim hi Statement ctermfg=Blue guifg=Blue -< カラースキームが読み込まれる前に、自動コマンドイベント - |ColorSchemePre| が発生する。カラースキームが読み込ま - れた後、自動コマンドイベント |ColorScheme| が発生す - る。カラースキームファイルを書くための情報については次 - を参照: > +< カラースキームが読み込まれる前に全デフォルトのカラーリ + ストのスクリプト(`colors/lists/default.vim`)が実行さ + れ、|ColorSchemePre| 自動コマンドイベントがトリガーさ + れる。カラースキームが読み込まれた後に |ColorScheme| + 自動コマンドイベントがトリガーされる。 + カラースキームファイルを書くための情報については次を参 + 照: > :edit $VIMRUNTIME/colors/README.txt :hi[ghlight] 属性がセットされたハイライトグループを全て表示する。 @@ -4668,6 +4700,7 @@ Note: "*/" を含む文字列で行をまたぐものがあると、Cコメン :hi[ghlight] {group-name} 1つのハイライトグループを表示する。 + *highlight-clear* :hi[ghlight] clear 全てのハイライトをデフォルトに戻す。ユーザーによって加 えられたグループに対するハイライトが全て消去される。 現在の 'background' の値によってデフォルトの色が決ま @@ -4681,7 +4714,9 @@ Note: "*/" を含む文字列で行をまたぐものがあると、Cコメン :hi[ghlight] [default] {group-name} {key}={arg} .. ハイライトグループを追加する、または既存のグループに対 - する強調を変更する。 + する強調を変更する。指定された色の名前が認識されない場 + 合、|'runtimepath'| 上で見付かる各 + `colors/lists/default.vim` が読み込まれる。 引数{key}={arg}については|highlight-args|を参照。 オプショナルな引数[default]については |:highlight-default|を参照。 @@ -4952,8 +4987,32 @@ guisp={color-name} *highlight-guisp* "gg" Green値 "bb" Blue値 これらの値は16進であり、範囲は "00" から "ff"。例: > - :highlight Comment guifg=#11f0c3 guibg=#ff00ff + :highlight Comment guifg=#11f0c3 guibg=#ff00ff +< + あなたがカラースキームの作者であり同じ16進数値を繰り返し使うのであれば + |v:colornames| にカラー名を定義することができる。例えば: > + + # デフォルト値を提供するがユーザーが上書きすることを許容する。 + :call extend(v:colornames, {'alt_turquoise': '#11f0c3'}, 'keep') + :highlight Comment guifg=alt_turquoise guibg=magenta +< + 名前付きのカラーに依存するカラースキームを使用していて、それらのカラー + の正確な見栄えを調整したい場合は、スキームを読み込む前に + |v:colornames| の値をオーバーライドすることで調整できる: > + + let v:colornames['alt_turquoise'] = '#22f0d3' + colorscheme alt < + 他人に信頼されるカラーリストを開発したい場合は、カラー名にプリフィック + スを付けるとよい。慣例により、これらのカラーリストは colors/lists ディ + レクトリに配置される。その例を + '$VIMRUNTIME/colors/lists/csscolors.vim' で見ることができる。このリス + トは、以下を使用したカラースキームによってソースされる: > + + :runtime colors/lists/csscolors.vim + :highlight Comment guifg=css_turquoise +< + *highlight-groups* *highlight-default* 以下はデフォルトのハイライトグループである。これらのグループはデフォルトでオプ ション 'highlight' によって使われる。ただしハイライトは 'background' の値に依 @@ -5013,6 +5072,12 @@ LineNrBelow 'relativenumber' オプションが設定されているときのカ CursorLineNr LineNr と同じだが 'cursorline' が設定され、'cursorlineopt' に "number" が含まれるか "both" が設定されているときに現在行に使 われる。 + *hl-CursorLineSign* +CursorLineSign SignColumn と同じだが 'cursorline' が設定されたときに現在行に + 使われる。 + *hl-CursorLineFold* +CursorLineFold FoldColumn と同じだが 'cursorline' が設定されたときに現在行に + 使われる。 *hl-MatchParen* MatchParen カーソル下の文字、または直後の文字が括弧であるとき、その文字と 対応する括弧に使われる。|pi_paren.txt| @@ -5225,24 +5290,25 @@ Unixでは~/.vim/after/syntax/syncolor.vimファイルを使うとよい。例: else highlight comment ctermfg=green guifg=green endif - -カラースキームを使用すると、ユーザー定義の色が使われるのか、それともカラース -キームで定義された色が使われるのかわからなくなる場合がある。これはカラースキー -ムファイルに依存する。|:colorscheme|を参照。 - +< *E679* このsyncolor.vimが "syntax on" を実行しないこと、また、オプション 'background' を設定したりコマンド "colorscheme" を実行しないように注意すること。もしこれら を実行すると無限ループに陥ってしまう。 +Note カラースキームを使用すると、ユーザー定義の色が使われるのか、それともカラー +スキームで定義された色が使われるのかわからなくなる場合がある。これはカラース +キームファイルに依存する。|:colorscheme|を参照。 + *syntax_cmd* syntax/syncolor.vimファイルが読み込まれると、変数 "syntax_cmd" に次の3つの値の どれかがセットされる: - "on" ":syntax on" コマンド。ハイライト色が上書きされるがリンクはそ + "on" `:syntax on` コマンド。ハイライト色が上書きされるがリンクはそ のまま。 - "enable" ":syntax enable" コマンド。まだハイライトが定義されていないグ - ループに対して色を定義するだけ。":syntax default" を使うこと。 - "reset" ":syntax reset" コマンドまたはカラースキームを読み込む。全ての + "enable" `:syntax enable` コマンド。まだハイライトが定義されていないグ + ループに対して色を定義するだけ。`:highlight default` を使うこ + と。 + "reset" `:syntax reset` コマンドまたはカラースキームを読み込む。全ての 色を定義する。 "skip" 色を定義しない。'runtimepath' で前にあるsyncolor.vimファイルが 既にデフォルト設定をセットしているとき、そのデフォルト設定をス diff --git a/en/syntax.txt b/en/syntax.txt index 1ade9e99d..35a4e3ad7 100644 --- a/en/syntax.txt +++ b/en/syntax.txt @@ -1,4 +1,4 @@ -*syntax.txt* For Vim version 8.2. Last change: 2021 Aug 16 +*syntax.txt* For Vim version 8.2. Last change: 2021 Nov 20 VIM REFERENCE MANUAL by Bram Moolenaar @@ -1081,33 +1081,47 @@ This works immediately. CLOJURE *ft-clojure-syntax* -The default syntax groups can be augmented through the -*g:clojure_syntax_keywords* and *b:clojure_syntax_keywords* variables. The -value should be a |Dictionary| of syntax group names to a |List| of custom -identifiers: + *g:clojure_syntax_keywords* + +Syntax highlighting of public vars in "clojure.core" is provided by default, +but additional symbols can be highlighted by adding them to the +|g:clojure_syntax_keywords| variable. The value should be a |Dictionary| of +syntax group names, each containing a |List| of identifiers. > let g:clojure_syntax_keywords = { - \ 'clojureMacro': ["defproject", "defcustom"], - \ 'clojureFunc': ["string/join", "string/replace"] + \ 'clojureMacro': ["defproject", "defcustom"], + \ 'clojureFunc': ["string/join", "string/replace"] \ } < Refer to the Clojure syntax script for valid syntax group names. -If the |buffer-variable| *b:clojure_syntax_without_core_keywords* is set, only -language constants and special forms are matched. +There is also *b:clojure_syntax_keywords* which is a buffer-local variant of +this variable intended for use by plugin authors to highlight symbols +dynamically. + +By setting the *b:clojure_syntax_without_core_keywords* variable, vars from +"clojure.core" will not be highlighted by default. This is useful for +namespaces that have set `(:refer-clojure :only [])` + + + *g:clojure_fold* -Setting *g:clojure_fold* enables folding Clojure code via the syntax engine. -Any list, vector, or map that extends over more than one line can be folded -using the standard Vim |fold-commands|. +Setting |g:clojure_fold| to `1` will enable the folding of Clojure code. Any +list, vector or map that extends over more than one line can be folded using +the standard Vim |fold-commands|. -Please note that this option does not work with scripts that redefine the -bracket syntax regions, such as rainbow-parentheses plugins. -This option is off by default. + *g:clojure_discard_macro* + +Set this variable to `1` to enable basic highlighting of Clojure's "discard +reader macro". > - " Default - let g:clojure_fold = 0 + #_(defn foo [x] + (println x)) < +Note that this option will not correctly highlight stacked discard macros +(e.g. `#_#_`). + COBOL *cobol.vim* *ft-cobol-syntax* @@ -1519,6 +1533,14 @@ gvim display. Here, statements are colored LightYellow instead of Yellow, and conditionals are LightBlue for better distinction. +FORTH *forth.vim* *ft-forth-syntax* + +Files matching "*.fs" could be F# or Forth. If the automatic detection +doesn't work for you, or you don't edit F# at all, use this in your +startup vimrc: > + :let filetype_fs = "forth" + + FORTRAN *fortran.vim* *ft-fortran-syntax* Default highlighting and dialect ~ @@ -1673,16 +1695,6 @@ as Fvwm2 configuration files, add the following: > :au! BufNewFile,BufRead /etc/X11/fvwm2/* let b:fvwm_version = 2 | \ set filetype=fvwm -If you'd like Vim to highlight all valid color names, tell it where to -find the color database (rgb.txt) on your system. Do this by setting -"rgb_file" to its location. Assuming your color database is located -in /usr/X11/lib/X11/, you should add the line > - - :let rgb_file = "/usr/X11/lib/X11/rgb.txt" - -to your .vimrc file. - - GSP *gsp.vim* *ft-gsp-syntax* The default coloring style for GSP pages is defined by |html.vim|, and @@ -3184,6 +3196,14 @@ buffer by buffer basis. For more detailed instructions see |ft_sql.txt|. +SQUIRREL *squirrel.vim* *ft-squirrel-syntax* + +Squirrel is a high level imperative, object-oriented programming language, +designed to be a light-weight scripting language that fits in the size, memory +bandwidth, and real-time requirements of applications like video games. Files +with the following extensions are recognized as squirrel files: .nut. + + TCSH *tcsh.vim* *ft-tcsh-syntax* This covers the shell named "tcsh". It is a superset of csh. See |csh.vim| @@ -4486,7 +4506,7 @@ it marks the "\(\I\i*\)" sub-expression as external; in the end pattern, it changes the \z1 back-reference into an external reference referring to the first external sub-expression in the start pattern. External references can also be used in skip patterns: > - :syn region foo start="start \(\I\i*\)" skip="not end \z1" end="end \z1" + :syn region foo start="start \z(\I\i*\)" skip="not end \z1" end="end \z1" Note that normal and external sub-expressions are completely orthogonal and indexed separately; for instance, if the pattern "\z(..\)\(..\)" is applied @@ -4830,16 +4850,28 @@ in their own color. Doesn't work recursively, thus you can't use ":colorscheme" in a color scheme script. - To customize a color scheme use another name, e.g. + You have two options for customizing a color scheme. + For changing the appearance of specific colors, you + can redefine a color name before loading the scheme. + The desert scheme uses the khaki color for the cursor. + To use a darker variation of the same color: > + + let v:colornames['khaki'] = '#bdb76b' + colorscheme desert +< + For further customization, such as changing + |:highlight-link| associations, use another name, e.g. "~/.vim/colors/mine.vim", and use `:runtime` to load the original color scheme: > runtime colors/evening.vim hi Statement ctermfg=Blue guifg=Blue -< Before the color scheme will be loaded the - |ColorSchemePre| autocommand event is triggered. - After the color scheme has been loaded the - |ColorScheme| autocommand event is triggered. +< Before the color scheme will be loaded all default + color list scripts (`colors/lists/default.vim`) will + be executed and then the |ColorSchemePre| autocommand + event is triggered. After the color scheme has been + loaded the |ColorScheme| autocommand event is + triggered. For info about writing a color scheme file: > :edit $VIMRUNTIME/colors/README.txt @@ -4849,6 +4881,7 @@ in their own color. :hi[ghlight] {group-name} List one highlight group. + *highlight-clear* :hi[ghlight] clear Reset all highlighting to the defaults. Removes all highlighting for groups added by the user! Uses the current value of 'background' to decide which @@ -4862,7 +4895,9 @@ in their own color. :hi[ghlight] [default] {group-name} {key}={arg} .. Add a highlight group, or change the highlighting for - an existing group. + an existing group. If a given color name is not + recognized, each `colors/lists/default.vim` found on + |'runtimepath'| will be loaded. See |highlight-args| for the {key}={arg} arguments. See |:highlight-default| for the optional [default] argument. @@ -5143,8 +5178,35 @@ guisp={color-name} *highlight-guisp* "gg" is the Green value "bb" is the Blue value All values are hexadecimal, range from "00" to "ff". Examples: > - :highlight Comment guifg=#11f0c3 guibg=#ff00ff + :highlight Comment guifg=#11f0c3 guibg=#ff00ff +< + If you are authoring a color scheme and use the same hexademical value + repeatedly, you can define a name for it in |v:colornames|. For + example: > + + # provide a default value for this color but allow the user to + # override it. + :call extend(v:colornames, {'alt_turquoise': '#11f0c3'}, 'keep') + :highlight Comment guifg=alt_turquoise guibg=magenta < + If you are using a color scheme that relies on named colors and you + would like to adjust the precise appearance of those colors, you can + do so by overriding the values in |v:colornames| prior to loading the + scheme: > + + let v:colornames['alt_turquoise'] = '#22f0d3' + colorscheme alt +< + If you want to develop a color list that can be relied on by others, + it is best to prefix your color names. By convention these color lists + are placed in the colors/lists directory. You can see an example in + '$VIMRUNTIME/colors/lists/csscolors.vim'. This list would be sourced + by a color scheme using: > + + :runtime colors/lists/csscolors.vim + :highlight Comment guifg=css_turquoise +< + *highlight-groups* *highlight-default* These are the default highlighting groups. These groups are used by the 'highlight' option default. Note that the highlighting depends on the value @@ -5205,6 +5267,10 @@ LineNrBelow Line number for when the 'relativenumber' *hl-CursorLineNr* CursorLineNr Like LineNr when 'cursorline' is set and 'cursorlineopt' contains "number" or is "both", for the cursor line. + *hl-CursorLineSign* +CursorLineSign Like SignColumn when 'cursorline' is set for the cursor line. + *hl-CursorLineFold* +CursorLineFold Like FoldColumn when 'cursorline' is set for the cursor line. *hl-MatchParen* MatchParen The character under the cursor or just before it, if it is a paired bracket, and its match. |pi_paren.txt| @@ -5431,7 +5497,7 @@ For Unix you can use the file ~/.vim/after/syntax/syncolor.vim. Example: > else highlight comment ctermfg=green guifg=green endif - +< *E679* Do make sure this syncolor.vim script does not use a "syntax on", set the 'background' option or uses a "colorscheme" command, because it results in an @@ -5444,11 +5510,11 @@ depends on the color scheme file. See |:colorscheme|. *syntax_cmd* The "syntax_cmd" variable is set to one of these values when the syntax/syncolor.vim files are loaded: - "on" ":syntax on" command. Highlight colors are overruled but + "on" `:syntax on` command. Highlight colors are overruled but links are kept - "enable" ":syntax enable" command. Only define colors for groups that - don't have highlighting yet. Use ":syntax default". - "reset" ":syntax reset" command or loading a color scheme. Define all + "enable" `:syntax enable` command. Only define colors for groups that + don't have highlighting yet. Use `:highlight default` . + "reset" `:syntax reset` command or loading a color scheme. Define all the colors. "skip" Don't define colors. Used to skip the default settings when a syncolor.vim file earlier in 'runtimepath' has already set