From 1ffa4e50477eb8a95c7097973c4d13d97551d784 Mon Sep 17 00:00:00 2001 From: ZyX Date: Sun, 19 Nov 2017 23:33:02 +0300 Subject: doc: Update documentation --- runtime/doc/eval.txt | 121 ++++++++++++++++++++++++++++++++++++++++++++++- runtime/doc/vim_diff.txt | 13 ++--- 2 files changed, 127 insertions(+), 7 deletions(-) (limited to 'runtime') diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt index b752667d9a..090eb022e2 100644 --- a/runtime/doc/eval.txt +++ b/runtime/doc/eval.txt @@ -10506,7 +10506,7 @@ option will still be marked as it was set in the sandbox. In a few situations it is not allowed to change the text in the buffer, jump to another window and some other things that might confuse or break what Vim is currently doing. This mostly applies to things that happen when Vim is -actually doing something else. For example, evaluating the 'balloonexpr' may +actually doing something else. For example, evaluating the 'balloonexpr' may happen any moment the mouse cursor is resting at some position. This is not allowed when the textlock is active: @@ -10516,5 +10516,124 @@ This is not allowed when the textlock is active: - closing a window or quitting Vim - etc. +============================================================================== +13. Command-line expressions coloring *expr-coloring* + +Expressions entered by user in |i_CTRL-R_=|, |c_CTRL-\_e|, |quote=| are +colored by built-in expressions parser. It uses highlight groups described in +the below table, which may be overriden by user colorschemes, all linked to +some other highlighting group. + *hl-NVimInvalid* +In addition to highlighting groups prefixed with NVim described below there +are highlighting groups prefixed with NVimInvalid which have just the same +meaning, but used to indicate that relevant token contains an error or that +error had occurred just before it. They have mostly the same hierarchy, +except that by default in place of any non-NVim-prefixed group NVimInvalid +linking to `Error` is used and some other intermediate groups are present. + +Group Default link Colored expression ~ +*hl-NVimInternalError* None, red/red Parser bug + +*hl-NVimAssignment* Operator Generic assignment +*hl-NVimPlainAssignment* NVimAssignment `=` in |:let| +*hl-NVimAugmentedAssignment* NVimAssignment Generic, `+=`/`-=`/`.=` +*hl-NVimAssignmentWithAddition* NVimAugmentedAssignment `+=` in |:let+=| +*hl-NVimAssignmentWithSubtraction* NVimAugmentedAssignment `-=` in |:let-=| +*hl-NVimAssignmentWithConcatenation* NVimAugmentedAssignment `.=` in |:let.=| + +*hl-NVimOperator* Operator Generic operator + +*hl-NVimUnaryOperator* NVimOperator Generic unary op +*hl-NVimUnaryPlus* NVimUnaryOperator |expr-unary-+| +*hl-NVimUnaryMinus* NVimUnaryOperator |expr-unary--| +*hl-NVimNot* NVimUnaryOperator |expr-!| + +*hl-NVimBinaryOperator* NVimOperator Generic binary op +*hl-NVimComparison* NVimBinaryOperator Any |expr4| operator +*hl-NVimComparisonModifier* NVimComparison `#`/`?` near |expr4| op +*hl-NVimBinaryPlus* NVimBinaryOperator |expr-+| +*hl-NVimBinaryMinus* NVimBinaryOperator |expr--| +*hl-NVimConcat* NVimBinaryOperator |expr-.| +*hl-NVimConcatOrSubscript* NVimConcat |expr-.| or |expr-entry| +*hl-NVimOr* NVimBinaryOperator |expr-barbar| +*hl-NVimAnd* NVimBinaryOperator |expr-&&| +*hl-NVimMultiplication* NVimBinaryOperator |expr-star| +*hl-NVimDivision* NVimBinaryOperator |expr-/| +*hl-NVimMod* NVimBinaryOperator |expr-%| + +*hl-NVimTernary* NVimOperator `?` in |expr1| +*hl-NVimTernaryColon* NVimTernary `:` in |expr1| + +*hl-NVimParenthesis* Delimiter Generic bracket +*hl-NVimLambda* NVimParenthesis `{`/`}` in |lambda| +*hl-NVimNestingParenthesis* NVimParenthesis `(`/`)` in |expr-nesting| +*hl-NVimCallingParenthesis* NVimParenthesis `(`/`)` in |expr-function| + +*hl-NVimSubscript* NVimParenthesis Generic subscript +*hl-NVimSubscriptBracket* NVimSubscript `[`/`]` in |expr-[]| +*hl-NVimSubscriptColon* NVimSubscript `:` in |expr-[:]| +*hl-NVimCurly* NVimSubscript `{`/`}` in + |curly-braces-names| + +*hl-NVimContainer* NVimParenthesis Generic container +*hl-NVimDict* NVimContainer `{`/`}` in |dict| literal +*hl-NVimList* NVimContainer `[`/`]` in |list| literal + +*hl-NVimIdentifier* Identifier Generic identifier +*hl-NVimIdentifierScope* NVimIdentifier Namespace: letter + before `:` in + |internal-variables| +*hl-NVimIdentifierScopeDelimiter* NVimIdentifier `:` after namespace + letter +*hl-NVimIdentifierName* NVimIdentifier Rest of the ident +*hl-NVimIdentifierKey* NVimIdentifier Identifier after + |expr-entry| + +*hl-NVimColon* Delimiter `:` in |dict| literal +*hl-NVimComma* Delimiter `,` in |dict|/|list| + literal or + |expr-function| +*hl-NVimArrow* Delimiter `->` in |lambda| + +*hl-NVimRegister* SpecialChar |expr-register| +*hl-NVimNumber* Number Non-prefix digits + in integer + |expr-number| +*hl-NVimNumberPrefix* Type `0` for |octal-number| + `0x` for |hex-number| + `0b` for |binary-number| +*hl-NVimFloat* NVimNumber Floating-point + number + +*hl-NVimOptionSigil* Type `&` in |expr-option| +*hl-NVimOptionScope* NVimIdentifierScope Option scope if any +*hl-NVimOptionScopeDelimiter* NVimIdentifierScopeDelimiter + `:` after option scope +*hl-NVimOptionName* NVimIdentifier Option name + +*hl-NVimEnvironmentSigil* NVimOptionSigil `$` in |expr-env| +*hl-NVimEnvironmentName* NVimIdentifier Env variable name + +*hl-NVimString* String Generic string +*hl-NVimStringBody* NVimString Generic string + literal body +*hl-NVimStringQuote* NVimString Generic string quote +*hl-NVimStringSpecial* SpecialChar Generic string + non-literal body + +*hl-NVimSingleQuote* NVimStringQuote `'` in |expr-'| +*hl-NVimSingleQuotedBody* NVimStringBody Literal part of + |expr-'| string body +*hl-NVimSingleQuotedQuote* NVimStringSpecial `''` inside |expr-'| + string body + +*hl-NVimDoubleQuote* NVimStringQuote `"` in |expr-quote| +*hl-NVimDoubleQuotedBody* NVimStringBody Literal part of + |expr-quote| body +*hl-NVimDoubleQuotedEscape* NVimStringSpecial Valid |expr-quote| + escape sequence +*hl-NVimDoubleQuotedUnknownEscape* NVimInvalidValue Unrecognized + |expr-quote| escape + sequence vim:tw=78:ts=8:noet:ft=help:norl: diff --git a/runtime/doc/vim_diff.txt b/runtime/doc/vim_diff.txt index 026ff6a0fb..22e6f11bb5 100644 --- a/runtime/doc/vim_diff.txt +++ b/runtime/doc/vim_diff.txt @@ -167,12 +167,13 @@ Highlight groups: |hl-Whitespace| highlights 'listchars' whitespace UI: - *E5408* *E5409* *g:Nvim_color_expr* *g:Nvim_color_cmdline* - Command-line coloring is supported. Only |input()| and |inputdialog()| may - be colored. For testing purposes expressions (e.g. |i_CTRL-R_=|) and regular - command-line (|:|) are colored by callbacks defined in `g:Nvim_color_expr` - and `g:Nvim_color_cmdline` respectively (these callbacks are for testing - only, and will be removed in a future version). + *E5408* *E5409* *g:Nvim_color_cmdline* + Command-line coloring is supported. Only |input()| and |inputdialog()| may + be colored by user. For testing purposes regular command-line (|:|) is + colored by callback defined in `g:Nvim_color_cmdline` (this callback is for + testing only, and will be removed in a future version). Additionally + expression command-line is colored using built-in expressions parser (it is + not yet used for actually parsing expressions though), see |expr-coloring|. ============================================================================== 4. Changed features *nvim-features-changed* -- cgit From 11a05e778fd5f33f791ca8047f9839caa15b8da5 Mon Sep 17 00:00:00 2001 From: ZyX Date: Sun, 26 Nov 2017 15:56:27 +0300 Subject: doc: Some small fixes --- runtime/doc/eval.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'runtime') diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt index 2e04c1d96e..46a7d92730 100644 --- a/runtime/doc/eval.txt +++ b/runtime/doc/eval.txt @@ -10578,13 +10578,13 @@ This is not allowed when the textlock is active: Expressions entered by user in |i_CTRL-R_=|, |c_CTRL-\_e|, |quote=| are colored by built-in expressions parser. It uses highlight groups described in -the below table, which may be overriden by user colorschemes, all linked to +the table below, which may be overriden by user colorschemes, all linked to some other highlighting group. *hl-NVimInvalid* In addition to highlighting groups prefixed with NVim described below there are highlighting groups prefixed with NVimInvalid which have just the same -meaning, but used to indicate that relevant token contains an error or that -error had occurred just before it. They have mostly the same hierarchy, +meaning, but used to indicate that the relevant token contains an error or +that error had occurred just before it. They have mostly the same hierarchy, except that by default in place of any non-NVim-prefixed group NVimInvalid linking to `Error` is used and some other intermediate groups are present. -- cgit From 5ab0f988caffad5e8c87a075cbd3f91f0f7e002c Mon Sep 17 00:00:00 2001 From: ZyX Date: Thu, 30 Nov 2017 11:53:25 +0300 Subject: *: Replace all occurrences of NVim with Nvim --- runtime/doc/eval.txt | 154 +++++++++++++++++++++++++-------------------------- 1 file changed, 77 insertions(+), 77 deletions(-) (limited to 'runtime') diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt index 46a7d92730..2b2fda25e9 100644 --- a/runtime/doc/eval.txt +++ b/runtime/doc/eval.txt @@ -10580,116 +10580,116 @@ Expressions entered by user in |i_CTRL-R_=|, |c_CTRL-\_e|, |quote=| are colored by built-in expressions parser. It uses highlight groups described in the table below, which may be overriden by user colorschemes, all linked to some other highlighting group. - *hl-NVimInvalid* -In addition to highlighting groups prefixed with NVim described below there -are highlighting groups prefixed with NVimInvalid which have just the same + *hl-NvimInvalid* +In addition to highlighting groups prefixed with Nvim described below there +are highlighting groups prefixed with NvimInvalid which have just the same meaning, but used to indicate that the relevant token contains an error or that error had occurred just before it. They have mostly the same hierarchy, -except that by default in place of any non-NVim-prefixed group NVimInvalid +except that by default in place of any non-Nvim-prefixed group NvimInvalid linking to `Error` is used and some other intermediate groups are present. Group Default link Colored expression ~ -*hl-NVimInternalError* None, red/red Parser bug - -*hl-NVimAssignment* Operator Generic assignment -*hl-NVimPlainAssignment* NVimAssignment `=` in |:let| -*hl-NVimAugmentedAssignment* NVimAssignment Generic, `+=`/`-=`/`.=` -*hl-NVimAssignmentWithAddition* NVimAugmentedAssignment `+=` in |:let+=| -*hl-NVimAssignmentWithSubtraction* NVimAugmentedAssignment `-=` in |:let-=| -*hl-NVimAssignmentWithConcatenation* NVimAugmentedAssignment `.=` in |:let.=| - -*hl-NVimOperator* Operator Generic operator - -*hl-NVimUnaryOperator* NVimOperator Generic unary op -*hl-NVimUnaryPlus* NVimUnaryOperator |expr-unary-+| -*hl-NVimUnaryMinus* NVimUnaryOperator |expr-unary--| -*hl-NVimNot* NVimUnaryOperator |expr-!| - -*hl-NVimBinaryOperator* NVimOperator Generic binary op -*hl-NVimComparison* NVimBinaryOperator Any |expr4| operator -*hl-NVimComparisonModifier* NVimComparison `#`/`?` near |expr4| op -*hl-NVimBinaryPlus* NVimBinaryOperator |expr-+| -*hl-NVimBinaryMinus* NVimBinaryOperator |expr--| -*hl-NVimConcat* NVimBinaryOperator |expr-.| -*hl-NVimConcatOrSubscript* NVimConcat |expr-.| or |expr-entry| -*hl-NVimOr* NVimBinaryOperator |expr-barbar| -*hl-NVimAnd* NVimBinaryOperator |expr-&&| -*hl-NVimMultiplication* NVimBinaryOperator |expr-star| -*hl-NVimDivision* NVimBinaryOperator |expr-/| -*hl-NVimMod* NVimBinaryOperator |expr-%| - -*hl-NVimTernary* NVimOperator `?` in |expr1| -*hl-NVimTernaryColon* NVimTernary `:` in |expr1| - -*hl-NVimParenthesis* Delimiter Generic bracket -*hl-NVimLambda* NVimParenthesis `{`/`}` in |lambda| -*hl-NVimNestingParenthesis* NVimParenthesis `(`/`)` in |expr-nesting| -*hl-NVimCallingParenthesis* NVimParenthesis `(`/`)` in |expr-function| - -*hl-NVimSubscript* NVimParenthesis Generic subscript -*hl-NVimSubscriptBracket* NVimSubscript `[`/`]` in |expr-[]| -*hl-NVimSubscriptColon* NVimSubscript `:` in |expr-[:]| -*hl-NVimCurly* NVimSubscript `{`/`}` in +*hl-NvimInternalError* None, red/red Parser bug + +*hl-NvimAssignment* Operator Generic assignment +*hl-NvimPlainAssignment* NvimAssignment `=` in |:let| +*hl-NvimAugmentedAssignment* NvimAssignment Generic, `+=`/`-=`/`.=` +*hl-NvimAssignmentWithAddition* NvimAugmentedAssignment `+=` in |:let+=| +*hl-NvimAssignmentWithSubtraction* NvimAugmentedAssignment `-=` in |:let-=| +*hl-NvimAssignmentWithConcatenation* NvimAugmentedAssignment `.=` in |:let.=| + +*hl-NvimOperator* Operator Generic operator + +*hl-NvimUnaryOperator* NvimOperator Generic unary op +*hl-NvimUnaryPlus* NvimUnaryOperator |expr-unary-+| +*hl-NvimUnaryMinus* NvimUnaryOperator |expr-unary--| +*hl-NvimNot* NvimUnaryOperator |expr-!| + +*hl-NvimBinaryOperator* NvimOperator Generic binary op +*hl-NvimComparison* NvimBinaryOperator Any |expr4| operator +*hl-NvimComparisonModifier* NvimComparison `#`/`?` near |expr4| op +*hl-NvimBinaryPlus* NvimBinaryOperator |expr-+| +*hl-NvimBinaryMinus* NvimBinaryOperator |expr--| +*hl-NvimConcat* NvimBinaryOperator |expr-.| +*hl-NvimConcatOrSubscript* NvimConcat |expr-.| or |expr-entry| +*hl-NvimOr* NvimBinaryOperator |expr-barbar| +*hl-NvimAnd* NvimBinaryOperator |expr-&&| +*hl-NvimMultiplication* NvimBinaryOperator |expr-star| +*hl-NvimDivision* NvimBinaryOperator |expr-/| +*hl-NvimMod* NvimBinaryOperator |expr-%| + +*hl-NvimTernary* NvimOperator `?` in |expr1| +*hl-NvimTernaryColon* NvimTernary `:` in |expr1| + +*hl-NvimParenthesis* Delimiter Generic bracket +*hl-NvimLambda* NvimParenthesis `{`/`}` in |lambda| +*hl-NvimNestingParenthesis* NvimParenthesis `(`/`)` in |expr-nesting| +*hl-NvimCallingParenthesis* NvimParenthesis `(`/`)` in |expr-function| + +*hl-NvimSubscript* NvimParenthesis Generic subscript +*hl-NvimSubscriptBracket* NvimSubscript `[`/`]` in |expr-[]| +*hl-NvimSubscriptColon* NvimSubscript `:` in |expr-[:]| +*hl-NvimCurly* NvimSubscript `{`/`}` in |curly-braces-names| -*hl-NVimContainer* NVimParenthesis Generic container -*hl-NVimDict* NVimContainer `{`/`}` in |dict| literal -*hl-NVimList* NVimContainer `[`/`]` in |list| literal +*hl-NvimContainer* NvimParenthesis Generic container +*hl-NvimDict* NvimContainer `{`/`}` in |dict| literal +*hl-NvimList* NvimContainer `[`/`]` in |list| literal -*hl-NVimIdentifier* Identifier Generic identifier -*hl-NVimIdentifierScope* NVimIdentifier Namespace: letter +*hl-NvimIdentifier* Identifier Generic identifier +*hl-NvimIdentifierScope* NvimIdentifier Namespace: letter before `:` in |internal-variables| -*hl-NVimIdentifierScopeDelimiter* NVimIdentifier `:` after namespace +*hl-NvimIdentifierScopeDelimiter* NvimIdentifier `:` after namespace letter -*hl-NVimIdentifierName* NVimIdentifier Rest of the ident -*hl-NVimIdentifierKey* NVimIdentifier Identifier after +*hl-NvimIdentifierName* NvimIdentifier Rest of the ident +*hl-NvimIdentifierKey* NvimIdentifier Identifier after |expr-entry| -*hl-NVimColon* Delimiter `:` in |dict| literal -*hl-NVimComma* Delimiter `,` in |dict|/|list| +*hl-NvimColon* Delimiter `:` in |dict| literal +*hl-NvimComma* Delimiter `,` in |dict|/|list| literal or |expr-function| -*hl-NVimArrow* Delimiter `->` in |lambda| +*hl-NvimArrow* Delimiter `->` in |lambda| -*hl-NVimRegister* SpecialChar |expr-register| -*hl-NVimNumber* Number Non-prefix digits +*hl-NvimRegister* SpecialChar |expr-register| +*hl-NvimNumber* Number Non-prefix digits in integer |expr-number| -*hl-NVimNumberPrefix* Type `0` for |octal-number| +*hl-NvimNumberPrefix* Type `0` for |octal-number| `0x` for |hex-number| `0b` for |binary-number| -*hl-NVimFloat* NVimNumber Floating-point +*hl-NvimFloat* NvimNumber Floating-point number -*hl-NVimOptionSigil* Type `&` in |expr-option| -*hl-NVimOptionScope* NVimIdentifierScope Option scope if any -*hl-NVimOptionScopeDelimiter* NVimIdentifierScopeDelimiter +*hl-NvimOptionSigil* Type `&` in |expr-option| +*hl-NvimOptionScope* NvimIdentifierScope Option scope if any +*hl-NvimOptionScopeDelimiter* NvimIdentifierScopeDelimiter `:` after option scope -*hl-NVimOptionName* NVimIdentifier Option name +*hl-NvimOptionName* NvimIdentifier Option name -*hl-NVimEnvironmentSigil* NVimOptionSigil `$` in |expr-env| -*hl-NVimEnvironmentName* NVimIdentifier Env variable name +*hl-NvimEnvironmentSigil* NvimOptionSigil `$` in |expr-env| +*hl-NvimEnvironmentName* NvimIdentifier Env variable name -*hl-NVimString* String Generic string -*hl-NVimStringBody* NVimString Generic string +*hl-NvimString* String Generic string +*hl-NvimStringBody* NvimString Generic string literal body -*hl-NVimStringQuote* NVimString Generic string quote -*hl-NVimStringSpecial* SpecialChar Generic string +*hl-NvimStringQuote* NvimString Generic string quote +*hl-NvimStringSpecial* SpecialChar Generic string non-literal body -*hl-NVimSingleQuote* NVimStringQuote `'` in |expr-'| -*hl-NVimSingleQuotedBody* NVimStringBody Literal part of +*hl-NvimSingleQuote* NvimStringQuote `'` in |expr-'| +*hl-NvimSingleQuotedBody* NvimStringBody Literal part of |expr-'| string body -*hl-NVimSingleQuotedQuote* NVimStringSpecial `''` inside |expr-'| +*hl-NvimSingleQuotedQuote* NvimStringSpecial `''` inside |expr-'| string body -*hl-NVimDoubleQuote* NVimStringQuote `"` in |expr-quote| -*hl-NVimDoubleQuotedBody* NVimStringBody Literal part of +*hl-NvimDoubleQuote* NvimStringQuote `"` in |expr-quote| +*hl-NvimDoubleQuotedBody* NvimStringBody Literal part of |expr-quote| body -*hl-NVimDoubleQuotedEscape* NVimStringSpecial Valid |expr-quote| +*hl-NvimDoubleQuotedEscape* NvimStringSpecial Valid |expr-quote| escape sequence -*hl-NVimDoubleQuotedUnknownEscape* NVimInvalidValue Unrecognized +*hl-NvimDoubleQuotedUnknownEscape* NvimInvalidValue Unrecognized |expr-quote| escape sequence -- cgit From e9990b43c23ef5f9cb10c75d6f0db00aa862db0e Mon Sep 17 00:00:00 2001 From: Filip Szymański Date: Sun, 3 Dec 2017 20:49:01 +0100 Subject: Fix job_control doc --- runtime/doc/job_control.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'runtime') diff --git a/runtime/doc/job_control.txt b/runtime/doc/job_control.txt index e57015db22..ed5f16902a 100644 --- a/runtime/doc/job_control.txt +++ b/runtime/doc/job_control.txt @@ -58,7 +58,7 @@ Description of what happens: - The first shell is idle, waiting to read commands from its stdin. - The second shell is started with -c which executes the command (a for-loop printing 0 through 9) and then exits. - - `JobHandler()` callback is passed to |jobstart()| to handle various job + - `OnEvent()` callback is passed to |jobstart()| to handle various job events. It displays stdout/stderr data received from the shells. For |on_stdout| and |on_stderr| see |channel-callback|. -- cgit From 3aa24042a8f7d591b8091b437fc9cdb03497bc7a Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Mon, 27 Nov 2017 00:35:09 +0100 Subject: tui: dump termcap info if -V3 ('verbose' >= 3) Get terminal debugging info by starting Nvim with 'verbose' level 3: nvim -V3log This is like Vim's `:set termcap`, which was removed in Nvim (and would be very awkward to restore because of the decoupled UI). --- runtime/doc/eval.txt | 5 ----- runtime/doc/options.txt | 1 + runtime/doc/starting.txt | 10 +++++----- runtime/doc/vim_diff.txt | 12 ++++++++---- 4 files changed, 14 insertions(+), 14 deletions(-) (limited to 'runtime') diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt index d2a3a962e6..71551e38e9 100644 --- a/runtime/doc/eval.txt +++ b/runtime/doc/eval.txt @@ -8889,11 +8889,6 @@ This does NOT work: > value and the global value are changed. Example: > :let &path = &path . ',/usr/local/include' -< This also works for terminal codes in the form t_xx. - But only for alphanumerical names. Example: > - :let &t_k1 = "\[234;" -< When the code does not exist yet it will be created as - a terminal key code, there is no error. :let &{option-name} .= {expr1} For a string option: Append {expr1} to the value. diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt index 4fe2e07909..4180ca21f2 100644 --- a/runtime/doc/options.txt +++ b/runtime/doc/options.txt @@ -6424,6 +6424,7 @@ A jump table for the options with a short description can be found at |Q_op|. Currently, these messages are given: >= 1 When the shada file is read or written. >= 2 When a file is ":source"'ed. + >= 3 UI info, terminal capabilities >= 5 Every searched tags file and include file. >= 8 Files for which a group of autocommands is executed. >= 9 Every executed autocommand. diff --git a/runtime/doc/starting.txt b/runtime/doc/starting.txt index 9b33926d04..30c0641ef7 100644 --- a/runtime/doc/starting.txt +++ b/runtime/doc/starting.txt @@ -249,14 +249,14 @@ argument. for reading or writing a ShaDa file. Can be used to find out what is happening upon startup and exit. Example: > - vim -V8 foobar + nvim -V8 -V[N]{filename} - Like -V and set 'verbosefile' to {filename}. The result is - that messages are not displayed but written to the file - {filename}. {filename} must not start with a digit. + Like -V and set 'verbosefile' to {filename}. Messages are not + displayed; instead they are written to the file {filename}. + {filename} must not start with a digit. Example: > - vim -V20vimlog foobar + nvim -V20vimlog < *-D* -D Debugging. Go to debugging mode when executing the first diff --git a/runtime/doc/vim_diff.txt b/runtime/doc/vim_diff.txt index c8155f7a68..45c88f6fe9 100644 --- a/runtime/doc/vim_diff.txt +++ b/runtime/doc/vim_diff.txt @@ -327,22 +327,26 @@ Ed-compatible mode: ":set noedcompatible" is ignored ":set edcompatible" is an error - *t_xx* *:set-termcap* *termcap-options* *t_AB* *t_Sb* *t_vb* *t_SI* + *t_xx* *termcap-options* *t_AB* *t_Sb* *t_vb* *t_SI* Nvim does not have special `t_XX` options nor keycodes to configure terminal capabilities. Instead Nvim treats the terminal as any other UI. For example, 'guicursor' sets the terminal cursor style if possible. - *'term'* *E529* *E530* *E531* + *:set-termcap* +Start Nvim with 'verbose' level 3 to see the terminal capabilities. > + nvim -V3 +< + *'term'* *E529* *E530* *E531* 'term' reflects the terminal type derived from |$TERM| and other environment checks. For debugging only; not reliable during startup. > :echo &term "builtin_x" means one of the |builtin-terms| was chosen, because the expected terminfo file was not found on the system. - *termcap* + *termcap* Nvim never uses the termcap database, only |terminfo| and |builtin-terms|. - *xterm-8bit* *xterm-8-bit* + *xterm-8bit* *xterm-8-bit* Xterm can be run in a mode where it uses true 8-bit CSI. Supporting this requires autodetection of whether the terminal is in UTF-8 mode or non-UTF-8 mode, as the 8-bit CSI character has to be written differently in each case. -- cgit From dc232b74fb1a7927d6c13bd8c80bb42fc18a859f Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Sun, 10 Dec 2017 01:24:54 +0100 Subject: doc: hack to avoid doxygen bug Use `@cond ` to obscure a section from doxygen. doxygen thinks kvec_withinit_t() is a function. That adds noise to the generated API documentation, and also prevents the following function from being noticed. --- runtime/doc/api.txt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'runtime') diff --git a/runtime/doc/api.txt b/runtime/doc/api.txt index ef8b9c7d47..ecf829d356 100644 --- a/runtime/doc/api.txt +++ b/runtime/doc/api.txt @@ -446,7 +446,11 @@ nvim_get_keymap({mode}) *nvim_get_keymap()* Array of maparg()-like dictionaries describing mappings nvim_get_api_info() *nvim_get_api_info()* - TODO: Documentation + Returns a 2-tuple (Array), where item 0 is the current channel + id and item 1 is the |api-metadata| map (Dictionary). + + Return:~ + 2-tuple [{channel-id}, {api-metadata}] Attributes:~ {async} -- cgit From ad9c2d3cb97bbc4ba83ce7d23c9df23f9d3d11db Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Tue, 14 Nov 2017 10:47:49 +0100 Subject: doc closes #7622 --- runtime/doc/api.txt | 91 +++++++++++++++++++++++++++++++++++++++++++----- runtime/doc/autocmd.txt | 27 ++++++-------- runtime/doc/syntax.txt | 12 +------ runtime/doc/ui.txt | 2 +- runtime/doc/various.txt | 19 +++++----- runtime/doc/vim_diff.txt | 3 +- 6 files changed, 105 insertions(+), 49 deletions(-) (limited to 'runtime') diff --git a/runtime/doc/api.txt b/runtime/doc/api.txt index ecf829d356..6c2a3a8632 100644 --- a/runtime/doc/api.txt +++ b/runtime/doc/api.txt @@ -60,8 +60,7 @@ External programs ("clients") can use the metadata to discover the |rpc-api|. API contract *api-contract* The API is made of functions and events. Clients call functions like those -described at |api-global|, and may "attach" in order to receive rich events, -described at |rpc-remote-ui|. +described at |api-global|, and may "attach" to receive rich |ui-events|. As Nvim develops, its API may change only according the following "contract": @@ -481,6 +480,84 @@ nvim_call_atomic({calls}) *nvim_call_atomic()* error ocurred, the values from all preceding calls will still be returned. + *nvim_parse_expression()* +nvim_parse_expression({expr}, {flags}, {highlight}) + Parse a VimL expression + + Attributes:~ + {async} + + Parameters:~ + {expr} Expression to parse. Is always treated as a + single line. + {flags} Flags: - "m" if multiple expressions in a + row are allowed (only the first one will be + parsed), - "E" if EOC tokens are not allowed + (determines whether they will stop parsing + process or be recognized as an + operator/space, though also yielding an + error). - "l" when needing to start parsing + with lvalues for ":let" or ":for". Common + flag sets: - "m" to parse like for ":echo". - + "E" to parse like for "=". - empty + string for ":call". - "lm" to parse for + ":let". + {highlight} If true, return value will also include + "highlight" key containing array of 4-tuples + (arrays) (Integer, Integer, Integer, String), + where first three numbers define the + highlighted region and represent line, + starting column and ending column (latter + exclusive: one should highlight region + [start_col, end_col)). + + Return:~ + AST: top-level dictionary holds keys "error": Dictionary + with error, present only if parser saw some error. + Contains the following keys: "message": String, error + message in printf format, translated. Must contain exactly + one "%.*s". "arg": String, error message argument. "len": + Amount of bytes successfully parsed. With flags equal to + "" that should be equal to the length of expr string. + @note: “Sucessfully parsed” here means “participated in + AST creation”, not “till the first error”. "ast": AST, + either nil or a dictionary with these keys: "type": node + type, one of the value names from ExprASTNodeType + stringified without "kExprNode" prefix. "start": a pair + [line, column] describing where node is “started” where + "line" is always 0 (will not be 0 if you will be using + nvim_parse_viml() on e.g. ":let", but that is not present + yet). Both elements are Integers. "len": “length” of the + node. This and "start" are there for debugging purposes + primary (debugging parser and providing debug + information). "children": a list of nodes described in + top/"ast". There always is zero, one or two children, key + will not be present if node has no children. Maximum + number of children may be found in node_maxchildren array. + Local values (present only for certain nodes): "scope": a + single Integer, specifies scope for "Option" and + "PlainIdentifier" nodes. For "Option" it is one of + ExprOptScope values, for "PlainIdentifier" it is one of + ExprVarScope values. "ident": identifier (without scope, + if any), present for "Option", "PlainIdentifier", + "PlainKey" and "Environment" nodes. "name": Integer, + register name (one character) or -1. Only present for + "Register" nodes. "cmp_type": String, comparison type, one + of the value names from ExprComparisonType, stringified + without "kExprCmp" prefix. Only present for "Comparison" + nodes. "ccs_strategy": String, case comparison strategy, + one of the value names from ExprCaseCompareStrategy, + stringified without "kCCStrategy" prefix. Only present for + "Comparison" nodes. "augmentation": String, augmentation + type for "Assignment" nodes. Is either an empty string, + "Add", "Subtract" or "Concat" for "=", "+=", "-=" or ".=" + respectively. "invert": Boolean, true if result of + comparison needs to be inverted. Only present for + "Comparison" nodes. "ivalue": Integer, integer value for + "Integer" nodes. "fvalue": Float, floating-point value for + "Float" nodes. "svalue": String, value for + "SingleQuotedString" and "DoubleQuotedString" nodes. + nvim__id({obj}) *nvim__id()* Returns object given as argument @@ -721,9 +798,10 @@ nvim_buf_add_highlight({buffer}, {src_id}, {hl_group}, {line}, or -1 for ungrouped highlight {hl_group} Name of the highlight group to use {line} Line to highlight (zero-indexed) - {col_start} Start of range of columns to highlight - {col_end} End of range of columns to highlight, or -1 - to highlight to end of line + {col_start} Start of (byte-indexed) column range to + highlight + {col_end} End of (byte-indexed) column range to + highlight, or -1 to highlight to end of line Return:~ The src_id that was used @@ -957,9 +1035,6 @@ nvim_tabpage_is_valid({tabpage}) *nvim_tabpage_is_valid()* ============================================================================== UI Functions *api-ui* -remote_ui_disconnect() *remote_ui_disconnect()* - TODO: Documentation - nvim_ui_attach({width}, {height}, {options}) *nvim_ui_attach()* TODO: Documentation diff --git a/runtime/doc/autocmd.txt b/runtime/doc/autocmd.txt index 740f44414a..9a04bf2824 100644 --- a/runtime/doc/autocmd.txt +++ b/runtime/doc/autocmd.txt @@ -259,13 +259,12 @@ Name triggered by ~ |BufNew| just after creating a new buffer |SwapExists| detected an existing swap file -|TermOpen| when a terminal buffer is starting -|TermClose| when a terminal buffer ends +|TermOpen| when a terminal job starts +|TermClose| when a terminal job ends Options |FileType| when the 'filetype' option has been set |Syntax| when the 'syntax' option has been set -|TermChanged| after the value of 'term' has changed |OptionSet| after setting any option Startup and exit @@ -933,26 +932,20 @@ TabEnter Just after entering a tab page. |tab-page| TabLeave Just before leaving a tab page. |tab-page| A WinLeave event will have been triggered first. - {Nvim} *TabNew* + *TabNew* TabNew When creating a new tab page. |tab-page| After WinEnter and before TabEnter. - {Nvim} *TabNewEntered* + *TabNewEntered* TabNewEntered After entering a new tab page. |tab-page| After BufEnter. - {Nvim} *TabClosed* + *TabClosed* TabClosed After closing a tab page. can be used for the tab page number. - *TermChanged* -TermChanged After the value of 'term' has changed. Useful - for re-loading the syntax file to update the - colors, fonts and other terminal-dependent - settings. Executed for all loaded buffers. - {Nvim} *TermClose* -TermClose When a terminal buffer ends. - {Nvim} *TermOpen* -TermOpen When a terminal buffer is starting. This can - be used to configure the terminal emulator by - setting buffer variables. |terminal| + *TermClose* +TermClose When a |terminal| job ends. + *TermOpen* +TermOpen When a |terminal| job is starting. Can be + used to configure the terminal buffer. *TermResponse* TermResponse After the response to |t_RV| is received from the terminal. The value of |v:termresponse| diff --git a/runtime/doc/syntax.txt b/runtime/doc/syntax.txt index 85330f3dec..ff9773b136 100644 --- a/runtime/doc/syntax.txt +++ b/runtime/doc/syntax.txt @@ -4709,17 +4709,7 @@ ctermbg={color-nr} *highlight-ctermbg* "cterm". For example, on some systems "cterm=bold ctermfg=3" gives another color, on others you just get color 3. - For an xterm this depends on your resources, and is a bit - unpredictable. See your xterm documentation for the defaults. The - colors for a color-xterm can be changed from the .Xdefaults file. - Unfortunately this means that it's not possible to get the same colors - for each user. - - The MSDOS standard colors are fixed (in a console window), so these - have been used for the names. But the meaning of color names in X11 - are fixed, so these color settings have been used, to make the - highlighting settings portable (complicated, isn't it?). The - following names are recognized, with the color number used: + The following names are recognized, with the color number used: *cterm-colors* NR-16 NR-8 COLOR NAME ~ diff --git a/runtime/doc/ui.txt b/runtime/doc/ui.txt index 685019aed7..abbd063483 100644 --- a/runtime/doc/ui.txt +++ b/runtime/doc/ui.txt @@ -9,7 +9,7 @@ Nvim UI protocol *ui* Type |gO| to see the table of contents. ============================================================================== -Introduction *ui-intro* +UI Events *ui-events* GUIs can be implemented as external processes communicating with Nvim over the RPC API. The UI model consists of a terminal-like grid with a single, diff --git a/runtime/doc/various.txt b/runtime/doc/various.txt index baac72c106..9232cd70c5 100644 --- a/runtime/doc/various.txt +++ b/runtime/doc/various.txt @@ -207,21 +207,18 @@ g8 Print the hex values of the bytes used in the :sh[ell] Removed. |vim-differences| {Nvim} *:terminal* *:te* -:te[rminal][!] [{cmd}] Execute {cmd} with 'shell' in a new |terminal| buffer. - Equivalent to: > - :enew - :call termopen('{cmd}') -< - See |termopen()|. +:te[rminal][!] [{cmd}] Execute {cmd} with 'shell' in a new |terminal-emulator| + buffer. Without {cmd}, start an interactive 'shell'. - Without {cmd}, start an interactive shell. + Type |i| to enter |Terminal-mode|, then keys are sent to + the job running in the terminal. Type to + leave Terminal-mode. |CTRL-\_CTRL-N| - Creating the terminal buffer fails when changes have been - made to the current buffer, unless 'hidden' is set. + Fails if changes have been made to the current buffer, + unless 'hidden' is set. To enter |Terminal-mode| automatically: > - autocmd BufEnter term://* startinsert - autocmd BufLeave term://* stopinsert + autocmd TermOpen * startinsert < *:!cmd* *:!* *E34* :!{cmd} Execute {cmd} with 'shell'. See also |:terminal|. diff --git a/runtime/doc/vim_diff.txt b/runtime/doc/vim_diff.txt index 1a4a66ed89..7061f01316 100644 --- a/runtime/doc/vim_diff.txt +++ b/runtime/doc/vim_diff.txt @@ -302,7 +302,8 @@ Highlight groups: |hl-ColorColumn|, |hl-CursorColumn| are lower priority than most other groups -The variable name "count" is no fallback for |v:count| anymore. +VimL (Vim script) compatibility: + `count` does not alias to |v:count| ============================================================================== 5. Missing legacy features *nvim-features-missing* -- cgit From 34057045beca40406673ff421a4ef1e8e8c08853 Mon Sep 17 00:00:00 2001 From: Björn Linse Date: Tue, 12 Dec 2017 18:23:19 +0100 Subject: ui: forward relevant option updates to UIs (#7520) also make termguicolors mutable after startup --- runtime/doc/options.txt | 1 - runtime/doc/ui.txt | 21 +++++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) (limited to 'runtime') diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt index 4180ca21f2..d3072d83e2 100644 --- a/runtime/doc/options.txt +++ b/runtime/doc/options.txt @@ -6192,7 +6192,6 @@ A jump table for the options with a short description can be found at |Q_op|. When on, uses |highlight-guifg| and |highlight-guibg| attributes in the terminal (thus using 24-bit color). Requires a ISO-8613-3 compatible terminal. - Must be set at startup (in your |init.vim| or |--cmd|). *'terse'* *'noterse'* 'terse' boolean (default off) diff --git a/runtime/doc/ui.txt b/runtime/doc/ui.txt index abbd063483..e1c5523202 100644 --- a/runtime/doc/ui.txt +++ b/runtime/doc/ui.txt @@ -80,6 +80,27 @@ Global Events *ui-global* Some keys are missing in some modes. +["option_set", name, value] + The value of ui related option `name` changed. The sent options are + listed below: + + 'arabicshape' + 'ambiwith' + 'emoji' + 'guifont' + 'guifontset' + 'guifontwide' + 'showtabline' + 'termguicolors' + + Options are not added to the list if their effects are already taken + care of. For instance, instead of forwarding the raw 'mouse' option + value, `mouse_on` and `mouse_off` directly indicate if mouse support + is active right now. Some options like 'ambiwith' have already taken + effect on the grid, where appropriate empty cells are added, however + an ui might still use these options when rendering raw text sent from + Nvim, like the text of the cmdline when |ui-ext-cmdline| is set. + ["mode_change", mode, mode_idx] The mode changed. The first parameter `mode` is a string representing the current mode. `mode_idx` is an index into the array received in -- cgit From fb07391ce46b8bff90ef7ef073b75919a307e64c Mon Sep 17 00:00:00 2001 From: ZyX Date: Fri, 15 Dec 2017 11:38:34 +0300 Subject: window: Fix matchaddpos() and enhance error reporting --- runtime/doc/eval.txt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'runtime') diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt index e337c5d6d5..6c3fd43db0 100644 --- a/runtime/doc/eval.txt +++ b/runtime/doc/eval.txt @@ -5493,7 +5493,7 @@ matchaddpos({group}, {pos} [, {priority} [, {id} [, {dict}]]]) sets buffer line boundaries to redraw screen. It is supposed to be used when fast match additions and deletions are required, for example to highlight matching parentheses. - + *E5030* *E5031* The list {pos} can contain one of these items: - A number. This whole line will be highlighted. The first line has number 1. @@ -5507,6 +5507,10 @@ matchaddpos({group}, {pos} [, {priority} [, {id} [, {dict}]]]) - A list with three numbers, e.g., [23, 11, 3]. As above, but the third number gives the length of the highlight in bytes. + Entries with zero and negative line numbers are silently + ignored, as well as entries with negative column numbers and + lengths. + The maximum number of positions is 8. Example: > -- cgit From a1adfdc7d59979824addce2f519a527f9a5c0290 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Wed, 29 Nov 2017 01:50:11 -0500 Subject: ci: nodejs client acceptance-test #7706 ci: install nodejs 8 in Appveyor, Travis provider: check node version for debug support Resolve https://github.com/neovim/neovim/pull/7577#issuecomment-350590592 for Unix. provider: test if nodejs in ci supports --inspect-brk nodejs host for neovim requires nodejs 6+ to work properly. nodejs 6.12+ or 7.6+ is required for debug support via `node --inspect-brk`. provider: run cli.js of nodejs host directly npm shims are useless because the user cannot set node to debug mode via --inspect-brk. This is problematic on Windows which use batchfiles and shell scripts to compensate for not supporting shebang. The patch uses `npm root -g` to get the absolute path of the global npm modules. If that fails, then the user did not install neovim npm package globally. Use that absolute path to find `neovim/bin/cli.js`, which is what the npm shim actually runs with node. glob() is for a simple file check in case bin/ is removed because the npm shims are ignored now. --- runtime/autoload/health/provider.vim | 15 ++++++++++---- runtime/autoload/provider/node.vim | 40 +++++++++++++++++++++++++++--------- 2 files changed, 41 insertions(+), 14 deletions(-) (limited to 'runtime') diff --git a/runtime/autoload/health/provider.vim b/runtime/autoload/health/provider.vim index 0201ed8062..188b67c4c1 100644 --- a/runtime/autoload/health/provider.vim +++ b/runtime/autoload/health/provider.vim @@ -488,7 +488,7 @@ function! s:check_ruby() abort endfunction function! s:check_node() abort - call health#report_start('Node provider (optional)') + call health#report_start('Node.js provider (optional)') let loaded_var = 'g:loaded_node_provider' if exists(loaded_var) && !exists('*provider#node#Call') @@ -502,7 +502,14 @@ function! s:check_node() abort \ ['Install Node.js and verify that `node` and `npm` commands work.']) return endif - call health#report_info('Node: '. s:system('node -v')) + let node_v = get(split(s:system('node -v'), "\n"), 0, '') + call health#report_info('Node.js: '. node_v) + if !s:shell_error && s:version_cmp(node_v[1:], '6.0.0') < 0 + call health#report_warn('Neovim node.js host does not support '.node_v) + endif + if !provider#node#can_inspect() + call health#report_warn('node.js on this system does not support --inspect-brk so $NVIM_NODE_HOST_DEBUG is ignored.') + endif let host = provider#node#Detect() if empty(host) @@ -511,7 +518,7 @@ function! s:check_node() abort \ 'Is the npm bin directory in $PATH?']) return endif - call health#report_info('Host: '. host) + call health#report_info('Neovim node.js host: '. host) let latest_npm_cmd = has('win32') ? 'cmd /c npm info neovim --json' : 'npm info neovim --json' let latest_npm = s:system(split(latest_npm_cmd)) @@ -530,7 +537,7 @@ function! s:check_node() abort let latest_npm = get(get(pkg_data, 'dist-tags', {}), 'latest', 'unable to parse') endif - let current_npm_cmd = host .' --version' + let current_npm_cmd = ['node', host, '--version'] let current_npm = s:system(current_npm_cmd) if s:shell_error call health#report_error('Failed to run: '. current_npm_cmd, diff --git a/runtime/autoload/provider/node.vim b/runtime/autoload/provider/node.vim index b08ad4f316..67b54c6439 100644 --- a/runtime/autoload/provider/node.vim +++ b/runtime/autoload/provider/node.vim @@ -5,8 +5,32 @@ let g:loaded_node_provider = 1 let s:job_opts = {'rpc': v:true, 'on_stderr': function('provider#stderr_collector')} +" Support for --inspect-brk requires node 6.12+ or 7.6+ or 8+ +" Return 1 if it is supported +" Return 0 otherwise +function! provider#node#can_inspect() + if !executable('node') + return 0 + endif + let node_v = get(split(system(['node', '-v']), "\n"), 0, '') + if v:shell_error || node_v[0] !=# 'v' + return 0 + endif + " [major, minor, patch] + let node_v = split(node_v[1:], '\.') + return len(node_v) == 3 && ( + \ (node_v[0] > 7) || + \ (node_v[0] == 7 && node_v[1] >= 6) || + \ (node_v[0] == 6 && node_v[1] >= 12) + \ ) +endfunction + function! provider#node#Detect() abort - return has('win32') ? exepath('neovim-node-host.cmd') : exepath('neovim-node-host') + let global_modules = get(split(system('npm root -g'), "\n"), 0, '') + if v:shell_error || !isdirectory(global_modules) + return '' + endif + return glob(global_modules . '/neovim/bin/cli.js') endfunction function! provider#node#Prog() @@ -19,18 +43,14 @@ function! provider#node#Require(host) abort return endif - if has('win32') - let args = provider#node#Prog() - else - let args = ['node'] - - if !empty($NVIM_NODE_HOST_DEBUG) - call add(args, '--inspect-brk') - endif + let args = ['node'] - call add(args , provider#node#Prog()) + if !empty($NVIM_NODE_HOST_DEBUG) && provider#node#can_inspect() + call add(args, '--inspect-brk') endif + call add(args, provider#node#Prog()) + try let channel_id = jobstart(args, s:job_opts) if rpcrequest(channel_id, 'poll') ==# 'ok' -- cgit From e0054fef7d351b0f8af3a04bb22d6e6ee8bae63f Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Sun, 17 Dec 2017 15:03:07 +0100 Subject: health.vim: nodejs: skip if nodejs is too old --- runtime/autoload/health/provider.vim | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'runtime') diff --git a/runtime/autoload/health/provider.vim b/runtime/autoload/health/provider.vim index 188b67c4c1..205a23dcbd 100644 --- a/runtime/autoload/health/provider.vim +++ b/runtime/autoload/health/provider.vim @@ -506,6 +506,8 @@ function! s:check_node() abort call health#report_info('Node.js: '. node_v) if !s:shell_error && s:version_cmp(node_v[1:], '6.0.0') < 0 call health#report_warn('Neovim node.js host does not support '.node_v) + " Skip further checks, they are nonsense if nodejs is too old. + return endif if !provider#node#can_inspect() call health#report_warn('node.js on this system does not support --inspect-brk so $NVIM_NODE_HOST_DEBUG is ignored.') @@ -540,8 +542,8 @@ function! s:check_node() abort let current_npm_cmd = ['node', host, '--version'] let current_npm = s:system(current_npm_cmd) if s:shell_error - call health#report_error('Failed to run: '. current_npm_cmd, - \ ['Report this issue with the output of: ', current_npm_cmd]) + call health#report_error('Failed to run: '. string(current_npm_cmd), + \ ['Report this issue with the output of: ', string(current_npm_cmd)]) return endif @@ -551,7 +553,7 @@ function! s:check_node() abort \ current_npm, latest_npm), \ ['Run in shell: npm update neovim']) else - call health#report_ok('Latest "neovim" npm is installed: '. current_npm) + call health#report_ok('Latest "neovim" npm package is installed: '. current_npm) endif endfunction -- cgit From 103ff26c0ae76491c73a6c078b52f2e56af16fb8 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Sun, 17 Dec 2017 15:53:11 +0100 Subject: provider/nodejs: check version in Detect() --- runtime/autoload/provider/node.vim | 44 ++++++++++++++++++++++++----------- runtime/autoload/provider/python.vim | 6 ++--- runtime/autoload/provider/python3.vim | 6 ++--- runtime/autoload/provider/ruby.vim | 6 ++--- 4 files changed, 40 insertions(+), 22 deletions(-) (limited to 'runtime') diff --git a/runtime/autoload/provider/node.vim b/runtime/autoload/provider/node.vim index 67b54c6439..f75d2632be 100644 --- a/runtime/autoload/provider/node.vim +++ b/runtime/autoload/provider/node.vim @@ -5,24 +5,35 @@ let g:loaded_node_provider = 1 let s:job_opts = {'rpc': v:true, 'on_stderr': function('provider#stderr_collector')} +function! s:is_minimum_version(version, min_major, min_minor) abort + let nodejs_version = a:version + if !a:version + let nodejs_version = get(split(system(['node', '-v']), "\n"), 0, '') + if v:shell_error || nodejs_version[0] !=# 'v' + return 0 + endif + endif + " [major, minor, patch] + let v_list = !!a:version ? a:version : split(nodejs_version[1:], '\.') + return len(v_list) == 3 + \ && ((str2nr(v_list[0]) > str2nr(a:min_major)) + \ || (str2nr(v_list[0]) == str2nr(a:min_major) + \ && str2nr(v_list[1]) >= str2nr(a:min_minor))) +endfunction + " Support for --inspect-brk requires node 6.12+ or 7.6+ or 8+ " Return 1 if it is supported " Return 0 otherwise -function! provider#node#can_inspect() +function! provider#node#can_inspect() abort if !executable('node') return 0 endif - let node_v = get(split(system(['node', '-v']), "\n"), 0, '') - if v:shell_error || node_v[0] !=# 'v' + let ver = get(split(system(['node', '-v']), "\n"), 0, '') + if v:shell_error || ver[0] !=# 'v' return 0 endif - " [major, minor, patch] - let node_v = split(node_v[1:], '\.') - return len(node_v) == 3 && ( - \ (node_v[0] > 7) || - \ (node_v[0] == 7 && node_v[1] >= 6) || - \ (node_v[0] == 6 && node_v[1] >= 12) - \ ) + return (ver[1] ==# '6' && s:is_minimum_version(ver, 6, 12)) + \ || s:is_minimum_version(ver, 7, 6) endfunction function! provider#node#Detect() abort @@ -30,10 +41,17 @@ function! provider#node#Detect() abort if v:shell_error || !isdirectory(global_modules) return '' endif - return glob(global_modules . '/neovim/bin/cli.js') + if !s:is_minimum_version(v:null, 6, 0) + return '' + endif + let entry_point = glob(global_modules . '/neovim/bin/cli.js') + if !filereadable(entry_point) + return '' + endif + return entry_point endfunction -function! provider#node#Prog() +function! provider#node#Prog() abort return s:prog endfunction @@ -69,7 +87,7 @@ function! provider#node#Require(host) abort throw remote#host#LoadErrorForHost(a:host.orig_name, '$NVIM_NODE_LOG_FILE') endfunction -function! provider#node#Call(method, args) +function! provider#node#Call(method, args) abort if s:err != '' echoerr s:err return diff --git a/runtime/autoload/provider/python.vim b/runtime/autoload/provider/python.vim index 81fe194cb9..a06cbe4814 100644 --- a/runtime/autoload/provider/python.vim +++ b/runtime/autoload/provider/python.vim @@ -11,11 +11,11 @@ let g:loaded_python_provider = 1 let [s:prog, s:err] = provider#pythonx#Detect(2) -function! provider#python#Prog() +function! provider#python#Prog() abort return s:prog endfunction -function! provider#python#Error() +function! provider#python#Error() abort return s:err endfunction @@ -29,7 +29,7 @@ endif call remote#host#RegisterClone('legacy-python-provider', 'python') call remote#host#RegisterPlugin('legacy-python-provider', 'script_host.py', []) -function! provider#python#Call(method, args) +function! provider#python#Call(method, args) abort if s:err != '' return endif diff --git a/runtime/autoload/provider/python3.vim b/runtime/autoload/provider/python3.vim index 0c3b75b73d..242a224cb3 100644 --- a/runtime/autoload/provider/python3.vim +++ b/runtime/autoload/provider/python3.vim @@ -11,11 +11,11 @@ let g:loaded_python3_provider = 1 let [s:prog, s:err] = provider#pythonx#Detect(3) -function! provider#python3#Prog() +function! provider#python3#Prog() abort return s:prog endfunction -function! provider#python3#Error() +function! provider#python3#Error() abort return s:err endfunction @@ -29,7 +29,7 @@ endif call remote#host#RegisterClone('legacy-python3-provider', 'python3') call remote#host#RegisterPlugin('legacy-python3-provider', 'script_host.py', []) -function! provider#python3#Call(method, args) +function! provider#python3#Call(method, args) abort if s:err != '' return endif diff --git a/runtime/autoload/provider/ruby.vim b/runtime/autoload/provider/ruby.vim index da73a0dfc0..3fb65fecdf 100644 --- a/runtime/autoload/provider/ruby.vim +++ b/runtime/autoload/provider/ruby.vim @@ -7,7 +7,7 @@ let g:loaded_ruby_provider = 1 let s:stderr = {} let s:job_opts = {'rpc': v:true} -function! s:job_opts.on_stderr(chan_id, data, event) +function! s:job_opts.on_stderr(chan_id, data, event) abort let stderr = get(s:stderr, a:chan_id, ['']) let last = remove(stderr, -1) let a:data[0] = last.a:data[0] @@ -23,7 +23,7 @@ function! provider#ruby#Detect() abort end endfunction -function! provider#ruby#Prog() +function! provider#ruby#Prog() abort return s:prog endfunction @@ -50,7 +50,7 @@ function! provider#ruby#Require(host) abort throw remote#host#LoadErrorForHost(a:host.orig_name, '$NVIM_RUBY_LOG_FILE') endfunction -function! provider#ruby#Call(method, args) +function! provider#ruby#Call(method, args) abort if s:err != '' echoerr s:err return -- cgit From c162bc629440afaf8910f1a29f1dfdb03f898101 Mon Sep 17 00:00:00 2001 From: James McCoy Date: Sat, 16 Dec 2017 21:50:20 -0500 Subject: vim-patch:8.0.0420: text garbled when the system encoding differs from 'encoding' Problem: When running :make the output may be in the system encoding, different from 'encoding'. Solution: Add the 'makeencoding' option. (Ken Takata) https://github.com/vim/vim/commit/2c7292dc5bbf155fe2192d417363b8c085759cad --- runtime/doc/options.txt | 17 +++++++++++++++++ runtime/doc/quickfix.txt | 21 +++++++++++++++++++++ runtime/doc/quickref.txt | 1 + 3 files changed, 39 insertions(+) (limited to 'runtime') diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt index d3072d83e2..f70ec32bd8 100644 --- a/runtime/doc/options.txt +++ b/runtime/doc/options.txt @@ -3809,6 +3809,23 @@ A jump table for the options with a short description can be found at |Q_op|. This option cannot be set from a |modeline| or in the |sandbox|, for security reasons. + *'makeencoding'* *'menc'* +'makeencoding' 'menc' string (default "") + global or local to buffer |global-local| + {only available when compiled with the |+multi_byte| + feature} + {not in Vi} + Encoding used for reading the output of external commands. When empty, + encoding is not converted. + This is used for `:make`, `:lmake`, `:grep`, `:lgrep`, `:grepadd`, + `:lgrepadd`, `:cfile`, `:cgetfile`, `:caddfile`, `:lfile`, `:lgetfile`, + and `:laddfile`. + + This would be mostly useful when you use MS-Windows. If |+iconv| is + enabled and GNU libiconv is used, setting 'makeencoding' to "char" has + the same effect as setting to the system locale encoding. Example: > + :set makeencoding=char " system locale is used +< *'makeprg'* *'mp'* 'makeprg' 'mp' string (default "make") global or local to buffer |global-local| diff --git a/runtime/doc/quickfix.txt b/runtime/doc/quickfix.txt index da167c0f5b..74f82b2c65 100644 --- a/runtime/doc/quickfix.txt +++ b/runtime/doc/quickfix.txt @@ -165,6 +165,9 @@ processing a quickfix or location list command, it will be aborted. keep Vim running while compiling. If you give the name of the errorfile, the 'errorfile' option will be set to [errorfile]. See |:cc| for [!]. + If the encoding of the error file differs from the + 'encoding' option, you can use the 'makeencoding' + option to specify the encoding. *:lf* *:lfile* :lf[ile][!] [errorfile] Same as ":cfile", except the location list for the @@ -176,6 +179,9 @@ processing a quickfix or location list command, it will be aborted. :cg[etfile] [errorfile] *:cg* *:cgetfile* Read the error file. Just like ":cfile" but don't jump to the first error. + If the encoding of the error file differs from the + 'encoding' option, you can use the 'makeencoding' + option to specify the encoding. :lg[etfile] [errorfile] *:lg* *:lgetfile* @@ -186,6 +192,9 @@ processing a quickfix or location list command, it will be aborted. :caddf[ile] [errorfile] Read the error file and add the errors from the errorfile to the current quickfix list. If a quickfix list is not present, then a new list is created. + If the encoding of the error file differs from the + 'encoding' option, you can use the 'makeencoding' + option to specify the encoding. *:laddf* *:laddfile* :laddf[ile] [errorfile] Same as ":caddfile", except the location list for the @@ -322,6 +331,7 @@ use this code: > endfunction au QuickfixCmdPost make call QfMakeConv() +Another option is using 'makeencoding'. EXECUTE A COMMAND IN ALL THE BUFFERS IN QUICKFIX OR LOCATION LIST: *:cdo* @@ -586,6 +596,9 @@ lists, use ":cnewer 99" first. like |:cnext| and |:cprevious|, see above. This command does not accept a comment, any " characters are considered part of the arguments. + If the encoding of the program output differs from the + 'encoding' option, you can use the 'makeencoding' + option to specify the encoding. *:lmak* *:lmake* :lmak[e][!] [arguments] @@ -645,6 +658,7 @@ read the error messages: > au QuickfixCmdPost make call QfMakeConv() (Example by Faque Cheng) +Another option is using 'makeencoding'. ============================================================================== 5. Using :vimgrep and :grep *grep* *lid* @@ -759,6 +773,9 @@ id-utils) in a similar way to its compiler integration (see |:make| above). When 'grepprg' is "internal" this works like |:vimgrep|. Note that the pattern needs to be enclosed in separator characters then. + If the encoding of the program output differs from the + 'encoding' option, you can use the 'makeencoding' + option to specify the encoding. *:lgr* *:lgrep* :lgr[ep][!] [arguments] Same as ":grep", except the location list for the @@ -783,6 +800,10 @@ id-utils) in a similar way to its compiler integration (see |:make| above). \ | catch /E480:/ \ | endtry" < + If the encoding of the program output differs from the + 'encoding' option, you can use the 'makeencoding' + option to specify the encoding. + *:lgrepa* *:lgrepadd* :lgrepa[dd][!] [arguments] Same as ":grepadd", except the location list for the diff --git a/runtime/doc/quickref.txt b/runtime/doc/quickref.txt index b22d2afa7e..902b0175a2 100644 --- a/runtime/doc/quickref.txt +++ b/runtime/doc/quickref.txt @@ -762,6 +762,7 @@ Short explanation of each option: *option-list* 'loadplugins' 'lpl' load plugin scripts when starting up 'magic' changes special characters in search patterns 'makeef' 'mef' name of the errorfile for ":make" +'makeencoding' 'menc' encoding of external make/grep commands 'makeprg' 'mp' program to use for the ":make" command 'matchpairs' 'mps' pairs of characters that "%" can match 'matchtime' 'mat' tenths of a second to show matching paren -- cgit From f3d7eeff7736b10e43b52016fe9de5daa000a585 Mon Sep 17 00:00:00 2001 From: quinoa42 Date: Sat, 30 Sep 2017 16:08:32 -0700 Subject: health.vim: Try `pyenv root` #7341 --- runtime/autoload/health/provider.vim | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'runtime') diff --git a/runtime/autoload/health/provider.vim b/runtime/autoload/health/provider.vim index 205a23dcbd..fbd8d50f1b 100644 --- a/runtime/autoload/health/provider.vim +++ b/runtime/autoload/health/provider.vim @@ -253,14 +253,18 @@ function! s:check_python(version) abort if !empty(pyenv) if empty(pyenv_root) - call health#report_warn( - \ 'pyenv was found, but $PYENV_ROOT is not set.', - \ ['Did you follow the final install instructions?', - \ 'If you use a shell "framework" like Prezto or Oh My Zsh, try without.', - \ 'Try a different shell (bash).'] + call health#report_info( + \ 'pyenv was found, but $PYENV_ROOT is not set. `pyenv root` will be used.' + \ .' If you run into problems, try setting $PYENV_ROOT explicitly.' \ ) + let pyenv_root = s:trim(s:system([pyenv, 'root'])) + endif + + if !isdirectory(pyenv_root) + call health#report_error('Invalid pyenv root: '.pyenv_root) else - call health#report_ok(printf('pyenv found: "%s"', pyenv)) + call health#report_info(printf('pyenv: %s', pyenv)) + call health#report_info(printf('pyenv root: %s', pyenv_root)) endif endif -- cgit From 2851bb9effafda599e21e3b639e99c636ce70ba6 Mon Sep 17 00:00:00 2001 From: Alex Genco Date: Sun, 17 Dec 2017 08:47:52 -0800 Subject: health.vim: mention g:ruby_host_prog #7737 --- runtime/autoload/health/provider.vim | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'runtime') diff --git a/runtime/autoload/health/provider.vim b/runtime/autoload/health/provider.vim index fbd8d50f1b..39e592c471 100644 --- a/runtime/autoload/health/provider.vim +++ b/runtime/autoload/health/provider.vim @@ -455,10 +455,11 @@ function! s:check_ruby() abort let host = provider#ruby#Detect() if empty(host) - call health#report_warn('Missing "neovim" gem.', - \ ['Run in shell: gem install neovim', - \ 'Is the gem bin directory in $PATH? Check `gem environment`.', - \ 'If you are using rvm/rbenv/chruby, try "rehashing".']) + call health#report_warn("`neovim-ruby-host` not found.", + \ ['Run `gem install neovim` to ensure the neovim RubyGem is installed.', + \ 'Run `gem environment` to ensure the gem bin directory is in $PATH.', + \ 'If you are using rvm/rbenv/chruby, try "rehashing".', + \ 'See :help g:ruby_host_prog for non-standard gem installations.']) return endif call health#report_info('Host: '. host) -- cgit From cca6d4b2674304d544b3880a616fd2ca7df2b891 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Mon, 18 Dec 2017 01:48:30 +0100 Subject: provider/nodejs: more robust version-check (#7738) --- runtime/autoload/provider/node.vim | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'runtime') diff --git a/runtime/autoload/provider/node.vim b/runtime/autoload/provider/node.vim index f75d2632be..4e737fb51c 100644 --- a/runtime/autoload/provider/node.vim +++ b/runtime/autoload/provider/node.vim @@ -6,15 +6,18 @@ let g:loaded_node_provider = 1 let s:job_opts = {'rpc': v:true, 'on_stderr': function('provider#stderr_collector')} function! s:is_minimum_version(version, min_major, min_minor) abort - let nodejs_version = a:version - if !a:version + if empty(a:version) let nodejs_version = get(split(system(['node', '-v']), "\n"), 0, '') if v:shell_error || nodejs_version[0] !=# 'v' return 0 endif + else + let nodejs_version = a:version endif + " Remove surrounding junk. Example: 'v4.12.0' => '4.12.0' + let nodejs_version = matchstr(nodejs_version, '\(\d\.\?\)\+') " [major, minor, patch] - let v_list = !!a:version ? a:version : split(nodejs_version[1:], '\.') + let v_list = split(nodejs_version, '\.') return len(v_list) == 3 \ && ((str2nr(v_list[0]) > str2nr(a:min_major)) \ || (str2nr(v_list[0]) == str2nr(a:min_major) -- cgit From fb8592b7ba673f230f144dc8c29e5dffc33fc50a Mon Sep 17 00:00:00 2001 From: James McCoy Date: Mon, 18 Dec 2017 14:26:49 -0500 Subject: vim-patch:8.0.0517: there is no way to remove quickfix lists Problem: There is no way to remove quickfix lists (for testing). Solution: Add the 'f' action to setqflist(). Add tests. (Yegappan Lakshmanan) https://github.com/vim/vim/commit/b6fa30ccc39cdb7f1d07b99fe2f4c6b61671dac2 --- runtime/doc/eval.txt | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) (limited to 'runtime') diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt index e337c5d6d5..efc8775d0a 100644 --- a/runtime/doc/eval.txt +++ b/runtime/doc/eval.txt @@ -6855,16 +6855,19 @@ setqflist({list} [, {action}[, {what}]]) *setqflist()* Note that the list is not exactly the same as what |getqflist()| returns. - *E927* - If {action} is set to 'a', then the items from {list} are - added to the existing quickfix list. If there is no existing - list, then a new list is created. + {action} values: *E927* + 'a' The items from {list} are added to the existing + quickfix list. If there is no existing list, then a + new list is created. - If {action} is set to 'r', then the items from the current - quickfix list are replaced with the items from {list}. This - can also be used to clear the list: > - :call setqflist([], 'r') + 'r' The items from the current quickfix list are replaced + with the items from {list}. This can also be used to + clear the list: > + :call setqflist([], 'r') < + 'f' All the quickfix lists in the quickfix stack are + freed. + If {action} is not present or is set to ' ', then a new list is created. -- cgit From 4d2d844c12e1a94a5d3cbe93794bb04ef6fb8377 Mon Sep 17 00:00:00 2001 From: James McCoy Date: Mon, 18 Dec 2017 21:40:34 -0500 Subject: vim-patch:8.0.0580: cannot set the valid flag with setqflist() Problem: Cannot set the valid flag with setqflist(). Solution: Add the "valid" argument. (Yegappan Lakshmanan, closes vim/vim#1642) https://github.com/vim/vim/commit/f1d21c8cc83f40c815b6bf13cd2043152db533ee --- runtime/doc/eval.txt | 3 +++ 1 file changed, 3 insertions(+) (limited to 'runtime') diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt index efc8775d0a..0b50340dee 100644 --- a/runtime/doc/eval.txt +++ b/runtime/doc/eval.txt @@ -6841,6 +6841,7 @@ setqflist({list} [, {action}[, {what}]]) *setqflist()* nr error number text description of the error type single-character error type, 'E', 'W', etc. + valid recognized error message The "col", "vcol", "nr", "type" and "text" entries are optional. Either "lnum" or "pattern" entry can be used to @@ -6850,6 +6851,8 @@ setqflist({list} [, {action}[, {what}]]) *setqflist()* item will not be handled as an error line. If both "pattern" and "lnum" are present then "pattern" will be used. + If the "valid" entry is not supplied, then the valid flag is + set when "bufnr" is a valid buffer or "filename" exists. If you supply an empty {list}, the quickfix list will be cleared. Note that the list is not exactly the same as what -- cgit From 308dd53783314103710a37c9809eddb78279eab4 Mon Sep 17 00:00:00 2001 From: Björn Linse Date: Mon, 27 Nov 2017 13:01:49 +0100 Subject: channel: check for existance before trying to set key This avoids an error message in async context, where it is not safe. --- runtime/doc/channel.txt | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'runtime') diff --git a/runtime/doc/channel.txt b/runtime/doc/channel.txt index c94c64eb84..c4f7eb1ff1 100644 --- a/runtime/doc/channel.txt +++ b/runtime/doc/channel.txt @@ -43,7 +43,7 @@ bytes. Additionally, for a job channel using rpc, bytes can still be read over its stderr. Similarily, only bytes can be written to nvim's own stderr. *channel-callback* *buffered* - *on_stdout* *on_stderr* *on_stdin* *on_data* + *E5210* *on_stdout* *on_stderr* *on_stdin* *on_data* A callback function `on_{stream}` will be invoked with data read from the channel. By default, the callback will be invoked immediately when data is available, to facilitate interactive communication. The same callback will @@ -52,7 +52,11 @@ Alternatively the `{stream}_buffered` option can be set to invoke the callback only when the underlying stream reaches EOF, and will then be passed in complete output. This is helpful when only the complete output is useful, and not partial data. Futhermore if `{stream}_buffered` is set but not a callback, -the data is saved in the options dict, with the stream name as key. +the data is saved in the options dict, with the stream name as key. For this +to work a new options dict must be used for each opened channel. If a script +uses a global `s:job_opts` dict, it can be copied with |copy()| before supplying +it to |jobstart()|. If a dict is reused, so that the dict key already is +occupied, error `E5210` will be raised. - The arguments passed to the callback function are: -- cgit From 61ba3c5e31bf5bf491046098e4d9922dd6c3c082 Mon Sep 17 00:00:00 2001 From: Björn Linse Date: Sat, 25 Nov 2017 10:37:41 +0100 Subject: provider: delete vimL stderr collector, now that it exists builtin --- runtime/autoload/provider.vim | 20 -------------------- runtime/autoload/provider/clipboard.vim | 13 ++++++------- runtime/autoload/provider/node.vim | 9 ++++----- runtime/autoload/provider/pythonx.vim | 9 ++++----- 4 files changed, 14 insertions(+), 37 deletions(-) delete mode 100644 runtime/autoload/provider.vim (limited to 'runtime') diff --git a/runtime/autoload/provider.vim b/runtime/autoload/provider.vim deleted file mode 100644 index e6514f5ba8..0000000000 --- a/runtime/autoload/provider.vim +++ /dev/null @@ -1,20 +0,0 @@ -" Common functionality for providers - -let s:stderr = {} - -function! provider#stderr_collector(chan_id, data, event) - let stderr = get(s:stderr, a:chan_id, ['']) - let stderr[-1] .= a:data[0] - call extend(stderr, a:data[1:]) - let s:stderr[a:chan_id] = stderr -endfunction - -function! provider#clear_stderr(chan_id) - if has_key(s:stderr, a:chan_id) - call remove(s:stderr, a:chan_id) - endif -endfunction - -function! provider#get_stderr(chan_id) - return get(s:stderr, a:chan_id, []) -endfunction diff --git a/runtime/autoload/provider/clipboard.vim b/runtime/autoload/provider/clipboard.vim index 6454a01c2a..e5a6e4748a 100644 --- a/runtime/autoload/provider/clipboard.vim +++ b/runtime/autoload/provider/clipboard.vim @@ -7,7 +7,7 @@ let s:clipboard = {} " When caching is enabled, store the jobid of the xclip/xsel process keeping " ownership of the selection, so we know how long the cache is valid. -let s:selection = { 'owner': 0, 'data': [], 'on_stderr': function('provider#stderr_collector') } +let s:selection = { 'owner': 0, 'data': [], 'stderr_buffered': v:true } function! s:selection.on_exit(jobid, data, event) abort " At this point this nvim instance might already have launched @@ -16,12 +16,10 @@ function! s:selection.on_exit(jobid, data, event) abort let self.owner = 0 endif if a:data != 0 - let stderr = provider#get_stderr(a:jobid) echohl WarningMsg - echomsg 'clipboard: error invoking '.get(self.argv, 0, '?').': '.join(stderr) + echomsg 'clipboard: error invoking '.get(self.argv, 0, '?').': '.join(self.stderr) echohl None endif - call provider#clear_stderr(a:jobid) endfunction let s:selections = { '*': s:selection, '+': copy(s:selection) } @@ -142,12 +140,13 @@ function! s:clipboard.set(lines, regtype, reg) abort return 0 end - let selection = s:selections[a:reg] - if selection.owner > 0 + if s:selections[a:reg].owner > 0 " The previous provider instance should exit when the new one takes " ownership, but kill it to be sure we don't fill up the job table. - call jobstop(selection.owner) + call jobstop(s:selections[a:reg].owner) end + let s:selections[a:reg] = copy(s:selection) + let selection = s:selections[a:reg] let selection.data = [a:lines, a:regtype] let argv = split(s:copy[a:reg], " ") let selection.argv = argv diff --git a/runtime/autoload/provider/node.vim b/runtime/autoload/provider/node.vim index 4e737fb51c..adcc926074 100644 --- a/runtime/autoload/provider/node.vim +++ b/runtime/autoload/provider/node.vim @@ -3,7 +3,7 @@ if exists('g:loaded_node_provider') endif let g:loaded_node_provider = 1 -let s:job_opts = {'rpc': v:true, 'on_stderr': function('provider#stderr_collector')} +let s:job_opts = {'rpc': v:true, 'stderr_buffered': v:true} function! s:is_minimum_version(version, min_major, min_minor) abort if empty(a:version) @@ -73,19 +73,18 @@ function! provider#node#Require(host) abort call add(args, provider#node#Prog()) try - let channel_id = jobstart(args, s:job_opts) + let job = copy(s:job_opts) + let channel_id = jobstart(args, job) if rpcrequest(channel_id, 'poll') ==# 'ok' return channel_id endif catch echomsg v:throwpoint echomsg v:exception - for row in provider#get_stderr(channel_id) + for row in job.stderr echomsg row endfor endtry - finally - call provider#clear_stderr(channel_id) endtry throw remote#host#LoadErrorForHost(a:host.orig_name, '$NVIM_NODE_LOG_FILE') endfunction diff --git a/runtime/autoload/provider/pythonx.vim b/runtime/autoload/provider/pythonx.vim index 7285ed43ea..1c77eabe23 100644 --- a/runtime/autoload/provider/pythonx.vim +++ b/runtime/autoload/provider/pythonx.vim @@ -5,7 +5,7 @@ endif let s:loaded_pythonx_provider = 1 -let s:job_opts = {'rpc': v:true, 'on_stderr': function('provider#stderr_collector')} +let s:job_opts = {'rpc': v:true, 'stderr_buffered': v:true} function! provider#pythonx#Require(host) abort let ver = (a:host.orig_name ==# 'python') ? 2 : 3 @@ -21,18 +21,17 @@ function! provider#pythonx#Require(host) abort endfor try - let channel_id = jobstart(args, s:job_opts) + let job = copy(s:job_opts) + let channel_id = jobstart(args, job) if rpcrequest(channel_id, 'poll') ==# 'ok' return channel_id endif catch echomsg v:throwpoint echomsg v:exception - for row in provider#get_stderr(channel_id) + for row in job.stderr echomsg row endfor - finally - call provider#clear_stderr(channel_id) endtry throw remote#host#LoadErrorForHost(a:host.orig_name, \ '$NVIM_PYTHON_LOG_FILE') -- cgit From fe60fa9faafd90cfe756c80119abae6f8906fc4b Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Sat, 16 Dec 2017 21:33:59 +0100 Subject: doc vim-patch:8.0.1206: no autocmd for entering or leaving the command line (commit a4f6cec7a31ff8dbfa089b9e22227afbeb951e9b) NA patches: vim-patch:8.0.0320: warning for unused variable with small build --- runtime/autoload/health/nvim.vim | 2 +- runtime/doc/api.txt | 44 ++++++++++++++++++++-------------------- runtime/doc/channel.txt | 4 ++-- runtime/doc/develop.txt | 6 +++--- runtime/doc/vim_diff.txt | 1 + 5 files changed, 29 insertions(+), 28 deletions(-) (limited to 'runtime') diff --git a/runtime/autoload/health/nvim.vim b/runtime/autoload/health/nvim.vim index 58033f0405..017c047ef4 100644 --- a/runtime/autoload/health/nvim.vim +++ b/runtime/autoload/health/nvim.vim @@ -174,7 +174,7 @@ function! s:check_terminal() abort \ .(empty(kbs_entry) ? '? (not found)' : kdch1_entry)) endif for env_var in ['XTERM_VERSION', 'VTE_VERSION', 'TERM_PROGRAM', 'COLORTERM', 'SSH_TTY'] - if !exists('$'.env_var) + if exists('$'.env_var) call health#report_info(printf("$%s='%s'", env_var, eval('$'.env_var))) endif endfor diff --git a/runtime/doc/api.txt b/runtime/doc/api.txt index 6c2a3a8632..fd6918de43 100644 --- a/runtime/doc/api.txt +++ b/runtime/doc/api.txt @@ -512,27 +512,27 @@ nvim_parse_expression({expr}, {flags}, {highlight}) [start_col, end_col)). Return:~ - AST: top-level dictionary holds keys "error": Dictionary - with error, present only if parser saw some error. - Contains the following keys: "message": String, error - message in printf format, translated. Must contain exactly - one "%.*s". "arg": String, error message argument. "len": - Amount of bytes successfully parsed. With flags equal to - "" that should be equal to the length of expr string. - @note: “Sucessfully parsed” here means “participated in - AST creation”, not “till the first error”. "ast": AST, - either nil or a dictionary with these keys: "type": node - type, one of the value names from ExprASTNodeType - stringified without "kExprNode" prefix. "start": a pair - [line, column] describing where node is “started” where - "line" is always 0 (will not be 0 if you will be using - nvim_parse_viml() on e.g. ":let", but that is not present - yet). Both elements are Integers. "len": “length” of the - node. This and "start" are there for debugging purposes - primary (debugging parser and providing debug - information). "children": a list of nodes described in - top/"ast". There always is zero, one or two children, key - will not be present if node has no children. Maximum + AST: top-level dictionary with these keys: "error": + Dictionary with error, present only if parser saw some + error. Contains the following keys: "message": String, + error message in printf format, translated. Must contain + exactly one "%.*s". "arg": String, error message argument. + "len": Amount of bytes successfully parsed. With flags + equal to "" that should be equal to the length of expr + string. @note: “Sucessfully parsed” here means + “participated in AST creation”, not “till the first + error”. "ast": AST, either nil or a dictionary with these + keys: "type": node type, one of the value names from + ExprASTNodeType stringified without "kExprNode" prefix. + "start": a pair [line, column] describing where node is + “started” where "line" is always 0 (will not be 0 if you + will be using nvim_parse_viml() on e.g. ":let", but that + is not present yet). Both elements are Integers. "len": + “length” of the node. This and "start" are there for + debugging purposes primary (debugging parser and providing + debug information). "children": a list of nodes described + in top/"ast". There always is zero, one or two children, + key will not be present if node has no children. Maximum number of children may be found in node_maxchildren array. Local values (present only for certain nodes): "scope": a single Integer, specifies scope for "Option" and @@ -1047,4 +1047,4 @@ nvim_ui_try_resize({width}, {height}) *nvim_ui_try_resize()* nvim_ui_set_option({name}, {value}) *nvim_ui_set_option()* TODO: Documentation - vim:tw=78:ts=8:ft=help:norl: \ No newline at end of file + vim:tw=78:ts=8:ft=help:norl: diff --git a/runtime/doc/channel.txt b/runtime/doc/channel.txt index c4f7eb1ff1..eb2bac6fce 100644 --- a/runtime/doc/channel.txt +++ b/runtime/doc/channel.txt @@ -4,9 +4,9 @@ NVIM REFERENCE MANUAL by Thiago de Arruda -Nvim's facilities for async io *channel* +Nvim asynchronous IO *channel* - Type to see the table of contents. + Type |gO| to see the table of contents. ============================================================================== 1. Introduction *channel-intro* diff --git a/runtime/doc/develop.txt b/runtime/doc/develop.txt index 36826e2479..4e77f40035 100644 --- a/runtime/doc/develop.txt +++ b/runtime/doc/develop.txt @@ -270,9 +270,9 @@ External UIs are expected to implement these common features: - Send the "super" key (Windows key, Apple key) as a | - autocmd OptionSet guifont call rpcnotify(42, 'option-changed', 'guifont', &guifont) +- UI-related options ('guifont', 'ambiwidth', …) are published in the + "option_set" |ui-global| event. The event is triggered when the UI first + connects to Nvim and whenever an option is changed by the user or a plugin. vim:tw=78:ts=8:ft=help:norl: diff --git a/runtime/doc/vim_diff.txt b/runtime/doc/vim_diff.txt index 7061f01316..9643777975 100644 --- a/runtime/doc/vim_diff.txt +++ b/runtime/doc/vim_diff.txt @@ -70,6 +70,7 @@ Providers Ruby plugins |provider-ruby| Shared data |shada| Embedded terminal |terminal| +VimL parser |nvim_parse_expression()| XDG base directories |xdg| USER EXPERIENCE ~ -- cgit From 341102fe9f26e3f4207f14e097348d3bd6831b0d Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Wed, 27 Dec 2017 13:00:58 +0100 Subject: health.vim: remove :CheckHealth command For back-compat, :CheckHealth runs :checkhealth. But don't define :CheckHealth explicitly, it adds noise to wildmenu completion. Completion of healthchecks doesn't yet work with :checkhealth, this is a regression but it needs to be implemented for :checkhealth rather than keeping :CheckHealth around. --- runtime/autoload/provider/node.vim | 2 +- runtime/plugin/health.vim | 9 +-------- 2 files changed, 2 insertions(+), 9 deletions(-) (limited to 'runtime') diff --git a/runtime/autoload/provider/node.vim b/runtime/autoload/provider/node.vim index adcc926074..3dde18022e 100644 --- a/runtime/autoload/provider/node.vim +++ b/runtime/autoload/provider/node.vim @@ -114,7 +114,7 @@ let s:err = '' let s:prog = provider#node#Detect() if empty(s:prog) - let s:err = 'Cannot find the "neovim" node package. Try :CheckHealth' + let s:err = 'Cannot find the "neovim" node package. Try :checkhealth' endif call remote#host#RegisterPlugin('node-provider', 'node', []) diff --git a/runtime/plugin/health.vim b/runtime/plugin/health.vim index e3482cb0fe..66ae8fb239 100644 --- a/runtime/plugin/health.vim +++ b/runtime/plugin/health.vim @@ -1,8 +1 @@ -function! s:complete(lead, _line, _pos) abort - return sort(filter(map(globpath(&runtimepath, 'autoload/health/*', 1, 1), - \ 'fnamemodify(v:val, ":t:r")'), - \ 'empty(a:lead) || v:val[:strlen(a:lead)-1] ==# a:lead')) -endfunction - -command! -nargs=* -complete=customlist,s:complete CheckHealth - \ call health#check([]) +autocmd CmdUndefined CheckHealth checkhealth -- cgit From 2f3e00171749c5fddc2b76d080d2bb26f1765405 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Wed, 27 Dec 2017 13:53:01 +0100 Subject: health.vim: minor refactor (group related logic) --- runtime/autoload/health/provider.vim | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'runtime') diff --git a/runtime/autoload/health/provider.vim b/runtime/autoload/health/provider.vim index 39e592c471..83dee043a0 100644 --- a/runtime/autoload/health/provider.vim +++ b/runtime/autoload/health/provider.vim @@ -370,10 +370,11 @@ function! s:check_python(version) abort let python_bin = '' endif - " Check if $VIRTUAL_ENV is active - let virtualenv_inactive = 0 + " Check if $VIRTUAL_ENV is active. if exists('$VIRTUAL_ENV') + let virtualenv_inactive = 0 + if !empty(pyenv) let pyenv_prefix = resolve(s:trim(s:system([pyenv, 'prefix']))) if $VIRTUAL_ENV != pyenv_prefix @@ -382,13 +383,13 @@ function! s:check_python(version) abort elseif !empty(pyname) && exepath(pyname) !~# '^'.$VIRTUAL_ENV.'/' let virtualenv_inactive = 1 endif - endif - if virtualenv_inactive - call health#report_warn( - \ '$VIRTUAL_ENV exists but appears to be inactive. ' - \ . 'This could lead to unexpected results.', - \ [ 'If you are using Zsh, see: http://vi.stackexchange.com/a/7654/5229' ]) + if virtualenv_inactive + call health#report_warn( + \ '$VIRTUAL_ENV exists but appears to be inactive. ' + \ . 'This could lead to unexpected results.', + \ [ 'If you are using Zsh, see: http://vi.stackexchange.com/a/7654' ]) + endif endif " Diagnostic output -- cgit From 0446d4d6916d27041de5ac24ba0c741ae4ad5a39 Mon Sep 17 00:00:00 2001 From: Gabriel Holodak Date: Fri, 10 Nov 2017 23:27:00 -0500 Subject: Highlight backspaced characters --- runtime/autoload/man.vim | 57 +++++++++++++++++++++++++++++++++++++++++++----- runtime/syntax/man.vim | 12 ++++++++++ 2 files changed, 64 insertions(+), 5 deletions(-) (limited to 'runtime') diff --git a/runtime/autoload/man.vim b/runtime/autoload/man.vim index dd71ede680..3ea0b734c0 100644 --- a/runtime/autoload/man.vim +++ b/runtime/autoload/man.vim @@ -148,7 +148,8 @@ function! s:get_page(path) abort let manwidth = empty($MANWIDTH) ? winwidth(0) : $MANWIDTH " Force MANPAGER=cat to ensure Vim is not recursively invoked (by man-db). " http://comments.gmane.org/gmane.editors.vim.devel/29085 - let cmd = ['env', 'MANPAGER=cat', 'MANWIDTH='.manwidth, 'man'] + " Set MAN_KEEP_FORMATTING so Debian man doesn't discard backspaces. + let cmd = ['env', 'MANPAGER=cat', 'MANWIDTH='.manwidth, 'MAN_KEEP_FORMATTING=1', 'man'] return s:system(cmd + (s:localfile_arg ? ['-l', a:path] : [a:path])) endfunction @@ -157,11 +158,10 @@ function! s:put_page(page) abort setlocal noreadonly silent keepjumps %delete _ silent put =a:page - " Remove all backspaced/escape characters. - execute 'silent keeppatterns keepjumps %substitute,.\b\|\e\[\d\+m,,e'.(&gdefault?'':'g') while getline(1) =~# '^\s*$' silent keepjumps 1delete _ endwhile + call man#highlight_backspaced_text() setlocal filetype=man endfunction @@ -370,13 +370,12 @@ function! s:format_candidate(path, psect) abort endfunction function! man#init_pager() abort - " Remove all backspaced/escape characters. - execute 'silent keeppatterns keepjumps %substitute,.\b\|\e\[\d\+m,,e'.(&gdefault?'':'g') if getline(1) =~# '^\s*$' silent keepjumps 1delete _ else keepjumps 1 endif + call man#highlight_backspaced_text() " This is not perfect. See `man glDrawArraysInstanced`. Since the title is " all caps it is impossible to tell what the original capitilization was. let ref = substitute(matchstr(getline(1), '^[^)]\+)'), ' ', '_', 'g') @@ -388,4 +387,52 @@ function! man#init_pager() abort execute 'silent file man://'.fnameescape(ref) endfunction +function! man#highlight_backspaced_text() abort + let l:modifiable = &modifiable + set modifiable + + let l:lines = getline(1, line('$')) + call map(l:lines, function('s:highlight_backspaced_line')) + call setline(1, l:lines) + + let &modifiable = l:modifiable +endfunction + +" This pattern is for "overstruck" text containing backspaces. It matches bold +" text first, so a word beginning with "_^H_" is bold and text such as +" "_^Hf_^Ho_^Ho_^H__^Hb_^Ha_^Hr" is entirely underlined. +" +" Bolded text can also be mixed with whitespace as a performance tweak, since +" it's visually identical. +let s:backspace_pattern = '\v%((.)\b\1\s*)+|%(_\b.)+' + +function! s:highlight_backspaced_line(index, val) abort + let l:line = a:val + let l:search_pos = 0 + + while 1 + " Scanning for the next backspace without matching the entire pattern is + " slightly faster + let l:match_start = stridx(l:line, "\b", l:search_pos) + if l:match_start == -1 + break + endif + + let l:match = matchstrpos(l:line, s:backspace_pattern, l:match_start - 1) + if l:match[0] =~# '^_\b[^_]' + let l:hlgroup = 'manUnderline' + else + let l:hlgroup = 'manBold' + endif + + let l:stripped = substitute(l:match[0], '.\b', '', 'g') + let l:search_pos = l:match[1] + len(l:stripped) + let l:line = strpart(l:line, 0, l:match[1]) . l:stripped . strpart(l:line, l:match[2]) + + call nvim_buf_add_highlight(0, -1, l:hlgroup, a:index, l:match[1], l:search_pos) + endwhile + + return l:line +endfunction + call s:init() diff --git a/runtime/syntax/man.vim b/runtime/syntax/man.vim index 0975b160ae..9eb613169c 100644 --- a/runtime/syntax/man.vim +++ b/runtime/syntax/man.vim @@ -18,6 +18,18 @@ highlight default link manOptionDesc Constant highlight default link manReference PreProc highlight default link manSubHeading Function +function! s:init_highlight_groups() + highlight default manUnderline cterm=underline gui=underline + highlight default manBold cterm=bold gui=bold +endfunction + +augroup man_init_highlight_groups + autocmd! + autocmd ColorScheme * call s:init_highlight_groups() +augroup END + +call s:init_highlight_groups() + if &filetype != 'man' " May have been included by some other filetype. finish -- cgit From c28ce5f6191d233228d1688de300727e1ae42831 Mon Sep 17 00:00:00 2001 From: Gabriel Holodak Date: Mon, 20 Nov 2017 00:19:08 -0500 Subject: Switch to processing in Lua --- runtime/autoload/man.vim | 42 ++------------------------- runtime/lua/man.lua | 75 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 77 insertions(+), 40 deletions(-) create mode 100644 runtime/lua/man.lua (limited to 'runtime') diff --git a/runtime/autoload/man.vim b/runtime/autoload/man.vim index 3ea0b734c0..12c1bf3c86 100644 --- a/runtime/autoload/man.vim +++ b/runtime/autoload/man.vim @@ -391,48 +391,10 @@ function! man#highlight_backspaced_text() abort let l:modifiable = &modifiable set modifiable - let l:lines = getline(1, line('$')) - call map(l:lines, function('s:highlight_backspaced_line')) - call setline(1, l:lines) + lua man = require("man") + luado return man.highlight_backspaced(line, linenr) let &modifiable = l:modifiable endfunction -" This pattern is for "overstruck" text containing backspaces. It matches bold -" text first, so a word beginning with "_^H_" is bold and text such as -" "_^Hf_^Ho_^Ho_^H__^Hb_^Ha_^Hr" is entirely underlined. -" -" Bolded text can also be mixed with whitespace as a performance tweak, since -" it's visually identical. -let s:backspace_pattern = '\v%((.)\b\1\s*)+|%(_\b.)+' - -function! s:highlight_backspaced_line(index, val) abort - let l:line = a:val - let l:search_pos = 0 - - while 1 - " Scanning for the next backspace without matching the entire pattern is - " slightly faster - let l:match_start = stridx(l:line, "\b", l:search_pos) - if l:match_start == -1 - break - endif - - let l:match = matchstrpos(l:line, s:backspace_pattern, l:match_start - 1) - if l:match[0] =~# '^_\b[^_]' - let l:hlgroup = 'manUnderline' - else - let l:hlgroup = 'manBold' - endif - - let l:stripped = substitute(l:match[0], '.\b', '', 'g') - let l:search_pos = l:match[1] + len(l:stripped) - let l:line = strpart(l:line, 0, l:match[1]) . l:stripped . strpart(l:line, l:match[2]) - - call nvim_buf_add_highlight(0, -1, l:hlgroup, a:index, l:match[1], l:search_pos) - endwhile - - return l:line -endfunction - call s:init() diff --git a/runtime/lua/man.lua b/runtime/lua/man.lua new file mode 100644 index 0000000000..63c2c14480 --- /dev/null +++ b/runtime/lua/man.lua @@ -0,0 +1,75 @@ +local function highlight_backspaced(line, linenr) + local chars = {} + local prev_char = '' + local overstrike = false + local hls = {} -- Store highlight groups as { attr, start, end } + local NONE, BOLD, UNDERLINE = 0, 1, 2 + local attr = NONE + local byte = 0 -- byte offset + + -- Break input into UTF8 characters + for char in line:gmatch("[^\128-\191][\128-\191]*") do + if overstrike then + local last_hl = hls[#hls] + if char == prev_char then + if char == '_' and attr == UNDERLINE and last_hl and last_hl[3] == byte then + -- This underscore is in the middle of an underlined word + attr = UNDERLINE + else + attr = BOLD + end + elseif prev_char == '_' then + -- char is underlined + attr = UNDERLINE + elseif prev_char == '+' and char == 'o' then + -- bullet (overstrike text '+^Ho') + attr = BOLD + char = [[·]] + elseif prev_char == [[·]] and char == 'o' then + -- bullet (additional handling for '+^H+^Ho^Ho') + attr = BOLD + char = [[·]] + else + -- use plain char + attr = NONE + end + + -- Grow the previous highlight group if possible + if last_hl and last_hl[1] == attr and last_hl[3] == byte then + last_hl[3] = byte + #char + else + hls[#hls + 1] = {attr, byte, byte + #char} + end + + overstrike = false + prev_char = '' + byte = byte + #char + chars[#chars + 1] = char + elseif char == "\b" then + overstrike = true + prev_char = chars[#chars] + byte = byte - #prev_char + chars[#chars] = nil + else + byte = byte + #char + chars[#chars + 1] = char + end + end + + for i, hl in ipairs(hls) do + if hl[1] ~= NONE then + vim.api.nvim_buf_add_highlight( + 0, + -1, + hl[1] == BOLD and "manBold" or "manUnderline", + linenr - 1, + hl[2], + hl[3] + ) + end + end + + return table.concat(chars, '') +end + +return { highlight_backspaced = highlight_backspaced } -- cgit From 6740c94562cc1b271a6ea2458ebb847a6e3665e2 Mon Sep 17 00:00:00 2001 From: Gabriel Holodak Date: Thu, 30 Nov 2017 22:15:39 -0500 Subject: Add support for escape sequences --- runtime/autoload/man.vim | 8 ++--- runtime/lua/man.lua | 76 ++++++++++++++++++++++++++++++++++++++++++++---- runtime/syntax/man.vim | 1 + 3 files changed, 76 insertions(+), 9 deletions(-) (limited to 'runtime') diff --git a/runtime/autoload/man.vim b/runtime/autoload/man.vim index 12c1bf3c86..0a502be4c7 100644 --- a/runtime/autoload/man.vim +++ b/runtime/autoload/man.vim @@ -161,7 +161,7 @@ function! s:put_page(page) abort while getline(1) =~# '^\s*$' silent keepjumps 1delete _ endwhile - call man#highlight_backspaced_text() + call man#highlight_formatted_text() setlocal filetype=man endfunction @@ -375,7 +375,7 @@ function! man#init_pager() abort else keepjumps 1 endif - call man#highlight_backspaced_text() + call man#highlight_formatted_text() " This is not perfect. See `man glDrawArraysInstanced`. Since the title is " all caps it is impossible to tell what the original capitilization was. let ref = substitute(matchstr(getline(1), '^[^)]\+)'), ' ', '_', 'g') @@ -387,12 +387,12 @@ function! man#init_pager() abort execute 'silent file man://'.fnameescape(ref) endfunction -function! man#highlight_backspaced_text() abort +function! man#highlight_formatted_text() abort let l:modifiable = &modifiable set modifiable lua man = require("man") - luado return man.highlight_backspaced(line, linenr) + luado return man.highlight_formatted(line, linenr) let &modifiable = l:modifiable endfunction diff --git a/runtime/lua/man.lua b/runtime/lua/man.lua index 63c2c14480..c3d7df2a2a 100644 --- a/runtime/lua/man.lua +++ b/runtime/lua/man.lua @@ -1,12 +1,60 @@ -local function highlight_backspaced(line, linenr) +local function highlight_formatted(line, linenr) local chars = {} local prev_char = '' - local overstrike = false + local overstrike, escape = false, false local hls = {} -- Store highlight groups as { attr, start, end } - local NONE, BOLD, UNDERLINE = 0, 1, 2 + local NONE, BOLD, UNDERLINE, ITALIC = 0, 1, 2, 3 + local hl_groups = {[BOLD]="manBold", [UNDERLINE]="manUnderline", [ITALIC]="manItalic"} local attr = NONE local byte = 0 -- byte offset + local function end_attr_hl(attr) + for i, hl in ipairs(hls) do + if hl[1] == attr and hl[3] == -1 then + hl[3] = byte + hls[i] = hl + end + end + end + + local function add_attr_hl(code) + local on = true + if code == 0 then + attr = NONE + on = false + elseif code == 1 then + attr = BOLD + elseif code == 21 or code == 22 then + attr = BOLD + on = false + elseif code == 3 then + attr = ITALIC + elseif code == 23 then + attr = ITALIC + on = false + elseif code == 4 then + attr = UNDERLINE + elseif code == 24 then + attr = UNDERLINE + on = false + else + attr = NONE + return + end + + if on then + hls[#hls + 1] = {attr, byte, -1} + else + if attr == NONE then + for a, _ in pairs(hl_groups) do + end_attr_hl(a) + end + else + end_attr_hl(attr) + end + end + end + -- Break input into UTF8 characters for char in line:gmatch("[^\128-\191][\128-\191]*") do if overstrike then @@ -45,6 +93,24 @@ local function highlight_backspaced(line, linenr) prev_char = '' byte = byte + #char chars[#chars + 1] = char + elseif escape then + -- Use prev_char to store the escape sequence + prev_char = prev_char .. char + local sgr = prev_char:match("^%[([\020-\063]*)m$") + if sgr then + local match = '' + while sgr and #sgr > 0 do + match, sgr = sgr:match("^(%d*);?(.*)") + add_attr_hl(match + 0) -- coerce to number + end + escape = false + elseif not prev_char:match("^%[[\020-\063]*$") then + -- Stop looking if this isn't a partial CSI sequence + escape = false + end + elseif char == "\027" then + escape = true + prev_char = '' elseif char == "\b" then overstrike = true prev_char = chars[#chars] @@ -61,7 +127,7 @@ local function highlight_backspaced(line, linenr) vim.api.nvim_buf_add_highlight( 0, -1, - hl[1] == BOLD and "manBold" or "manUnderline", + hl_groups[hl[1]], linenr - 1, hl[2], hl[3] @@ -72,4 +138,4 @@ local function highlight_backspaced(line, linenr) return table.concat(chars, '') end -return { highlight_backspaced = highlight_backspaced } +return { highlight_formatted = highlight_formatted } diff --git a/runtime/syntax/man.vim b/runtime/syntax/man.vim index 9eb613169c..0544fb29e2 100644 --- a/runtime/syntax/man.vim +++ b/runtime/syntax/man.vim @@ -21,6 +21,7 @@ highlight default link manSubHeading Function function! s:init_highlight_groups() highlight default manUnderline cterm=underline gui=underline highlight default manBold cterm=bold gui=bold + highlight default manItalic cterm=italic gui=italic endfunction augroup man_init_highlight_groups -- cgit From eb44519b5debf740f692bb4ea19ad83b29749484 Mon Sep 17 00:00:00 2001 From: Gabriel Holodak Date: Sun, 24 Dec 2017 12:16:58 -0500 Subject: Address PR comments --- runtime/autoload/man.vim | 14 ++------ runtime/lua/man.lua | 87 +++++++++++++++++++++++++++++++----------------- runtime/syntax/man.vim | 15 ++------- 3 files changed, 62 insertions(+), 54 deletions(-) (limited to 'runtime') diff --git a/runtime/autoload/man.vim b/runtime/autoload/man.vim index 0a502be4c7..d20b8c05b0 100644 --- a/runtime/autoload/man.vim +++ b/runtime/autoload/man.vim @@ -161,7 +161,7 @@ function! s:put_page(page) abort while getline(1) =~# '^\s*$' silent keepjumps 1delete _ endwhile - call man#highlight_formatted_text() + lua require("man").highlight_man_page() setlocal filetype=man endfunction @@ -375,7 +375,7 @@ function! man#init_pager() abort else keepjumps 1 endif - call man#highlight_formatted_text() + lua require("man").highlight_man_page() " This is not perfect. See `man glDrawArraysInstanced`. Since the title is " all caps it is impossible to tell what the original capitilization was. let ref = substitute(matchstr(getline(1), '^[^)]\+)'), ' ', '_', 'g') @@ -387,14 +387,4 @@ function! man#init_pager() abort execute 'silent file man://'.fnameescape(ref) endfunction -function! man#highlight_formatted_text() abort - let l:modifiable = &modifiable - set modifiable - - lua man = require("man") - luado return man.highlight_formatted(line, linenr) - - let &modifiable = l:modifiable -endfunction - call s:init() diff --git a/runtime/lua/man.lua b/runtime/lua/man.lua index c3d7df2a2a..baa522f343 100644 --- a/runtime/lua/man.lua +++ b/runtime/lua/man.lua @@ -1,8 +1,10 @@ -local function highlight_formatted(line, linenr) +local buf_hls = {} + +local function highlight_line(line, linenr) local chars = {} local prev_char = '' local overstrike, escape = false, false - local hls = {} -- Store highlight groups as { attr, start, end } + local hls = {} -- Store highlight groups as { attr, start, final } local NONE, BOLD, UNDERLINE, ITALIC = 0, 1, 2, 3 local hl_groups = {[BOLD]="manBold", [UNDERLINE]="manUnderline", [ITALIC]="manItalic"} local attr = NONE @@ -10,40 +12,40 @@ local function highlight_formatted(line, linenr) local function end_attr_hl(attr) for i, hl in ipairs(hls) do - if hl[1] == attr and hl[3] == -1 then - hl[3] = byte + if hl.attr == attr and hl.final == -1 then + hl.final = byte hls[i] = hl end end end local function add_attr_hl(code) - local on = true + local continue_hl = true if code == 0 then attr = NONE - on = false + continue_hl = false elseif code == 1 then attr = BOLD - elseif code == 21 or code == 22 then + elseif code == 22 then attr = BOLD - on = false + continue_hl = false elseif code == 3 then attr = ITALIC elseif code == 23 then attr = ITALIC - on = false + continue_hl = false elseif code == 4 then attr = UNDERLINE elseif code == 24 then attr = UNDERLINE - on = false + continue_hl = false else attr = NONE return end - if on then - hls[#hls + 1] = {attr, byte, -1} + if continue_hl then + hls[#hls + 1] = {attr=attr, start=byte, final=-1} else if attr == NONE then for a, _ in pairs(hl_groups) do @@ -55,12 +57,15 @@ local function highlight_formatted(line, linenr) end end - -- Break input into UTF8 characters + -- Break input into UTF8 code points. ASCII code points (from 0x00 to 0x7f) + -- can be represented in one byte. Any code point above that is represented by + -- a leading byte (0xc0 and above) and continuation bytes (0x80 to 0xbf, or + -- decimal 128 to 191). for char in line:gmatch("[^\128-\191][\128-\191]*") do if overstrike then local last_hl = hls[#hls] if char == prev_char then - if char == '_' and attr == UNDERLINE and last_hl and last_hl[3] == byte then + if char == '_' and attr == UNDERLINE and last_hl and last_hl.final == byte then -- This underscore is in the middle of an underlined word attr = UNDERLINE else @@ -72,21 +77,21 @@ local function highlight_formatted(line, linenr) elseif prev_char == '+' and char == 'o' then -- bullet (overstrike text '+^Ho') attr = BOLD - char = [[·]] - elseif prev_char == [[·]] and char == 'o' then + char = '·' + elseif prev_char == '·' and char == 'o' then -- bullet (additional handling for '+^H+^Ho^Ho') attr = BOLD - char = [[·]] + char = '·' else -- use plain char attr = NONE end -- Grow the previous highlight group if possible - if last_hl and last_hl[1] == attr and last_hl[3] == byte then - last_hl[3] = byte + #char + if last_hl and last_hl.attr == attr and last_hl.final == byte then + last_hl.final = byte + #char else - hls[#hls + 1] = {attr, byte, byte + #char} + hls[#hls + 1] = {attr=attr, start=byte, final=byte + #char} end overstrike = false @@ -96,15 +101,19 @@ local function highlight_formatted(line, linenr) elseif escape then -- Use prev_char to store the escape sequence prev_char = prev_char .. char - local sgr = prev_char:match("^%[([\020-\063]*)m$") + -- We only want to match against SGR sequences, which consist of ESC + -- followed by '[', then a series of parameter and intermediate bytes in + -- the range 0x20 - 0x3f, then 'm'. (See ECMA-48, sections 5.4 & 8.3.117) + local sgr = prev_char:match("^%[([\032-\063]*)m$") if sgr then local match = '' while sgr and #sgr > 0 do + -- Match against SGR parameters, which may be separated by ';' match, sgr = sgr:match("^(%d*);?(.*)") add_attr_hl(match + 0) -- coerce to number end escape = false - elseif not prev_char:match("^%[[\020-\063]*$") then + elseif not prev_char:match("^%[[\032-\063]*$") then -- Stop looking if this isn't a partial CSI sequence escape = false end @@ -122,20 +131,38 @@ local function highlight_formatted(line, linenr) end end - for i, hl in ipairs(hls) do - if hl[1] ~= NONE then - vim.api.nvim_buf_add_highlight( + for _, hl in ipairs(hls) do + if hl.attr ~= NONE then + buf_hls[#buf_hls + 1] = { 0, -1, - hl_groups[hl[1]], + hl_groups[hl.attr], linenr - 1, - hl[2], - hl[3] - ) + hl.start, + hl.final + } end end return table.concat(chars, '') end -return { highlight_formatted = highlight_formatted } +local function highlight_man_page() + local mod = vim.api.nvim_eval("&modifiable") + vim.api.nvim_command("set modifiable") + + local lines = vim.api.nvim_buf_get_lines(0, 0, -1, false) + for i, line in ipairs(lines) do + lines[i] = highlight_line(line, i) + end + vim.api.nvim_buf_set_lines(0, 0, -1, false, lines) + + for _, args in ipairs(buf_hls) do + vim.api.nvim_buf_add_highlight(unpack(args)) + end + buf_hls = {} + + vim.api.nvim_command("let &modifiable = "..mod) +end + +return { highlight_man_page = highlight_man_page } diff --git a/runtime/syntax/man.vim b/runtime/syntax/man.vim index 0544fb29e2..b8e605cb9a 100644 --- a/runtime/syntax/man.vim +++ b/runtime/syntax/man.vim @@ -18,18 +18,9 @@ highlight default link manOptionDesc Constant highlight default link manReference PreProc highlight default link manSubHeading Function -function! s:init_highlight_groups() - highlight default manUnderline cterm=underline gui=underline - highlight default manBold cterm=bold gui=bold - highlight default manItalic cterm=italic gui=italic -endfunction - -augroup man_init_highlight_groups - autocmd! - autocmd ColorScheme * call s:init_highlight_groups() -augroup END - -call s:init_highlight_groups() +highlight default manUnderline cterm=underline gui=underline +highlight default manBold cterm=bold gui=bold +highlight default manItalic cterm=italic gui=italic if &filetype != 'man' " May have been included by some other filetype. -- cgit From 5563e808da545fb931f5a7fd7c2d391cfc6e21ca Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Fri, 29 Dec 2017 18:35:05 +0100 Subject: health.vim: fix $VIRTUAL_ENV validation Check that the full path to the python interpreter starts with $VIRTUAL_ENV. closes #7770 --- runtime/autoload/health/provider.vim | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) (limited to 'runtime') diff --git a/runtime/autoload/health/provider.vim b/runtime/autoload/health/provider.vim index 83dee043a0..d1239db605 100644 --- a/runtime/autoload/health/provider.vim +++ b/runtime/autoload/health/provider.vim @@ -370,21 +370,9 @@ function! s:check_python(version) abort let python_bin = '' endif - - " Check if $VIRTUAL_ENV is active. + " Check if $VIRTUAL_ENV is valid. if exists('$VIRTUAL_ENV') - let virtualenv_inactive = 0 - - if !empty(pyenv) - let pyenv_prefix = resolve(s:trim(s:system([pyenv, 'prefix']))) - if $VIRTUAL_ENV != pyenv_prefix - let virtualenv_inactive = 1 - endif - elseif !empty(pyname) && exepath(pyname) !~# '^'.$VIRTUAL_ENV.'/' - let virtualenv_inactive = 1 - endif - - if virtualenv_inactive + if !empty(pyname) && $VIRTUAL_ENV !=# matchstr(exepath(pyname), '^\V'.$VIRTUAL_ENV) call health#report_warn( \ '$VIRTUAL_ENV exists but appears to be inactive. ' \ . 'This could lead to unexpected results.', -- cgit From 3eaa9a2579f5406f80e0d1d67f2e74c5a33c5e18 Mon Sep 17 00:00:00 2001 From: Anmol Sethi Date: Fri, 29 Dec 2017 13:00:10 -0500 Subject: man.vim: always keep the alternate buffer (#7784) Closes #7772 --- runtime/autoload/man.vim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'runtime') diff --git a/runtime/autoload/man.vim b/runtime/autoload/man.vim index dd71ede680..af5c4dbd60 100644 --- a/runtime/autoload/man.vim +++ b/runtime/autoload/man.vim @@ -65,9 +65,9 @@ function! man#open_page(count, count1, mods, ...) abort try set eventignore+=BufReadCmd if a:mods !~# 'tab' && s:find_man() - execute 'silent edit' fnameescape(bufname) + execute 'silent keepalt edit' fnameescape(bufname) else - execute 'silent' a:mods 'split' fnameescape(bufname) + execute 'silent keepalt' a:mods 'split' fnameescape(bufname) endif finally set eventignore-=BufReadCmd -- cgit From 89d1b36084f50acffdc7680212c37383e08787b5 Mon Sep 17 00:00:00 2001 From: James McCoy Date: Sat, 30 Dec 2017 23:30:40 -0500 Subject: vim-patch:8.0.0591: changes to eval functionality not documented Problem: Changes to eval functionality not documented. Solution: Include all the changes. https://github.com/vim/vim/commit/45d2cca1ea3f90fc70ad99d0c6812a9d8536303c --- runtime/doc/eval.txt | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'runtime') diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt index a9474b58a3..2c3d38ced7 100644 --- a/runtime/doc/eval.txt +++ b/runtime/doc/eval.txt @@ -4327,6 +4327,7 @@ getqflist([{what}]) *getqflist()* If the optional {what} dictionary argument is supplied, then returns only the items listed in {what} as a dictionary. The following string items are supported in {what}: + context get the context stored with |setqflist()| nr get information for this quickfix list; zero means the current quickfix list title get the list title @@ -4338,6 +4339,7 @@ getqflist([{what}]) *getqflist()* returned. The returned dictionary contains the following entries: + context context information stored with |setqflist()| nr quickfix list number title quickfix list title text winid quickfix |window-ID| (if opened) @@ -6885,6 +6887,7 @@ setqflist({list} [, {action}[, {what}]]) *setqflist()* only the items listed in {what} are set. The first {list} argument is ignored. The following items can be specified in {what}: + context any Vim type can be stored as a context nr list number in the quickfix stack title quickfix list title text Unsupported keys in {what} are ignored. @@ -10508,18 +10511,19 @@ missing: > To execute a command only when the |+eval| feature is disabled requires a trick, as this example shows: > - if 1 - nnoremap : :" - endif - normal :set history=111 - if 1 - nunmap : - endif + + silent! while 0 + set history=111 + silent! endwhile + +When the |+eval| feature is available the command is skipped because of the +"while 0". Without the |+eval| feature the "while 0" is an error, which is +silently ignored, and the command is executed. The "" here is a real CR character, type CTRL-V Enter to get it. When the |+eval| feature is available the ":" is remapped to add a double -quote, which has the effect of commenting-out the command. without the +quote, which has the effect of commenting-out the command. Without the |+eval| feature the nnoremap command is skipped and the command is executed. ============================================================================== -- cgit From 6742fd8aead06e45f19b59222f96ccdcb1748e4c Mon Sep 17 00:00:00 2001 From: James McCoy Date: Sat, 30 Dec 2017 23:39:51 -0500 Subject: vim-patch:8.0.0634: cannot easily get to the last quickfix list Problem: Cannot easily get to the last quickfix list. Solution: Add "$" as a value for the "nr" argument of getqflist() and setqflist(). (Yegappan Lakshmanan) https://github.com/vim/vim/commit/875feea6ce223462d55543735143d747dcaf4287 --- runtime/doc/eval.txt | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'runtime') diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt index 2c3d38ced7..7c1e524b66 100644 --- a/runtime/doc/eval.txt +++ b/runtime/doc/eval.txt @@ -4329,12 +4329,16 @@ getqflist([{what}]) *getqflist()* following string items are supported in {what}: context get the context stored with |setqflist()| nr get information for this quickfix list; zero - means the current quickfix list + means the current quickfix list and '$' means + the last quickfix list title get the list title winid get the |window-ID| (if opened) all all of the above quickfix properties Non-string items in {what} are ignored. If "nr" is not present then the current quickfix list is used. + To get the number of lists in the quickfix stack, set 'nr' to + '$' in {what}. The 'nr' value in the returned dictionary + contains the quickfix stack size. In case of error processing {what}, an empty dictionary is returned. @@ -6888,7 +6892,9 @@ setqflist({list} [, {action}[, {what}]]) *setqflist()* argument is ignored. The following items can be specified in {what}: context any Vim type can be stored as a context - nr list number in the quickfix stack + nr list number in the quickfix stack; zero + means the current quickfix list and '$' means + the last quickfix list title quickfix list title text Unsupported keys in {what} are ignored. If the "nr" item is not present, then the current quickfix list @@ -6993,18 +6999,22 @@ shellescape({string} [, {special}]) *shellescape()* quotes within {string}. Otherwise, it will enclose {string} in single quotes and replace all "'" with "'\''". + When the {special} argument is present and it's a non-zero Number or a non-empty String (|non-zero-arg|), then special items such as "!", "%", "#" and "" will be preceded by a backslash. This backslash will be removed again by the |:!| command. + The "!" character will be escaped (again with a |non-zero-arg| {special}) when 'shell' contains "csh" in the tail. That is because for csh and tcsh "!" is used for history replacement even when inside single quotes. - The character is also escaped. With a |non-zero-arg| - {special} and 'shell' containing "csh" in the tail it's + + With a |non-zero-arg| {special} the character is also + escaped. When 'shell' containing "csh" in the tail it's escaped a second time. + Example of use with a |:!| command: > :exe '!dir ' . shellescape(expand(''), 1) < This results in a directory listing for the file under the -- cgit From 3efc50d1d4e97c3d7bc3734ac77e6ed7b43a391d Mon Sep 17 00:00:00 2001 From: James McCoy Date: Sun, 31 Dec 2017 00:27:08 -0500 Subject: vim-patch:8.0.0641: cannot set a separate highlighting for the quickfix line Problem: Cannot set a separate highlighting for the current line in the quickfix window. Solution: Add QuickFixLine. (anishsane, closes vim/vim#1755) https://github.com/vim/vim/commit/2102035488e80ef6fd5038ed15d21672712ba0f6 --- runtime/doc/options.txt | 4 ++++ runtime/doc/quickfix.txt | 6 +++++- 2 files changed, 9 insertions(+), 1 deletion(-) (limited to 'runtime') diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt index f70ec32bd8..067aad1f93 100644 --- a/runtime/doc/options.txt +++ b/runtime/doc/options.txt @@ -2712,6 +2712,10 @@ A jump table for the options with a short description can be found at |Q_op|. :s///g subst. one subst. all :s///gg subst. all subst. one + DEPRECATED: Setting this option may break plugins that are not aware + of this option. Also, many users get confused that adding the /g flag + has the opposite effect of that it normally does. + *'grepformat'* *'gfm'* 'grepformat' 'gfm' string (default "%f:%l:%m,%f:%l%m,%f %l%m") global diff --git a/runtime/doc/quickfix.txt b/runtime/doc/quickfix.txt index 74f82b2c65..f280286290 100644 --- a/runtime/doc/quickfix.txt +++ b/runtime/doc/quickfix.txt @@ -470,7 +470,11 @@ keep its height, ignoring 'winheight' and 'equalalways'. You can change the height manually (e.g., by dragging the status line above it with the mouse). In the quickfix window, each line is one error. The line number is equal to -the error number. You can use ":.cc" to jump to the error under the cursor. +the error number. The current entry is highlighted with the QuickFixLine +highlighting. You can change it to your liking, e.g.: > + :hi QuickFixLine ctermbg=Yellow guibg=Yellow + +You can use ":.cc" to jump to the error under the cursor. Hitting the key or double-clicking the mouse on a line has the same effect. The file containing the error is opened in the window above the quickfix window. If there already is a window for that file, it is used -- cgit From d0c4bd23f78ee00943725ea77a63f2a223dba66b Mon Sep 17 00:00:00 2001 From: James McCoy Date: Sun, 31 Dec 2017 00:36:35 -0500 Subject: vim-patch:8.0.0657: cannot get and set quickfix list items Problem: Cannot get and set quickfix list items. Solution: Add the "items" argument to getqflist() and setqflist(). (Yegappan Lakshmanan) https://github.com/vim/vim/commit/6a8958db259d4444da6e6956e54a6513c1af8860 --- runtime/doc/eval.txt | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'runtime') diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt index 7c1e524b66..ae62498d35 100644 --- a/runtime/doc/eval.txt +++ b/runtime/doc/eval.txt @@ -4328,6 +4328,7 @@ getqflist([{what}]) *getqflist()* returns only the items listed in {what} as a dictionary. The following string items are supported in {what}: context get the context stored with |setqflist()| + items quickfix list entries nr get information for this quickfix list; zero means the current quickfix list and '$' means the last quickfix list @@ -4344,6 +4345,7 @@ getqflist([{what}]) *getqflist()* The returned dictionary contains the following entries: context context information stored with |setqflist()| + items quickfix list entries nr quickfix list number title quickfix list title text winid quickfix |window-ID| (if opened) @@ -6892,6 +6894,8 @@ setqflist({list} [, {action}[, {what}]]) *setqflist()* argument is ignored. The following items can be specified in {what}: context any Vim type can be stored as a context + items list of quickfix entries. Same as the {list} + argument. nr list number in the quickfix stack; zero means the current quickfix list and '$' means the last quickfix list -- cgit From 9fe6c12e8159b656e53b6d79226aa5a1c39fdc27 Mon Sep 17 00:00:00 2001 From: James McCoy Date: Sun, 31 Dec 2017 09:50:05 -0500 Subject: doc: deprecate 'gdefault' [ci skip] --- runtime/doc/deprecated.txt | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'runtime') diff --git a/runtime/doc/deprecated.txt b/runtime/doc/deprecated.txt index 72dfe1230e..b3073ffe58 100644 --- a/runtime/doc/deprecated.txt +++ b/runtime/doc/deprecated.txt @@ -37,8 +37,8 @@ Functions ~ *file_readable()* Obsolete name for |filereadable()|. *highlight_exists()* Obsolete name for |hlexists()|. *highlightID()* Obsolete name for |hlID()|. -*jobclose()* Obsolete name for |chanclose()| -*jobsend()* Obsolete name for |chansend()| +*jobclose()* Obsolete name for |chanclose()| +*jobsend()* Obsolete name for |chansend()| *last_buffer_nr()* Obsolete name for bufnr("$"). Modifiers ~ @@ -48,8 +48,10 @@ Modifiers ~ *:map-special* <> notation is always enabled. |cpo-<| Options ~ +'gd' +'gdefault' Enables the |:substitute| flag 'g' by default. *'fe'* 'fenc'+'enc' before Vim 6.0; no longer used. -*'highlight'* *'hl'* Names of builtin |highlight-groups| cannot be changed. +*'highlight'* *'hl'* Names of builtin |highlight-groups| cannot be changed. *'langnoremap'* Deprecated alias to 'nolangremap'. *'vi'* *'viminfo'* Deprecated alias to 'shada' option. -- cgit From f4e372c8abed86650b22fdb5b50c9ac82dae6613 Mon Sep 17 00:00:00 2001 From: Felipe Morales Date: Mon, 1 Jan 2018 14:26:45 +0100 Subject: tutor: readjust tutor for 80 char wide terminals --- runtime/tutor/en/vim-01-beginner.tutor | 625 ++++++++++++++-------------- runtime/tutor/en/vim-01-beginner.tutor.json | 74 ++-- 2 files changed, 359 insertions(+), 340 deletions(-) (limited to 'runtime') diff --git a/runtime/tutor/en/vim-01-beginner.tutor b/runtime/tutor/en/vim-01-beginner.tutor index 3f243a18fa..dce98d53a4 100644 --- a/runtime/tutor/en/vim-01-beginner.tutor +++ b/runtime/tutor/en/vim-01-beginner.tutor @@ -1,26 +1,26 @@ # Welcome to the VIM Tutor -Vim is a very powerful editor that has many commands, too many to explain in a -tutor such as this. This tutor is designed to describe enough of the commands -that you will be able to easily use Vim as an all-purpose editor. It is -IMPORTANT to remember that this tutor is set up to teach by use. That means -that you need to do the exercises to learn them properly. If you only read -the text, you will soon forget what is most important! +Vim is a very powerful editor that has many commands, too many to explain in +a tutor such as this. This tutor is designed to describe enough of the +commands that you will be able to easily use Vim as an all-purpose editor. +It is IMPORTANT to remember that this tutor is set up to teach by use. That +means that you need to do the exercises to learn them properly. If you only +read the text, you will soon forget what is most important! -For now, make sure that your Shift-Lock key is NOT depressed and press the `j`{normal} -key enough times to move the cursor so that Lesson 0 completely fills the -screen. +For now, make sure that your Shift-Lock key is NOT depressed and press the +`j`{normal} key enough times to move the cursor so that Lesson 0 completely +fills the screen. # Lesson 0 -NOTE: The commands in the lessons will modify the text, but those changes won't -be saved. Don't worry about messing things up; just remember that pressing -[]() and then [u](u) will undo the latest change. +NOTE: The commands in the lessons will modify the text, but those changes +won't be saved. Don't worry about messing things up; just remember that +pressing []() and then [u](u) will undo the latest change. This tutorial is interactive, and there are a few things you should know. -Pressing []() over text highlighted [like this](holy-grail) will take you to some -relevant help (hopefully), and pressing K over any word will try to do so too. -Sometimes you will be required to modify text like +Pressing []() over text highlighted [like this](holy-grail ) +will take you to some relevant help (hopefully), and pressing K over any +word will try to do so too. Sometimes you will be required to modify text like this here Once you have done the changes correctly, the ✗ sign at the left will change to ✓. I imagine you can already see how neat Vim can be. ;) @@ -33,10 +33,10 @@ or press a sequence of keys 0fd3wP$P ~~~ -Text within <'s and >'s (like ``{normal}) describes a key to press instead of text -to type. +Text within <'s and >'s (like ``{normal}) describes a key to press +instead of text to type. -Now, move to the next lesson (remember, use the `j`{normal} key to scroll down). +Now, move to the next lesson (use the `j`{normal} key to scroll down). ## Lesson 1.1: MOVING THE CURSOR @@ -63,87 +63,90 @@ NOTE: The cursor keys should also work. But using hjkl you will be able to # Lesson 1.2: EXITING VIM -!! NOTE: Before executing any of the steps below, read this entire lesson !! +!! NOTE: Before executing any of the steps below, +read this entire lesson !! - 1. Press the key (to make sure you are in [Normal mode](Normal-mode). + 1. Press the key (to make sure you are in Normal mode). - 2. Type: + 2. Type: `:q!`{vim} ``{normal}. This exits the editor, DISCARDING any changes you have made. - 3. Open vim and get back here by executing the command that got you into this - tutor. That might be: + 3. Open vim and get back here by executing the command that got you into + this tutor. That might be: :Tutor - 4. If you have these steps memorized and are confident, execute steps + 4. If you have these steps memorized and are confident, execute steps 1 through 3 to exit and re-enter the editor. NOTE: [:q!](:q) discards any changes you made. In a few lessons you will learn how to save the changes to a file. - 5. Move the cursor down to Lesson 1.3. + 5. Move the cursor down to Lesson 1.3. ## Lesson 1.3: TEXT EDITING - DELETION ** Press `x`{normal} to delete the character under the cursor. ** - 1. Move the cursor to the line below marked --->. + 1. Move the cursor to the line below marked --->. - 2. To fix the errors, move the cursor until it is on top of the + 2. To fix the errors, move the cursor until it is on top of the character to be deleted. - 3. Press [the x key](x) to delete the unwanted character. + 3. Press [the x key](x) to delete the unwanted character. - 4. Repeat steps 2 through 4 until the sentence is correct. + 4. Repeat steps 2 through 4 until the sentence is correct. The ccow jumpedd ovverr thhe mooon. - 5. Now that the line is correct, go on to Lesson 1.4. + 5. Now that the line is correct, go on to Lesson 1.4. -NOTE: As you go through this tutor, do not try to memorize, learn by usage. +NOTE: As you go through this tutor, do not try to memorize, learn by + usage. # Lesson 1.4: TEXT EDITING: INSERTION ** Press `i`{normal} to insert text. ** - 1. Move the cursor to the first line below marked --->. + 1. Move the cursor to the first line below marked --->. - 2. To make the first line the same as the second, move the cursor on top + 2. To make the first line the same as the second, move the cursor on top of the first character AFTER where the text is to be inserted. - 3. Press `i`{normal} and type in the necessary additions. + 3. Press `i`{normal} and type in the necessary additions. - 4. As each error is fixed press ``{normal} to return to Normal mode. + 4. As each error is fixed press ``{normal} to return to Normal mode. Repeat steps 2 through 4 to correct the sentence. There is text misng this . There is some text missing from this line. - 5. When you are comfortable inserting text move to Lesson 1.5. + 5. When you are comfortable inserting text move to Lesson 1.5. # Lesson 1.5: TEXT EDITING: APPENDING ** Press `A`{normal} to append text. ** - 1. Move the cursor to the first line below marked --->. - It does not matter on what character the cursor is in that line. + 1. Move the cursor to the first line below marked --->. + It does not matter on what character the cursor is in that line. - 2. Press [A](A) and type in the necessary additions. + 2. Press [A](A) and type in the necessary additions. - 3. As the text has been appended press ``{normal} to return to Normal mode. + 3. As the text has been appended press ``{normal} to return to Normal + mode. - 4. Move the cursor to the second line marked ---> and repeat - steps 2 and 3 to correct this sentence. + 4. Move the cursor to the second line marked ---> and repeat + steps 2 and 3 to correct this sentence. There is some text missing from th There is some text missing from this line. There is also some text miss There is also some text missing here. - 5. When you are comfortable appending text move to Lesson 1.6. + 5. When you are comfortable appending text move to Lesson 1.6. # Lesson 1.6: EDITING A FILE @@ -151,49 +154,51 @@ There is also some text missing here. !! NOTE: Before executing any of the steps below, read this entire lesson !! - 1. Exit this tutor as you did in Lesson 1.2: `:q!`{vim} - Or, if you have access to another terminal, do the following there. + 1. Exit this tutor as you did in Lesson 1.2: `:q!`{vim} + Or, if you have access to another terminal, do the following there. - 2. At the shell prompt type this command: + 2. At the shell prompt type this command: ~~~ sh $ vim tutor ~~~ - 'vim' is the command to start the Vim editor, 'tutor' is the name of the - file you wish to edit. Use a file that may be changed. + 'vim' is the command to start the Vim editor, 'tutor' is the name of + the file you wish to edit. Use a file that may be changed. - 3. Insert and delete text as you learned in the previous lessons. + 3. Insert and delete text as you learned in the previous lessons. - 4. Save the file with changes and exit Vim with: + 4. Save the file with changes and exit Vim with: ~~~ cmd :wq ~~~ - Note you'll need to press `` to execute the command. + Note you'll need to press `` to execute the command. - 5. If you have quit vimtutor in step 1 restart the vimtutor and move down to - the following summary. + 5. If you have quit vimtutor in step 1 restart the vimtutor and move down + to the following summary. - 6. After reading the above steps and understanding them: do it. + 6. After reading the above steps and understanding them: do it. # Lesson 1 SUMMARY - 1. The cursor is moved using either the arrow keys or the hjkl keys. + 1. The cursor is moved using either the arrow keys or the hjkl keys. h (left) j (down) k (up) l (right) - 2. To start Vim from the shell prompt type: + 2. To start Vim from the shell prompt type: ~~~ sh $ vim FILENAME ~~~ - 3. To exit Vim type: ``{normal} `:q!`{vim} ``{normal} to trash all changes. - OR type: ``{normal} `:wq`{vim} ``{normal} to save the changes. + 3. To exit Vim type: ``{normal} `:q!`{vim} ``{normal} to trash + all changes. + OR type: ``{normal} `:wq`{vim} ``{normal} to save + the changes. - 4. To delete the character at the cursor type: `x`{normal} + 4. To delete the character at the cursor type: `x`{normal} - 5. To insert or append text type: - `i`{normal} insert text ``{normal} insert before the cursor. - `A`{normal} append text ``{normal} append after the line. + 5. To insert or append text type: + `i`{normal} insert text ``{normal} insert before the cursor. + `A`{normal} append text ``{normal} append after the line. NOTE: Pressing ``{normal} will place you in Normal mode or will cancel an unwanted and partially completed command. @@ -204,38 +209,38 @@ Now continue with Lesson 2. ** Type `dw`{normal} to delete a word. ** - 1. Press ``{normal} to make sure you are in Normal mode. + 1. Press ``{normal} to make sure you are in Normal mode. - 2. Move the cursor to the line below marked --->. + 2. Move the cursor to the line below marked --->. - 3. Move the cursor to the beginning of a word that needs to be deleted. + 3. Move the cursor to the beginning of a word that needs to be deleted. - 4. Type [d](d)[w](w) to make the word disappear. + 4. Type [d](d)[w](w) to make the word disappear. There are a some words fun that don't belong paper in this sentence. - 5. Repeat steps 3 and 4 until the sentence is correct and go to Lesson 2.2. + 5. Repeat steps 3 and 4 until the sentence is correct and go to Lesson 2.2. # Lesson 2.2: MORE DELETION COMMANDS ** Type `d$`{normal} to delete to the end of the line. ** - 1. Press ``{normal} to make sure you are in Normal mode. + 1. Press ``{normal} to make sure you are in Normal mode. - 2. Move the cursor to the line below marked --->. + 2. Move the cursor to the line below marked --->. - 3. Move the cursor to the end of the correct line (AFTER the first . ). + 3. Move the cursor to the end of the correct line (AFTER the first . ). - 4. Type `d$`{normal} to delete to the end of the line. + 4. Type `d$`{normal} to delete to the end of the line. Somebody typed the end of this line twice. end of this line twice. - 5. Move on to Lesson 2.3 to understand what is happening. + 5. Move on to Lesson 2.3 to understand what is happening. # Lesson 2.3: ON OPERATORS AND MOTIONS - -Many commands that change text are made from an [operator](operator) and a [motion](navigation). +Many commands that change text are made from an [operator](operator) and +a [motion](navigation). The format for a delete command with the [d](d) delete operator is as follows: d motion @@ -251,26 +256,26 @@ The format for a delete command with the [d](d) delete operator is as follows: Thus typing `de`{normal} will delete from the cursor to the end of the word. -NOTE: Pressing just the motion while in Normal mode without an operator will - move the cursor as specified. +NOTE: Pressing just the motion while in Normal mode without an operator + will move the cursor as specified. # Lesson 2.4: USING A COUNT FOR A MOTION ** Typing a number before a motion repeats it that many times. ** - 1. Move the cursor to the start of the line marked ---> below. + 1. Move the cursor to the start of the line marked ---> below. - 2. Type `2w`{normal} to move the cursor two words forward. + 2. Type `2w`{normal} to move the cursor two words forward. - 3. Type `3e`{normal} to move the cursor to the end of the third word forward. + 3. Type `3e`{normal} to move the cursor to the end of the third word forward. - 4. Type `0`{normal} ([zero](0)) to move to the start of the line. + 4. Type `0`{normal} ([zero](0)) to move to the start of the line. - 5. Repeat steps 2 and 3 with different numbers. + 5. Repeat steps 2 and 3 with different numbers. This is just a line with words you can move around in. - 6. Move on to Lesson 2.5. + 6. Move on to Lesson 2.5. # Lesson 2.5: USING A COUNT TO DELETE MORE @@ -280,12 +285,12 @@ In the combination of the delete operator and a motion mentioned above you insert a count before the motion to delete more: d number motion - 1. Move the cursor to the first UPPER CASE word in the line marked --->. + 1. Move the cursor to the first UPPER CASE word in the line marked --->. - 2. Type `d2w`{normal} to delete the two UPPER CASE words + 2. Type `d2w`{normal} to delete the two UPPER CASE words - 3. Repeat steps 1 and 2 with a different count to delete the consecutive - UPPER CASE words with one command + 3. Repeat steps 1 and 2 with a different count to delete the consecutive + UPPER CASE words with one command This ABC DE line FGHI JK LMN OP of words is Q RS TUV cleaned up. @@ -293,13 +298,13 @@ This ABC DE line FGHI JK LMN OP of words is Q RS TUV cleaned up. ** Type `dd`{normal} to delete a whole line. ** - Due to the frequency of whole line deletion, the designers of Vi decided - it would be easier to simply type two d's to delete a line. +Due to the frequency of whole line deletion, the designers of Vi decided +it would be easier to simply type two d's to delete a line. - 1. Move the cursor to the second line in the phrase below. - 2. Type [dd](dd) to delete the line. - 3. Now move to the fourth line. - 4. Type `2dd`{normal} to delete two lines. + 1. Move the cursor to the second line in the phrase below. + 2. Type [dd](dd) to delete the line. + 3. Now move to the fourth line. + 4. Type `2dd`{normal} to delete two lines. 1) Roses are red, 2) Mud is fun, @@ -313,54 +318,56 @@ This ABC DE line FGHI JK LMN OP of words is Q RS TUV cleaned up. ** Press `u`{normal} to undo the last commands, `U`{normal} to fix a whole line. ** - 1. Move the cursor to the line below marked ---> and place it on the - first error. - 2. Type `x`{normal} to delete the first unwanted character. - 3. Now type `u`{normal} to undo the last command executed. - 4. This time fix all the errors on the line using the `x`{normal} command. - 5. Now type a capital `U`{normal} to return the line to its original state. - 6. Now type `u`{normal} a few times to undo the `U`{normal} and preceding commands. - 7. Now type ``{normal} a few times to redo the commands (undo the undo's). + 1. Move the cursor to the line below marked ---> and place it on the + first error. + 2. Type `x`{normal} to delete the first unwanted character. + 3. Now type `u`{normal} to undo the last command executed. + 4. This time fix all the errors on the line using the `x`{normal} command. + 5. Now type a capital `U`{normal} to return the line to its original state. + 6. Now type `u`{normal} a few times to undo the `U`{normal} and preceding + commands. + 7. Now type ``{normal} (Control + R) a few times to redo the commands + (undo the undos). Fiix the errors oon thhis line and reeplace them witth undo. - 8. These are very useful commands. Now move on to the Lesson 2 Summary. + 8. These are very useful commands. Now move on to the Lesson 2 Summary. # Lesson 2 SUMMARY - 1. To delete from the cursor up to the next word type: `dw`{normal} - 2. To delete from the cursor to the end of a line type: `d$`{normal} - 3. To delete a whole line type: `dd`{normal} - 4. To repeat a motion prepend it with a number: `2w`{normal} + 1. To delete from the cursor up to the next word type: `dw`{normal} + 2. To delete from the cursor to the end of a line type: `d$`{normal} + 3. To delete a whole line type: `dd`{normal} + 4. To repeat a motion prepend it with a number: `2w`{normal} - 5. The format for a change command is: + 5. The format for a change command is: operator [number] motion - where: + where: operator - is what to do, such as [d](d) for delete [number] - is an optional count to repeat the motion motion - moves over the text to operate on, such as: [w](w) (word), [$]($) (to the end of line), etc. - 6. To move to the start of the line use a zero: [0](0) + 6. To move to the start of the line use a zero: [0](0) - 7. To undo previous actions, type: `u`{normal} (lowercase u) - To undo all the changes on a line, type: `U`{normal} (capital U) - To undo the undo's, type: ``{normal} + 7. To undo previous actions, type: `u`{normal} (lowercase u) + To undo all the changes on a line, type: `U`{normal} (capital U) + To undo the undo's, type: ``{normal} # Lesson 3.1: THE PUT COMMAND ** Type `p`{normal} to put previously deleted text after the cursor. ** - 1. Move the cursor to the first ---> line below. + 1. Move the cursor to the first ---> line below. - 2. Type `dd`{normal} to delete the line and store it in a Vim register. + 2. Type `dd`{normal} to delete the line and store it in a Vim register. - 3. Move the cursor to the c) line, ABOVE where the deleted line should go. + 3. Move the cursor to the c) line, ABOVE where the deleted line should go. - 4. Type `p`{normal} to put the line below the cursor. + 4. Type `p`{normal} to put the line below the cursor. - 5. Repeat steps 2 through 4 to put all the lines in correct order. + 5. Repeat steps 2 through 4 to put all the lines in correct order. d) Can you learn too? b) Violets are blue, @@ -371,18 +378,18 @@ a) Roses are red, ** Type `rx`{normal} to replace the character at the cursor with x. ** - 1. Move the cursor to the first line below marked --->. + 1. Move the cursor to the first line below marked --->. - 2. Move the cursor so that it is on top of the first error. + 2. Move the cursor so that it is on top of the first error. - 3. Type `r`{normal} and then the character which should be there. + 3. Type `r`{normal} and then the character which should be there. - 4. Repeat steps 2 and 3 until the first line is equal to the second one. + 4. Repeat steps 2 and 3 until the first line is equal to the second one. Whan this lime was tuoed in, someone presswd some wrojg keys! When this line was typed in, someone pressed some wrong keys! - 5. Now move on to Lesson 3.3. + 5. Now move on to Lesson 3.3. NOTE: Remember that you should be learning by doing, not memorization. @@ -390,15 +397,16 @@ NOTE: Remember that you should be learning by doing, not memorization. ** To change until the end of a word, type `ce`{normal}. ** - 1. Move the cursor to the first line below marked --->. + 1. Move the cursor to the first line below marked --->. - 2. Place the cursor on the "u" in "lubw". + 2. Place the cursor on the "u" in "lubw". - 3. Type `ce`{normal} and the correct word (in this case, type "ine" ). + 3. Type `ce`{normal} and the correct word (in this case, type "ine" ). - 4. Press ``{normal} and move to the next character that needs to be changed. + 4. Press ``{normal} and move to the next character that needs to be + changed. - 5. Repeat steps 3 and 4 until the first sentence is the same as the second. + 5. Repeat steps 3 and 4 until the first sentence is the same as the second. This lubw has a few wptfd that mrrf changing usf the change operator. This line has a few words that need changing using the change operator. @@ -409,17 +417,17 @@ Notice that [c](c)e deletes the word and places you in Insert mode. ** The change operator is used with the same motions as delete. ** - 1. The change operator works in the same way as delete. The format is: + 1. The change operator works in the same way as delete. The format is: c [number] motion - 2. The motions are the same, such as `w`{normal} (word) and `$`{normal} (end of line). + 2. The motions are the same, such as `w`{normal} (word) and `$`{normal} (end of line). - 3. Move to the first line below marked --->. + 3. Move to the first line below marked --->. - 4. Move the cursor to the first error. + 4. Move the cursor to the first error. - 5. Type `c$`{normal} and type the rest of the line like the second and press ``{normal}. + 5. Type `c$`{normal} and type the rest of the line like the second and press ``{normal}. The end of this line needs some help to make it like the second. The end of this line needs to be corrected using the `c$`{normal} command. @@ -428,18 +436,18 @@ NOTE: You can use the Backspace key to correct mistakes while typing. # Lesson 3 SUMMARY - 1. To put back text that has just been deleted, type [p](p). This puts the - deleted text AFTER the cursor (if a line was deleted it will go on the - line below the cursor). + 1. To put back text that has just been deleted, type [p](p). This puts the + deleted text AFTER the cursor (if a line was deleted it will go on the + line below the cursor). - 2. To replace the character under the cursor, type [r](r) and then the - character you want to have there. + 2. To replace the character under the cursor, type [r](r) and then the + character you want to have there. - 3. The [change operator](c) allows you to change from the cursor to where the - motion takes you. Type `ce`{normal} to change from the cursor to the end of - the word, `c$`{normal} to change to the end of a line. + 3. The [change operator](c) allows you to change from the cursor to where + the motion takes you. Type `ce`{normal} to change from the cursor to the + end of the word, `c$`{normal} to change to the end of a line. - 4. The format for change is: + 4. The format for change is: c [number] motion @@ -447,42 +455,44 @@ Now go on to the next lesson. # Lesson 4.1: CURSOR LOCATION AND FILE STATUS -** Type ``{normal} to show your location in the file and the file status. +** Type ``{normal} to show your location in a file and the file status. Type `G`{normal} to move to a line in the file. ** NOTE: Read this entire lesson before executing any of the steps!! - 1. Hold down the ``{normal} key and press `g`{normal}. We call this ``{normal}. - A message will appear at the bottom of the page with the filename and the - position in the file. Remember the line number for Step 3. + 1. Hold down the ``{normal} key and press `g`{normal}. We call this + ``{normal}. A message will appear at the bottom of the page with the + filename and the position in the file. Remember the line number for + Step 3. -NOTE: You may see the cursor position in the lower right corner of the screen - This happens when the ['ruler']('ruler') option is set (see `:help 'ruler'`{vim} ). +NOTE: You may see the cursor position in the lower right corner of the + screen. This happens when the ['ruler']('ruler') option is set. + 2. Press [G](G) to move you to the bottom of the file. + Type [gg](gg) to move you to the start of the file. - 2. Press [G](G) to move you to the bottom of the file. - Type [gg](gg) to move you to the start of the file. + 3. Type the number of the line you were on and then `G`{normal}. This will + return you to the line you were on when you first pressed ``{normal}. - 3. Type the number of the line you were on and then `G`{normal}. This will - return you to the line you were on when you first pressed ``{normal}. - - 4. If you feel confident to do this, execute steps 1 through 3. + 4. If you feel confident to do this, execute steps 1 through 3. # Lesson 4.2: THE SEARCH COMMAND ** Type `/`{normal} followed by a phrase to search for the phrase. ** - 1. In Normal mode type the `/`{normal} character. Notice that it and the cursor - appear at the bottom of the screen as with the `:`{normal} command. + 1. In Normal mode type the `/`{normal} character. Notice that it and the + cursor appear at the bottom of the screen as with the `:`{normal} command. - 2. Now type 'errroor' ``{normal}. This is the word you want to search for. + 2. Now type 'errroor' ``{normal}. This is the word you want to search + for. - 3. To search for the same phrase again, simply type [n](n). - To search for the same phrase in the opposite direction, type [N](N). + 3. To search for the same phrase again, simply type [n](n). + To search for the same phrase in the opposite direction, type [N](N). - 4. To search for a phrase in the backward direction, use [?](?) instead of `/`{normal}. + 4. To search for a phrase in the backward direction, use [?](?) instead + of `/`{normal}. - 5. To go back to where you came from press ``{normal} (keep ``{normal} pressed down while - pressing the letter `o`{normal}). Repeat to go back further. ``{normal} goes forward. + 5. To go back to where you came from press ``{normal} (keep ``{normal} pressed down while pressing the letter `o`{normal}). Repeat to go back + further. ``{normal} goes forward. "errroor" is not the way to spell error; errroor is an error. @@ -493,15 +503,15 @@ NOTE: When the search reaches the end of the file it will continue at the ** Type `%`{normal} to find a matching ),], or }. ** - 1. Place the cursor on any (, [, or { in the line below marked --->. + 1. Place the cursor on any (, [, or { in the line below marked --->. - 2. Now type the [%](%) character. + 2. Now type the [%](%) character. - 3. The cursor will move to the matching parenthesis or bracket. + 3. The cursor will move to the matching parenthesis or bracket. - 4. Type `%`{normal} to move the cursor to the other matching bracket. + 4. Type `%`{normal} to move the cursor to the other matching bracket. - 5. Move the cursor to another (,),[,],{ or } and see what `%`{normal} does. + 5. Move the cursor to another (,),[,],{ or } and see what `%`{normal} does. This ( is a test line with ('s, ['s ] and {'s } in it. )) @@ -511,75 +521,79 @@ NOTE: This is very useful in debugging a program with unmatched parentheses! ** Type `:s/old/new/g` to substitute "new" for "old". ** - 1. Move the cursor to the line below marked --->. + 1. Move the cursor to the line below marked --->. - 2. Type + 2. Type ~~~ cmd :s/thee/the/ ~~~ NOTE that the [:s](:s) command only changed the first occurrence of "thee" in the line. - 3. Now type + 3. Now type ~~~ cmd :s/thee/the/g ~~~ - Adding the g [flag](:s_flags) means to substitute globally in the line, change - all occurrences of "thee" in the line. + Adding the g [flag](:s_flags) means to substitute globally in the line, + change all occurrences of "thee" in the line. Usually thee best time to see thee flowers is in thee spring. - 4. To change every occurrence of a character string between two lines, type + 4. To change every occurrence of a character string between two lines, type ~~~ cmd :#,#s/old/new/g ~~~ - where #,# are the line numbers of the range of lines where the substitution is to be done. + where #,# are the line numbers of the range of lines where the + substitution is to be done. - Type + Type ~~~ cmd - :%s/old/new/g + :%s/old/new/g ~~~ - to change every occurrence in the whole file. + to change every occurrence in the whole file. - Type + Type ~~~ cmd - :%s/old/new/gc + :%s/old/new/gc ~~~ - to find every occurrence in the whole file, with a prompt whether to substitute or not. + to find every occurrence in the whole file, with a prompt whether to + substitute or not. # Lesson 4 SUMMARY - 1. ``{normal} displays your location in the file and the file status. - `G`{normal} moves to the end of the file. - number `G`{normal} moves to that line number. - `gg`{normal} moves to the first line. + 1. ``{normal} displays your location and the file status. + `G`{normal} moves to the end of the file. + number `G`{normal} moves to that line number. + `gg`{normal} moves to the first line. - 2. Typing `/`{normal} followed by a phrase searches FORWARD for the phrase. - Typing `?`{normal} followed by a phrase searches BACKWARD for the phrase. - After a search type `n`{normal} to find the next occurrence in the same direction - or `N`{normal} to search in the opposite direction. - ``{normal} takes you back to older positions, ``{normal} to newer positions. + 2. Typing `/`{normal} followed by a phrase searches FORWARD for the phrase. + Typing `?`{normal} followed by a phrase searches BACKWARD for the phrase. + After a search type `n`{normal} to find the next occurrence in the same + direction or `N`{normal} to search in the opposite direction. + ``{normal} takes you back to older positions, ``{normal} to + newer positions. - 3. Typing `%`{normal} while the cursor is on a (,),[,],{, or } goes to its match. + 3. Typing `%`{normal} while the cursor is on a (,),[,],{, or } goes to its + match. - 4. To substitute new for the first old in a line type + 4. To substitute new for the first old in a line type ~~~ cmd :s/old/new ~~~ - To substitute new for all 'old's on a line type + To substitute new for all 'old's on a line type ~~~ cmd :s/old/new/g ~~~ - To substitute phrases between two line #'s type + To substitute phrases between two line #'s type ~~~ cmd :#,#s/old/new/g ~~~ - To substitute all occurrences in the file type + To substitute all occurrences in the file type ~~~ cmd :%s/old/new/g ~~~ - To ask for confirmation each time add 'c' + To ask for confirmation each time add 'c' ~~~ cmd :%s/old/new/gc ~~~ @@ -588,15 +602,15 @@ Usually thee best time to see thee flowers is in thee spring. ** Type `:!`{vim} followed by an external command to execute that command. ** - 1. Type the familiar command `:`{normal} to set the cursor at the bottom of the - screen. This allows you to enter a command-line command. + 1. Type the familiar command `:`{normal} to set the cursor at the bottom of + the screen. This allows you to enter a command-line command. - 2. Now type the [!](!cmd) (exclamation point) character. This allows you to - execute any external shell command. + 2. Now type the [!](!cmd) (exclamation point) character. This allows you to + execute any external shell command. - 3. As an example type "ls" following the "!" and then hit ``{normal}. This - will show you a listing of your directory, just as if you were at the - shell prompt. + 3. As an example type "ls" following the "!" and then hit ``{normal}. + This will show you a listing of your directory, just as if you were + at the shell prompt. NOTE: It is possible to execute any external command this way, also with arguments. @@ -608,24 +622,24 @@ NOTE: All `:`{vim} commands must be finished by hitting ``{normal}. ** To save the changes made to the text, type `:w`{vim} FILENAME. ** - 1. Type `:!ls`{vim} to get a listing of your directory. - You already know you must hit ``{normal} after this. + 1. Type `:!ls`{vim} to get a listing of your directory. + You already know you must hit ``{normal} after this. - 2. Choose a filename that does not exist yet, such as TEST. + 2. Choose a filename that does not exist yet, such as TEST. - 3. Now type: + 3. Now type: ~~~ cmd :w TEST ~~~ - (where TEST is the filename you chose.) + (where TEST is the filename you chose.) - 4. This saves the whole file (the Vim Tutor) under the name TEST. - To verify this, type `:!ls`{vim} again to see your directory. + 4. This saves the whole file (the Vim Tutor) under the name TEST. + To verify this, type `:!ls`{vim} again to see your directory. NOTE: If you were to exit Vim and start it again with `nvim TEST`, the file would be an exact copy of the tutor when you saved it. - 5. Now remove the file by typing: + 5. Now remove the file by typing: ~~~ cmd :!rm TEST ~~~ @@ -634,53 +648,52 @@ NOTE: If you were to exit Vim and start it again with `nvim TEST`, the file ** To save part of the file, type `v`{normal} motion `:w FILENAME`{vim}. ** - 1. Move the cursor to this line. + 1. Move the cursor to this line. - 2. Press [v](v) and move the cursor to the fifth item below. Notice that the - text is highlighted. + 2. Press [v](v) and move the cursor to the fifth item below. Notice that the + text is highlighted. - 3. Press the `:`{normal} character. At the bottom of the screen + 3. Press the `:`{normal} character. At the bottom of the screen :'<,'> will appear. - 4. Type + 4. Type `:w TEST`{vim} - where TEST is a filename that does not exist yet. Verify that you see + where TEST is a filename that does not exist yet. Verify that you see `:'<,'>w TEST`{vim} - before you press ``{normal}. + before you press ``{normal}. - 5. Vim will write the selected lines to the file TEST. Use `:!ls`{vim} to see it. - Do not remove it yet! We will use it in the next lesson. + 5. Vim will write the selected lines to the file TEST. Use `:!ls`{vim} to see it. Do not remove it yet! We will use it in the next lesson. NOTE: Pressing [v](v) starts [Visual selection](visual-mode). You can move the cursor around to make the selection bigger or smaller. Then you can - use an operator to do something with the text. For example, `d`{normal} deletes - the text. + use an operator to do something with the text. For example, `d`{normal} + deletes the text. # Lesson 5.4: RETRIEVING AND MERGING FILES ** To insert the contents of a file, type `:r FILENAME`{vim}. ** - 1. Place the cursor just above this line. + 1. Place the cursor just above this line. NOTE: After executing Step 2 you will see text from Lesson 5.3. Then move DOWN to see this lesson again. - 2. Now retrieve your TEST file using the command + 2. Now retrieve your TEST file using the command `:r TEST`{vim} where TEST is the name of the file you used. The file you retrieve is placed below the cursor line. - 3. To verify that a file was retrieved, cursor back and notice that there - are now two copies of Lesson 5.3, the original and the file version. + 3. To verify that a file was retrieved, cursor back and notice that there + are now two copies of Lesson 5.3, the original and the file version. NOTE: You can also read the output of an external command. For example, @@ -690,39 +703,39 @@ NOTE: You can also read the output of an external command. For example, # Lesson 5 SUMMARY - 1. [:!command](:!cmd) executes an external command. + 1. [:!command](:!cmd) executes an external command. Some useful examples are: `:!ls`{vim} - shows a directory listing `:!rm FILENAME`{vim} - removes file FILENAME - 2. [:w](:w) FILENAME writes the current Vim file to disk with - name FILENAME. + 2. [:w](:w) FILENAME writes the current Vim file to disk with + name FILENAME. - 3. [v](v) motion :w FILENAME saves the Visually selected lines in file - FILENAME. + 3. [v](v) motion :w FILENAME saves the Visually selected lines in file + FILENAME. - 4. [:r](:r) FILENAME retrieves disk file FILENAME and puts it - below the cursor position. + 4. [:r](:r) FILENAME retrieves disk file FILENAME and puts it + below the cursor position. - 5. [:r !dir](:r!) reads the output of the dir command and - puts it below the cursor position. + 5. [:r !dir](:r!) reads the output of the dir command and + puts it below the cursor position. # Lesson 6.1: THE OPEN COMMAND ** Type `o`{normal} to open a line below the cursor and place you in Insert mode. ** - 1. Move the cursor to the line below marked --->. + 1. Move the cursor to the line below marked --->. - 2. Type the lowercase letter `o`{normal} to [open](o) up a line BELOW the cursor and place - you in Insert mode. + 2. Type the lowercase letter `o`{normal} to [open](o) up a line BELOW the + cursor and place you in Insert mode. - 3. Now type some text and press ``{normal} to exit Insert mode. + 3. Now type some text and press ``{normal} to exit Insert mode. After typing `o`{normal} the cursor is placed on the open line in Insert mode. - 4. To open up a line ABOVE the cursor, simply type a [capital O](O), rather - than a lowercase `o`{normal}. Try this on the line below. + 4. To open up a line ABOVE the cursor, simply type a [capital O](O), rather + than a lowercase `o`{normal}. Try this on the line below. Open up a line above this by typing O while the cursor is on this line. @@ -730,37 +743,39 @@ Open up a line above this by typing O while the cursor is on this line. ** Type `a`{normal} to insert text AFTER the cursor. ** - 1. Move the cursor to the start of the line below marked --->. + 1. Move the cursor to the start of the line below marked --->. - 2. Press `e`{normal} until the cursor is on the end of "li". + 2. Press `e`{normal} until the cursor is on the end of "li". - 3. Type the lowercase letter `a`{normal} to [append](a) text AFTER the cursor. + 3. Type the lowercase letter `a`{normal} to [append](a) text AFTER the + cursor. - 4. Complete the word like the line below it. Press ``{normal} to exit Insert - mode. + 4. Complete the word like the line below it. Press ``{normal} to exit + Insert mode. - 5. Use `e`{normal} to move to the next incomplete word and repeat steps 3 and 4. + 5. Use `e`{normal} to move to the next incomplete word and repeat steps 3 + and 4. This li will allow you to pract appendi text to a line. This line will allow you to practice appending text to a line. -NOTE: [a](a), [i](i) and [A](A) all go to the same Insert mode, the only difference is where - the characters are inserted. +NOTE: [a](a), [i](i) and [A](A) all go to the same Insert mode, the only + difference is where the characters are inserted. # Lesson 6.3: ANOTHER WAY TO REPLACE ** Type a capital `R`{normal} to replace more than one character. ** - 1. Move the cursor to the first line below marked --->. Move the cursor to + 1. Move the cursor to the first line below marked --->. Move the cursor to the beginning of the first "xxx". - 2. Now press `R`{normal} ([capital R](R)) and type the number below it in the second line, so that it - replaces the "xxx". + 2. Now press `R`{normal} ([capital R](R)) and type the number below it in the + second line, so that it replaces the "xxx". - 3. Press ``{normal} to leave [Replace mode](mode-replace). Notice that the rest of the line - remains unmodified. + 3. Press ``{normal} to leave [Replace mode](mode-replace). Notice that + the rest of the line remains unmodified. - 4. Repeat the steps to replace the remaining "xxx". + 4. Repeat the steps to replace the remaining "xxx". Adding 123 to xxx gives you xxx. Adding 123 to 456 gives you 579. @@ -772,51 +787,53 @@ NOTE: Replace mode is like Insert mode, but every typed character deletes an ** Use the `y`{normal} operator to copy text and `p`{normal} to paste it. ** - 1. Go to the line marked with ---> below and place the cursor after "a)". + 1. Go to the line marked with ---> below and place the cursor after "a)". - 2. Start Visual mode with `v`{normal} and move the cursor to just before "first". + 2. Start Visual mode with `v`{normal} and move the cursor to just before + "first". - 3. Type `y`{normal} to [yank](yank) (copy) the highlighted text. + 3. Type `y`{normal} to [yank](yank) (copy) the highlighted text. - 4. Move the cursor to the end of the next line: `j$`{normal} + 4. Move the cursor to the end of the next line: `j$`{normal} - 5. Type `p`{normal} to [put](put) (paste) the text. + 5. Type `p`{normal} to [put](put) (paste) the text. - 6. Press `a`{normal} and then type "second". Press ``{normal} to leave Insert mode. + 6. Press `a`{normal} and then type "second". Press ``{normal} to leave + Insert mode. - 7. Use Visual mode to select " item.", yank it with `y`{normal}, move to the end of - the next line with `j$`{normal} and put the text there with `p`{normal}. + 7. Use Visual mode to select "item.", yank it with `y`{normal}, move to the + end of the next line with `j$`{normal} and put the text there with `p`{normal} a) This is the first item. b) -NOTE: you can also use `y`{normal} as an operator; `yw`{normal} yanks one word. +NOTE: you can use `y`{normal} as an operator: `yw`{normal} yanks one word. # Lesson 6.5: SET OPTION ** Set an option so a search or substitute ignores case. ** - 1. Search for 'ignore' by entering: `/ignore` - Repeat several times by pressing `n`{normal}. + 1. Search for 'ignore' by entering: `/ignore` + Repeat several times by pressing `n`{normal}. - 2. Set the 'ic' (Ignore case) option by entering: + 2. Set the 'ic' (Ignore case) option by entering: ~~~ cmd :set ic ~~~ - 3. Now search for 'ignore' again by pressing `n`{normal}. - Notice that Ignore and IGNORE are now also found. + 3. Now search for 'ignore' again by pressing `n`{normal}. + Notice that Ignore and IGNORE are now also found. - 4. Set the 'hlsearch' and 'incsearch' options: + 4. Set the 'hlsearch' and 'incsearch' options: ~~~ cmd :set hls is ~~~ - 5. Now type the search command again and see what happens: /ignore + 5. Now type the search command again and see what happens: /ignore - 6. To disable ignoring case enter: + 6. To disable ignoring case enter: ~~~ cmd :set noic ~~~ - 7. To toggle the value of a setting, prepend it with "inv": + 7. To toggle the value of a setting, prepend it with "inv": ~~~ cmd :set invic ~~~ @@ -829,19 +846,20 @@ NOTE: If you want to ignore case for just one search command, use [\c](/\c) # Lesson 6 SUMMARY - 1. Type `o`{normal} to open a line BELOW the cursor and start Insert mode. - Type `O`{normal} to open a line ABOVE the cursor. + 1. Type `o`{normal} to open a line BELOW the cursor and start Insert mode. + Type `O`{normal} to open a line ABOVE the cursor. - 2. Type `a`{normal} to insert text AFTER the cursor. - Type `A`{normal} to insert text after the end of the line. + 2. Type `a`{normal} to insert text AFTER the cursor. + Type `A`{normal} to insert text after the end of the line. - 3. The `e`{normal} command moves to the end of a word. + 3. The `e`{normal} command moves to the end of a word. - 4. The `y`{normal} operator yanks (copies) text, `p`{normal} puts (pastes) it. + 4. The `y`{normal} operator copies text, `p`{normal} pastes it. - 5. Typing a capital `R`{normal} enters Replace mode until ``{normal} is pressed. + 5. Typing a capital `R`{normal} enters Replace mode until ``{normal} is + pressed. - 6. Typing "[:set](:set) xxx" sets the option "xxx". Some options are: + 6. Typing "[:set](:set) xxx" sets the option "xxx". Some options are: 'ic' 'ignorecase' ignore upper/lower case when searching 'is' 'incsearch' show partial matches for a search phrase @@ -849,11 +867,11 @@ NOTE: If you want to ignore case for just one search command, use [\c](/\c) You can either use the long or the short option name. - 7. Prepend "no" to switch an option off: + 7. Prepend "no" to switch an option off: ~~~ cmd :set noic ~~~ - 8. Prepend "inv" to toggle an option: + 8. Prepend "inv" to toggle an option: ~~~ cmd :set invic ~~~ @@ -870,7 +888,7 @@ these three: `:help`{vim} Read the text in the help window to find out how the help works. -Type ``{normal} to jump from one window to another. +Type ``{normal} to jump from one window to another. Type `:q`{vim} to close the help window. You can find help on just about any subject, by giving an argument to the @@ -888,13 +906,13 @@ You can find help on just about any subject, by giving an argument to the Vim has many more features than Vi, but most of them are disabled by default. To start using more features you have to create a "vimrc" file. - 1. Start editing the "vimrc" file. This depends on your system: + 1. Start editing the "vimrc" file. This depends on your system: `:e ~/.config/nvim/init.vim`{vim} for Unix-like systems - 2. Now read the example "vimrc" file contents: + 2. Now read the example "vimrc" file contents: `:r $VIMRUNTIME/vimrc_example.vim`{vim} - 3. Write the file with: + 3. Write the file with: `:w`{vim} The next time you start Vim it will use syntax highlighting. @@ -903,36 +921,38 @@ default. To start using more features you have to create a "vimrc" file. # Lesson 7.3: COMPLETION -** Command line completion with ``{normal} and ``{normal}. ** +** Command line completion with ``{normal} and ``{normal}. ** - 1. Look what files exist in the directory: `:!ls`{vim} + 1. Look what files exist in the directory: `:!ls`{vim} - 2. Type the start of a command: `:e`{vim} + 2. Type the start of a command: `:e`{vim} - 3. Press ``{normal} and Vim will show a list of commands that start with "e". + 3. Press ``{normal} and Vim will show a list of commands that start + with "e". - 4. Press ``{normal} and Vim will complete the command name to ":edit". + 4. Press ``{normal} and Vim will complete the command name to ":edit". - 5. Now add a space and the start of an existing file name: `:edit FIL`{vim} + 5. Now add a space and the start of an existing file name: `:edit FIL`{vim} - 6. Press ``{normal}. Vim will complete the name (if it is unique). + 6. Press ``{normal}. Vim will complete the name (if it is unique). -NOTE: Completion works for many commands. It is especially useful for `:help`{vim}. +NOTE: Completion works for many commands. It is especially useful for + `:help`{vim}. # Lesson 7 SUMMARY - 1. Type `:help`{vim} - or press ``{normal} or ``{normal} to open a help window. + 1. Type `:help`{vim} + or press ``{normal} or ``{normal} to open a help window. - 2. Type `:help TOPIC`{vim} to find help on TOPIC. + 2. Type `:help TOPIC`{vim} to find help on TOPIC. - 3. Type ``{normal} to jump to another window + 3. Type ``{normal} to jump to another window - 4. Type `:q`{vim} to close the help window + 4. Type `:q`{vim} to close the help window - 5. Create a vimrc startup script to keep your preferred settings. + 5. Create a vimrc startup script to keep your preferred settings. - 6. While in command mode, press ``{normal} to see possible completions. + 6. While in command mode, press ``{normal} to see possible completions. Press ``{normal} to use one completion. # CONCLUSION @@ -941,7 +961,8 @@ This was intended to give a brief overview of the Vim editor, just enough to allow you to use the editor fairly easily. It is far from complete as Vim has many many more commands. Consult the help often. -There are many resources online to learn more about vim. Here's a bunch of them: +There are many resources online to learn more about vim. Here's a bunch of +them: - *Learn Vim Progressively*: http://yannesposito.com/Scratch/en/blog/Learn-Vim-Progressively/ - *Learning Vim in 2014*: http://benmccormick.org/learning-vim-in-2014/ @@ -951,8 +972,8 @@ There are many resources online to learn more about vim. Here's a bunch of them: - *7 Habits of Effective Text Editing*: http://www.moolenaar.net/habits.html - *vim-galore*: https://github.com/mhinz/vim-galore -If you prefer a book, *Practical Vim* by Drew Neil is recommended often (the sequel, *Modern -Vim*, includes material specific to nvim). +If you prefer a book, *Practical Vim* by Drew Neil is recommended often +(the sequel, *Modern Vim*, includes material specific to nvim). This tutorial was written by Michael C. Pierce and Robert K. Ware, Colorado School of Mines using ideas supplied by Charles Smith, Colorado State diff --git a/runtime/tutor/en/vim-01-beginner.tutor.json b/runtime/tutor/en/vim-01-beginner.tutor.json index 444bd7c4b7..2f87d7543f 100644 --- a/runtime/tutor/en/vim-01-beginner.tutor.json +++ b/runtime/tutor/en/vim-01-beginner.tutor.json @@ -1,45 +1,43 @@ { "expect": { "24": -1, - "102": "The cow jumped over the moon.", - "122": "There is some text missing from this line.", - "123": "There is some text missing from this line.", - "141": "There is some text missing from this line.", - "142": "There is some text missing from this line.", - "143": "There is also some text missing here.", - "144": "There is also some text missing here.", - "215": "There are some words that don't belong in this sentence.", - "231": "Somebody typed the end of this line twice.", - "271": -1, - "290": "This line of words is cleaned up.", - "304": -1, - "305": -1, - "306": -1, - "307": -1, - "308": -1, + "103": "The cow jumped over the moon.", + "124": "There is some text missing from this line.", + "125": "There is some text missing from this line.", + "144": "There is some text missing from this line.", + "145": "There is some text missing from this line.", + "146": "There is also some text missing here.", + "147": "There is also some text missing here.", + "220": "There are some words that don't belong in this sentence.", + "236": "Somebody typed the end of this line twice.", + "276": -1, + "295": "This line of words is cleaned up.", "309": -1, "310": -1, - "325": "Fix the errors on this line and replace them with undo.", - "365": -1, - "366": -1, - "367": -1, - "368": -1, - "382": "When this line was typed in, someone pressed some wrong keys!", - "383": "When this line was typed in, someone pressed some wrong keys!", - "403": "This line has a few words that need changing using the change operator.", - "404": "This line has a few words that need changing using the change operator.", - "424": "The end of this line needs to be corrected using the c$ command.", - "425": "The end of this line needs to be corrected using the c$ command.", - "487": -1, - "506": -1, - "531": "Usually the best time to see the flowers is in the spring.", - "722": -1, - "727": -1, - "744": "This line will allow you to practice appending text to a line.", - "745": "This line will allow you to practice appending text to a line.", - "765": "Adding 123 to 456 gives you 579.", - "766": "Adding 123 to 456 gives you 579.", - "790": "a) This is the first item.", - "791": " b) This is the second item." + "311": -1, + "312": -1, + "313": -1, + "314": -1, + "315": -1, + "332": "Fix the errors on this line and replace them with undo.", + "372": -1, + "373": -1, + "374": -1, + "375": -1, + "389": "When this line was typed in, someone pressed some wrong keys!", + "390": "When this line was typed in, someone pressed some wrong keys!", + "411": "This line has a few words that need changing using the change operator.", + "412": "This line has a few words that need changing using the change operator.", + "432": "The end of this line needs to be corrected using the c$ command.", + "433": "The end of this line needs to be corrected using the c$ command.", + "497": -1, + "516": -1, + "541": "Usually the best time to see the flowers is in the spring.", + "759": "This line will allow you to practice appending text to a line.", + "760": "This line will allow you to practice appending text to a line.", + "780": "Adding 123 to 456 gives you 579.", + "781": "Adding 123 to 456 gives you 579.", + "807": "a) This is the first item.", + "808": " b) This is the second item." } } -- cgit From 6a9f2cdc6837f7e6989ad1f5454a555682a27baa Mon Sep 17 00:00:00 2001 From: Felipe Morales Date: Mon, 1 Jan 2018 19:08:01 +0100 Subject: tutor: install metadata files for tutor documents --- runtime/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'runtime') diff --git a/runtime/CMakeLists.txt b/runtime/CMakeLists.txt index 6dbe049232..52a8609fec 100644 --- a/runtime/CMakeLists.txt +++ b/runtime/CMakeLists.txt @@ -138,7 +138,7 @@ endforeach() file(GLOB_RECURSE RUNTIME_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} rgb.txt - *.vim *.dict *.py *.rb *.ps *.tutor) + *.vim *.dict *.py *.rb *.ps *.tutor *.tutor.json) foreach(F ${RUNTIME_FILES}) get_filename_component(BASEDIR ${F} PATH) -- cgit From 60716371e97dae916c6525e9ba840aae562069bb Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Mon, 1 Jan 2018 19:38:18 +0100 Subject: tui: support TERM=konsole-256color TERM=konsole-256color is recognized by ncurses. TERM=konsole-xterm might be more clever, but should not be necessary (for Nvim at least), we already special-case Konsole in various places. We may need to clean up some areas that currently assume Konsole always "pretends xterm" (`TERM=xterm-256color`), though I didn't find any such cases. ref #6403 ref https://github.com/neovim/neovim/issues/6403#issuecomment-348713346 --- runtime/doc/term.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'runtime') diff --git a/runtime/doc/term.txt b/runtime/doc/term.txt index a694185fc9..6cf62f9bb5 100644 --- a/runtime/doc/term.txt +++ b/runtime/doc/term.txt @@ -38,13 +38,13 @@ Otherwise Nvim cannot know what sequences your terminal expects, and weird or sub-optimal behavior will result (scrolling quirks, wrong colors, etc.). $TERM is also important because it is mirrored by SSH to the remote session, -unlike other common client-end environment variables ($COLORTERM, -$XTERM_VERSION, $VTE_VERSION, $KONSOLE_PROFILE_NAME, $TERM_PROGRAM, ...). +unlike most other environment variables. For this terminal Set $TERM to |builtin-terms| ------------------------------------------------------------------------- iTerm (original) iterm, iTerm.app N iTerm2 (new capabilities) iterm2, iTerm2.app Y + Konsole konsole-256color N anything libvte-based vte, vte-256color Y (e.g. GNOME Terminal) (aliases: gnome, gnome-256color) tmux tmux, tmux-256color Y -- cgit From 7c4bb23ff38a459911a742657572bc273e528ddf Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Wed, 3 Jan 2018 19:57:22 +0100 Subject: defaults: do :filetype stuff unless explicitly "off" Until now, the default `:filetype ...` setup was skipped if the user config touched `:filetype` in any way (including implicitly via `:syntax on`). No one needs that, and it's very confusing. Instead, proceed with `:filetype ... on` unless the user explicitly called `:filetype ... off`. closes #7765 --- runtime/doc/filetype.txt | 6 ++---- runtime/doc/starting.txt | 9 ++++----- 2 files changed, 6 insertions(+), 9 deletions(-) (limited to 'runtime') diff --git a/runtime/doc/filetype.txt b/runtime/doc/filetype.txt index 78402b47fe..74c453f79a 100644 --- a/runtime/doc/filetype.txt +++ b/runtime/doc/filetype.txt @@ -24,10 +24,8 @@ Each time a new or existing file is edited, Vim will try to recognize the type of the file and set the 'filetype' option. This will trigger the FileType event, which can be used to set the syntax highlighting, set options, etc. -Detail: The ":filetype on" command will load one of these files: - Mac $VIMRUNTIME/filetype.vim - MS-DOS $VIMRUNTIME\filetype.vim - Unix $VIMRUNTIME/filetype.vim +Detail: The ":filetype on" command will load this file: + $VIMRUNTIME/filetype.vim This file is a Vim script that defines autocommands for the BufNewFile and BufRead events. If the file type is not found by the name, the file $VIMRUNTIME/scripts.vim is used to detect it from the diff --git a/runtime/doc/starting.txt b/runtime/doc/starting.txt index 30c0641ef7..e9188ba641 100644 --- a/runtime/doc/starting.txt +++ b/runtime/doc/starting.txt @@ -439,15 +439,14 @@ accordingly. Vim proceeds in this order: :runtime! filetype.vim :runtime! ftplugin.vim :runtime! indent.vim -< This step is skipped if ":filetype ..." was called before now or if - the "-u NONE" command line argument was given. +< Skipped if ":filetype … off" was called or if the "-u NONE" command + line argument was given. 5. Enable syntax highlighting. This does the same as the command: > :runtime! syntax/syntax.vim -< Note: This enables filetype detection even if ":filetype off" was - called before now. - This step is skipped if the "-u NONE" command line argument was given. +< Skipped if ":syntax off" was called or if the "-u NONE" command + line argument was given. 6. Load the plugin scripts. *load-plugins* This does the same as the command: > -- cgit From a8ad6b4d51eb5cb8a610753b6c7ade3cce3db9cc Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Tue, 9 Jan 2018 10:37:49 +0100 Subject: cmake: install *.lua files --- runtime/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'runtime') diff --git a/runtime/CMakeLists.txt b/runtime/CMakeLists.txt index 52a8609fec..d992c2cc77 100644 --- a/runtime/CMakeLists.txt +++ b/runtime/CMakeLists.txt @@ -138,7 +138,7 @@ endforeach() file(GLOB_RECURSE RUNTIME_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} rgb.txt - *.vim *.dict *.py *.rb *.ps *.tutor *.tutor.json) + *.vim *.lua *.dict *.py *.rb *.ps *.tutor *.tutor.json) foreach(F ${RUNTIME_FILES}) get_filename_component(BASEDIR ${F} PATH) -- cgit From 423d7af3df6de1ab38f9987cafc86499730da5dc Mon Sep 17 00:00:00 2001 From: Filip Szymański Date: Mon, 15 Jan 2018 20:14:27 +0100 Subject: man.lua: avoid float conversion on lua 5.3 (#7851) Error detected while processing function man#open_page[58]..54_put_page: line 8: E5105: Error while calling lua chunk: /usr/share/nvim/runtime/lua/man.lua:165: Vim(let):E805: Using a Float as a Number --- runtime/lua/man.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'runtime') diff --git a/runtime/lua/man.lua b/runtime/lua/man.lua index baa522f343..b0fbe9cc35 100644 --- a/runtime/lua/man.lua +++ b/runtime/lua/man.lua @@ -148,8 +148,8 @@ local function highlight_line(line, linenr) end local function highlight_man_page() - local mod = vim.api.nvim_eval("&modifiable") - vim.api.nvim_command("set modifiable") + local mod = vim.api.nvim_buf_get_option(0, "modifiable") + vim.api.nvim_buf_set_option(0, "modifiable", true) local lines = vim.api.nvim_buf_get_lines(0, 0, -1, false) for i, line in ipairs(lines) do @@ -162,7 +162,7 @@ local function highlight_man_page() end buf_hls = {} - vim.api.nvim_command("let &modifiable = "..mod) + vim.api.nvim_buf_set_option(0, "modifiable", mod) end return { highlight_man_page = highlight_man_page } -- cgit From 7dd3910f47621dd422e8c37ad16512295a11f5cc Mon Sep 17 00:00:00 2001 From: Felipe Morales Date: Mon, 15 Jan 2018 21:59:37 +0100 Subject: tutor: don't resize (#7854) --- runtime/autoload/tutor.vim | 3 --- 1 file changed, 3 deletions(-) (limited to 'runtime') diff --git a/runtime/autoload/tutor.vim b/runtime/autoload/tutor.vim index 56e2283465..0f01190b9b 100644 --- a/runtime/autoload/tutor.vim +++ b/runtime/autoload/tutor.vim @@ -2,9 +2,6 @@ " Setup: {{{1 function! tutor#SetupVim() - if &columns < 90 - set columns=90 - endif if !exists('g:did_load_ftplugin') || g:did_load_ftplugin != 1 filetype plugin on endif -- cgit From f8f7f9d5f5aead86541ffcd12e291b6dfb6811e5 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Mon, 15 Jan 2018 23:14:20 +0100 Subject: vim-patch:8.0.0151,3,4 #7389 vim-patch:8.0.0151 Problem: To pass buffer content to system() and systemlist() one has to first create a string or list. Solution: Allow passing a buffer number. (LemonBoy, closes vim/vim#1240) https://github.com/vim/vim/commit/12c4492dd35e0cd83c8816be2ec849b836109882 vim-patch:8.0.0153 Problem: system() test fails on MS-Windows. Solution: Deal when extra space and CR. https://github.com/vim/vim/commit/9d9c35651712b88c81f1ae11091de1fd0bbbd35c vim-patch:8.0.0154 Problem: system() test fails on OS/X. Solution: Deal with leading spaces. https://github.com/vim/vim/commit/31f19ce0a052f7c76d44a9a190e468c79cf5d56d --- runtime/doc/eval.txt | 3 +++ 1 file changed, 3 insertions(+) (limited to 'runtime') diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt index ae62498d35..7820b85bf4 100644 --- a/runtime/doc/eval.txt +++ b/runtime/doc/eval.txt @@ -7645,6 +7645,9 @@ system({cmd} [, {input}]) *system()* *E677* |writefile()| does with {binary} set to "b" (i.e. with a newline between each list item, and newlines inside list items converted to NULs). + When {input} is given and is a valid buffer id, the content of + the buffer is written to the file line by line, each line + terminated by a NL (and NUL where the text has NL). *E5677* Note: system() cannot write to or read from backgrounded ("&") shell commands, e.g.: > -- cgit From 2b1bcd446b6d95f608161818addecf7c6a2beeaa Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Sat, 13 Jan 2018 19:59:05 +0100 Subject: runtime: include en.utf-8.spl Install en.utf-8.spl by default. - Allows spell-related tests to run. - Avoids download prompt for spelllang=en users --- runtime/CMakeLists.txt | 2 +- runtime/spell/en.utf-8.spl | Bin 0 -> 609337 bytes 2 files changed, 1 insertion(+), 1 deletion(-) create mode 100644 runtime/spell/en.utf-8.spl (limited to 'runtime') diff --git a/runtime/CMakeLists.txt b/runtime/CMakeLists.txt index d992c2cc77..0172f630cd 100644 --- a/runtime/CMakeLists.txt +++ b/runtime/CMakeLists.txt @@ -138,7 +138,7 @@ endforeach() file(GLOB_RECURSE RUNTIME_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} rgb.txt - *.vim *.lua *.dict *.py *.rb *.ps *.tutor *.tutor.json) + *.vim *.lua *.dict *.py *.rb *.ps *.spl *.tutor *.tutor.json) foreach(F ${RUNTIME_FILES}) get_filename_component(BASEDIR ${F} PATH) diff --git a/runtime/spell/en.utf-8.spl b/runtime/spell/en.utf-8.spl new file mode 100644 index 0000000000..83b9b8f7c2 Binary files /dev/null and b/runtime/spell/en.utf-8.spl differ -- cgit From 8fc437ef43dbaccf873c9af448495387410e465c Mon Sep 17 00:00:00 2001 From: zandrmartin Date: Wed, 17 Jan 2018 19:50:17 +0000 Subject: runtime: UpdateRemotePlugins: allow bar (#7865) --- runtime/plugin/rplugin.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'runtime') diff --git a/runtime/plugin/rplugin.vim b/runtime/plugin/rplugin.vim index ca15ec82d1..56163c894e 100644 --- a/runtime/plugin/rplugin.vim +++ b/runtime/plugin/rplugin.vim @@ -56,6 +56,6 @@ function! s:LoadRemotePlugins() abort endif endfunction -command! UpdateRemotePlugins call remote#host#UpdateRemotePlugins() +command! -bar UpdateRemotePlugins call remote#host#UpdateRemotePlugins() call s:LoadRemotePlugins() -- cgit From 94f4469638590ca5cc724ab6459f2cfc78c621a4 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Fri, 19 Jan 2018 01:53:04 +0100 Subject: man.vim: infer $MANPAGER invocation in more cases This should handle most cases where Nvim was invoked as $MANPAGER. Ultimately the stakes are low: :quit will prompt if there are unsaved changes. fix #7873 --- runtime/ftplugin/man.vim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'runtime') diff --git a/runtime/ftplugin/man.vim b/runtime/ftplugin/man.vim index e36dfc5a90..68ebb33e45 100644 --- a/runtime/ftplugin/man.vim +++ b/runtime/ftplugin/man.vim @@ -6,7 +6,7 @@ if exists('b:did_ftplugin') || &filetype !=# 'man' endif let b:did_ftplugin = 1 -let s:pager = !exists('b:man_sect') +let s:pager = get(s:, 'pager', 0) || !exists('b:man_sect') if s:pager call man#init_pager() @@ -35,7 +35,7 @@ if !exists('g:no_plugin_maps') && !exists('g:no_man_maps') nnoremap :Man nnoremap K :Man nnoremap :call man#pop_tag() - if s:pager + if 1 == bufnr('%') || s:pager nnoremap q :lclose:q else nnoremap q :lclosec -- cgit From eb4aab7173fa1733f77bb6d7117351b47ada6134 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Sun, 21 Jan 2018 07:31:57 +0100 Subject: ui: forward 'linespace' option #7883 ref #7520 --- runtime/doc/options.txt | 2 +- runtime/doc/ui.txt | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) (limited to 'runtime') diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt index 067aad1f93..b3139f3298 100644 --- a/runtime/doc/options.txt +++ b/runtime/doc/options.txt @@ -3676,7 +3676,7 @@ A jump table for the options with a short description can be found at |Q_op|. < Minimum value is 2, maximum value is 1000. *'linespace'* *'lsp'* -'linespace' 'lsp' number (default 0, 1 for Win32 GUI) +'linespace' 'lsp' number (default 0) global {only in the GUI} Number of pixel lines inserted between characters. Useful if the font diff --git a/runtime/doc/ui.txt b/runtime/doc/ui.txt index e1c5523202..1b3c10b71e 100644 --- a/runtime/doc/ui.txt +++ b/runtime/doc/ui.txt @@ -90,6 +90,7 @@ Global Events *ui-global* 'guifont' 'guifontset' 'guifontwide' + 'linespace' 'showtabline' 'termguicolors' -- cgit From e2eff5269f3d33f7ae60db1a082300844403fe99 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Mon, 15 Jan 2018 22:26:11 +0100 Subject: doc: if_cscop: cleanup --- runtime/doc/if_cscop.txt | 195 +++++++++++------------------------------------ 1 file changed, 43 insertions(+), 152 deletions(-) (limited to 'runtime') diff --git a/runtime/doc/if_cscop.txt b/runtime/doc/if_cscop.txt index ac3d7a9ed8..90f60652f3 100644 --- a/runtime/doc/if_cscop.txt +++ b/runtime/doc/if_cscop.txt @@ -4,42 +4,19 @@ VIM REFERENCE MANUAL by Andy Kahn *cscope* *Cscope* -This document explains how to use Vim's cscope interface. +Cscope is a "code intelligence" tool that helps you navigate C programs. It +can also perform some refactoring tasks, such as renaming a global variable in +all source files. Think of it as "ctags on steroids". -Cscope is a tool like ctags, but think of it as ctags on steroids since it -does a lot more than what ctags provides. In Vim, jumping to a result from -a cscope query is just like jumping to any tag; it is saved on the tag stack -so that with the right keyboard mappings, you can jump back and forth between -functions as you normally would with |tags|. +See |cscope-usage| for a quickstart. Type |gO| to see the table of contents. ============================================================================== -1. Cscope introduction *cscope-intro* +Cscope introduction *cscope-intro* -The following text is taken from a version of the cscope man page: - ----- - - Cscope is an interactive screen-oriented tool that helps you: - - Learn how a C program works without endless flipping through a thick - listing. - - Locate the section of code to change to fix a bug without having to - learn the entire program. - - Examine the effect of a proposed change such as adding a value to an - enum variable. - - Verify that a change has been made in all source files such as adding - an argument to an existing function. - - Rename a global variable in all source files. - - Change a constant to a preprocessor symbol in selected lines of files. - - It is designed to answer questions like: +Cscope is designed to answer questions like: Where is this symbol used? Where is it defined? Where did this variable get its value? @@ -51,35 +28,17 @@ The following text is taken from a version of the cscope man page: Where is this source file in the directory structure? What files include this header file? - Cscope answers these questions from a symbol database that it builds the - first time it is used on the source files. On a subsequent call, cscope - rebuilds the database only if a source file has changed or the list of - source files is different. When the database is rebuilt the data for the - unchanged files is copied from the old database, which makes rebuilding - much faster than the initial build. - - ----- - -When cscope is normally invoked, you will get a full-screen selection -screen allowing you to make a query for one of the above questions. -However, once a match is found to your query and you have entered your -text editor to edit the source file containing match, you cannot simply -jump from tag to tag as you normally would with vi's Ctrl-] or :tag -command. - -Vim's cscope interface is done by invoking cscope with its line-oriented -interface, and then parsing the output returned from a query. The end -result is that cscope query results become just like regular tags, so -you can jump to them just like you do with normal tags (Ctrl-] or :tag) -and then go back by popping off the tagstack with Ctrl-T. (Please note -however, that you don't actually jump to a cscope tag simply by doing -Ctrl-] or :tag without remapping these commands or setting an option. -See the remaining sections on how the cscope interface works and for -suggested use.) +Cscope answers these questions from a symbol database that it builds the first +time it is used on the source files. On a subsequent call, cscope rebuilds +the database only if a source file has changed or the list of source files is +different. When the database is rebuilt the data for the unchanged files is +copied from the old database, which makes rebuilding much faster than the +initial build. +See |cscope-usage| to get started. ============================================================================== -2. Cscope related commands *cscope-commands* +Cscope commands *cscope-commands* *:cscope* *:cs* *:scs* *:scscope* *E259* *E262* *E561* *E560* All cscope commands are accessed through suboptions to the cscope commands. @@ -232,7 +191,7 @@ through your tags file(s). ============================================================================== -3. Cscope options *cscope-options* +Cscope options *cscope-options* Use the |:set| command to set all cscope options. Ideally, you would do this in one of your startup files (e.g., vimrc). Some cscope related @@ -245,7 +204,6 @@ started will have no effect! :set csprg=/usr/local/bin/cscope < *cscopequickfix* *csqf* *E469* -{not available when compiled without the |+quickfix| feature} 'cscopequickfix' specifies whether to use quickfix window to show cscope results. This is a list of comma-separated values. Each item consists of |cscope-find| command (s, g, d, c, t, e, f, i or a) and flag (+, - or 0). @@ -260,81 +218,64 @@ seems to be useful: > If 'cscopetag' is set, the commands ":tag" and CTRL-] as well as "vim -t" will always use |:cstag| instead of the default :tag behavior. Effectively, by setting 'cst', you will always search your cscope databases as well as -your tag files. The default is off. Examples: > - :set cst - :set nocst -< +your tag files. The default is off. + *cscoperelative* *csre* If 'cscoperelative' is set, then in absence of a prefix given to cscope (prefix is the argument of -P option of cscope), basename of cscope.out location (usually the project root directory) will be used as the prefix to construct an absolute path. The default is off. Note: This option is only effective when cscope (cscopeprg) is initialized without a prefix -path (-P). Examples: > - :set csre - :set nocsre -< +path (-P). + *cscopetagorder* *csto* The value of 'csto' determines the order in which |:cstag| performs a search. If 'csto' is set to zero, cscope database(s) are searched first, followed by tag file(s) if cscope did not return any matches. If 'csto' is set to one, tag file(s) are searched before cscope database(s). The default is zero. -Examples: > - :set csto=0 - :set csto=1 -< + *cscopeverbose* *csverb* If 'cscopeverbose' is not set (the default), messages will not be printed indicating success or failure when adding a cscope database. Ideally, you should reset this option in your |init.vim| before adding any cscope databases, and after adding them, set it. From then on, when you add more databases within Vim, you will get a (hopefully) useful message should the -database fail to be added. Examples: > - :set csverb - :set nocsverb -< +database fail to be added. + *cscopepathcomp* *cspc* -The value of 'cspc' determines how many components of a file's path to -display. With the default value of zero the entire path will be displayed. +'cscopepathcomp' determines how many components of a file's path to display. +With the default value of zero the entire path will be displayed. The value one will display only the filename with no path. Other values display that many components. For example: > - :set cspc=3 + :set cscopepathcomp=3 will display the last 3 components of the file's path, including the file name itself. ============================================================================== -4. How to use cscope in Vim *cscope-howtouse* +Using cscope in Nvim *cscope-usage* *cscope-howtouse* -The first thing you need to do is to build a cscope database for your -source files. For the most basic case, simply do "cscope -b". Please -refer to the cscope man page for more details. +To get started, build the cscope database in your project root directory: > + cscope -bcqR -Assuming you have a cscope database, you need to "add" the database to Vim. -This establishes a cscope "connection" and makes it available for Vim to use. -You can do this in your vimrc file, or you can do it manually after starting -vim. For example, to add the cscope database "cscope.out", you would do: +See the cscope manpage for details: > + :Man cscope - :cs add cscope.out +By default the cscope database file is named "cscope.out". After building the +database, connect to it from Nvim: > + :cscope add cscope.out -You can double-check the result of this by executing ":cs show". This will -produce output which looks like this: +That establishes a cscope connection for Nvim to use. You can check the +result with ":cs show". It will show something like: # pid database name prepend path 0 28806 cscope.out -Note: -Because of the Microsoft RTL limitations, Win32 version shows 0 instead -of the real pid. - Once a cscope connection is established, you can make queries to cscope and -the results will be printed to you. Queries are made using the command -":cs find". For example: - +the results will be printed. Queries are made using the command ":cs find". +For example: > :cs find g ALIGN_SIZE -This can get a little cumbersome since one ends up doing a significant -amount of typing. Fortunately, there are ways around this by mapping -shortcut keys. See |cscope-suggestions| for suggested usage. +To make this easier you can configure mappings, see |cscope-suggestions|. If the results return only one match, you will automatically be taken to it. If there is more than one match, you will be given a selection screen to pick @@ -343,25 +284,16 @@ simply hit Ctrl-T to get back to the previous one. ============================================================================== -5. Limitations *cscope-limitations* - -Cscope support for Vim is only available on systems that support these four -system calls: fork(), pipe(), execl(), waitpid(). This means it is mostly -limited to Unix systems. - -Additionally Cscope support works for Win32. For more information and a -cscope version for Win32 see: - - http://iamphet.nm.ru/cscope/index.html +Limitations *cscope-limitations* Hard-coded limitation: doing a |:tjump| when |:cstag| searches the tag files is not configurable (e.g., you can't do a tselect instead). + ============================================================================== -6. Suggested usage *cscope-suggestions* +Sample config *cscope-suggestions* -Put these entries in your vimrc (adjust the pathname accordingly to your -setup): > +Copy this into your init.vim (adjust paths for your system): > if has("cscope") set csprg=/usr/local/bin/cscope @@ -447,47 +379,6 @@ Cscope Home Page (http://cscope.sourceforge.net/): > \:vert scs find d =expand("") nmap a \:vert scs find a =expand("") - -============================================================================== -7. Cscope availability and information *cscope-info* - -If you do not already have cscope (it did not come with your compiler -license or OS distribution), then you can download it for free from: - http://cscope.sourceforge.net/ -This is released by SCO under the BSD license. - -If you want a newer version of cscope, you will probably have to buy it. -According to the (old) nvi documentation: - - You can buy version 13.3 source with an unrestricted license - for $400 from AT&T Software Solutions by calling +1-800-462-8146. - -Also you can download cscope 13.x and mlcscope 14.x (multi-lingual cscope -which supports C, C++, Java, lex, yacc, breakpoint listing, Ingres, and SDL) -from World-Wide Exptools Open Source packages page: - http://www.bell-labs.com/project/wwexptools/packages.html - -In Solaris 2.x, if you have the C compiler license, you will also have -cscope. Both are usually located under /opt/SUNWspro/bin - -SGI developers can also get it. Search for Cscope on this page: - http://freeware.sgi.com/index-by-alpha.html - https://toolbox.sgi.com/toolbox/utilities/cscope/ -The second one is for those who have a password for the SGI toolbox. - -There is source to an older version of a cscope clone (called "cs") available -on the net. Due to various reasons, this is not supported with Vim. - -The cscope interface/support for Vim was originally written by -Andy Kahn . The original structure (as well as a tiny -bit of code) was adapted from the cscope interface in nvi. Please report -any problems, suggestions, patches, et al., you have for the usage of -cscope within Vim to him. - *cscope-win32* -For a cscope version for Win32 see: - http://code.google.com/p/cscope-win32/ - -Win32 support was added by Sergey Khorev . Contact -him if you have Win32-specific issues. +< vim:tw=78:ts=8:ft=help:norl: -- cgit From 53749e174995b812a3985d089460a9d7b2670c71 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Mon, 15 Jan 2018 22:26:48 +0100 Subject: defaults: enable 'cscopeverbose', and deprecate it --- runtime/doc/deprecated.txt | 1 + runtime/doc/if_cscop.txt | 14 ++------------ runtime/doc/options.txt | 6 ------ runtime/doc/quickref.txt | 1 - runtime/doc/vim_diff.txt | 1 + 5 files changed, 4 insertions(+), 19 deletions(-) (limited to 'runtime') diff --git a/runtime/doc/deprecated.txt b/runtime/doc/deprecated.txt index b3073ffe58..ea61e847c7 100644 --- a/runtime/doc/deprecated.txt +++ b/runtime/doc/deprecated.txt @@ -48,6 +48,7 @@ Modifiers ~ *:map-special* <> notation is always enabled. |cpo-<| Options ~ +*'cscopeverbose'* Enabled by default. Use |:silent| instead. 'gd' 'gdefault' Enables the |:substitute| flag 'g' by default. *'fe'* 'fenc'+'enc' before Vim 6.0; no longer used. diff --git a/runtime/doc/if_cscop.txt b/runtime/doc/if_cscop.txt index 90f60652f3..451d525ea8 100644 --- a/runtime/doc/if_cscop.txt +++ b/runtime/doc/if_cscop.txt @@ -234,14 +234,6 @@ If 'csto' is set to zero, cscope database(s) are searched first, followed by tag file(s) if cscope did not return any matches. If 'csto' is set to one, tag file(s) are searched before cscope database(s). The default is zero. - *cscopeverbose* *csverb* -If 'cscopeverbose' is not set (the default), messages will not be printed -indicating success or failure when adding a cscope database. Ideally, you -should reset this option in your |init.vim| before adding any cscope -databases, and after adding them, set it. From then on, when you add more -databases within Vim, you will get a (hopefully) useful message should the -database fail to be added. - *cscopepathcomp* *cspc* 'cscopepathcomp' determines how many components of a file's path to display. With the default value of zero the entire path will be displayed. @@ -299,15 +291,13 @@ Copy this into your init.vim (adjust paths for your system): > set csprg=/usr/local/bin/cscope set csto=0 set cst - set nocsverb " add any database in current directory if filereadable("cscope.out") - cs add cscope.out + silent cs add cscope.out " else add database pointed to by environment elseif $CSCOPE_DB != "" - cs add $CSCOPE_DB + silent cs add $CSCOPE_DB endif - set csverb endif By setting 'cscopetag', we have effectively replaced all instances of the :tag diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt index b3139f3298..ded9f7667a 100644 --- a/runtime/doc/options.txt +++ b/runtime/doc/options.txt @@ -1807,12 +1807,6 @@ A jump table for the options with a short description can be found at |Q_op|. Determines the order in which ":cstag" performs a search. See |cscopetagorder|. - *'cscopeverbose'* *'csverb'* - *'nocscopeverbose'* *'nocsverb'* -'cscopeverbose' 'csverb' boolean (default off) - global - Give messages when adding a cscope database. See |cscopeverbose|. - *'cursorbind'* *'crb'* *'nocursorbind'* *'nocrb'* 'cursorbind' 'crb' boolean (default off) local to window diff --git a/runtime/doc/quickref.txt b/runtime/doc/quickref.txt index 902b0175a2..a0ca17cc4a 100644 --- a/runtime/doc/quickref.txt +++ b/runtime/doc/quickref.txt @@ -655,7 +655,6 @@ Short explanation of each option: *option-list* 'cscoperelative' 'csre' Use cscope.out path basename as prefix 'cscopetag' 'cst' use cscope for tag commands 'cscopetagorder' 'csto' determines ":cstag" search order -'cscopeverbose' 'csverb' give messages when adding a cscope database 'cursorbind' 'crb' move cursor in window as it moves in other windows 'cursorcolumn' 'cuc' highlight the screen column of the cursor 'cursorline' 'cul' highlight the screen line of the cursor diff --git a/runtime/doc/vim_diff.txt b/runtime/doc/vim_diff.txt index 9643777975..c5c558279e 100644 --- a/runtime/doc/vim_diff.txt +++ b/runtime/doc/vim_diff.txt @@ -32,6 +32,7 @@ a complete and centralized reference of those differences. - 'backupdir' defaults to .,~/.local/share/nvim/backup (|xdg|) - 'belloff' defaults to "all" - 'complete' doesn't include "i" +- 'cscopeverbose' is enabled - 'directory' defaults to ~/.local/share/nvim/swap// (|xdg|), auto-created - 'display' defaults to "lastline" - 'formatoptions' defaults to "tcqj" -- cgit From 154822933ee29f7b27157ff6e5138d8126cfc27f Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Sun, 21 Jan 2018 11:27:17 +0100 Subject: vim-patch:8.0.0659: no test for conceal mode Problem: No test for conceal mode. Solution: Add a conceal mode test. (Dominique Pelle, closes vim/vim#1783) https://github.com/vim/vim/commit/4d785895d1f8b54cdd3fabd87446ca692f49e94e --- runtime/doc/eval.txt | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) (limited to 'runtime') diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt index 7820b85bf4..8771604c89 100644 --- a/runtime/doc/eval.txt +++ b/runtime/doc/eval.txt @@ -7602,17 +7602,20 @@ synIDtrans({synID}) *synIDtrans()* ":highlight link" are followed. synconcealed({lnum}, {col}) *synconcealed()* - The result is a List. The first item in the list is 0 if the - character at the position {lnum} and {col} is not part of a - concealable region, 1 if it is. The second item in the list is - a string. If the first item is 1, the second item contains the - text which will be displayed in place of the concealed text, - depending on the current setting of 'conceallevel'. The third - and final item in the list is a unique number representing the - specific syntax region matched. This allows detection of the - beginning of a new concealable region if there are two - consecutive regions with the same replacement character. - For an example use see $VIMRUNTIME/syntax/2html.vim . + The result is a List with currently three items: + 1. The first item in the list is 0 if the character at the + position {lnum} and {col} is not part of a concealable + region, 1 if it is. + 2. The second item in the list is a string. If the first item + is 1, the second item contains the text which will be + displayed in place of the concealed text, depending on the + current setting of 'conceallevel' and 'listchars'. + 3. The third and final item in the list is a unique number + representing the specific syntax region matched. This + allows detection of the beginning of a new concealable + region if there are two consecutive regions with the same + replacement character. For an example use see + $VIMRUNTIME/syntax/2html.vim . synstack({lnum}, {col}) *synstack()* -- cgit From dbcdd29139a88d038834f85d74027dcf01fa1afb Mon Sep 17 00:00:00 2001 From: Marco Hinz Date: Mon, 22 Jan 2018 16:49:35 +0100 Subject: man.vim: use correct offset in presence of modifier commands The argument expansion for :Man depends on the number of arguments given to it starting at the command itself. But user completion functions always provide the entire command-line which can include modifier commands like :tab, :vert, etc. leading to a wrong number of arguments. Prune all arguments up to :Man. Fixes #7872. --- runtime/autoload/man.vim | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'runtime') diff --git a/runtime/autoload/man.vim b/runtime/autoload/man.vim index 00ce1c77d7..4d43a4582b 100644 --- a/runtime/autoload/man.vim +++ b/runtime/autoload/man.vim @@ -299,6 +299,12 @@ endfunction " see man#extract_sect_and_name_ref on why tolower(sect) function! man#complete(arg_lead, cmd_line, cursor_pos) abort let args = split(a:cmd_line) + let cmd_offset = index(args, 'Man') + if cmd_offset > 0 + " Prune all arguments up to :Man itself. Otherwise modifier commands like + " :tab, :vertical, etc. would lead to a wrong length. + let args = args[cmd_offset:] + endif let l = len(args) if l > 3 return -- cgit From 8b1f7d8774b235ae4f0dc0fa64d58e3cad9f8283 Mon Sep 17 00:00:00 2001 From: KunMing Xie Date: Thu, 25 Jan 2018 18:26:47 +0800 Subject: vim-patch:8.0.0431 (#7908) vim-patch:8.0.0431: 'cinoptions' cannot set indent for extern block Problem: 'cinoptions' cannot set indent for extern block. Solution: Add the "E" flag in 'cinoptions'. (Hirohito Higashi) https://github.com/vim/vim/commit/7720ba8599162fbbb8f7fc034f674a2ccd3ca7f1 --- runtime/doc/indent.txt | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'runtime') diff --git a/runtime/doc/indent.txt b/runtime/doc/indent.txt index cf45ec4f38..7ba5a373dc 100644 --- a/runtime/doc/indent.txt +++ b/runtime/doc/indent.txt @@ -320,6 +320,21 @@ The examples below assume a 'shiftwidth' of 4. { { void function(); void function(); } } +< + *cino-E* + EN Indent inside C++ linkage specifications (extern "C" or + extern "C++") N characters extra compared to a normal block. + (default 0). + + cino= cino=E-s > + extern "C" { extern "C" { + void function(); void function(); + } } + + extern "C" extern "C" + { { + void function(); void function(); + } } < *cino-p* pN Parameter declarations for K&R-style function declarations will @@ -550,7 +565,7 @@ The examples below assume a 'shiftwidth' of 4. The defaults, spelled out in full, are: - cinoptions=>s,e0,n0,f0,{0,}0,^0,L-1,:s,=s,l0,b0,gs,hs,N0,ps,ts,is,+s, + cinoptions=>s,e0,n0,f0,{0,}0,^0,L-1,:s,=s,l0,b0,gs,hs,N0,E0,ps,ts,is,+s, c3,C0,/0,(2s,us,U0,w0,W0,k0,m0,j0,J0,)20,*70,#0 Vim puts a line in column 1 if: -- cgit From 41394d82365b504c89bb4da9ed5adc11c6f619f0 Mon Sep 17 00:00:00 2001 From: Ömer Sinan Ağacan Date: Mon, 30 Oct 2017 11:07:35 +0300 Subject: vim-patch:8.0.1238 Problem: Incremental search only shows one match. Solution: When 'incsearch' and and 'hlsearch' are both set highlight all matches. (haya14busa, closes vim/vim#2198) https://github.com/vim/vim/commit/2e51d9a0972080b087d566608472928d5b7b35d7 --- runtime/doc/options.txt | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'runtime') diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt index ded9f7667a..2e584ea9bb 100644 --- a/runtime/doc/options.txt +++ b/runtime/doc/options.txt @@ -3299,7 +3299,17 @@ A jump table for the options with a short description can be found at |Q_op|. pattern and/or a lot of text the match may not be found. This is to avoid that Vim hangs while you are typing the pattern. The |hl-IncSearch| highlight group determines the highlighting. - See also: 'hlsearch'. + When 'hlsearch' is on, all matched strings are highlighted too while typing + a search command. See also: 'hlsearch'. + If you don't want turn 'hlsearch' on, but want to highlight all matches + while searching, you can turn on and off 'hlsearch' with autocmd. + Example: > + augroup vimrc-incsearch-highlight + autocmd! + autocmd CmdlineEnter [/\?] :set hlsearch + autocmd CmdlineLeave [/\?] :set nohlsearch + augroup END +< CTRL-L can be used to add one character from after the current match to the command line. If 'ignorecase' and 'smartcase' are set and the command line has no uppercase characters, the added character is -- cgit From cd973be11bfcdee286017f83e04c3d6c3be2f19a Mon Sep 17 00:00:00 2001 From: Ömer Sinan Ağacan Date: Fri, 3 Nov 2017 08:28:36 +0300 Subject: vim-patch:8.0.1250 Problem: 'hlsearch' highlighting not removed after incsearch (lacygoill) Solution: Redraw all windows. Start search at the end of the match. Improve how CTRL-G works with incremental search. Add tests. (Christian Brabandt, Hirohito Higashi, haya14busa, closes vim/vim#2267) https://github.com/vim/vim/commit/f8f8b2eadbaf3090fcfccbab560de5dbd501833d --- runtime/doc/options.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'runtime') diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt index 2e584ea9bb..6a36202177 100644 --- a/runtime/doc/options.txt +++ b/runtime/doc/options.txt @@ -3306,8 +3306,8 @@ A jump table for the options with a short description can be found at |Q_op|. Example: > augroup vimrc-incsearch-highlight autocmd! - autocmd CmdlineEnter [/\?] :set hlsearch - autocmd CmdlineLeave [/\?] :set nohlsearch + autocmd CmdlineEnter /,\? :set hlsearch + autocmd CmdlineLeave /,\? :set nohlsearch augroup END < CTRL-L can be used to add one character from after the current match -- cgit From 2569fabf04fa820814f2e13ac7579c5d759327f0 Mon Sep 17 00:00:00 2001 From: KunMing Xie Date: Mon, 29 Jan 2018 05:53:53 +0800 Subject: vim-patch:8.0.0427: 'makeencoding' missing from the options window (#7907) Problem: 'makeencoding' missing from the options window. Solution: Add the entry. https://github.com/vim/vim/commit/ad4187e6fc9c8e1083a172852d958a70a689a75c --- runtime/optwin.vim | 3 +++ 1 file changed, 3 insertions(+) (limited to 'runtime') diff --git a/runtime/optwin.vim b/runtime/optwin.vim index 8f04e495e5..13d0db0390 100644 --- a/runtime/optwin.vim +++ b/runtime/optwin.vim @@ -1087,6 +1087,9 @@ if has("quickfix") call OptionG("gp", &gp) call append("$", "grepformat\tlist of formats for output of 'grepprg'") call OptionG("gfm", &gfm) + call append("$", "makeencoding\tencoding of the \":make\" and \":grep\" output") + call append("$", "\t(global or local to buffer)") + call OptionG("menc", &menc) endif -- cgit From 5d2dd2ebe28c31f223d77355a8f9d40adfb41c82 Mon Sep 17 00:00:00 2001 From: Mahmoud Al-Qudsi Date: Wed, 27 Sep 2017 13:38:24 -0500 Subject: win: has("wsl") on Windows Subsystem for Linux #7330 Per CMAKE docs, CMAKE_HOST_SYSTEM_VERSION is the result of `uname -r`: https://cmake.org/cmake/help/v3.4/variable/CMAKE_HOST_SYSTEM_VERSION.html?highlight=uname A numeric version string for the system. On systems that support uname, this variable is set to the output of uname -r. On other systems this is set to major-minor version numbers. On Windows it is something like "6.1", so it won't match ".*-Microsoft". Closes #7329 --- runtime/doc/eval.txt | 1 + 1 file changed, 1 insertion(+) (limited to 'runtime') diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt index 8771604c89..37a4962732 100644 --- a/runtime/doc/eval.txt +++ b/runtime/doc/eval.txt @@ -8445,6 +8445,7 @@ win32 Windows version of Vim (32 or 64 bit). winaltkeys Compiled with 'winaltkeys' option. windows Compiled with support for more than one window. writebackup Compiled with 'writebackup' default on. +wsl WSL (Windows Subsystem for Linux) version of Vim. *string-match* Matching a pattern in a String -- cgit From 6452831cf985bd31d16eb5a04b345038f45d203f Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Tue, 30 Jan 2018 22:35:33 +0100 Subject: clipboard: macOS: fallback to tmux if pbcopy is broken #7940 On some versions of macOS, pbcopy doesn't work in tmux <2.6 https://superuser.com/q/231130 Fallback to tmux in that case. Add a healthcheck for this scenario. --- runtime/autoload/health/provider.vim | 13 +++++++++++++ runtime/autoload/provider/clipboard.vim | 4 ++-- 2 files changed, 15 insertions(+), 2 deletions(-) (limited to 'runtime') diff --git a/runtime/autoload/health/provider.vim b/runtime/autoload/health/provider.vim index d1239db605..ae106095f9 100644 --- a/runtime/autoload/health/provider.vim +++ b/runtime/autoload/health/provider.vim @@ -13,6 +13,12 @@ function! s:normalize_path(s) abort return substitute(substitute(a:s, '\', '/', 'g'), '/\./\|/\+', '/', 'g') endfunction +" Returns TRUE if `cmd` exits with success, else FALSE. +function! s:cmd_ok(cmd) abort + call system(a:cmd) + return v:shell_error == 0 +endfunction + " Simple version comparison. function! s:version_cmp(a, b) abort let a = split(a:a, '\.', 0) @@ -120,6 +126,13 @@ endfunction function! s:check_clipboard() abort call health#report_start('Clipboard (optional)') + if !empty($TMUX) && executable('tmux') && executable('pbcopy') && !s:cmd_ok('pbcopy') + let tmux_version = matchstr(system('tmux -V'), '\d\+\.\d\+') + call health#report_error('pbcopy does not work with tmux version: '.tmux_version, + \ ['Install tmux 2.6+. https://superuser.com/q/231130', + \ 'or use tmux with reattach-to-user-namespace. https://superuser.com/a/413233']) + endif + let clipboard_tool = provider#clipboard#Executable() if exists('g:clipboard') && empty(clipboard_tool) call health#report_error( diff --git a/runtime/autoload/provider/clipboard.vim b/runtime/autoload/provider/clipboard.vim index e5a6e4748a..9e2e6046f8 100644 --- a/runtime/autoload/provider/clipboard.vim +++ b/runtime/autoload/provider/clipboard.vim @@ -26,7 +26,7 @@ let s:selections = { '*': s:selection, '+': copy(s:selection) } function! s:try_cmd(cmd, ...) abort let argv = split(a:cmd, " ") - let out = a:0 ? systemlist(argv, a:1, 1) : systemlist(argv, [''], 1) + let out = systemlist(argv, (a:0 ? a:1 : ['']), 1) if v:shell_error if !exists('s:did_error_try_cmd') echohl WarningMsg @@ -64,7 +64,7 @@ function! provider#clipboard#Executable() abort let s:paste = get(g:clipboard, 'paste', { '+': v:null, '*': v:null }) let s:cache_enabled = get(g:clipboard, 'cache_enabled', 0) return get(g:clipboard, 'name', 'g:clipboard') - elseif has('mac') && executable('pbcopy') + elseif has('mac') && executable('pbcopy') && s:cmd_ok('pbcopy') let s:copy['+'] = 'pbcopy' let s:paste['+'] = 'pbpaste' let s:copy['*'] = s:copy['+'] -- cgit From dfcd09dc225d7500a3df316193151cafe8bbb644 Mon Sep 17 00:00:00 2001 From: nate Date: Mon, 4 Dec 2017 07:36:03 -0800 Subject: vim-patch:8.0.0672: synconcealed() changes too often #7887 Problem: Third item of synconcealed() changes too often. (Dominique Pelle) Solution: Reset the sequence number at the start of each line. https://github.com/vim/vim/commit/cc0750dc6e878394ab0fd922b7ea4280918ae406 closes #7589 --- runtime/doc/eval.txt | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) (limited to 'runtime') diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt index 37a4962732..767fc133d8 100644 --- a/runtime/doc/eval.txt +++ b/runtime/doc/eval.txt @@ -7610,12 +7610,21 @@ synconcealed({lnum}, {col}) *synconcealed()* is 1, the second item contains the text which will be displayed in place of the concealed text, depending on the current setting of 'conceallevel' and 'listchars'. - 3. The third and final item in the list is a unique number - representing the specific syntax region matched. This - allows detection of the beginning of a new concealable - region if there are two consecutive regions with the same - replacement character. For an example use see - $VIMRUNTIME/syntax/2html.vim . + 3. The third and final item in the list is a number + representing the specific syntax region matched in the + line. When the character is not concealed the value is + zero. This allows detection of the beginning of a new + concealable region if there are two consecutive regions + with the same replacement character. For an example, if + the text is "123456" and both "23" and "45" are concealed + and replace by the character "X", then: + call returns ~ + synconcealed(lnum, 1) [0, '', 0] + synconcealed(lnum, 2) [1, 'X', 1] + synconcealed(lnum, 3) [1, 'X', 1] + synconcealed(lnum, 4) [1, 'X', 2] + synconcealed(lnum, 5) [1, 'X', 2] + synconcealed(lnum, 6) [0, '', 0] synstack({lnum}, {col}) *synstack()* -- cgit From dc536295875640ef5d7b28d8135d0ef72d782d5e Mon Sep 17 00:00:00 2001 From: Marco Hinz Date: Thu, 8 Feb 2018 00:27:54 +0100 Subject: macOS: Use `pbpaste` to detect a working clipboard (#7983) `pbcopy` writes to the clipboard, it should not be used to sanity-check the clipboard. --- runtime/autoload/health/provider.vim | 2 +- runtime/autoload/provider/clipboard.vim | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'runtime') diff --git a/runtime/autoload/health/provider.vim b/runtime/autoload/health/provider.vim index ae106095f9..073dcf92a8 100644 --- a/runtime/autoload/health/provider.vim +++ b/runtime/autoload/health/provider.vim @@ -126,7 +126,7 @@ endfunction function! s:check_clipboard() abort call health#report_start('Clipboard (optional)') - if !empty($TMUX) && executable('tmux') && executable('pbcopy') && !s:cmd_ok('pbcopy') + if !empty($TMUX) && executable('tmux') && executable('pbpaste') && !s:cmd_ok('pbpaste') let tmux_version = matchstr(system('tmux -V'), '\d\+\.\d\+') call health#report_error('pbcopy does not work with tmux version: '.tmux_version, \ ['Install tmux 2.6+. https://superuser.com/q/231130', diff --git a/runtime/autoload/provider/clipboard.vim b/runtime/autoload/provider/clipboard.vim index 9e2e6046f8..87a0315073 100644 --- a/runtime/autoload/provider/clipboard.vim +++ b/runtime/autoload/provider/clipboard.vim @@ -64,7 +64,7 @@ function! provider#clipboard#Executable() abort let s:paste = get(g:clipboard, 'paste', { '+': v:null, '*': v:null }) let s:cache_enabled = get(g:clipboard, 'cache_enabled', 0) return get(g:clipboard, 'name', 'g:clipboard') - elseif has('mac') && executable('pbcopy') && s:cmd_ok('pbcopy') + elseif has('mac') && executable('pbpaste') && s:cmd_ok('pbpaste') let s:copy['+'] = 'pbcopy' let s:paste['+'] = 'pbpaste' let s:copy['*'] = s:copy['+'] -- cgit From a265334406ca9ec84732acd1fde93300ce00310b Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Thu, 8 Feb 2018 01:11:54 +0100 Subject: defaults: sidescroll=1 ref #6289 --- runtime/doc/options.txt | 7 +++---- runtime/doc/term.txt | 5 ----- runtime/doc/vim_diff.txt | 1 + 3 files changed, 4 insertions(+), 9 deletions(-) (limited to 'runtime') diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt index 6a36202177..a1a361fc85 100644 --- a/runtime/doc/options.txt +++ b/runtime/doc/options.txt @@ -5445,14 +5445,13 @@ A jump table for the options with a short description can be found at |Q_op|. See |tab-page| for more information about tab pages. *'sidescroll'* *'ss'* -'sidescroll' 'ss' number (default 0) +'sidescroll' 'ss' number (default 1) global The minimal number of columns to scroll horizontally. Used only when the 'wrap' option is off and the cursor is moved off of the screen. When it is zero the cursor will be put in the middle of the screen. - When using a slow terminal set it to a large number or 0. When using - a fast terminal use a small number or 1. Not used for "zh" and "zl" - commands. + When using a slow terminal set it to a large number or 0. Not used + for "zh" and "zl" commands. *'sidescrolloff'* *'siso'* 'sidescrolloff' 'siso' number (default 0) diff --git a/runtime/doc/term.txt b/runtime/doc/term.txt index 6cf62f9bb5..075ffdac52 100644 --- a/runtime/doc/term.txt +++ b/runtime/doc/term.txt @@ -232,11 +232,6 @@ correct values. See |:mode|. Slow and fast terminals *slow-fast-terminal* *slow-terminal* -If you have a fast terminal you may like to set the 'ruler' option. The -cursor position is shown in the status line. If you are using horizontal -scrolling ('wrap' option off) consider setting 'sidescroll' to a small -number. - If you have a slow terminal you may want to reset the 'showcmd' and 'ruler' options. The command characters and cursor positions will not be shown in the status line (which involves a lot of cursor motions and attribute changes for diff --git a/runtime/doc/vim_diff.txt b/runtime/doc/vim_diff.txt index c5c558279e..d61c4d0c06 100644 --- a/runtime/doc/vim_diff.txt +++ b/runtime/doc/vim_diff.txt @@ -48,6 +48,7 @@ a complete and centralized reference of those differences. - 'ruler' is set by default - 'sessionoptions' doesn't include "options" - 'showcmd' is set by default +- 'sidescroll' defaults to 1 - 'smarttab' is set by default - 'tabpagemax' defaults to 50 - 'tags' defaults to "./tags;,tags" -- cgit From c8356e1151cf6db8cad93f74973a7452e62d6be0 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Thu, 1 Feb 2018 23:32:43 +0100 Subject: vim-patch:8.0.0440: not enough test coverage in Insert mode [Nvim note: test_override() omitted] Problem: Not enough test coverage in Insert mode. Solution: Add lots of tests. Add test_override(). (Christian Brabandt, closes vim/vim#1521) https://github.com/vim/vim/commit/eb992cb90fd79c77ad2743459ac898e6ac3de939 --- runtime/doc/vim_diff.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'runtime') diff --git a/runtime/doc/vim_diff.txt b/runtime/doc/vim_diff.txt index d61c4d0c06..7426cd0940 100644 --- a/runtime/doc/vim_diff.txt +++ b/runtime/doc/vim_diff.txt @@ -376,7 +376,6 @@ MS-DOS support: Test functions: test_alloc_fail() test_autochdir() - test_disable_char_avail() test_garbagecollect_now() test_null_channel() test_null_dict() @@ -384,6 +383,7 @@ Test functions: test_null_list() test_null_partial() test_null_string() + test_override() test_settime() Other options: -- cgit From bbdb074aec4f5ae1f61c451fb059e83d790e173e Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Fri, 2 Feb 2018 22:27:43 +0100 Subject: vim-patch:8.0.0721: :argedit can only have one argument Problem: :argedit can only have one argument. Solution: Allow for multiple arguments. (Christian Brabandt) https://github.com/vim/vim/commit/90305c66a8637ea43a6509c7ab597734dd218365 --- runtime/doc/editing.txt | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'runtime') diff --git a/runtime/doc/editing.txt b/runtime/doc/editing.txt index 1b9a1b38fb..5939cb8a8b 100644 --- a/runtime/doc/editing.txt +++ b/runtime/doc/editing.txt @@ -562,16 +562,16 @@ list of the current window. buffer. Also see |++opt| and |+cmd|. -:[count]arge[dit][!] [++opt] [+cmd] {name} *:arge* *:argedit* - Add {name} to the argument list and edit it. +:[count]arge[dit][!] [++opt] [+cmd] {name} .. *:arge* *:argedit* + Add {name}s to the argument list and edit it. When {name} already exists in the argument list, this entry is edited. This is like using |:argadd| and then |:edit|. - Note that only one file name is allowed, and spaces - inside the file name are allowed, like with |:edit|. + Spaces in filenames have to be escaped with "\". [count] is used like with |:argadd|. - [!] is required if the current file cannot be - |abandon|ed. + If the current file cannot be |abandon|ed {name}s will + still be added to the argument list, but won't be + edited. No check for duplicates is done. Also see |++opt| and |+cmd|. :[count]arga[dd] {name} .. *:arga* *:argadd* *E479* -- cgit From 16a416836464d64f3054aeb727c773ebe5ac7124 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Sat, 3 Feb 2018 11:58:44 +0100 Subject: vim-patch:8.0.0613: the conf filetype is used before ftdetect from packages Problem: The conf filetype detection is done before ftdetect scripts from packages that are added later. Solution: Add the FALLBACK argument to :setfiletype. (closes vim/vim#1679, closes vim/vim#1693) https://github.com/vim/vim/commit/3e54569b17683318e0cb6693ab0024c2ad1e3e8f --- runtime/filetype.vim | 31 +++++++++++++++++++++++++------ 1 file changed, 25 insertions(+), 6 deletions(-) (limited to 'runtime') diff --git a/runtime/filetype.vim b/runtime/filetype.vim index 76f76af345..90b4fdaa74 100644 --- a/runtime/filetype.vim +++ b/runtime/filetype.vim @@ -1183,14 +1183,21 @@ au BufNewFile,BufRead *.markdown,*.mdown,*.mkd,*.mkdn,*.mdwn,*.md setf markdown " Mason au BufNewFile,BufRead *.mason,*.mhtml,*.comp setf mason -" Matlab or Objective C +" Mathematica, Matlab, Murphi or Objective C au BufNewFile,BufRead *.m call s:FTm() func! s:FTm() let n = 1 - while n < 10 + let saw_comment = 0 " Whether we've seen a multiline comment leader. + while n < 100 let line = getline(n) - if line =~ '^\s*\(#\s*\(include\|import\)\>\|@import\>\|/\*\|//\)' + if line =~ '^\s*/\*' + " /* ... */ is a comment in Objective C and Murphi, so we can't conclude + " it's either of them yet, but track this as a hint in case we don't see + " anything more definitive. + let saw_comment = 1 + endif + if line =~ '^\s*\(#\s*\(include\|import\)\>\|@import\>\|//\)' setf objc return endif @@ -1202,11 +1209,23 @@ func! s:FTm() setf mma return endif + if line =~ '^\c\s*\(\(type\|var\)\>\|--\)' + setf murphi + return + endif let n = n + 1 endwhile - if exists("g:filetype_m") + + if saw_comment + " We didn't see anything definitive, but this looks like either Objective C + " or Murphi based on the comment leader. Assume the former as it is more + " common. + setf objc + elseif exists("g:filetype_m") + " Use user specified default filetype for .m exe "setf " . g:filetype_m else + " Default is matlab setf matlab endif endfunc @@ -2792,12 +2811,12 @@ runtime! ftdetect/*.vim " state. augroup END -" Generic configuration file (check this last, it's just guessing!) +" Generic configuration file. Use FALLBACK, it's just guessing! au filetypedetect BufNewFile,BufRead,StdinReadPost * \ if !did_filetype() && expand("") !~ g:ft_ignore_pat \ && (getline(1) =~ '^#' || getline(2) =~ '^#' || getline(3) =~ '^#' \ || getline(4) =~ '^#' || getline(5) =~ '^#') | - \ setf conf | + \ setf FALLBACK conf | \ endif -- cgit From 9baf60c6170489d3e7ba159d6391f88fed15b9a9 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Sat, 3 Feb 2018 12:03:43 +0100 Subject: vim-patch:8.0.0894: there is no test for runtime filetype detection Problem: There is no test for runtime filetype detection. Solution: Test a list of filetypes from patterns. https://github.com/vim/vim/commit/0a0217abfabcee8b0779df2e18a186a4b41e18ce --- runtime/filetype.vim | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'runtime') diff --git a/runtime/filetype.vim b/runtime/filetype.vim index 90b4fdaa74..fb2fad1220 100644 --- a/runtime/filetype.vim +++ b/runtime/filetype.vim @@ -1019,7 +1019,7 @@ au BufNewFile,BufRead *.java,*.jav setf java au BufNewFile,BufRead *.jj,*.jjt setf javacc " JavaScript, ECMAScript -au BufNewFile,BufRead *.js,*.javascript,*.es,*.jsx setf javascript +au BufNewFile,BufRead *.js,*.javascript,*.es,*.jsx,*.mjs setf javascript " Java Server Pages au BufNewFile,BufRead *.jsp setf jsp @@ -2265,6 +2265,8 @@ func! s:FTtex() elseif format == 'plaintex' let format = 'plain' endif + elseif expand('%') =~ 'tex/context/.*/.*.tex' + let format = 'context' else " Default value, may be changed later: let format = exists("g:tex_flavor") ? g:tex_flavor : 'plain' @@ -2306,7 +2308,7 @@ func! s:FTtex() endfunc " ConTeXt -au BufNewFile,BufRead tex/context/*/*.tex,*.mkii,*.mkiv,*.mkvi setf context +au BufNewFile,BufRead *.mkii,*.mkiv,*.mkvi setf context " Texinfo au BufNewFile,BufRead *.texinfo,*.texi,*.txi setf texinfo -- cgit From e15f2b4b9623df739ca38f1115286b2a4d4956cd Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Sat, 3 Feb 2018 12:07:59 +0100 Subject: vim-patch:8.0.0906: don't recognize Couchbase files Problem: Don't recognize Couchbase files. Solution: Add filetype detection. (Eugene Ciurana, closes vim/vim#1951) https://github.com/vim/vim/commit/d9bc8a801aeaffa77d4094d43bf97f0ced3db92b --- runtime/filetype.vim | 3 +++ 1 file changed, 3 insertions(+) (limited to 'runtime') diff --git a/runtime/filetype.vim b/runtime/filetype.vim index fb2fad1220..a2e1f23bf1 100644 --- a/runtime/filetype.vim +++ b/runtime/filetype.vim @@ -1334,6 +1334,9 @@ au BufNewFile,BufRead *.mush setf mush " Mutt setup file (also for Muttng) au BufNewFile,BufRead Mutt{ng,}rc setf muttrc +" N1QL +au BufRead,BufNewfile *.n1ql,*.nql setf n1ql + " Nano au BufNewFile,BufRead */etc/nanorc,*.nanorc setf nanorc -- cgit From 6e5cb0debd23693175bd05409d3f1af4015567df Mon Sep 17 00:00:00 2001 From: Björn Linse Date: Tue, 13 Feb 2018 13:45:49 +0100 Subject: ui: refactor ui options --- runtime/doc/api.txt | 1 + runtime/doc/ui.txt | 21 +++++++++++++++++---- 2 files changed, 18 insertions(+), 4 deletions(-) (limited to 'runtime') diff --git a/runtime/doc/api.txt b/runtime/doc/api.txt index fd6918de43..f828f2cdc1 100644 --- a/runtime/doc/api.txt +++ b/runtime/doc/api.txt @@ -49,6 +49,7 @@ version.api_prerelease Declares the current API level as unstable > (version.api_prerelease && fn.since == version.api_level) functions API function signatures ui_events UI event signatures |ui| +ui_options Supported |ui-options| {fn}.since API level where function {fn} was introduced {fn}.deprecated_since API level where function {fn} was deprecated types Custom handle types defined by Nvim diff --git a/runtime/doc/ui.txt b/runtime/doc/ui.txt index 1b3c10b71e..6f6df2d7ae 100644 --- a/runtime/doc/ui.txt +++ b/runtime/doc/ui.txt @@ -30,10 +30,22 @@ a dictionary with these (optional) keys: `ext_cmdline` Externalize the cmdline. |ui-cmdline| `ext_wildmenu` Externalize the wildmenu. |ui-ext-wildmenu| -Nvim will then send msgpack-rpc notifications, with the method name "redraw" -and a single argument, an array of screen update events. -Update events are tuples whose first element is the event name and remaining -elements the event parameters. +Specifying a non-existent option is an error. To facilitate an ui that +supports different versions of Nvim, the |api-metadata| key `ui_options` +contains the list of supported options. Additionally Nvim currently requires +that all connected UIs use the same set of widgets. Therefore the active +widgets will be the intersection of the requested widget sets of all connected +UIs. The "option_set" event will be used to specify which widgets actually are +active. + +After attaching, Nvim will send msgpack-rpc notifications, with the method +name "redraw" and a single argument, an array of screen update events. Update +events are arrays whose first element is the event name and remaining elements +are each tuples of event parameters. This allows multiple events of the same +kind to be sent in a row without the event name being repeated. This batching +is mostly used for "put", as each "put" event just puts contents in one screen +cell, but clients must be prepared for multiple argument sets being batched +for all event kinds. Events must be handled in order. The user should only see the updated screen state after all events in the same "redraw" batch are processed (not any @@ -93,6 +105,7 @@ Global Events *ui-global* 'linespace' 'showtabline' 'termguicolors' + `ext_*` (all |ui-ext-options|) Options are not added to the list if their effects are already taken care of. For instance, instead of forwarding the raw 'mouse' option -- cgit From e9134421ab8f72393d469d9d7793d4a75984cb93 Mon Sep 17 00:00:00 2001 From: Nimit Bhardwaj Date: Wed, 14 Feb 2018 19:48:01 +0530 Subject: vim-patch-8.0.0649 and vim-patch-8.0.0650: autocmd open help 2 times --- runtime/filetype.vim | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'runtime') diff --git a/runtime/filetype.vim b/runtime/filetype.vim index a2e1f23bf1..4e0f145c18 100644 --- a/runtime/filetype.vim +++ b/runtime/filetype.vim @@ -1,7 +1,7 @@ " Vim support file to detect file types " " Maintainer: Bram Moolenaar -" Last Change: 2017 Nov 02 +" Last Change: 2018 Feb 14 " Listen very carefully, I will say this only once if exists("did_load_filetypes") @@ -48,6 +48,9 @@ func! s:StarSetf(ft) endif endfunc +" Vim help file +au BufNewFile,BufRead $VIMRUNTIME/doc/*.txt setf help + " Abaqus or Trasys au BufNewFile,BufRead *.inp call s:Check_inp() @@ -2804,8 +2807,13 @@ au BufNewFile,BufRead zsh*,zlog* call s:StarSetf('zsh') " Plain text files, needs to be far down to not override others. This avoids " the "conf" type being used if there is a line starting with '#'. -au BufNewFile,BufRead *.txt,*.text,README setf text +au BufNewFile,BufRead *.text,README setf text +" Help files match *.txt but should have a last line that is a modeline. +au BufNewFile,BufRead *.txt + \ if getline('$') !~ 'vim:.*ft=help' + \| setf text + \| endif " Use the filetype detect plugins. They may overrule any of the previously " detected filetypes. -- cgit From 48dc1f3f90c6bbebcaa93ecf3348648f45c45239 Mon Sep 17 00:00:00 2001 From: James McCoy Date: Fri, 16 Feb 2018 13:33:07 -0500 Subject: provider: ruby: Use stderr_buffered to collect stderr --- runtime/autoload/provider/ruby.vim | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) (limited to 'runtime') diff --git a/runtime/autoload/provider/ruby.vim b/runtime/autoload/provider/ruby.vim index 3fb65fecdf..3d1f7a4138 100644 --- a/runtime/autoload/provider/ruby.vim +++ b/runtime/autoload/provider/ruby.vim @@ -4,16 +4,7 @@ if exists('g:loaded_ruby_provider') endif let g:loaded_ruby_provider = 1 -let s:stderr = {} -let s:job_opts = {'rpc': v:true} - -function! s:job_opts.on_stderr(chan_id, data, event) abort - let stderr = get(s:stderr, a:chan_id, ['']) - let last = remove(stderr, -1) - let a:data[0] = last.a:data[0] - call extend(stderr, a:data) - let s:stderr[a:chan_id] = stderr -endfunction +let s:job_opts = {'rpc': v:true, 'stderr_buffered': v:true} function! provider#ruby#Detect() abort if exists("g:ruby_host_prog") @@ -36,14 +27,15 @@ function! provider#ruby#Require(host) abort endfor try - let channel_id = jobstart(prog, s:job_opts) + let job = copy(s:job_opts) + let channel_id = jobstart(prog, job) if rpcrequest(channel_id, 'poll') ==# 'ok' return channel_id endif catch echomsg v:throwpoint echomsg v:exception - for row in get(s:stderr, channel_id, []) + for row in get(job, 'stderr', []) echomsg row endfor endtry -- cgit From 6fbb8d6739b353752dc405452fb41f9cdf20a0b9 Mon Sep 17 00:00:00 2001 From: James McCoy Date: Fri, 16 Feb 2018 13:33:23 -0500 Subject: provider: Safely access job.stderr in #Require If `jobstart()` fails, then the subsequent `rpcrequest()` will throw due to an invalid channel id. This causes `job.stderr` not to exist, so we throw another exception when trying to dump the job's stderr. Error detected while processing function remote#define#AutocmdBootstrap[1]..remote#host#Require[10]..provider#pythonx#Require: line 22: E716: Key not present in Dictionary: stderr This obfuscates the actual problem. --- runtime/autoload/provider/node.vim | 2 +- runtime/autoload/provider/pythonx.vim | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'runtime') diff --git a/runtime/autoload/provider/node.vim b/runtime/autoload/provider/node.vim index 3dde18022e..493eecf433 100644 --- a/runtime/autoload/provider/node.vim +++ b/runtime/autoload/provider/node.vim @@ -81,7 +81,7 @@ function! provider#node#Require(host) abort catch echomsg v:throwpoint echomsg v:exception - for row in job.stderr + for row in get(job, 'stderr', []) echomsg row endfor endtry diff --git a/runtime/autoload/provider/pythonx.vim b/runtime/autoload/provider/pythonx.vim index 1c77eabe23..f9aa09b16b 100644 --- a/runtime/autoload/provider/pythonx.vim +++ b/runtime/autoload/provider/pythonx.vim @@ -29,7 +29,7 @@ function! provider#pythonx#Require(host) abort catch echomsg v:throwpoint echomsg v:exception - for row in job.stderr + for row in get(job, 'stderr', []) echomsg row endfor endtry -- cgit From 3af3515e74c925c783ad5321589830ed3d54b24a Mon Sep 17 00:00:00 2001 From: James McCoy Date: Fri, 16 Feb 2018 13:53:02 -0500 Subject: Add provider#Poll() to handle starting and polling the provider --- runtime/autoload/provider.vim | 21 +++++++++++++++++++++ runtime/autoload/provider/node.vim | 18 +----------------- runtime/autoload/provider/pythonx.vim | 18 +----------------- runtime/autoload/provider/ruby.vim | 17 +---------------- 4 files changed, 24 insertions(+), 50 deletions(-) create mode 100644 runtime/autoload/provider.vim (limited to 'runtime') diff --git a/runtime/autoload/provider.vim b/runtime/autoload/provider.vim new file mode 100644 index 0000000000..dc24e801d0 --- /dev/null +++ b/runtime/autoload/provider.vim @@ -0,0 +1,21 @@ +" Common functions for providers + +" Start the provider and perform a 'poll' request +" +" Returns a valid channel on success +function! provider#Poll(argv, orig_name, log_env) abort + let job = {'rpc': v:true, 'stderr_buffered': v:true} + try + let channel_id = jobstart(a:argv, job) + if channel_id > 0 && rpcrequest(channel_id, 'poll') ==# 'ok' + return channel_id + endif + catch + echomsg v:throwpoint + echomsg v:exception + for row in get(job, 'stderr', []) + echomsg row + endfor + endtry + throw remote#host#LoadErrorForHost(a:orig_name, a:log_env) +endfunction diff --git a/runtime/autoload/provider/node.vim b/runtime/autoload/provider/node.vim index 493eecf433..ae6f84de72 100644 --- a/runtime/autoload/provider/node.vim +++ b/runtime/autoload/provider/node.vim @@ -3,8 +3,6 @@ if exists('g:loaded_node_provider') endif let g:loaded_node_provider = 1 -let s:job_opts = {'rpc': v:true, 'stderr_buffered': v:true} - function! s:is_minimum_version(version, min_major, min_minor) abort if empty(a:version) let nodejs_version = get(split(system(['node', '-v']), "\n"), 0, '') @@ -72,21 +70,7 @@ function! provider#node#Require(host) abort call add(args, provider#node#Prog()) - try - let job = copy(s:job_opts) - let channel_id = jobstart(args, job) - if rpcrequest(channel_id, 'poll') ==# 'ok' - return channel_id - endif - catch - echomsg v:throwpoint - echomsg v:exception - for row in get(job, 'stderr', []) - echomsg row - endfor - endtry - endtry - throw remote#host#LoadErrorForHost(a:host.orig_name, '$NVIM_NODE_LOG_FILE') + return provider#Poll(args, a:host.orig_name, '$NVIM_NODE_LOG_FILE') endfunction function! provider#node#Call(method, args) abort diff --git a/runtime/autoload/provider/pythonx.vim b/runtime/autoload/provider/pythonx.vim index f9aa09b16b..b51c398410 100644 --- a/runtime/autoload/provider/pythonx.vim +++ b/runtime/autoload/provider/pythonx.vim @@ -5,8 +5,6 @@ endif let s:loaded_pythonx_provider = 1 -let s:job_opts = {'rpc': v:true, 'stderr_buffered': v:true} - function! provider#pythonx#Require(host) abort let ver = (a:host.orig_name ==# 'python') ? 2 : 3 @@ -20,21 +18,7 @@ function! provider#pythonx#Require(host) abort call add(args, plugin.path) endfor - try - let job = copy(s:job_opts) - let channel_id = jobstart(args, job) - if rpcrequest(channel_id, 'poll') ==# 'ok' - return channel_id - endif - catch - echomsg v:throwpoint - echomsg v:exception - for row in get(job, 'stderr', []) - echomsg row - endfor - endtry - throw remote#host#LoadErrorForHost(a:host.orig_name, - \ '$NVIM_PYTHON_LOG_FILE') + return provider#Poll(args, a:host.orig_name, '$NVIM_PYTHON_LOG_FILE') endfunction function! provider#pythonx#Detect(major_ver) abort diff --git a/runtime/autoload/provider/ruby.vim b/runtime/autoload/provider/ruby.vim index 3d1f7a4138..2fe3817512 100644 --- a/runtime/autoload/provider/ruby.vim +++ b/runtime/autoload/provider/ruby.vim @@ -4,8 +4,6 @@ if exists('g:loaded_ruby_provider') endif let g:loaded_ruby_provider = 1 -let s:job_opts = {'rpc': v:true, 'stderr_buffered': v:true} - function! provider#ruby#Detect() abort if exists("g:ruby_host_prog") return g:ruby_host_prog @@ -26,20 +24,7 @@ function! provider#ruby#Require(host) abort let prog .= " " . shellescape(plugin.path) endfor - try - let job = copy(s:job_opts) - let channel_id = jobstart(prog, job) - if rpcrequest(channel_id, 'poll') ==# 'ok' - return channel_id - endif - catch - echomsg v:throwpoint - echomsg v:exception - for row in get(job, 'stderr', []) - echomsg row - endfor - endtry - throw remote#host#LoadErrorForHost(a:host.orig_name, '$NVIM_RUBY_LOG_FILE') + return provider#Poll(prog, a:host.orig_name, '$NVIM_RUBY_LOG_FILE') endfunction function! provider#ruby#Call(method, args) abort -- cgit From eccd60aaf4ebc445d45e51a73d0807242e496a6a Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Sun, 18 Feb 2018 19:43:10 +0100 Subject: runtime/doc: modeline is mandatory in help docs see Vim 8.0.0650 e9134421ab8f --- runtime/doc/msgpack_rpc.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'runtime') diff --git a/runtime/doc/msgpack_rpc.txt b/runtime/doc/msgpack_rpc.txt index 2d8f5af6d2..11fad105b5 100644 --- a/runtime/doc/msgpack_rpc.txt +++ b/runtime/doc/msgpack_rpc.txt @@ -242,4 +242,4 @@ Even for statically compiled clients it is good practice to avoid hardcoding the type codes, because a client may be built against one Nvim version but connect to another with different type codes. - + vim:tw=78:ts=8:ft=help:norl: -- cgit From 00665d3c701ef1b6b276f750a772a6aa8a42c8c1 Mon Sep 17 00:00:00 2001 From: Shougo Date: Mon, 19 Feb 2018 07:56:59 +0900 Subject: vim-patch:8.0.1493: completion items cannot be annotated (#8003) Problem: Completion items cannot be annotated. Solution: Add a "user_data" entry to the completion item. (Ben Jackson, coses vim/vim#2608, closes vim/vim#2508) https://github.com/vim/vim/commit/9b56a57cdae31f7a2c85d440392bf63d3253a158 --- runtime/doc/insert.txt | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'runtime') diff --git a/runtime/doc/insert.txt b/runtime/doc/insert.txt index b6cc18ab1b..9ae35bea52 100644 --- a/runtime/doc/insert.txt +++ b/runtime/doc/insert.txt @@ -1077,6 +1077,8 @@ items: item with the same word is already present. empty when non-zero this match will be added even when it is an empty string + user_data custom data which is associated with the item and + available in |v:completed_item| All of these except "icase", "dup" and "empty" must be a string. If an item does not meet these requirements then an error message is given and further @@ -1170,6 +1172,8 @@ The menu is used when: The 'pumheight' option can be used to set a maximum height. The default is to use all space available. +The 'pumwidth' option can be used to set a minimum width. The default is 15 +characters. There are three states: 1. A complete match has been inserted, e.g., after using CTRL-N or CTRL-P. -- cgit From 06b7561e785afc9ad0bb66b789a450b96605fd97 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Mon, 19 Feb 2018 21:10:16 +0100 Subject: build: remove contents of build/runtime/doc/* surgically (#8024) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Only remove the directory contents. If the directory itself is removed, then `sudo make install` creates a root-owned …/doc/ directory. That breaks the next non-root build. This was an accident of 0b1904d835a2. Note: the following does not work, because it misses renamed help files (which would no longer be in the build-tree definition) COMMAND ${CMAKE_COMMAND} -E remove ${BUILDDOCFILES} ${GENERATED_HELP_TAGS} --- runtime/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'runtime') diff --git a/runtime/CMakeLists.txt b/runtime/CMakeLists.txt index 0172f630cd..b3907fdf37 100644 --- a/runtime/CMakeLists.txt +++ b/runtime/CMakeLists.txt @@ -71,7 +71,7 @@ foreach(DF ${DOCFILES}) endforeach() add_custom_target(helptags - COMMAND ${CMAKE_COMMAND} -E remove_directory ${GENERATED_RUNTIME_DIR}/doc + COMMAND ${CMAKE_COMMAND} -E remove ${GENERATED_RUNTIME_DIR}/doc/* COMMAND ${CMAKE_COMMAND} -E copy_directory ${PROJECT_SOURCE_DIR}/runtime/doc ${GENERATED_RUNTIME_DIR}/doc COMMAND "${PROJECT_BINARY_DIR}/bin/nvim" -- cgit From c8074e3792727a378cf8510a347ac6b784b210c8 Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Thu, 22 Feb 2018 02:30:39 +0100 Subject: runtime/autoload/health/*.vim: fix vint warning (#8048) --- runtime/autoload/health/nvim.vim | 8 ++++---- runtime/autoload/health/provider.vim | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'runtime') diff --git a/runtime/autoload/health/nvim.vim b/runtime/autoload/health/nvim.vim index 017c047ef4..d09a714719 100644 --- a/runtime/autoload/health/nvim.vim +++ b/runtime/autoload/health/nvim.vim @@ -7,12 +7,12 @@ function! s:check_config() abort " If $VIM is empty we don't care. Else make sure it is valid. if !empty($VIM) && !filereadable($VIM.'/runtime/doc/nvim.txt') let ok = v:false - call health#report_error("$VIM is invalid: ".$VIM) + call health#report_error('$VIM is invalid: '.$VIM) endif if exists('$NVIM_TUI_ENABLE_CURSOR_SHAPE') let ok = v:false - call health#report_warn("$NVIM_TUI_ENABLE_CURSOR_SHAPE is ignored in Nvim 0.2+", + call health#report_warn('$NVIM_TUI_ENABLE_CURSOR_SHAPE is ignored in Nvim 0.2+', \ [ "Use the 'guicursor' option to configure cursor shape. :help 'guicursor'", \ 'https://github.com/neovim/neovim/wiki/Following-HEAD#20170402' ]) endif @@ -100,8 +100,8 @@ function! s:check_performance() abort else call health#report_info(buildtype) call health#report_warn( - \ "Non-optimized build-type. Nvim will be slower.", - \ ["Install a different Nvim package, or rebuild with `CMAKE_BUILD_TYPE=RelWithDebInfo`.", + \ 'Non-optimized build-type. Nvim will be slower.', + \ ['Install a different Nvim package, or rebuild with `CMAKE_BUILD_TYPE=RelWithDebInfo`.', \ s:suggest_faq]) endif endfunction diff --git a/runtime/autoload/health/provider.vim b/runtime/autoload/health/provider.vim index 073dcf92a8..e5daa0a4cc 100644 --- a/runtime/autoload/health/provider.vim +++ b/runtime/autoload/health/provider.vim @@ -457,7 +457,7 @@ function! s:check_ruby() abort let host = provider#ruby#Detect() if empty(host) - call health#report_warn("`neovim-ruby-host` not found.", + call health#report_warn('`neovim-ruby-host` not found.', \ ['Run `gem install neovim` to ensure the neovim RubyGem is installed.', \ 'Run `gem environment` to ensure the gem bin directory is in $PATH.', \ 'If you are using rvm/rbenv/chruby, try "rehashing".', -- cgit From 1eb4aff57a7c3f247b3d6267b608308ac96f5ec9 Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Thu, 22 Feb 2018 02:37:23 +0100 Subject: checkhealth: python: do not report pythonx_errs twice (#8045) They get reported unconditionally as errors below. --- runtime/autoload/health/provider.vim | 3 --- 1 file changed, 3 deletions(-) (limited to 'runtime') diff --git a/runtime/autoload/health/provider.vim b/runtime/autoload/health/provider.vim index e5daa0a4cc..b124d04ea8 100644 --- a/runtime/autoload/health/provider.vim +++ b/runtime/autoload/health/provider.vim @@ -289,9 +289,6 @@ function! s:check_python(version) abort if empty(pyname) call health#report_warn('No Python interpreter was found with the neovim ' \ . 'module. Using the first available for diagnostics.') - if !empty(pythonx_errs) - call health#report_warn(pythonx_errs) - endif endif if !empty(pyname) -- cgit From 830b5819a046b03750a74fa6d745d1200c6215ec Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Thu, 22 Feb 2018 02:38:00 +0100 Subject: health/provider: check Python also with loaded_var (#8047) `g:loaded_python3_provider` gets set when the autoload file is sourced, but this might error out, e.g. with deoplete: [deoplete] Failed to load python3 host. You can try to see what happened by starting nvim with $NVIM_PYTHON_LOG_FILE set and opening the generated log file. Also, the host stderr is available in messages. [deoplete] function remote#define#FunctionBootstrap[1]..remote#host#Require[10]..provider#pythonx#Require[13]..provider#Poll, line 14 [deoplete] deoplete requires Python3 support("+python3"). [deoplete] deoplete failed to load. Try the :UpdateRemotePlugins command and restart Neovim. See also :checkhealth. It refers to `:checkhealth` from there explicitly, which would then (without this patch) say that Python 3 is disabled. This patch changes the reported info to include that it might have been disabled due to some error, and keeps on going. --- runtime/autoload/health/provider.vim | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'runtime') diff --git a/runtime/autoload/health/provider.vim b/runtime/autoload/health/provider.vim index b124d04ea8..e18125300c 100644 --- a/runtime/autoload/health/provider.vim +++ b/runtime/autoload/health/provider.vim @@ -260,8 +260,7 @@ function! s:check_python(version) abort let python_multiple = [] if exists(loaded_var) && !exists('*provider#'.pyname.'#Call') - call health#report_info('Disabled. '.loaded_var.'='.eval(loaded_var)) - return + call health#report_info('Disabled ('.loaded_var.'='.eval(loaded_var).'). This might be due to some previous error.') endif if !empty(pyenv) -- cgit From 4696a5a10e16ca5c571e6b69248c5a8ee9685fda Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Thu, 22 Feb 2018 02:42:08 +0100 Subject: health.vim: minor cleanup (#8046) --- runtime/autoload/health.vim | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) (limited to 'runtime') diff --git a/runtime/autoload/health.vim b/runtime/autoload/health.vim index 53d45afc2e..56ae2071e9 100644 --- a/runtime/autoload/health.vim +++ b/runtime/autoload/health.vim @@ -93,26 +93,26 @@ function! s:help_to_link(s) abort return substitute(a:s, '\v:h%[elp] ([^|][^"\r\n ]+)', ':help |\1|', 'g') endfunction -" Format a message for a specific report item +" Format a message for a specific report item. +" a:1: Optional advice (string or list) function! s:format_report_message(status, msg, ...) abort " {{{ let output = ' - ' . a:status . ': ' . s:indent_after_line1(a:msg, 4) - let advice = [] " Optional parameters if a:0 > 0 - let advice = type(a:1) == type("") ? [a:1] : a:1 + let advice = type(a:1) == type('') ? [a:1] : a:1 if type(advice) != type([]) - throw "Expected String or List" + throw 'a:1: expected String or List' endif - endif - " Report each suggestion - if len(advice) > 0 - let output .= "\n - ADVICE:" + " Report each suggestion + if !empty(advice) + let output .= "\n - ADVICE:" + for suggestion in advice + let output .= "\n - " . s:indent_after_line1(suggestion, 10) + endfor + endif endif - for suggestion in advice - let output .= "\n - " . s:indent_after_line1(suggestion, 10) - endfor return s:help_to_link(output) endfunction " }}} @@ -128,6 +128,7 @@ function! health#report_ok(msg) abort " {{{ endfunction " }}} " Reports a health warning. +" a:1: Optional advice (string or list) function! health#report_warn(msg, ...) abort " {{{ if a:0 > 0 echo s:format_report_message('WARNING', a:msg, a:1) @@ -137,6 +138,7 @@ function! health#report_warn(msg, ...) abort " {{{ endfunction " }}} " Reports a failed healthcheck. +" a:1: Optional advice (string or list) function! health#report_error(msg, ...) abort " {{{ if a:0 > 0 echo s:format_report_message('ERROR', a:msg, a:1) -- cgit From 0c930c2969a8c7cce49382d0acb83e165644af41 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Tue, 17 Oct 2017 00:31:43 +0200 Subject: defaults: 'fillchars' MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Most fonts should have these by now. Both are a significant visual improvement. - Vertical connecting bar `│` is used by tmux, pstree, Windows 7 cmd.exe and nvim-qt.exe. - Middle dot `·` works on Windows 7 cmd.exe, nvim-qt.exe. For reference: tmux uses these chars to draw lines: │ ├ ─ --- runtime/doc/options.txt | 8 ++++---- runtime/doc/vim_diff.txt | 1 + 2 files changed, 5 insertions(+), 4 deletions(-) (limited to 'runtime') diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt index a1a361fc85..0345960b0d 100644 --- a/runtime/doc/options.txt +++ b/runtime/doc/options.txt @@ -2377,7 +2377,7 @@ A jump table for the options with a short description can be found at |Q_op|. Only normal file name characters can be used, "/\*?[|<>" are illegal. *'fillchars'* *'fcs'* -'fillchars' 'fcs' string (default "vert:|,fold:-") +'fillchars' 'fcs' string (default "vert:│,fold:·") global {not available when compiled without the |+windows| and |+folding| features} @@ -2387,8 +2387,8 @@ A jump table for the options with a short description can be found at |Q_op|. item default Used for ~ stl:c ' ' or '^' statusline of the current window stlnc:c ' ' or '=' statusline of the non-current windows - vert:c '|' vertical separators |:vsplit| - fold:c '-' filling 'foldtext' + vert:c '│' vertical separators |:vsplit| + fold:c '·' filling 'foldtext' diff:c '-' deleted lines of the 'diff' option Any one that is omitted will fall back to the default. For "stl" and @@ -2396,7 +2396,7 @@ A jump table for the options with a short description can be found at |Q_op|. otherwise. Example: > - :set fillchars=stl:^,stlnc:=,vert:\|,fold:-,diff:- + :set fillchars=stl:^,stlnc:=,vert:│,fold:·,diff:- < This is similar to the default, except that these characters will also be used when there is highlighting. diff --git a/runtime/doc/vim_diff.txt b/runtime/doc/vim_diff.txt index 7426cd0940..3924dd4ebe 100644 --- a/runtime/doc/vim_diff.txt +++ b/runtime/doc/vim_diff.txt @@ -35,6 +35,7 @@ a complete and centralized reference of those differences. - 'cscopeverbose' is enabled - 'directory' defaults to ~/.local/share/nvim/swap// (|xdg|), auto-created - 'display' defaults to "lastline" +- 'fillchars' defaults (in effect) to "vert:│,fold:·" - 'formatoptions' defaults to "tcqj" - 'history' defaults to 10000 (the maximum) - 'hlsearch' is set by default -- cgit From 384a39479a0b70abf9cd6ced0b5f1d53cd817c11 Mon Sep 17 00:00:00 2001 From: Matthieu Coudron Date: Fri, 9 Feb 2018 08:44:24 +0900 Subject: 'fillchars': fix defaults logic; handle ambiwidth=double #7986 Update tests. --- runtime/doc/options.txt | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'runtime') diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt index 0345960b0d..fbc055ddd5 100644 --- a/runtime/doc/options.txt +++ b/runtime/doc/options.txt @@ -2377,7 +2377,7 @@ A jump table for the options with a short description can be found at |Q_op|. Only normal file name characters can be used, "/\*?[|<>" are illegal. *'fillchars'* *'fcs'* -'fillchars' 'fcs' string (default "vert:│,fold:·") +'fillchars' 'fcs' string (default "") global {not available when compiled without the |+windows| and |+folding| features} @@ -2387,14 +2387,17 @@ A jump table for the options with a short description can be found at |Q_op|. item default Used for ~ stl:c ' ' or '^' statusline of the current window stlnc:c ' ' or '=' statusline of the non-current windows - vert:c '│' vertical separators |:vsplit| - fold:c '·' filling 'foldtext' + vert:c '│' or '|' vertical separators |:vsplit| + fold:c '·' or '-' filling 'foldtext' diff:c '-' deleted lines of the 'diff' option Any one that is omitted will fall back to the default. For "stl" and "stlnc" the space will be used when there is highlighting, '^' or '=' otherwise. + If 'ambiwidth' is "double" then "vert" and "fold" default to + single-byte alternatives. + Example: > :set fillchars=stl:^,stlnc:=,vert:│,fold:·,diff:- < This is similar to the default, except that these characters will also -- cgit From e18177692ab48e5ffc0c11184c723a52eed1248e Mon Sep 17 00:00:00 2001 From: Björn Linse Date: Fri, 23 Feb 2018 13:08:13 +0100 Subject: screen.c: make negative 'writedelay' show all redraws Currently writedelay shows the sequence of characters that are sent to the UI/TUI module. Here nvim has already applied an optimization: when attempting to put a char in a screen cell, if the same char already was there with the same attributes, UI output is disabled. When debugging redrawing it it sometimes more useful to inspect the redraw stream one step earlier, what region of the screen nvim actually is recomputing from buffer contents (win_line) and from evaluating statusline expressions. Take the popupmenu as an example. When closing the popupmenu (in the TUI), currently 'writedelay' looks like vim only is redrawing the region which the pum covered. This is not what happens internally: vim redraws the entire screen, even if only outputs the changed region. This commit allows negative values of 'writedelay', which causes a delay for all redrawn characters, even if the character already was displayed by the UI before. --- runtime/doc/options.txt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'runtime') diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt index fbc055ddd5..9ef5ccb5c5 100644 --- a/runtime/doc/options.txt +++ b/runtime/doc/options.txt @@ -6922,7 +6922,8 @@ A jump table for the options with a short description can be found at |Q_op|. 'writedelay' 'wd' number (default 0) global The number of milliseconds to wait for each character sent to the - screen. When non-zero, characters are sent to the terminal one by - one. For debugging purposes. + screen. When positive, characters are sent to the UI one by one. + When negative, all redrawn characters cause a delay, even if the + character already was displayed by the UI. For debugging purposes. vim:tw=78:ts=8:ft=help:noet:norl: -- cgit From 1d5eec2c626bd8125940c0425cc6f33213851781 Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Sun, 4 Mar 2018 20:04:52 +0100 Subject: health/provider: python: warning with correct host prog (#8049) I have `g:python3_host_prog` set to the system Python, where a package is also installed to provide the "neovim" module. `:checkhealth provider` however displays a warning for this: > Your virtualenv is not set up optimally. This is because /usr/bin/python is not in /home/user/.pyenv. I think this warning should not get displayed if host_prog_var exists. It goes back to the initial commit (20447ba09), and is maybe only missing the `!` there as with the previous commit. Full output: ``` - INFO: pyenv: /home/user/.pyenv/libexec/pyenv - INFO: pyenv root: /home/user/.pyenv - INFO: Using: g:python3_host_prog = "/usr/bin/python" - WARNING: Your virtualenv is not set up optimally (/usr/bin/python is not in /home/user/.pyenv). - ADVICE: - Create a virtualenv specifically for Neovim and use `g:python3_host_prog`. This will avoid the need to install Neovim's Python module in each virtualenv. - WARNING: $VIRTUAL_ENV exists but appears to be inactive. This could lead to unexpected results. - ADVICE: - If you are using Zsh, see: http://vi.stackexchange.com/a/7654 - INFO: Executable: /usr/bin/python - INFO: Python3 version: 3.6.4 - INFO: python-neovim version: 0.2.1 - OK: Latest python-neovim is installed: 0.2.1 ``` --- runtime/autoload/health/provider.vim | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'runtime') diff --git a/runtime/autoload/health/provider.vim b/runtime/autoload/health/provider.vim index e18125300c..4adab1aa76 100644 --- a/runtime/autoload/health/provider.vim +++ b/runtime/autoload/health/provider.vim @@ -345,8 +345,8 @@ function! s:check_python(version) abort endif endif - if !empty(python_bin) - if empty(venv) && !empty(pyenv) && !exists('g:'.host_prog_var) + if !empty(python_bin) && !exists('g:'.host_prog_var) + if empty(venv) && !empty(pyenv) \ && !empty(pyenv_root) && resolve(python_bin) !~# '^'.pyenv_root.'/' call health#report_warn('pyenv is not set up optimally.', [ \ printf('Create a virtualenv specifically ' @@ -354,7 +354,7 @@ function! s:check_python(version) abort \ . 'the need to install the Neovim Python module in each ' \ . 'version/virtualenv.', host_prog_var) \ ]) - elseif !empty(venv) && exists('g:'.host_prog_var) + elseif !empty(venv) if !empty(pyenv_root) let venv_root = pyenv_root else -- cgit From 338664e96c9b0fd00cfe2c1312fa40219301379d Mon Sep 17 00:00:00 2001 From: chemzqm Date: Wed, 14 Mar 2018 16:32:19 +0800 Subject: node/provider: support g:node_host_prog #8135 --- runtime/autoload/provider/node.vim | 3 +++ runtime/doc/provider.txt | 34 ++++++++++++++++++++++++++++------ 2 files changed, 31 insertions(+), 6 deletions(-) (limited to 'runtime') diff --git a/runtime/autoload/provider/node.vim b/runtime/autoload/provider/node.vim index ae6f84de72..39b5dc63b8 100644 --- a/runtime/autoload/provider/node.vim +++ b/runtime/autoload/provider/node.vim @@ -38,6 +38,9 @@ function! provider#node#can_inspect() abort endfunction function! provider#node#Detect() abort + if exists('g:node_host_prog') + return g:node_host_prog + endif let global_modules = get(split(system('npm root -g'), "\n"), 0, '') if v:shell_error || !isdirectory(global_modules) return '' diff --git a/runtime/doc/provider.txt b/runtime/doc/provider.txt index b806b08f95..d44cc2558e 100644 --- a/runtime/doc/provider.txt +++ b/runtime/doc/provider.txt @@ -33,20 +33,20 @@ To use Vim Python 2/3 plugins with Nvim: - For Python 2 plugins, make sure an interpreter for Python 2.6 or 2.7 is available in your `$PATH`, then install the `neovim` Python package systemwide: > - $ sudo pip2 install --upgrade neovim + sudo pip2 install --upgrade neovim < or for the current user: > - $ pip2 install --user --upgrade neovim + pip2 install --user --upgrade neovim < - For Python 3 plugins, make sure an interpreter for Python 3.3 or above is available in your `$PATH`, then install the `neovim` Python package systemwide: > - $ sudo pip3 install --upgrade neovim + sudo pip3 install --upgrade neovim < or for the current user: > - $ pip3 install --user --upgrade neovim + pip3 install --user --upgrade neovim < Note: The `--upgrade` flag ensures you have the latest version even if - a previous version was already installed. +a previous version was already installed. PYTHON PROVIDER CONFIGURATION ~ *g:python_host_prog* @@ -93,7 +93,7 @@ Run |:checkhealth| to see if your system is up-to-date. RUBY QUICKSTART ~ To use Vim Ruby plugins with Nvim, just install the latest `neovim` RubyGem: > - $ gem install neovim + gem install neovim RUBY PROVIDER CONFIGURATION ~ *g:loaded_ruby_provider* @@ -112,6 +112,28 @@ To use an absolute path (e.g. to an rbenv installation): > To use the RVM "system" Ruby installation: > let g:ruby_host_prog = 'rvm system do neovim-ruby-host' < +============================================================================== +Node.js integration *provider-nodejs* + +Nvim supports Node.js |remote-plugin|s. +https://github.com/neovim/node-client/ +https://nodejs.org/ + +NODEJS QUICKSTART~ + +To use javascript remote-plugins with Nvim, install the `neovim` npm package: > + npm install -g neovim +< +NODEJS PROVIDER CONFIGURATION~ + *g:loaded_node_provider* +To disable Node support: > + :let g:loaded_node_provider = 1 +< + *g:node_host_prog* +Command to start the Node host. Setting this makes startup faster. + +By default, Nvim searches for `neovim-node-host` using "npm root -g". This is +rather slow, you can set g:node_host_prog to avoid it. ============================================================================== Clipboard integration *provider-clipboard* *clipboard* -- cgit From 0093c25dd3795972b953f9914cc33fc38c5d9dbc Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Thu, 15 Mar 2018 04:59:18 +0100 Subject: doc: nodejs --- runtime/doc/provider.txt | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'runtime') diff --git a/runtime/doc/provider.txt b/runtime/doc/provider.txt index d44cc2558e..4a76f1399e 100644 --- a/runtime/doc/provider.txt +++ b/runtime/doc/provider.txt @@ -132,9 +132,10 @@ To disable Node support: > *g:node_host_prog* Command to start the Node host. Setting this makes startup faster. -By default, Nvim searches for `neovim-node-host` using "npm root -g". This is -rather slow, you can set g:node_host_prog to avoid it. - +By default, Nvim searches for `neovim-node-host` using "npm root -g", which +can be slow. To avoid this, set g:node_host_prog to an absolute path: > + let g:node_host_prog = '/usr/local/bin/neovim-node-host' +< ============================================================================== Clipboard integration *provider-clipboard* *clipboard* -- cgit From c49dac7cd36972571f1b8b60367e336842e13bec Mon Sep 17 00:00:00 2001 From: b-r-o-c-k Date: Sat, 17 Mar 2018 16:20:32 -0500 Subject: build: Fix CMake target dependency problem nvim was being ran before its runtime dependencies were copied. --- runtime/CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) (limited to 'runtime') diff --git a/runtime/CMakeLists.txt b/runtime/CMakeLists.txt index b3907fdf37..0ae7c231af 100644 --- a/runtime/CMakeLists.txt +++ b/runtime/CMakeLists.txt @@ -42,6 +42,7 @@ foreach(PACKAGE ${PACKAGES}) nvim WORKING_DIRECTORY "${GENERATED_PACKAGE_DIR}/${PACKNAME}" ) + add_dependencies(${PACKNAME}-tags nvim_runtime_deps) add_custom_command(OUTPUT "${GENERATED_PACKAGE_DIR}/${PACKNAME}/doc/tags" DEPENDS @@ -80,6 +81,7 @@ add_custom_target(helptags nvim WORKING_DIRECTORY "${GENERATED_RUNTIME_DIR}" ) +add_dependencies(helptags nvim_runtime_deps) add_custom_command(OUTPUT ${GENERATED_HELP_TAGS} DEPENDS -- cgit From d407a48665d8f8e1e42eb1060ea245d979419605 Mon Sep 17 00:00:00 2001 From: Björn Linse Date: Mon, 14 Mar 2016 23:58:47 +0100 Subject: getchar: implement key to invoke command in any mode --- runtime/doc/map.txt | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) (limited to 'runtime') diff --git a/runtime/doc/map.txt b/runtime/doc/map.txt index 9b61fa6527..038e90fab0 100644 --- a/runtime/doc/map.txt +++ b/runtime/doc/map.txt @@ -232,8 +232,10 @@ For this reason the following is blocked: - Editing another buffer. - The |:normal| command. - Moving the cursor is allowed, but it is restored afterwards. +- If the cmdline is changed, the old text and cursor position are restored. If you want the mapping to do any of these let the returned characters do -that. +that. Alternatively use a || mapping which doesn't have these +restrictions. You can use getchar(), it consumes typeahead if there is any. E.g., if you have these mappings: > @@ -272,6 +274,29 @@ again for using . This does work: > Using 0x80 as a single byte before other text does not work, it will be seen as a special key. + ** *:map-command* +A command mapping is a mapping that directly executes a command. Command +mappings are written by placing a command in between and in the +rhs of a mapping (in any mode): > + noremap echo mode(1) +< + *E5520* +The command must be complete and ended with a . If the command is +incomplete, an error is raised. |Command-line| mode is never entered. + +This is more flexible than using `:` in visual and operator pending +mode, or `:` in insert mode, as the commands are exectued directly in the +mode, and not normal mode. Also visual mode is not aborted. Commands can be +invoked directly in cmdline mode, which is not simple otherwise (a timer has +to be used). Unlike mappings, there are not any specific restrictions +what the command can do, except for what is normally possible to do in every +specific mode. The command should be executed the same way as if an +(unrestricted) |autocmd| was invoked or an async event event was processed. + +Note: In select mode, |:map| or |:vmap| command mappings will be executed in +visual mode. If a mapping is intended to work in select mode, it is +recomendend to map it using |:smap|, possibly in addition to the same mapping +with |:map| or |:xmap|. 1.3 MAPPING AND MODES *:map-modes* *mapmode-nvo* *mapmode-n* *mapmode-v* *mapmode-o* *mapmode-t* -- cgit From 131aad953c007d382cbff1d2560471b29975da87 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Sat, 30 Sep 2017 21:31:31 -0400 Subject: win: defaults: 'shellcmdflag', 'shellxquote' #7343 closes #7698 Wrapping a command in double-quotes allows cmd.exe to safely dequote the entire command as if the user entered the entire command in an interactive prompt. This reduces the need to escape nested and uneven double quotes. The `/s` flag of cmd.exe makes the behaviour more reliable: :set shellcmdflag=/s\ /c Before this patch, cmd.exe cannot use cygwin echo.exe (as opposed to cmd.exe `echo` builtin) even if it is wrapped in double quotes. Example: :: internal echo > cmd /s /c " echo foo\:bar" " foo\:bar" :: cygwin echo.exe > cmd /s /c " "echo" foo\:bar" " foo:bar --- runtime/doc/options.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'runtime') diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt index 9ef5ccb5c5..f4bf49c7c5 100644 --- a/runtime/doc/options.txt +++ b/runtime/doc/options.txt @@ -5160,10 +5160,10 @@ A jump table for the options with a short description can be found at |Q_op|. security reasons. *'shellcmdflag'* *'shcf'* -'shellcmdflag' 'shcf' string (default: "-c"; Windows: "/c") +'shellcmdflag' 'shcf' string (default: "-c"; Windows: "/s /c") global Flag passed to the shell to execute "!" and ":!" commands; e.g., - "bash.exe -c ls" or "cmd.exe /c dir". For Windows + `bash.exe -c ls` or `cmd.exe /s /c "dir"`. For Windows systems, the default is set according to the value of 'shell', to reduce the need to set this option by the user. On Unix it can have more than one flag. Each white space separated @@ -5284,7 +5284,7 @@ A jump table for the options with a short description can be found at |Q_op|. to execute most external commands with cmd.exe. *'shellxquote'* *'sxq'* -'shellxquote' 'sxq' string (default: "") +'shellxquote' 'sxq' string (default: "", Windows: "\"") global Quoting character(s), put around the command passed to the shell, for the "!" and ":!" commands. Includes the redirection. See -- cgit From 9ebe2ad3312088d1a899e830bd414d4893c3e073 Mon Sep 17 00:00:00 2001 From: "Vadim A. Misbakh-Soloviov" Date: Sun, 25 Mar 2018 20:45:02 +0700 Subject: runtime/dircolors.vim: support termguicolors (#8175) --- runtime/syntax/dircolors.vim | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'runtime') diff --git a/runtime/syntax/dircolors.vim b/runtime/syntax/dircolors.vim index 1b598c39b5..3d7f63dc55 100644 --- a/runtime/syntax/dircolors.vim +++ b/runtime/syntax/dircolors.vim @@ -32,7 +32,7 @@ syntax match dircolorsEscape '\\[abefnrtv?_\\^#]' syntax match dircolorsEscape '\\[0-9]\{3}' syntax match dircolorsEscape '\\x[0-9a-f]\{3}' -if !has('gui_running') && &t_Co == '' +if !(has('gui_running') || &termguicolors) && &t_Co == '' syntax match dircolorsNumber '\<\d\+\>' highlight default link dircolorsNumber Number endif @@ -84,7 +84,7 @@ endfunction function! s:get_hi_str(color, place) abort if a:color >= 0 && a:color <= 255 - if has('gui_running') + if has('gui_running') || &termguicolors return ' gui' . a:place . '=' . s:termguicolors[a:color] elseif a:color <= 7 || &t_Co == 256 || &t_Co == 88 return ' cterm' . a:place . '=' . a:color @@ -169,7 +169,7 @@ function! s:preview_color(linenr) abort \ ' "\_s\zs' . colordef . '\ze\_s"' let hi_attrs_str = '' if !empty(hi_attrs) - if has('gui_running') + if has('gui_running') || &termguicolors let hi_attrs_str = ' gui=' . join(hi_attrs, ',') else let hi_attrs_str = ' cterm=' . join(hi_attrs, ',') @@ -199,11 +199,11 @@ endfunction let b:dc_next_index = 0 -if has('gui_running') +if has('gui_running') || &termguicolors call s:set_guicolors() endif -if has('gui_running') || &t_Co != '' +if has('gui_running') || &termguicolors || &t_Co != '' call s:reset_colors() autocmd CursorMoved,CursorMovedI call s:preview_color('.') -- cgit From 98e71123900fbdf26a16a43297a1f58118cde41b Mon Sep 17 00:00:00 2001 From: Björn Linse Date: Sat, 31 Mar 2018 11:12:27 +0200 Subject: msg: do not scroll entire screen (#8088) --- runtime/doc/options.txt | 6 ++++++ runtime/doc/syntax.txt | 2 ++ runtime/doc/vim_diff.txt | 5 ++++- 3 files changed, 12 insertions(+), 1 deletion(-) (limited to 'runtime') diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt index f4bf49c7c5..d9ce668962 100644 --- a/runtime/doc/options.txt +++ b/runtime/doc/options.txt @@ -2036,6 +2036,11 @@ A jump table for the options with a short description can be found at |Q_op|. column of the last screen line. Overrules "lastline". uhex Show unprintable characters hexadecimal as instead of using ^C and ~C. + msgsep When showing messages longer than 'cmdheight' lines, + only scroll the message lines and not the entire + screen. This also shows a separator line filled with + chars determined by 'fillchars' option, and + highlighted with the |MsgSeparator| group. When neither "lastline" nor "truncate" is included, a last line that doesn't fit is replaced with "@" lines. @@ -2390,6 +2395,7 @@ A jump table for the options with a short description can be found at |Q_op|. vert:c '│' or '|' vertical separators |:vsplit| fold:c '·' or '-' filling 'foldtext' diff:c '-' deleted lines of the 'diff' option + msgsep:c ' ' message separator 'display' Any one that is omitted will fall back to the default. For "stl" and "stlnc" the space will be used when there is highlighting, '^' or '=' diff --git a/runtime/doc/syntax.txt b/runtime/doc/syntax.txt index ff9773b136..fa66d9d071 100644 --- a/runtime/doc/syntax.txt +++ b/runtime/doc/syntax.txt @@ -4909,6 +4909,8 @@ MatchParen The character under the cursor or just before it, if it *hl-ModeMsg* ModeMsg 'showmode' message (e.g., "-- INSERT --") + *hl-MsgSeparator* +MsgSeparator Separator for scrolled messages, `msgsep` flag of 'display' *hl-MoreMsg* MoreMsg |more-prompt| *hl-NonText* diff --git a/runtime/doc/vim_diff.txt b/runtime/doc/vim_diff.txt index 3924dd4ebe..3575a420b7 100644 --- a/runtime/doc/vim_diff.txt +++ b/runtime/doc/vim_diff.txt @@ -34,7 +34,7 @@ a complete and centralized reference of those differences. - 'complete' doesn't include "i" - 'cscopeverbose' is enabled - 'directory' defaults to ~/.local/share/nvim/swap// (|xdg|), auto-created -- 'display' defaults to "lastline" +- 'display' defaults to "lastline,msgsep" - 'fillchars' defaults (in effect) to "vert:│,fold:·" - 'formatoptions' defaults to "tcqj" - 'history' defaults to 10000 (the maximum) @@ -130,7 +130,9 @@ Some `CTRL-SHIFT-...` key chords are distinguished from `CTRL-...` variants Options: 'cpoptions' flags: |cpo-_| + 'display' flag `msgsep` to minimize scrolling when showing messages 'guicursor' works in the terminal + 'fillchars' flag `msgsep` (see 'display' above) 'inccommand' shows interactive results for |:substitute|-like commands 'scrollback' 'statusline' supports unlimited alignment sections @@ -164,6 +166,7 @@ Events: Highlight groups: |hl-NormalNC| highlights non-current windows + |hl-MsgSeparator| highlights separator for scrolled messages |hl-QuickFixLine| |hl-Substitute| |hl-TermCursor| -- cgit From 04f506297862d1993b2680170b5dacdf137228d9 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Fri, 10 Nov 2017 01:41:45 +0100 Subject: vim-patch:8.0.1281 Problem: Loading file type detection slows down startup. Solution: Move functions to an autoload script. https://github.com/vim/vim/commit/851ee6c3da5fd726d92e1e3300d7e5e2e8b907c5 --- vim-patch:8.0.0635 Problem: When 'ignorecase' is set script detection is inaccurate. Solution: Enforce matching case for text. (closes #1753) --- runtime/autoload/filetype.vim | 740 +++++++++++++++++++++++++++++++++++++ runtime/filetype.vim | 823 +++--------------------------------------- runtime/scripts.vim | 191 +++++----- 3 files changed, 888 insertions(+), 866 deletions(-) create mode 100644 runtime/autoload/filetype.vim (limited to 'runtime') diff --git a/runtime/autoload/filetype.vim b/runtime/autoload/filetype.vim new file mode 100644 index 0000000000..ffca01ed0c --- /dev/null +++ b/runtime/autoload/filetype.vim @@ -0,0 +1,740 @@ +" Vim functions for file type detection +" +" Maintainer: Bram Moolenaar +" Last Change: 2017 Nov 09 + +" These functions are moved here from runtime/filetype.vim to make startup +" faster. + +" Line continuation is used here, remove 'C' from 'cpoptions' +let s:cpo_save = &cpo +set cpo&vim + +func filetype#Check_inp() + if getline(1) =~ '^\*' + setf abaqus + else + let n = 1 + if line("$") > 500 + let nmax = 500 + else + let nmax = line("$") + endif + while n <= nmax + if getline(n) =~? "^header surface data" + setf trasys + break + endif + let n = n + 1 + endwhile + endif +endfunc + +" This function checks for the kind of assembly that is wanted by the user, or +" can be detected from the first five lines of the file. +func filetype#FTasm() + " make sure b:asmsyntax exists + if !exists("b:asmsyntax") + let b:asmsyntax = "" + endif + + if b:asmsyntax == "" + call filetype#FTasmsyntax() + endif + + " if b:asmsyntax still isn't set, default to asmsyntax or GNU + if b:asmsyntax == "" + if exists("g:asmsyntax") + let b:asmsyntax = g:asmsyntax + else + let b:asmsyntax = "asm" + endif + endif + + exe "setf " . fnameescape(b:asmsyntax) +endfunc + +func filetype#FTasmsyntax() + " see if file contains any asmsyntax=foo overrides. If so, change + " b:asmsyntax appropriately + let head = " ".getline(1)." ".getline(2)." ".getline(3)." ".getline(4). + \" ".getline(5)." " + let match = matchstr(head, '\sasmsyntax=\zs[a-zA-Z0-9]\+\ze\s') + if match != '' + let b:asmsyntax = match + elseif ((head =~? '\.title') || (head =~? '\.ident') || (head =~? '\.macro') || (head =~? '\.subtitle') || (head =~? '\.library')) + let b:asmsyntax = "vmasm" + endif +endfunc + +" Check if one of the first five lines contains "VB_Name". In that case it is +" probably a Visual Basic file. Otherwise it's assumed to be "alt" filetype. +func filetype#FTVB(alt) + if getline(1).getline(2).getline(3).getline(4).getline(5) =~? 'VB_Name\|Begin VB\.\(Form\|MDIForm\|UserControl\)' + setf vb + else + exe "setf " . a:alt + endif +endfunc + +func filetype#FTbtm() + if exists("g:dosbatch_syntax_for_btm") && g:dosbatch_syntax_for_btm + setf dosbatch + else + setf btm + endif +endfunc + +func filetype#BindzoneCheck(default) + if getline(1).getline(2).getline(3).getline(4) =~ '^; <<>> DiG [0-9.]\+.* <<>>\|$ORIGIN\|$TTL\|IN\s\+SOA' + setf bindzone + elseif a:default != '' + exe 'setf ' . a:default + endif +endfunc + +func filetype#FTlpc() + if exists("g:lpc_syntax_for_c") + let lnum = 1 + while lnum <= 12 + if getline(lnum) =~# '^\(//\|inherit\|private\|protected\|nosave\|string\|object\|mapping\|mixed\)' + setf lpc + return + endif + let lnum = lnum + 1 + endwhile + endif + setf c +endfunc + +func filetype#FTheader() + if match(getline(1, min([line("$"), 200])), '^@\(interface\|end\|class\)') > -1 + if exists("g:c_syntax_for_h") + setf objc + else + setf objcpp + endif + elseif exists("g:c_syntax_for_h") + setf c + elseif exists("g:ch_syntax_for_h") + setf ch + else + setf cpp + endif +endfunc + +" This function checks if one of the first ten lines start with a '@'. In +" that case it is probably a change file. +" If the first line starts with # or ! it's probably a ch file. +" If a line has "main", "include", "//" ir "/*" it's probably ch. +" Otherwise CHILL is assumed. +func filetype#FTchange() + let lnum = 1 + while lnum <= 10 + if getline(lnum)[0] == '@' + setf change + return + endif + if lnum == 1 && (getline(1)[0] == '#' || getline(1)[0] == '!') + setf ch + return + endif + if getline(lnum) =~ "MODULE" + setf chill + return + endif + if getline(lnum) =~ 'main\s*(\|#\s*include\|//' + setf ch + return + endif + let lnum = lnum + 1 + endwhile + setf chill +endfunc + +func filetype#FTent() + " This function checks for valid cl syntax in the first five lines. + " Look for either an opening comment, '#', or a block start, '{". + " If not found, assume SGML. + let lnum = 1 + while lnum < 6 + let line = getline(lnum) + if line =~ '^\s*[#{]' + setf cl + return + elseif line !~ '^\s*$' + " Not a blank line, not a comment, and not a block start, + " so doesn't look like valid cl code. + break + endif + let lnum = lnum + 1 + endw + setf dtd +endfunc + +func filetype#EuphoriaCheck() + if exists('g:filetype_euphoria') + exe 'setf ' . g:filetype_euphoria + else + setf euphoria3 + endif +endfunc + +func filetype#DtraceCheck() + let lines = getline(1, min([line("$"), 100])) + if match(lines, '^module\>\|^import\>') > -1 + " D files often start with a module and/or import statement. + setf d + elseif match(lines, '^#!\S\+dtrace\|#pragma\s\+D\s\+option\|:\S\{-}:\S\{-}:') > -1 + setf dtrace + else + setf d + endif +endfunc + +func filetype#FTe() + if exists('g:filetype_euphoria') + exe 'setf ' . g:filetype_euphoria + else + let n = 1 + while n < 100 && n < line("$") + if getline(n) =~ "^\\s*\\(<'\\|'>\\)\\s*$" + setf specman + return + endif + let n = n + 1 + endwhile + setf eiffel + endif +endfunc + +" Distinguish between HTML, XHTML and Django +func filetype#FThtml() + let n = 1 + while n < 10 && n < line("$") + if getline(n) =~ '\\|{#\s\+' + setf htmldjango + return + endif + let n = n + 1 + endwhile + setf html +endfunc + +" Distinguish between standard IDL and MS-IDL +func filetype#FTidl() + let n = 1 + while n < 50 && n < line("$") + if getline(n) =~ '^\s*import\s\+"\(unknwn\|objidl\)\.idl"' + setf msidl + return + endif + let n = n + 1 + endwhile + setf idl +endfunc + +" Distinguish between "default" and Cproto prototype file. */ +func filetype#ProtoCheck(default) + " Cproto files have a comment in the first line and a function prototype in + " the second line, it always ends in ";". Indent files may also have + " comments, thus we can't match comments to see the difference. + " IDL files can have a single ';' in the second line, require at least one + " chacter before the ';'. + if getline(2) =~ '.;$' + setf cpp + else + exe 'setf ' . a:default + endif +endfunc + +func filetype#FTm() + let n = 1 + let saw_comment = 0 " Whether we've seen a multiline comment leader. + while n < 100 + let line = getline(n) + if line =~ '^\s*/\*' + " /* ... */ is a comment in Objective C and Murphi, so we can't conclude + " it's either of them yet, but track this as a hint in case we don't see + " anything more definitive. + let saw_comment = 1 + endif + if line =~ '^\s*\(#\s*\(include\|import\)\>\|@import\>\|//\)' + setf objc + return + endif + if line =~ '^\s*%' + setf matlab + return + endif + if line =~ '^\s*(\*' + setf mma + return + endif + if line =~ '^\c\s*\(\(type\|var\)\>\|--\)' + setf murphi + return + endif + let n = n + 1 + endwhile + + if saw_comment + " We didn't see anything definitive, but this looks like either Objective C + " or Murphi based on the comment leader. Assume the former as it is more + " common. + setf objc + elseif exists("g:filetype_m") + " Use user specified default filetype for .m + exe "setf " . g:filetype_m + else + " Default is matlab + setf matlab + endif +endfunc + +func filetype#FTmms() + let n = 1 + while n < 10 + let line = getline(n) + if line =~ '^\s*\(%\|//\)' || line =~ '^\*' + setf mmix + return + endif + if line =~ '^\s*#' + setf make + return + endif + let n = n + 1 + endwhile + setf mmix +endfunc + +" This function checks if one of the first five lines start with a dot. In +" that case it is probably an nroff file: 'filetype' is set and 1 is returned. +func filetype#FTnroff() + if getline(1)[0] . getline(2)[0] . getline(3)[0] . getline(4)[0] . getline(5)[0] =~ '\.' + setf nroff + return 1 + endif + return 0 +endfunc + +func filetype#FTmm() + let n = 1 + while n < 10 + let line = getline(n) + if line =~ '^\s*\(#\s*\(include\|import\)\>\|@import\>\|/\*\)' + setf objcpp + return + endif + let n = n + 1 + endwhile + setf nroff +endfunc + +func filetype#FTpl() + if exists("g:filetype_pl") + exe "setf " . g:filetype_pl + else + " recognize Prolog by specific text in the first non-empty line + " require a blank after the '%' because Perl uses "%list" and "%translate" + let l = getline(nextnonblank(1)) + if l =~ '\' || l =~ '^\s*\(%\+\(\s\|$\)\|/\*\)' || l =~ ':-' + setf prolog + else + setf perl + endif + endif +endfunc + +func filetype#FTinc() + if exists("g:filetype_inc") + exe "setf " . g:filetype_inc + else + let lines = getline(1).getline(2).getline(3) + if lines =~? "perlscript" + setf aspperl + elseif lines =~ "<%" + setf aspvbs + elseif lines =~ "' + \ || line =~ '^\s*{' || line =~ '^\s*(\*' + setf pascal + return + elseif line !~ '^\s*$' || line =~ '^/\*' + " Not an empty line: Doesn't look like valid Pascal code. + " Or it looks like a Progress /* comment + break + endif + let lnum = lnum + 1 + endw + setf progress +endfunc + +func filetype#FTr() + let max = line("$") > 50 ? 50 : line("$") + + for n in range(1, max) + " Rebol is easy to recognize, check for that first + if getline(n) =~? '\' + setf rebol + return + endif + endfor + + for n in range(1, max) + " R has # comments + if getline(n) =~ '^\s*#' + setf r + return + endif + " Rexx has /* comments */ + if getline(n) =~ '^\s*/\*' + setf rexx + return + endif + endfor + + " Nothing recognized, use user default or assume Rexx + if exists("g:filetype_r") + exe "setf " . g:filetype_r + else + " Rexx used to be the default, but R appears to be much more popular. + setf r + endif +endfunc + +func filetype#McSetf() + " Rely on the file to start with a comment. + " MS message text files use ';', Sendmail files use '#' or 'dnl' + for lnum in range(1, min([line("$"), 20])) + let line = getline(lnum) + if line =~ '^\s*\(#\|dnl\)' + setf m4 " Sendmail .mc file + return + elseif line =~ '^\s*;' + setf msmessages " MS Message text file + return + endif + endfor + setf m4 " Default: Sendmail .mc file +endfunc + +" Called from filetype.vim and scripts.vim. +func filetype#SetFileTypeSH(name) + if expand("") =~ g:ft_ignore_pat + return + endif + if a:name =~ '\' + " Some .sh scripts contain #!/bin/csh. + call filetype#SetFileTypeShell("csh") + return + elseif a:name =~ '\' + " Some .sh scripts contain #!/bin/tcsh. + call filetype#SetFileTypeShell("tcsh") + return + elseif a:name =~ '\' + " Some .sh scripts contain #!/bin/zsh. + call filetype#SetFileTypeShell("zsh") + return + elseif a:name =~ '\' + let b:is_kornshell = 1 + if exists("b:is_bash") + unlet b:is_bash + endif + if exists("b:is_sh") + unlet b:is_sh + endif + elseif exists("g:bash_is_sh") || a:name =~ '\' || a:name =~ '\' + let b:is_bash = 1 + if exists("b:is_kornshell") + unlet b:is_kornshell + endif + if exists("b:is_sh") + unlet b:is_sh + endif + elseif a:name =~ '\' + let b:is_sh = 1 + if exists("b:is_kornshell") + unlet b:is_kornshell + endif + if exists("b:is_bash") + unlet b:is_bash + endif + endif + call filetype#SetFileTypeShell("sh") +endfunc + +" For shell-like file types, check for an "exec" command hidden in a comment, +" as used for Tcl. +" Also called from scripts.vim, thus can't be local to this script. +func filetype#SetFileTypeShell(name) + if expand("") =~ g:ft_ignore_pat + return + endif + let l = 2 + while l < 20 && l < line("$") && getline(l) =~ '^\s*\(#\|$\)' + " Skip empty and comment lines. + let l = l + 1 + endwhile + if l < line("$") && getline(l) =~ '\s*exec\s' && getline(l - 1) =~ '^\s*#.*\\$' + " Found an "exec" line after a comment with continuation + let n = substitute(getline(l),'\s*exec\s\+\([^ ]*/\)\=', '', '') + if n =~ '\:p') + if path =~ '^/\(etc/udev/\%(rules\.d/\)\=.*\.rules\|lib/udev/\%(rules\.d/\)\=.*\.rules\)$' + setf udevrules + return + endif + if path =~ '^/etc/ufw/' + setf conf " Better than hog + return + endif + if path =~ '^/\(etc\|usr/share\)/polkit-1/rules\.d' + setf javascript + return + endif + try + let config_lines = readfile('/etc/udev/udev.conf') + catch /^Vim\%((\a\+)\)\=:E484/ + setf hog + return + endtry + let dir = expand(':p:h') + for line in config_lines + if line =~ s:ft_rules_udev_rules_pattern + let udev_rules = substitute(line, s:ft_rules_udev_rules_pattern, '\1', "") + if dir == udev_rules + setf udevrules + endif + break + endif + endfor + setf hog +endfunc + +func filetype#SQL() + if exists("g:filetype_sql") + exe "setf " . g:filetype_sql + else + setf sql + endif +endfunc + +" If the file has an extension of 't' and is in a directory 't' or 'xt' then +" it is almost certainly a Perl test file. +" If the first line starts with '#' and contains 'perl' it's probably a Perl +" file. +" (Slow test) If a file contains a 'use' statement then it is almost certainly +" a Perl file. +func filetype#FTperl() + let dirname = expand("%:p:h:t") + if expand("%:e") == 't' && (dirname == 't' || dirname == 'xt') + setf perl + return 1 + endif + if getline(1)[0] == '#' && getline(1) =~ 'perl' + setf perl + return 1 + endif + if search('^use\s\s*\k', 'nc', 30) + setf perl + return 1 + endif + return 0 +endfunc + +" Choose context, plaintex, or tex (LaTeX) based on these rules: +" 1. Check the first line of the file for "%&". +" 2. Check the first 1000 non-comment lines for LaTeX or ConTeXt keywords. +" 3. Default to "latex" or to g:tex_flavor, can be set in user's vimrc. +func filetype#FTtex() + let firstline = getline(1) + if firstline =~ '^%&\s*\a\+' + let format = tolower(matchstr(firstline, '\a\+')) + let format = substitute(format, 'pdf', '', '') + if format == 'tex' + let format = 'latex' + elseif format == 'plaintex' + let format = 'plain' + endif + elseif expand('%') =~ 'tex/context/.*/.*.tex' + let format = 'context' + else + " Default value, may be changed later: + let format = exists("g:tex_flavor") ? g:tex_flavor : 'plain' + " Save position, go to the top of the file, find first non-comment line. + let save_cursor = getpos('.') + call cursor(1,1) + let firstNC = search('^\s*[^[:space:]%]', 'c', 1000) + if firstNC " Check the next thousand lines for a LaTeX or ConTeXt keyword. + let lpat = 'documentclass\>\|usepackage\>\|begin{\|newcommand\>\|renewcommand\>' + let cpat = 'start\a\+\|setup\a\+\|usemodule\|enablemode\|enableregime\|setvariables\|useencoding\|usesymbols\|stelle\a\+\|verwende\a\+\|stel\a\+\|gebruik\a\+\|usa\a\+\|imposta\a\+\|regle\a\+\|utilisemodule\>' + let kwline = search('^\s*\\\%(' . lpat . '\)\|^\s*\\\(' . cpat . '\)', + \ 'cnp', firstNC + 1000) + if kwline == 1 " lpat matched + let format = 'latex' + elseif kwline == 2 " cpat matched + let format = 'context' + endif " If neither matched, keep default set above. + " let lline = search('^\s*\\\%(' . lpat . '\)', 'cn', firstNC + 1000) + " let cline = search('^\s*\\\%(' . cpat . '\)', 'cn', firstNC + 1000) + " if cline > 0 + " let format = 'context' + " endif + " if lline > 0 && (cline == 0 || cline > lline) + " let format = 'tex' + " endif + endif " firstNC + call setpos('.', save_cursor) + endif " firstline =~ '^%&\s*\a\+' + + " Translation from formats to file types. TODO: add AMSTeX, RevTex, others? + if format == 'plain' + setf plaintex + elseif format == 'context' + setf context + else " probably LaTeX + setf tex + endif + return +endfunc + +func filetype#FTxml() + let n = 1 + while n < 100 && n < line("$") + let line = getline(n) + " DocBook 4 or DocBook 5. + let is_docbook4 = line =~ '\)' && getline(n) !~ '^\s*#\s*include' + setf racc + return + endif + let n = n + 1 + endwhile + setf yacc +endfunc + +func filetype#Redif() + let lnum = 1 + while lnum <= 5 && lnum < line('$') + if getline(lnum) =~ "^\ctemplate-type:" + setf redif + return + endif + let lnum = lnum + 1 + endwhile +endfunc + + +" Restore 'cpoptions' +let &cpo = s:cpo_save +unlet s:cpo_save diff --git a/runtime/filetype.vim b/runtime/filetype.vim index 4e0f145c18..c2012c05ec 100644 --- a/runtime/filetype.vim +++ b/runtime/filetype.vim @@ -52,27 +52,7 @@ endfunc au BufNewFile,BufRead $VIMRUNTIME/doc/*.txt setf help " Abaqus or Trasys -au BufNewFile,BufRead *.inp call s:Check_inp() - -func! s:Check_inp() - if getline(1) =~ '^\*' - setf abaqus - else - let n = 1 - if line("$") > 500 - let nmax = 500 - else - let nmax = line("$") - endif - while n <= nmax - if getline(n) =~? "^header surface data" - setf trasys - break - endif - let n = n + 1 - endwhile - endif -endfunc +au BufNewFile,BufRead *.inp call filetype#Check_inp() " A-A-P recipe au BufNewFile,BufRead *.aap setf aap @@ -170,44 +150,7 @@ au BufNewFile,BufRead */boot/grub/menu.lst,*/boot/grub/grub.conf,*/etc/grub.conf " Assembly (all kinds) " *.lst is not pure assembly, it has two extra columns (address, byte codes) -au BufNewFile,BufRead *.asm,*.[sS],*.[aA],*.mac,*.lst call s:FTasm() - -" This function checks for the kind of assembly that is wanted by the user, or -" can be detected from the first five lines of the file. -func! s:FTasm() - " make sure b:asmsyntax exists - if !exists("b:asmsyntax") - let b:asmsyntax = "" - endif - - if b:asmsyntax == "" - call s:FTasmsyntax() - endif - - " if b:asmsyntax still isn't set, default to asmsyntax or GNU - if b:asmsyntax == "" - if exists("g:asmsyntax") - let b:asmsyntax = g:asmsyntax - else - let b:asmsyntax = "asm" - endif - endif - - exe "setf " . fnameescape(b:asmsyntax) -endfunc - -func! s:FTasmsyntax() - " see if file contains any asmsyntax=foo overrides. If so, change - " b:asmsyntax appropriately - let head = " ".getline(1)." ".getline(2)." ".getline(3)." ".getline(4). - \" ".getline(5)." " - let match = matchstr(head, '\sasmsyntax=\zs[a-zA-Z0-9]\+\ze\s') - if match != '' - let b:asmsyntax = match - elseif ((head =~? '\.title') || (head =~? '\.ident') || (head =~? '\.macro') || (head =~? '\.subtitle') || (head =~? '\.library')) - let b:asmsyntax = "vmasm" - endif -endfunc +au BufNewFile,BufRead *.asm,*.[sS],*.[aA],*.mac,*.lst call filetype#FTasm() " Macro (VAX) au BufNewFile,BufRead *.mar setf vmasm @@ -237,17 +180,7 @@ au BufNewFile,BufRead *.awk setf awk au BufNewFile,BufRead *.mch,*.ref,*.imp setf b " BASIC or Visual Basic -au BufNewFile,BufRead *.bas call s:FTVB("basic") - -" Check if one of the first five lines contains "VB_Name". In that case it is -" probably a Visual Basic file. Otherwise it's assumed to be "alt" filetype. -func! s:FTVB(alt) - if getline(1).getline(2).getline(3).getline(4).getline(5) =~? 'VB_Name\|Begin VB\.\(Form\|MDIForm\|UserControl\)' - setf vb - else - exe "setf " . a:alt - endif -endfunc +au BufNewFile,BufRead *.bas call filetype#FTVB("basic") " Visual Basic Script (close to Visual Basic) or Visual Basic .NET au BufNewFile,BufRead *.vb,*.vbs,*.dsm,*.ctl setf vb @@ -265,14 +198,7 @@ au BufNewFile,BufRead *.cmd \ if getline(1) =~ '^/\*' | setf rexx | else | setf dosbatch | endif " Batch file for 4DOS -au BufNewFile,BufRead *.btm call s:FTbtm() -func! s:FTbtm() - if exists("g:dosbatch_syntax_for_btm") && g:dosbatch_syntax_for_btm - setf dosbatch - else - setf btm - endif -endfunc +au BufNewFile,BufRead *.btm call filetype#FTbtm() " BC calculator au BufNewFile,BufRead *.bc setf bc @@ -292,15 +218,7 @@ au BufNewFile,BufRead named*.conf,rndc*.conf,rndc*.key setf named " BIND zone au BufNewFile,BufRead named.root setf bindzone -au BufNewFile,BufRead *.db call s:BindzoneCheck('') - -func! s:BindzoneCheck(default) - if getline(1).getline(2).getline(3).getline(4) =~ '^; <<>> DiG [0-9.]\+.* <<>>\|$ORIGIN\|$TTL\|IN\s\+SOA' - setf bindzone - elseif a:default != '' - exe 'setf ' . a:default - endif -endfunc +au BufNewFile,BufRead *.db call filetype#BindzoneCheck('') " Blank au BufNewFile,BufRead *.bl setf blank @@ -315,21 +233,7 @@ if has("fname_case") endif " C or lpc -au BufNewFile,BufRead *.c call s:FTlpc() - -func! s:FTlpc() - if exists("g:lpc_syntax_for_c") - let lnum = 1 - while lnum <= 12 - if getline(lnum) =~# '^\(//\|inherit\|private\|protected\|nosave\|string\|object\|mapping\|mixed\)' - setf lpc - return - endif - let lnum = lnum + 1 - endwhile - endif - setf c -endfunc +au BufNewFile,BufRead *.c call filetype#FTlpc() " Calendar au BufNewFile,BufRead calendar setf calendar @@ -383,23 +287,7 @@ endif " .h files can be C, Ch C++, ObjC or ObjC++. " Set c_syntax_for_h if you want C, ch_syntax_for_h if you want Ch. ObjC is " detected automatically. -au BufNewFile,BufRead *.h call s:FTheader() - -func! s:FTheader() - if match(getline(1, min([line("$"), 200])), '^@\(interface\|end\|class\)') > -1 - if exists("g:c_syntax_for_h") - setf objc - else - setf objcpp - endif - elseif exists("g:c_syntax_for_h") - setf c - elseif exists("g:ch_syntax_for_h") - setf ch - else - setf cpp - endif -endfunc +au BufNewFile,BufRead *.h call filetype#FTheader() " Ch (CHscript) au BufNewFile,BufRead *.chf setf ch @@ -433,36 +321,7 @@ au BufNewFile,BufRead NEWS au BufNewFile,BufRead *..ch setf chill " Changes for WEB and CWEB or CHILL -au BufNewFile,BufRead *.ch call s:FTchange() - -" This function checks if one of the first ten lines start with a '@'. In -" that case it is probably a change file. -" If the first line starts with # or ! it's probably a ch file. -" If a line has "main", "include", "//" ir "/*" it's probably ch. -" Otherwise CHILL is assumed. -func! s:FTchange() - let lnum = 1 - while lnum <= 10 - if getline(lnum)[0] == '@' - setf change - return - endif - if lnum == 1 && (getline(1)[0] == '#' || getline(1)[0] == '!') - setf ch - return - endif - if getline(lnum) =~ "MODULE" - setf chill - return - endif - if getline(lnum) =~ 'main\s*(\|#\s*include\|//' - setf ch - return - endif - let lnum = lnum + 1 - endwhile - setf chill -endfunc +au BufNewFile,BufRead *.ch call filetype#FTchange() " ChordPro au BufNewFile,BufRead *.chopro,*.crd,*.cho,*.crdpro,*.chordpro setf chordpro @@ -474,27 +333,7 @@ au BufNewFile,BufRead *.dcl,*.icl setf clean au BufNewFile,BufRead *.eni setf cl " Clever or dtd -au BufNewFile,BufRead *.ent call s:FTent() - -func! s:FTent() - " This function checks for valid cl syntax in the first five lines. - " Look for either an opening comment, '#', or a block start, '{". - " If not found, assume SGML. - let lnum = 1 - while lnum < 6 - let line = getline(lnum) - if line =~ '^\s*[#{]' - setf cl - return - elseif line !~ '^\s*$' - " Not a blank line, not a comment, and not a block start, - " so doesn't look like valid cl code. - break - endif - let lnum = lnum + 1 - endw - setf dtd -endfunc +au BufNewFile,BufRead *.ent call filetype#FTent() " Clipper (or FoxPro; could also be eviews) au BufNewFile,BufRead *.prg @@ -549,19 +388,11 @@ au BufNewFile,BufRead *enlightenment/*.cfg setf c au BufNewFile,BufRead *Eterm/*.cfg setf eterm " Euphoria 3 or 4 -au BufNewFile,BufRead *.eu,*.ew,*.ex,*.exu,*.exw call s:EuphoriaCheck() +au BufNewFile,BufRead *.eu,*.ew,*.ex,*.exu,*.exw call filetype#EuphoriaCheck() if has("fname_case") - au BufNewFile,BufRead *.EU,*.EW,*.EX,*.EXU,*.EXW call s:EuphoriaCheck() + au BufNewFile,BufRead *.EU,*.EW,*.EX,*.EXU,*.EXW call filetype#EuphoriaCheck() endif -func! s:EuphoriaCheck() - if exists('g:filetype_euphoria') - exe 'setf ' . g:filetype_euphoria - else - setf euphoria3 - endif -endfunc - " Lynx config files au BufNewFile,BufRead lynx.cfg setf lynx @@ -606,19 +437,7 @@ au BufNewFile,BufRead */etc/dnsmasq.conf setf dnsmasq au BufNewFile,BufRead *.desc setf desc " the D language or dtrace -au BufNewFile,BufRead *.d call s:DtraceCheck() - -func! s:DtraceCheck() - let lines = getline(1, min([line("$"), 100])) - if match(lines, '^module\>\|^import\>') > -1 - " D files often start with a module and/or import statement. - setf d - elseif match(lines, '^#!\S\+dtrace\|#pragma\s\+D\s\+option\|:\S\{-}:\S\{-}:') > -1 - setf dtrace - else - setf d - endif -endfunc +au BufNewFile,BufRead *.d call filetype#DtraceCheck() " Desktop files au BufNewFile,BufRead *.desktop,.directory setf desktop @@ -650,7 +469,7 @@ au BufNewFile,BufRead *.rul \ endif " DCL (Digital Command Language - vms) or DNS zone file -au BufNewFile,BufRead *.com call s:BindzoneCheck('dcl') +au BufNewFile,BufRead *.com call filetype#BindzoneCheck('dcl') " DOT au BufNewFile,BufRead *.dot setf dot @@ -698,27 +517,11 @@ au BufNewFile,BufRead .editorconfig setf dosini au BufNewFile,BufRead *.ecd setf ecd " Eiffel or Specman or Euphoria -au BufNewFile,BufRead *.e,*.E call s:FTe() +au BufNewFile,BufRead *.e,*.E call filetype#FTe() " Elinks configuration au BufNewFile,BufRead */etc/elinks.conf,*/.elinks/elinks.conf setf elinks -func! s:FTe() - if exists('g:filetype_euphoria') - exe 'setf ' . g:filetype_euphoria - else - let n = 1 - while n < 100 && n < line("$") - if getline(n) =~ "^\\s*\\(<'\\|'>\\)\\s*$" - setf specman - return - endif - let n = n + 1 - endwhile - setf eiffel - endif -endfunc - " ERicsson LANGuage; Yaws is erlang too au BufNewFile,BufRead *.erl,*.hrl,*.yaws setf erlang @@ -887,24 +690,7 @@ au BufNewFile,BufRead *.hex,*.h32 setf hex au BufNewFile,BufRead *.t.html setf tilde " HTML (.shtml and .stm for server side) -au BufNewFile,BufRead *.html,*.htm,*.shtml,*.stm call s:FThtml() - -" Distinguish between HTML, XHTML and Django -func! s:FThtml() - let n = 1 - while n < 10 && n < line("$") - if getline(n) =~ '\\|{#\s\+' - setf htmldjango - return - endif - let n = n + 1 - endwhile - setf html -endfunc +au BufNewFile,BufRead *.html,*.htm,*.shtml,*.stm call filetype#FThtml() " HTML with Ruby - eRuby au BufNewFile,BufRead *.erb,*.rhtml setf eruby @@ -931,20 +717,7 @@ au BufNewFile,BufRead *.htt,*.htb setf httest au BufNewFile,BufRead *.icn setf icon " IDL (Interface Description Language) -au BufNewFile,BufRead *.idl call s:FTidl() - -" Distinguish between standard IDL and MS-IDL -func! s:FTidl() - let n = 1 - while n < 50 && n < line("$") - if getline(n) =~ '^\s*import\s\+"\(unknwn\|objidl\)\.idl"' - setf msidl - return - endif - let n = n + 1 - endwhile - setf idl -endfunc +au BufNewFile,BufRead *.idl call filetype#FTidl() " Microsoft IDL (Interface Description Language) Also *.idl " MOF = WMI (Windows Management Instrumentation) Managed Object Format @@ -955,25 +728,10 @@ au BufNewFile,BufRead */.icewm/menu setf icemenu " Indent profile (must come before IDL *.pro!) au BufNewFile,BufRead .indent.pro setf indent -au BufNewFile,BufRead indent.pro call s:ProtoCheck('indent') +au BufNewFile,BufRead indent.pro call filetype#ProtoCheck('indent') " IDL (Interactive Data Language) -au BufNewFile,BufRead *.pro call s:ProtoCheck('idlang') - -" Distinguish between "default" and Cproto prototype file. */ -func! s:ProtoCheck(default) - " Cproto files have a comment in the first line and a function prototype in - " the second line, it always ends in ";". Indent files may also have - " comments, thus we can't match comments to see the difference. - " IDL files can have a single ';' in the second line, require at least one - " chacter before the ';'. - if getline(2) =~ '.;$' - setf cpp - else - exe 'setf ' . a:default - endif -endfunc - +au BufNewFile,BufRead *.pro call filetype#ProtoCheck('idlang') " Indent RC au BufNewFile,BufRead indentrc setf indent @@ -1187,51 +945,7 @@ au BufNewFile,BufRead *.markdown,*.mdown,*.mkd,*.mkdn,*.mdwn,*.md setf markdown au BufNewFile,BufRead *.mason,*.mhtml,*.comp setf mason " Mathematica, Matlab, Murphi or Objective C -au BufNewFile,BufRead *.m call s:FTm() - -func! s:FTm() - let n = 1 - let saw_comment = 0 " Whether we've seen a multiline comment leader. - while n < 100 - let line = getline(n) - if line =~ '^\s*/\*' - " /* ... */ is a comment in Objective C and Murphi, so we can't conclude - " it's either of them yet, but track this as a hint in case we don't see - " anything more definitive. - let saw_comment = 1 - endif - if line =~ '^\s*\(#\s*\(include\|import\)\>\|@import\>\|//\)' - setf objc - return - endif - if line =~ '^\s*%' - setf matlab - return - endif - if line =~ '^\s*(\*' - setf mma - return - endif - if line =~ '^\c\s*\(\(type\|var\)\>\|--\)' - setf murphi - return - endif - let n = n + 1 - endwhile - - if saw_comment - " We didn't see anything definitive, but this looks like either Objective C - " or Murphi based on the comment leader. Assume the former as it is more - " common. - setf objc - elseif exists("g:filetype_m") - " Use user specified default filetype for .m - exe "setf " . g:filetype_m - else - " Default is matlab - setf matlab - endif -endfunc +au BufNewFile,BufRead *.m call filetype#FTm() " Mathematica notebook au BufNewFile,BufRead *.nb setf mma @@ -1261,29 +975,11 @@ au BufNewFile,BufRead *.mgl setf mgl au BufNewFile,BufRead *.mix,*.mixal setf mix " MMIX or VMS makefile -au BufNewFile,BufRead *.mms call s:FTmms() +au BufNewFile,BufRead *.mms call filetype#FTmms() " Symbian meta-makefile definition (MMP) au BufNewFile,BufRead *.mmp setf mmp -func! s:FTmms() - let n = 1 - while n < 10 - let line = getline(n) - if line =~ '^\s*\(%\|//\)' || line =~ '^\*' - setf mmix - return - endif - if line =~ '^\s*#' - setf make - return - endif - let n = n + 1 - endwhile - setf mmix -endfunc - - " Modsim III (or LambdaProlog) au BufNewFile,BufRead *.mod \ if getline(1) =~ '\' | @@ -1367,33 +1063,10 @@ au BufNewFile,BufRead *.me \ setf nroff | \ endif au BufNewFile,BufRead *.tr,*.nr,*.roff,*.tmac,*.mom setf nroff -au BufNewFile,BufRead *.[1-9] call s:FTnroff() - -" This function checks if one of the first five lines start with a dot. In -" that case it is probably an nroff file: 'filetype' is set and 1 is returned. -func! s:FTnroff() - if getline(1)[0] . getline(2)[0] . getline(3)[0] . getline(4)[0] . getline(5)[0] =~ '\.' - setf nroff - return 1 - endif - return 0 -endfunc +au BufNewFile,BufRead *.[1-9] call filetype#FTnroff() " Nroff or Objective C++ -au BufNewFile,BufRead *.mm call s:FTmm() - -func! s:FTmm() - let n = 1 - while n < 10 - let line = getline(n) - if line =~ '^\s*\(#\s*\(include\|import\)\>\|@import\>\|/\*\)' - setf objcpp - return - endif - let n = n + 1 - endwhile - setf nroff -endfunc +au BufNewFile,BufRead *.mm call filetype#FTmm() " Not Quite C au BufNewFile,BufRead *.nqc setf nqc @@ -1448,28 +1121,13 @@ au BufNewFile,BufRead *.pcmk setf pcmk " Perl if has("fname_case") - au BufNewFile,BufRead *.pl,*.PL call s:FTpl() + au BufNewFile,BufRead *.pl,*.PL call filetype#FTpl() else - au BufNewFile,BufRead *.pl call s:FTpl() + au BufNewFile,BufRead *.pl call filetype#FTpl() endif au BufNewFile,BufRead *.plx,*.al,*.psgi setf perl au BufNewFile,BufRead *.p6,*.pm6,*.pl6 setf perl6 -func! s:FTpl() - if exists("g:filetype_pl") - exe "setf " . g:filetype_pl - else - " recognize Prolog by specific text in the first non-empty line - " require a blank after the '%' because Perl uses "%list" and "%translate" - let l = getline(nextnonblank(1)) - if l =~ '\' || l =~ '^\s*\(%\+\(\s\|$\)\|/\*\)' || l =~ ':-' - setf prolog - else - setf perl - endif - endif -endfunc - " Perl, XPM or XPM2 au BufNewFile,BufRead *.pm \ if getline(1) =~ "XPM2" | @@ -1482,7 +1140,7 @@ au BufNewFile,BufRead *.pm " Perl POD au BufNewFile,BufRead *.pod setf pod -au BufNewFile,BufRead *.pod6 setf pod6 +au BufNewFile,BufRead *.pod6 setf pod6 " Php, php3, php4, etc. " Also Phtml (was used for PHP 2 in the past) @@ -1532,29 +1190,7 @@ au BufNewFile,BufRead *.pov setf pov au BufNewFile,BufRead .povrayrc setf povini " Povray, PHP or assembly -au BufNewFile,BufRead *.inc call s:FTinc() - -func! s:FTinc() - if exists("g:filetype_inc") - exe "setf " . g:filetype_inc - else - let lines = getline(1).getline(2).getline(3) - if lines =~? "perlscript" - setf aspperl - elseif lines =~ "<%" - setf aspvbs - elseif lines =~ "' - \ || line =~ '^\s*{' || line =~ '^\s*(\*' - setf pascal - return - elseif line !~ '^\s*$' || line =~ '^/\*' - " Not an empty line: Doesn't look like valid Pascal code. - " Or it looks like a Progress /* comment - break - endif - let lnum = lnum + 1 - endw - setf progress -endfunc - +au BufNewFile,BufRead *.p call filetype#FTprogress_pascal() " Software Distributor Product Specification File (POSIX 1387.2-1995) au BufNewFile,BufRead *.psf setf psf @@ -1736,40 +1311,7 @@ else endif " Rexx, Rebol or R -au BufNewFile,BufRead *.r,*.R call s:FTr() - -func! s:FTr() - let max = line("$") > 50 ? 50 : line("$") - - for n in range(1, max) - " Rebol is easy to recognize, check for that first - if getline(n) =~? '\' - setf rebol - return - endif - endfor - - for n in range(1, max) - " R has # comments - if getline(n) =~ '^\s*#' - setf r - return - endif - " Rexx has /* comments */ - if getline(n) =~ '^\s*/\*' - setf rexx - return - endif - endfor - - " Nothing recognized, use user default or assume Rexx - if exists("g:filetype_r") - exe "setf " . g:filetype_r - else - " Rexx used to be the default, but R appears to be much more popular. - setf r - endif -endfunc +au BufNewFile,BufRead *.r,*.R call filetype#FTr() " Remind au BufNewFile,BufRead .reminders,*.remind,*.rem setf remind @@ -1865,23 +1407,7 @@ au BufNewFile,BufRead *.siv setf sieve au BufNewFile,BufRead sendmail.cf setf sm " Sendmail .mc files are actually m4. Could also be MS Message text file. -au BufNewFile,BufRead *.mc call s:McSetf() - -func! s:McSetf() - " Rely on the file to start with a comment. - " MS message text files use ';', Sendmail files use '#' or 'dnl' - for lnum in range(1, min([line("$"), 20])) - let line = getline(lnum) - if line =~ '^\s*\(#\|dnl\)' - setf m4 " Sendmail .mc file - return - elseif line =~ '^\s*;' - setf msmessages " MS Message text file - return - endif - endfor - setf m4 " Default: Sendmail .mc file -endfunc +au BufNewFile,BufRead *.mc call filetype#McSetf() " Services au BufNewFile,BufRead */etc/services setf services @@ -1922,101 +1448,23 @@ au BufNewFile,BufRead sgml.catalog* call s:StarSetf('catalog') " Shell scripts (sh, ksh, bash, bash2, csh); Allow .profile_foo etc. " Gentoo ebuilds and Arch Linux PKGBUILDs are actually bash scripts -au BufNewFile,BufRead .bashrc*,bashrc,bash.bashrc,.bash[_-]profile*,.bash[_-]logout*,.bash[_-]aliases*,*.bash,*/{,.}bash[_-]completion{,.d,.sh}{,/*},*.ebuild,*.eclass,PKGBUILD* call SetFileTypeSH("bash") -au BufNewFile,BufRead .kshrc*,*.ksh call SetFileTypeSH("ksh") -au BufNewFile,BufRead */etc/profile,.profile*,*.sh,*.env call SetFileTypeSH(getline(1)) +au BufNewFile,BufRead .bashrc*,bashrc,bash.bashrc,.bash[_-]profile*,.bash[_-]logout*,.bash[_-]aliases*,*.bash,*/{,.}bash[_-]completion{,.d,.sh}{,/*},*.ebuild,*.eclass,PKGBUILD* call filetype#SetFileTypeSH("bash") +au BufNewFile,BufRead .kshrc*,*.ksh call filetype#SetFileTypeSH("ksh") +au BufNewFile,BufRead */etc/profile,.profile*,*.sh,*.env call filetype#SetFileTypeSH(getline(1)) " Shell script (Arch Linux) or PHP file (Drupal) au BufNewFile,BufRead *.install \ if getline(1) =~ '") =~ g:ft_ignore_pat - return - endif - if a:name =~ '\' - " Some .sh scripts contain #!/bin/csh. - call SetFileTypeShell("csh") - return - elseif a:name =~ '\' - " Some .sh scripts contain #!/bin/tcsh. - call SetFileTypeShell("tcsh") - return - elseif a:name =~ '\' - " Some .sh scripts contain #!/bin/zsh. - call SetFileTypeShell("zsh") - return - elseif a:name =~ '\' - let b:is_kornshell = 1 - if exists("b:is_bash") - unlet b:is_bash - endif - if exists("b:is_sh") - unlet b:is_sh - endif - elseif exists("g:bash_is_sh") || a:name =~ '\' || a:name =~ '\' - let b:is_bash = 1 - if exists("b:is_kornshell") - unlet b:is_kornshell - endif - if exists("b:is_sh") - unlet b:is_sh - endif - elseif a:name =~ '\' - let b:is_sh = 1 - if exists("b:is_kornshell") - unlet b:is_kornshell - endif - if exists("b:is_bash") - unlet b:is_bash - endif - endif - call SetFileTypeShell("sh") -endfunc - -" For shell-like file types, check for an "exec" command hidden in a comment, -" as used for Tcl. -" Also called from scripts.vim, thus can't be local to this script. -func! SetFileTypeShell(name) - if expand("") =~ g:ft_ignore_pat - return - endif - let l = 2 - while l < 20 && l < line("$") && getline(l) =~ '^\s*\(#\|$\)' - " Skip empty and comment lines. - let l = l + 1 - endwhile - if l < line("$") && getline(l) =~ '\s*exec\s' && getline(l - 1) =~ '^\s*#.*\\$' - " Found an "exec" line after a comment with continuation - let n = substitute(getline(l),'\s*exec\s\+\([^ ]*/\)\=', '', '') - if n =~ '\:p') - if path =~ '^/\(etc/udev/\%(rules\.d/\)\=.*\.rules\|lib/udev/\%(rules\.d/\)\=.*\.rules\)$' - setf udevrules - return - endif - if path =~ '^/etc/ufw/' - setf conf " Better than hog - return - endif - if path =~ '^/\(etc\|usr/share\)/polkit-1/rules\.d' - setf javascript - return - endif - try - let config_lines = readfile('/etc/udev/udev.conf') - catch /^Vim\%((\a\+)\)\=:E484/ - setf hog - return - endtry - let dir = expand(':p:h') - for line in config_lines - if line =~ s:ft_rules_udev_rules_pattern - let udev_rules = substitute(line, s:ft_rules_udev_rules_pattern, '\1', "") - if dir == udev_rules - setf udevrules - endif - break - endif - endfor - setf hog -endfunc - - " Spec (Linux RPM) au BufNewFile,BufRead *.spec setf spec @@ -2146,15 +1560,7 @@ au BufNewFile,BufRead squid.conf setf squid au BufNewFile,BufRead *.tyb,*.typ,*.tyc,*.pkb,*.pks setf sql " SQL -au BufNewFile,BufRead *.sql call s:SQL() - -func! s:SQL() - if exists("g:filetype_sql") - exe "setf " . g:filetype_sql - else - setf sql - endif -endfunc +au BufNewFile,BufRead *.sql call filetype#SQL() " SQLJ au BufNewFile,BufRead *.sqlj setf sqlj @@ -2201,32 +1607,9 @@ au BufNewFile,BufRead */etc/sudoers,sudoers.tmp setf sudoers " SVG (Scalable Vector Graphics) au BufNewFile,BufRead *.svg setf svg -" If the file has an extension of 't' and is in a directory 't' or 'xt' then -" it is almost certainly a Perl test file. -" If the first line starts with '#' and contains 'perl' it's probably a Perl -" file. -" (Slow test) If a file contains a 'use' statement then it is almost certainly -" a Perl file. -func! s:FTperl() - let dirname = expand("%:p:h:t") - if expand("%:e") == 't' && (dirname == 't' || dirname == 'xt') - setf perl - return 1 - endif - if getline(1)[0] == '#' && getline(1) =~ 'perl' - setf perl - return 1 - endif - if search('^use\s\s*\k', 'nc', 30) - setf perl - return 1 - endif - return 0 -endfunc - " Tads (or Nroff or Perl test file) au BufNewFile,BufRead *.t - \ if !s:FTnroff() && !s:FTperl() | setf tads | endif + \ if !filetype#FTnroff() && !filetype#FTperl() | setf tads | endif " Tags au BufNewFile,BufRead tags setf tags @@ -2255,63 +1638,7 @@ au BufNewFile,BufRead *.ti setf terminfo " TeX au BufNewFile,BufRead *.latex,*.sty,*.dtx,*.ltx,*.bbl setf tex -au BufNewFile,BufRead *.tex call s:FTtex() - -" Choose context, plaintex, or tex (LaTeX) based on these rules: -" 1. Check the first line of the file for "%&". -" 2. Check the first 1000 non-comment lines for LaTeX or ConTeXt keywords. -" 3. Default to "latex" or to g:tex_flavor, can be set in user's vimrc. -func! s:FTtex() - let firstline = getline(1) - if firstline =~ '^%&\s*\a\+' - let format = tolower(matchstr(firstline, '\a\+')) - let format = substitute(format, 'pdf', '', '') - if format == 'tex' - let format = 'latex' - elseif format == 'plaintex' - let format = 'plain' - endif - elseif expand('%') =~ 'tex/context/.*/.*.tex' - let format = 'context' - else - " Default value, may be changed later: - let format = exists("g:tex_flavor") ? g:tex_flavor : 'plain' - " Save position, go to the top of the file, find first non-comment line. - let save_cursor = getpos('.') - call cursor(1,1) - let firstNC = search('^\s*[^[:space:]%]', 'c', 1000) - if firstNC " Check the next thousand lines for a LaTeX or ConTeXt keyword. - let lpat = 'documentclass\>\|usepackage\>\|begin{\|newcommand\>\|renewcommand\>' - let cpat = 'start\a\+\|setup\a\+\|usemodule\|enablemode\|enableregime\|setvariables\|useencoding\|usesymbols\|stelle\a\+\|verwende\a\+\|stel\a\+\|gebruik\a\+\|usa\a\+\|imposta\a\+\|regle\a\+\|utilisemodule\>' - let kwline = search('^\s*\\\%(' . lpat . '\)\|^\s*\\\(' . cpat . '\)', - \ 'cnp', firstNC + 1000) - if kwline == 1 " lpat matched - let format = 'latex' - elseif kwline == 2 " cpat matched - let format = 'context' - endif " If neither matched, keep default set above. - " let lline = search('^\s*\\\%(' . lpat . '\)', 'cn', firstNC + 1000) - " let cline = search('^\s*\\\%(' . cpat . '\)', 'cn', firstNC + 1000) - " if cline > 0 - " let format = 'context' - " endif - " if lline > 0 && (cline == 0 || cline > lline) - " let format = 'tex' - " endif - endif " firstNC - call setpos('.', save_cursor) - endif " firstline =~ '^%&\s*\a\+' - - " Translation from formats to file types. TODO: add AMSTeX, RevTex, others? - if format == 'plain' - setf plaintex - elseif format == 'context' - setf context - else " probably LaTeX - setf tex - endif - return -endfunc +au BufNewFile,BufRead *.tex call filetype#FTtex() " ConTeXt au BufNewFile,BufRead *.mkii,*.mkiv,*.mkvi setf context @@ -2412,7 +1739,7 @@ au BufRead,BufNewFile *.hw,*.module,*.pkg \ endif " Visual Basic (also uses *.bas) or FORM -au BufNewFile,BufRead *.frm call s:FTVB("form") +au BufNewFile,BufRead *.frm call filetype#FTVB("form") " SaxBasic is close to Visual Basic au BufNewFile,BufRead *.sba setf vb @@ -2502,36 +1829,10 @@ au BufNewFile,BufRead .Xdefaults,.Xpdefaults,.Xresources,xdm-config,*.ad setf xd " Xmath au BufNewFile,BufRead *.msc,*.msf setf xmath au BufNewFile,BufRead *.ms - \ if !s:FTnroff() | setf xmath | endif + \ if !filetype#FTnroff() | setf xmath | endif " XML specific variants: docbk and xbl -au BufNewFile,BufRead *.xml call s:FTxml() - -func! s:FTxml() - let n = 1 - while n < 100 && n < line("$") - let line = getline(n) - " DocBook 4 or DocBook 5. - let is_docbook4 = line =~ '\)' && getline(n) !~ '^\s*#\s*include' - setf racc - return - endif - let n = n + 1 - endwhile - setf yacc -endfunc - +au BufNewFile,BufRead *.y call filetype#FTy() " Yaml au BufNewFile,BufRead *.yaml,*.yml setf yaml @@ -2608,9 +1891,9 @@ au BufNewFile,BufRead *.zut setf zimbutempl " Zope " dtml (zope dynamic template markup language), pt (zope page template), " cpt (zope form controller page template) -au BufNewFile,BufRead *.dtml,*.pt,*.cpt call s:FThtml() +au BufNewFile,BufRead *.dtml,*.pt,*.cpt call filetype#FThtml() " zsql (zope sql method) -au BufNewFile,BufRead *.zsql call s:SQL() +au BufNewFile,BufRead *.zsql call filetype#SQL() " Z80 assembler asz80 au BufNewFile,BufRead *.z8a setf z8a @@ -2759,17 +2042,7 @@ au BufNewFile,BufRead *termcap* " ReDIF " Only used when the .rdf file was not detected to be XML. -au BufRead,BufNewFile *.rdf call s:Redif() -func! s:Redif() - let lnum = 1 - while lnum <= 5 && lnum < line('$') - if getline(lnum) =~ "^\ctemplate-type:" - setf redif - return - endif - let lnum = lnum + 1 - endwhile -endfunc +au BufRead,BufNewFile *.rdf call filetype#Redif() " Remind au BufNewFile,BufRead .reminders* call s:StarSetf('remind') diff --git a/runtime/scripts.vim b/runtime/scripts.vim index 63bf9efcf9..24799c4287 100644 --- a/runtime/scripts.vim +++ b/runtime/scripts.vim @@ -1,11 +1,15 @@ " Vim support file to detect file types in scripts " " Maintainer: Bram Moolenaar -" Last change: 2017 Aug 27 +" Last change: 2017 Nov 09 " This file is called by an autocommand for every file that has just been " loaded into a buffer. It checks if the type of file can be recognized by " the file contents. The autocommand is in $VIMRUNTIME/filetype.vim. +" +" Note that the pattern matches are done with =~# to avoid the value of the +" 'ignorecase' option making a difference. Where case is to be ignored use +" =~? instead. Do not use =~ anywhere. " Only do the rest when the FileType autocommand has not been triggered yet. @@ -28,12 +32,12 @@ set cpo&vim let s:line1 = getline(1) -if s:line1 =~ "^#!" +if s:line1 =~# "^#!" " A script that starts with "#!". " Check for a line like "#!/usr/bin/env VAR=val bash". Turn it into " "#!/usr/bin/bash" to make matching easier. - if s:line1 =~ '^#!\s*\S*\' + elseif s:line1 =~# '^#!.*\' let s:name = substitute(s:line1, '^#!.*\\s\+\(\i\+\).*', '\1', '') - elseif s:line1 =~ '^#!\s*[^/\\ ]*\>\([^/\\]\|$\)' + elseif s:line1 =~# '^#!\s*[^/\\ ]*\>\([^/\\]\|$\)' let s:name = substitute(s:line1, '^#!\s*\([^/\\ ]*\>\).*', '\1', '') else let s:name = substitute(s:line1, '^#!\s*\S*[/\\]\(\i\+\).*', '\1', '') @@ -56,116 +60,116 @@ if s:line1 =~ "^#!" " tcl scripts may have #!/bin/sh in the first line and "exec wish" in the " third line. Suggested by Steven Atkinson. - if getline(3) =~ '^exec wish' + if getline(3) =~# '^exec wish' let s:name = 'wish' endif " Bourne-like shell scripts: bash bash2 ksh ksh93 sh - if s:name =~ '^\(bash\d*\|\|ksh\d*\|sh\)\>' - call SetFileTypeSH(s:line1) " defined in filetype.vim + if s:name =~# '^\(bash\d*\|\|ksh\d*\|sh\)\>' + call filetype#SetFileTypeSH(s:line1) " defined in filetype.vim " csh scripts - elseif s:name =~ '^csh\>' + elseif s:name =~# '^csh\>' if exists("g:filetype_csh") - call SetFileTypeShell(g:filetype_csh) + call filetype#SetFileTypeShell(g:filetype_csh) else - call SetFileTypeShell("csh") + call filetype#SetFileTypeShell("csh") endif " tcsh scripts - elseif s:name =~ '^tcsh\>' - call SetFileTypeShell("tcsh") + elseif s:name =~# '^tcsh\>' + call filetype#SetFileTypeShell("tcsh") " Z shell scripts - elseif s:name =~ '^zsh\>' + elseif s:name =~# '^zsh\>' set ft=zsh " TCL scripts - elseif s:name =~ '^\(tclsh\|wish\|expectk\|itclsh\|itkwish\)\>' + elseif s:name =~# '^\(tclsh\|wish\|expectk\|itclsh\|itkwish\)\>' set ft=tcl " Expect scripts - elseif s:name =~ '^expect\>' + elseif s:name =~# '^expect\>' set ft=expect " Gnuplot scripts - elseif s:name =~ '^gnuplot\>' + elseif s:name =~# '^gnuplot\>' set ft=gnuplot " Makefiles - elseif s:name =~ 'make\>' + elseif s:name =~# 'make\>' set ft=make " Lua - elseif s:name =~ 'lua' + elseif s:name =~# 'lua' set ft=lua " Perl 6 - elseif s:name =~ 'perl6' + elseif s:name =~# 'perl6' set ft=perl6 " Perl - elseif s:name =~ 'perl' + elseif s:name =~# 'perl' set ft=perl " PHP - elseif s:name =~ 'php' + elseif s:name =~# 'php' set ft=php " Python - elseif s:name =~ 'python' + elseif s:name =~# 'python' set ft=python " Groovy - elseif s:name =~ '^groovy\>' + elseif s:name =~# '^groovy\>' set ft=groovy " Ruby - elseif s:name =~ 'ruby' + elseif s:name =~# 'ruby' set ft=ruby " JavaScript - elseif s:name =~ 'node\(js\)\=\>' || s:name =~ 'rhino\>' + elseif s:name =~# 'node\(js\)\=\>' || s:name =~# 'rhino\>' set ft=javascript " BC calculator - elseif s:name =~ '^bc\>' + elseif s:name =~# '^bc\>' set ft=bc " sed - elseif s:name =~ 'sed\>' + elseif s:name =~# 'sed\>' set ft=sed " OCaml-scripts - elseif s:name =~ 'ocaml' + elseif s:name =~# 'ocaml' set ft=ocaml " Awk scripts - elseif s:name =~ 'awk\>' + elseif s:name =~# 'awk\>' set ft=awk " Website MetaLanguage - elseif s:name =~ 'wml' + elseif s:name =~# 'wml' set ft=wml " Scheme scripts - elseif s:name =~ 'scheme' + elseif s:name =~# 'scheme' set ft=scheme " CFEngine scripts - elseif s:name =~ 'cfengine' + elseif s:name =~# 'cfengine' set ft=cfengine " Erlang scripts - elseif s:name =~ 'escript' + elseif s:name =~# 'escript' set ft=erlang " Haskell - elseif s:name =~ 'haskell' + elseif s:name =~# 'haskell' set ft=haskell " Scala - elseif s:name =~ 'scala\>' + elseif s:name =~# 'scala\>' set ft=scala endif @@ -180,28 +184,28 @@ else let s:line5 = getline(5) " Bourne-like shell scripts: sh ksh bash bash2 - if s:line1 =~ '^:$' - call SetFileTypeSH(s:line1) " defined in filetype.vim + if s:line1 =~# '^:$' + call filetype#SetFileTypeSH(s:line1) " defined in filetype.vim " Z shell scripts - elseif s:line1 =~ '^#compdef\>' || s:line1 =~ '^#autoload\>' || - \ "\n".s:line1."\n".s:line2."\n".s:line3."\n".s:line4."\n".s:line5 =~ '\n\s*emulate\s\+\%(-[LR]\s\+\)\=[ckz]\=sh\>' + elseif s:line1 =~# '^#compdef\>' || s:line1 =~# '^#autoload\>' || + \ "\n".s:line1."\n".s:line2."\n".s:line3."\n".s:line4."\n".s:line5 =~# '\n\s*emulate\s\+\%(-[LR]\s\+\)\=[ckz]\=sh\>' set ft=zsh " ELM Mail files - elseif s:line1 =~ '^From \([a-zA-Z][a-zA-Z_0-9\.=-]*\(@[^ ]*\)\=\|-\) .* \(19\|20\)\d\d$' + elseif s:line1 =~# '^From \([a-zA-Z][a-zA-Z_0-9\.=-]*\(@[^ ]*\)\=\|-\) .* \(19\|20\)\d\d$' set ft=mail " Mason - elseif s:line1 =~ '^<[%&].*>' + elseif s:line1 =~# '^<[%&].*>' set ft=mason " Vim scripts (must have '" vim' as the first line to trigger this) - elseif s:line1 =~ '^" *[vV]im$' + elseif s:line1 =~# '^" *[vV]im$' set ft=vim " MOO - elseif s:line1 =~ '^\*\* LambdaMOO Database, Format Version \%([1-3]\>\)\@!\d\+ \*\*$' + elseif s:line1 =~# '^\*\* LambdaMOO Database, Format Version \%([1-3]\>\)\@!\d\+ \*\*$' set ft=moo " Diff file: @@ -215,40 +219,45 @@ else " - "=== ", "--- ", "+++ " (bzr diff, common case) " - "=== (removed|added|renamed|modified)" (bzr diff, alternative) " - "# HG changeset patch" in first line (Mercurial export format) - elseif s:line1 =~ '^\(diff\>\|Only in \|\d\+\(,\d\+\)\=[cda]\d\+\>\|# It was generated by makepatch \|Index:\s\+\f\+\r\=$\|===== \f\+ \d\+\.\d\+ vs edited\|==== //\f\+#\d\+\|# HG changeset patch\)' - \ || (s:line1 =~ '^--- ' && s:line2 =~ '^+++ ') - \ || (s:line1 =~ '^\* looking for ' && s:line2 =~ '^\* comparing to ') - \ || (s:line1 =~ '^\*\*\* ' && s:line2 =~ '^--- ') - \ || (s:line1 =~ '^=== ' && ((s:line2 =~ '^=\{66\}' && s:line3 =~ '^--- ' && s:line4 =~ '^+++') || (s:line2 =~ '^--- ' && s:line3 =~ '^+++ '))) - \ || (s:line1 =~ '^=== \(removed\|added\|renamed\|modified\)') + elseif s:line1 =~# '^\(diff\>\|Only in \|\d\+\(,\d\+\)\=[cda]\d\+\>\|# It was generated by makepatch \|Index:\s\+\f\+\r\=$\|===== \f\+ \d\+\.\d\+ vs edited\|==== //\f\+#\d\+\|# HG changeset patch\)' + \ || (s:line1 =~# '^--- ' && s:line2 =~# '^+++ ') + \ || (s:line1 =~# '^\* looking for ' && s:line2 =~# '^\* comparing to ') + \ || (s:line1 =~# '^\*\*\* ' && s:line2 =~# '^--- ') + \ || (s:line1 =~# '^=== ' && ((s:line2 =~# '^=\{66\}' && s:line3 =~# '^--- ' && s:line4 =~# '^+++') || (s:line2 =~# '^--- ' && s:line3 =~# '^+++ '))) + \ || (s:line1 =~# '^=== \(removed\|added\|renamed\|modified\)') set ft=diff " PostScript Files (must have %!PS as the first line, like a2ps output) - elseif s:line1 =~ '^%![ \t]*PS' + elseif s:line1 =~# '^%![ \t]*PS' set ft=postscr " M4 scripts: Guess there is a line that starts with "dnl". - elseif s:line1 =~ '^\s*dnl\>' - \ || s:line2 =~ '^\s*dnl\>' - \ || s:line3 =~ '^\s*dnl\>' - \ || s:line4 =~ '^\s*dnl\>' - \ || s:line5 =~ '^\s*dnl\>' + elseif s:line1 =~# '^\s*dnl\>' + \ || s:line2 =~# '^\s*dnl\>' + \ || s:line3 =~# '^\s*dnl\>' + \ || s:line4 =~# '^\s*dnl\>' + \ || s:line5 =~# '^\s*dnl\>' set ft=m4 + " AmigaDos scripts + elseif $TERM == "amiga" + \ && (s:line1 =~# "^;" || s:line1 =~? '^\.bra') + set ft=amiga + " SiCAD scripts (must have procn or procd as the first line to trigger this) elseif s:line1 =~? '^ *proc[nd] *$' set ft=sicad " Purify log files start with "**** Purify" - elseif s:line1 =~ '^\*\*\*\* Purify' + elseif s:line1 =~# '^\*\*\*\* Purify' set ft=purifylog " XML - elseif s:line1 =~ '' + elseif s:line1 =~# '' set ft=xml " XHTML (e.g.: PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN") - elseif s:line1 =~ '\' || s:line1 =~ '^// *JOB\>' + elseif s:line1 =~# '^\* $$ JOB\>' || s:line1 =~# '^// *JOB\>' set ft=vsejcl " TAK and SINDA - elseif s:line4 =~ 'K & K Associates' || s:line2 =~ 'TAK 2000' + elseif s:line4 =~# 'K & K Associates' || s:line2 =~# 'TAK 2000' set ft=takout - elseif s:line3 =~ 'S Y S T E M S I M P R O V E D ' + elseif s:line3 =~# 'S Y S T E M S I M P R O V E D ' set ft=sindaout - elseif getline(6) =~ 'Run Date: ' + elseif getline(6) =~# 'Run Date: ' set ft=takcmp - elseif getline(9) =~ 'Node File 1' + elseif getline(9) =~# 'Node File 1' set ft=sindacmp " DNS zone files @@ -319,34 +328,34 @@ else set ft=bindzone " BAAN - elseif s:line1 =~ '|\*\{1,80}' && s:line2 =~ 'VRC ' - \ || s:line2 =~ '|\*\{1,80}' && s:line3 =~ 'VRC ' + elseif s:line1 =~# '|\*\{1,80}' && s:line2 =~# 'VRC ' + \ || s:line2 =~# '|\*\{1,80}' && s:line3 =~# 'VRC ' set ft=baan " Valgrind - elseif s:line1 =~ '^==\d\+== valgrind' || s:line3 =~ '^==\d\+== Using valgrind' + elseif s:line1 =~# '^==\d\+== valgrind' || s:line3 =~# '^==\d\+== Using valgrind' set ft=valgrind " Go docs - elseif s:line1 =~ '^PACKAGE DOCUMENTATION$' + elseif s:line1 =~# '^PACKAGE DOCUMENTATION$' set ft=godoc " Renderman Interface Bytestream - elseif s:line1 =~ '^##RenderMan' + elseif s:line1 =~# '^##RenderMan' set ft=rib " Scheme scripts - elseif s:line1 =~ 'exec\s\+\S*scheme' || s:line2 =~ 'exec\s\+\S*scheme' + elseif s:line1 =~# 'exec\s\+\S*scheme' || s:line2 =~# 'exec\s\+\S*scheme' set ft=scheme " Git output - elseif s:line1 =~ '^\(commit\|tree\|object\) \x\{40\}\>\|^tag \S\+$' + elseif s:line1 =~# '^\(commit\|tree\|object\) \x\{40\}\>\|^tag \S\+$' set ft=git " Gprof (gnu profiler) elseif s:line1 == 'Flat profile:' \ && s:line2 == '' - \ && s:line3 =~ '^Each sample counts as .* seconds.$' + \ && s:line3 =~# '^Each sample counts as .* seconds.$' set ft=gprof " Erlang terms @@ -357,18 +366,18 @@ else " CVS diff else let s:lnum = 1 - while getline(s:lnum) =~ "^? " && s:lnum < line("$") + while getline(s:lnum) =~# "^? " && s:lnum < line("$") let s:lnum += 1 endwhile - if getline(s:lnum) =~ '^Index:\s\+\f\+$' + if getline(s:lnum) =~# '^Index:\s\+\f\+$' set ft=diff " locale input files: Formal Definitions of Cultural Conventions " filename must be like en_US, fr_FR@euro or en_US.UTF-8 - elseif expand("%") =~ '\a\a_\a\a\($\|[.@]\)\|i18n$\|POSIX$\|translit_' + elseif expand("%") =~# '\a\a_\a\a\($\|[.@]\)\|i18n$\|POSIX$\|translit_' let s:lnum = 1 while s:lnum < 100 && s:lnum < line("$") - if getline(s:lnum) =~ '^LC_\(IDENTIFICATION\|CTYPE\|COLLATE\|MONETARY\|NUMERIC\|TIME\|MESSAGES\|PAPER\|TELEPHONE\|MEASUREMENT\|NAME\|ADDRESS\)$' + if getline(s:lnum) =~# '^LC_\(IDENTIFICATION\|CTYPE\|COLLATE\|MONETARY\|NUMERIC\|TIME\|MESSAGES\|PAPER\|TELEPHONE\|MEASUREMENT\|NAME\|ADDRESS\)$' setf fdcc break endif -- cgit From 411d57813740328dbdce3ae237cf68a90ce7ac0e Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Fri, 10 Nov 2017 01:56:32 +0100 Subject: vim-patch:8.0.1282 Problem: script-local variable defined in the wrong script Solution: Move variable to autoload/filetype.vim. https://github.com/vim/vim/commit/cef7322d8a902b4655ed861489c4e798672074f0 --- runtime/autoload/filetype.vim | 1 + runtime/filetype.vim | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) (limited to 'runtime') diff --git a/runtime/autoload/filetype.vim b/runtime/autoload/filetype.vim index ffca01ed0c..66e64b29d8 100644 --- a/runtime/autoload/filetype.vim +++ b/runtime/autoload/filetype.vim @@ -560,6 +560,7 @@ func filetype#CSH() endif endfunc +let s:ft_rules_udev_rules_pattern = '^\s*\cudev_rules\s*=\s*"\([^"]\{-1,}\)/*".*' func filetype#FTRules() let path = expand(':p') if path =~ '^/\(etc/udev/\%(rules\.d/\)\=.*\.rules\|lib/udev/\%(rules\.d/\)\=.*\.rules\)$' diff --git a/runtime/filetype.vim b/runtime/filetype.vim index c2012c05ec..6996db017d 100644 --- a/runtime/filetype.vim +++ b/runtime/filetype.vim @@ -1537,7 +1537,6 @@ au BufNewFile,BufRead *.mib,*.my setf mib au BufNewFile,BufRead *.hog,snort.conf,vision.conf setf hog au BufNewFile,BufRead *.rules call filetype#FTRules() -let s:ft_rules_udev_rules_pattern = '^\s*\cudev_rules\s*=\s*"\([^"]\{-1,}\)/*".*' " Spec (Linux RPM) au BufNewFile,BufRead *.spec setf spec -- cgit From b982f0e654662588053cc7c9b53b7841adf5cf5c Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Mon, 2 Apr 2018 23:18:26 +0200 Subject: vim-patch:8.0.1285 https://github.com/vim/vim/commit/d09a206ee94ccb653707ce9b6e536d4d58886e04 vim-patch:8.0.0564: cannot detect Bazel BUILD files on some systems --- runtime/autoload/dist/ft.vim | 741 ++++++++++++++++++++++++++++++++++++++++++ runtime/autoload/filetype.vim | 741 ------------------------------------------ runtime/filetype.vim | 94 +++--- runtime/scripts.vim | 12 +- 4 files changed, 794 insertions(+), 794 deletions(-) create mode 100644 runtime/autoload/dist/ft.vim delete mode 100644 runtime/autoload/filetype.vim (limited to 'runtime') diff --git a/runtime/autoload/dist/ft.vim b/runtime/autoload/dist/ft.vim new file mode 100644 index 0000000000..2603c6822f --- /dev/null +++ b/runtime/autoload/dist/ft.vim @@ -0,0 +1,741 @@ +" Vim functions for file type detection +" +" Maintainer: Bram Moolenaar +" Last Change: 2017 Nov 11 + +" These functions are moved here from runtime/filetype.vim to make startup +" faster. + +" Line continuation is used here, remove 'C' from 'cpoptions' +let s:cpo_save = &cpo +set cpo&vim + +func dist#ft#Check_inp() + if getline(1) =~ '^\*' + setf abaqus + else + let n = 1 + if line("$") > 500 + let nmax = 500 + else + let nmax = line("$") + endif + while n <= nmax + if getline(n) =~? "^header surface data" + setf trasys + break + endif + let n = n + 1 + endwhile + endif +endfunc + +" This function checks for the kind of assembly that is wanted by the user, or +" can be detected from the first five lines of the file. +func dist#ft#FTasm() + " make sure b:asmsyntax exists + if !exists("b:asmsyntax") + let b:asmsyntax = "" + endif + + if b:asmsyntax == "" + call dist#ft#FTasmsyntax() + endif + + " if b:asmsyntax still isn't set, default to asmsyntax or GNU + if b:asmsyntax == "" + if exists("g:asmsyntax") + let b:asmsyntax = g:asmsyntax + else + let b:asmsyntax = "asm" + endif + endif + + exe "setf " . fnameescape(b:asmsyntax) +endfunc + +func dist#ft#FTasmsyntax() + " see if file contains any asmsyntax=foo overrides. If so, change + " b:asmsyntax appropriately + let head = " ".getline(1)." ".getline(2)." ".getline(3)." ".getline(4). + \" ".getline(5)." " + let match = matchstr(head, '\sasmsyntax=\zs[a-zA-Z0-9]\+\ze\s') + if match != '' + let b:asmsyntax = match + elseif ((head =~? '\.title') || (head =~? '\.ident') || (head =~? '\.macro') || (head =~? '\.subtitle') || (head =~? '\.library')) + let b:asmsyntax = "vmasm" + endif +endfunc + +" Check if one of the first five lines contains "VB_Name". In that case it is +" probably a Visual Basic file. Otherwise it's assumed to be "alt" filetype. +func dist#ft#FTVB(alt) + if getline(1).getline(2).getline(3).getline(4).getline(5) =~? 'VB_Name\|Begin VB\.\(Form\|MDIForm\|UserControl\)' + setf vb + else + exe "setf " . a:alt + endif +endfunc + +func dist#ft#FTbtm() + if exists("g:dosbatch_syntax_for_btm") && g:dosbatch_syntax_for_btm + setf dosbatch + else + setf btm + endif +endfunc + +func dist#ft#BindzoneCheck(default) + if getline(1).getline(2).getline(3).getline(4) =~ '^; <<>> DiG [0-9.]\+.* <<>>\|$ORIGIN\|$TTL\|IN\s\+SOA' + setf bindzone + elseif a:default != '' + exe 'setf ' . a:default + endif +endfunc + +func dist#ft#FTlpc() + if exists("g:lpc_syntax_for_c") + let lnum = 1 + while lnum <= 12 + if getline(lnum) =~# '^\(//\|inherit\|private\|protected\|nosave\|string\|object\|mapping\|mixed\)' + setf lpc + return + endif + let lnum = lnum + 1 + endwhile + endif + setf c +endfunc + +func dist#ft#FTheader() + if match(getline(1, min([line("$"), 200])), '^@\(interface\|end\|class\)') > -1 + if exists("g:c_syntax_for_h") + setf objc + else + setf objcpp + endif + elseif exists("g:c_syntax_for_h") + setf c + elseif exists("g:ch_syntax_for_h") + setf ch + else + setf cpp + endif +endfunc + +" This function checks if one of the first ten lines start with a '@'. In +" that case it is probably a change file. +" If the first line starts with # or ! it's probably a ch file. +" If a line has "main", "include", "//" ir "/*" it's probably ch. +" Otherwise CHILL is assumed. +func dist#ft#FTchange() + let lnum = 1 + while lnum <= 10 + if getline(lnum)[0] == '@' + setf change + return + endif + if lnum == 1 && (getline(1)[0] == '#' || getline(1)[0] == '!') + setf ch + return + endif + if getline(lnum) =~ "MODULE" + setf chill + return + endif + if getline(lnum) =~ 'main\s*(\|#\s*include\|//' + setf ch + return + endif + let lnum = lnum + 1 + endwhile + setf chill +endfunc + +func dist#ft#FTent() + " This function checks for valid cl syntax in the first five lines. + " Look for either an opening comment, '#', or a block start, '{". + " If not found, assume SGML. + let lnum = 1 + while lnum < 6 + let line = getline(lnum) + if line =~ '^\s*[#{]' + setf cl + return + elseif line !~ '^\s*$' + " Not a blank line, not a comment, and not a block start, + " so doesn't look like valid cl code. + break + endif + let lnum = lnum + 1 + endw + setf dtd +endfunc + +func dist#ft#EuphoriaCheck() + if exists('g:filetype_euphoria') + exe 'setf ' . g:filetype_euphoria + else + setf euphoria3 + endif +endfunc + +func dist#ft#DtraceCheck() + let lines = getline(1, min([line("$"), 100])) + if match(lines, '^module\>\|^import\>') > -1 + " D files often start with a module and/or import statement. + setf d + elseif match(lines, '^#!\S\+dtrace\|#pragma\s\+D\s\+option\|:\S\{-}:\S\{-}:') > -1 + setf dtrace + else + setf d + endif +endfunc + +func dist#ft#FTe() + if exists('g:filetype_euphoria') + exe 'setf ' . g:filetype_euphoria + else + let n = 1 + while n < 100 && n < line("$") + if getline(n) =~ "^\\s*\\(<'\\|'>\\)\\s*$" + setf specman + return + endif + let n = n + 1 + endwhile + setf eiffel + endif +endfunc + +" Distinguish between HTML, XHTML and Django +func dist#ft#FThtml() + let n = 1 + while n < 10 && n < line("$") + if getline(n) =~ '\\|{#\s\+' + setf htmldjango + return + endif + let n = n + 1 + endwhile + setf html +endfunc + +" Distinguish between standard IDL and MS-IDL +func dist#ft#FTidl() + let n = 1 + while n < 50 && n < line("$") + if getline(n) =~ '^\s*import\s\+"\(unknwn\|objidl\)\.idl"' + setf msidl + return + endif + let n = n + 1 + endwhile + setf idl +endfunc + +" Distinguish between "default" and Cproto prototype file. */ +func dist#ft#ProtoCheck(default) + " Cproto files have a comment in the first line and a function prototype in + " the second line, it always ends in ";". Indent files may also have + " comments, thus we can't match comments to see the difference. + " IDL files can have a single ';' in the second line, require at least one + " chacter before the ';'. + if getline(2) =~ '.;$' + setf cpp + else + exe 'setf ' . a:default + endif +endfunc + +func dist#ft#FTm() + let n = 1 + let saw_comment = 0 " Whether we've seen a multiline comment leader. + while n < 100 + let line = getline(n) + if line =~ '^\s*/\*' + " /* ... */ is a comment in Objective C and Murphi, so we can't conclude + " it's either of them yet, but track this as a hint in case we don't see + " anything more definitive. + let saw_comment = 1 + endif + if line =~ '^\s*\(#\s*\(include\|import\)\>\|@import\>\|//\)' + setf objc + return + endif + if line =~ '^\s*%' + setf matlab + return + endif + if line =~ '^\s*(\*' + setf mma + return + endif + if line =~ '^\c\s*\(\(type\|var\)\>\|--\)' + setf murphi + return + endif + let n = n + 1 + endwhile + + if saw_comment + " We didn't see anything definitive, but this looks like either Objective C + " or Murphi based on the comment leader. Assume the former as it is more + " common. + setf objc + elseif exists("g:filetype_m") + " Use user specified default filetype for .m + exe "setf " . g:filetype_m + else + " Default is matlab + setf matlab + endif +endfunc + +func dist#ft#FTmms() + let n = 1 + while n < 10 + let line = getline(n) + if line =~ '^\s*\(%\|//\)' || line =~ '^\*' + setf mmix + return + endif + if line =~ '^\s*#' + setf make + return + endif + let n = n + 1 + endwhile + setf mmix +endfunc + +" This function checks if one of the first five lines start with a dot. In +" that case it is probably an nroff file: 'filetype' is set and 1 is returned. +func dist#ft#FTnroff() + if getline(1)[0] . getline(2)[0] . getline(3)[0] . getline(4)[0] . getline(5)[0] =~ '\.' + setf nroff + return 1 + endif + return 0 +endfunc + +func dist#ft#FTmm() + let n = 1 + while n < 10 + let line = getline(n) + if line =~ '^\s*\(#\s*\(include\|import\)\>\|@import\>\|/\*\)' + setf objcpp + return + endif + let n = n + 1 + endwhile + setf nroff +endfunc + +func dist#ft#FTpl() + if exists("g:filetype_pl") + exe "setf " . g:filetype_pl + else + " recognize Prolog by specific text in the first non-empty line + " require a blank after the '%' because Perl uses "%list" and "%translate" + let l = getline(nextnonblank(1)) + if l =~ '\' || l =~ '^\s*\(%\+\(\s\|$\)\|/\*\)' || l =~ ':-' + setf prolog + else + setf perl + endif + endif +endfunc + +func dist#ft#FTinc() + if exists("g:filetype_inc") + exe "setf " . g:filetype_inc + else + let lines = getline(1).getline(2).getline(3) + if lines =~? "perlscript" + setf aspperl + elseif lines =~ "<%" + setf aspvbs + elseif lines =~ "' + \ || line =~ '^\s*{' || line =~ '^\s*(\*' + setf pascal + return + elseif line !~ '^\s*$' || line =~ '^/\*' + " Not an empty line: Doesn't look like valid Pascal code. + " Or it looks like a Progress /* comment + break + endif + let lnum = lnum + 1 + endw + setf progress +endfunc + +func dist#ft#FTr() + let max = line("$") > 50 ? 50 : line("$") + + for n in range(1, max) + " Rebol is easy to recognize, check for that first + if getline(n) =~? '\' + setf rebol + return + endif + endfor + + for n in range(1, max) + " R has # comments + if getline(n) =~ '^\s*#' + setf r + return + endif + " Rexx has /* comments */ + if getline(n) =~ '^\s*/\*' + setf rexx + return + endif + endfor + + " Nothing recognized, use user default or assume Rexx + if exists("g:filetype_r") + exe "setf " . g:filetype_r + else + " Rexx used to be the default, but R appears to be much more popular. + setf r + endif +endfunc + +func dist#ft#McSetf() + " Rely on the file to start with a comment. + " MS message text files use ';', Sendmail files use '#' or 'dnl' + for lnum in range(1, min([line("$"), 20])) + let line = getline(lnum) + if line =~ '^\s*\(#\|dnl\)' + setf m4 " Sendmail .mc file + return + elseif line =~ '^\s*;' + setf msmessages " MS Message text file + return + endif + endfor + setf m4 " Default: Sendmail .mc file +endfunc + +" Called from filetype.vim and scripts.vim. +func dist#ft#SetFileTypeSH(name) + if expand("") =~ g:ft_ignore_pat + return + endif + if a:name =~ '\' + " Some .sh scripts contain #!/bin/csh. + call dist#ft#SetFileTypeShell("csh") + return + elseif a:name =~ '\' + " Some .sh scripts contain #!/bin/tcsh. + call dist#ft#SetFileTypeShell("tcsh") + return + elseif a:name =~ '\' + " Some .sh scripts contain #!/bin/zsh. + call dist#ft#SetFileTypeShell("zsh") + return + elseif a:name =~ '\' + let b:is_kornshell = 1 + if exists("b:is_bash") + unlet b:is_bash + endif + if exists("b:is_sh") + unlet b:is_sh + endif + elseif exists("g:bash_is_sh") || a:name =~ '\' || a:name =~ '\' + let b:is_bash = 1 + if exists("b:is_kornshell") + unlet b:is_kornshell + endif + if exists("b:is_sh") + unlet b:is_sh + endif + elseif a:name =~ '\' + let b:is_sh = 1 + if exists("b:is_kornshell") + unlet b:is_kornshell + endif + if exists("b:is_bash") + unlet b:is_bash + endif + endif + call dist#ft#SetFileTypeShell("sh") +endfunc + +" For shell-like file types, check for an "exec" command hidden in a comment, +" as used for Tcl. +" Also called from scripts.vim, thus can't be local to this script. +func dist#ft#SetFileTypeShell(name) + if expand("") =~ g:ft_ignore_pat + return + endif + let l = 2 + while l < 20 && l < line("$") && getline(l) =~ '^\s*\(#\|$\)' + " Skip empty and comment lines. + let l = l + 1 + endwhile + if l < line("$") && getline(l) =~ '\s*exec\s' && getline(l - 1) =~ '^\s*#.*\\$' + " Found an "exec" line after a comment with continuation + let n = substitute(getline(l),'\s*exec\s\+\([^ ]*/\)\=', '', '') + if n =~ '\:p') + if path =~ '^/\(etc/udev/\%(rules\.d/\)\=.*\.rules\|lib/udev/\%(rules\.d/\)\=.*\.rules\)$' + setf udevrules + return + endif + if path =~ '^/etc/ufw/' + setf conf " Better than hog + return + endif + if path =~ '^/\(etc\|usr/share\)/polkit-1/rules\.d' + setf javascript + return + endif + try + let config_lines = readfile('/etc/udev/udev.conf') + catch /^Vim\%((\a\+)\)\=:E484/ + setf hog + return + endtry + let dir = expand(':p:h') + for line in config_lines + if line =~ s:ft_rules_udev_rules_pattern + let udev_rules = substitute(line, s:ft_rules_udev_rules_pattern, '\1', "") + if dir == udev_rules + setf udevrules + endif + break + endif + endfor + setf hog +endfunc + +func dist#ft#SQL() + if exists("g:filetype_sql") + exe "setf " . g:filetype_sql + else + setf sql + endif +endfunc + +" If the file has an extension of 't' and is in a directory 't' or 'xt' then +" it is almost certainly a Perl test file. +" If the first line starts with '#' and contains 'perl' it's probably a Perl +" file. +" (Slow test) If a file contains a 'use' statement then it is almost certainly +" a Perl file. +func dist#ft#FTperl() + let dirname = expand("%:p:h:t") + if expand("%:e") == 't' && (dirname == 't' || dirname == 'xt') + setf perl + return 1 + endif + if getline(1)[0] == '#' && getline(1) =~ 'perl' + setf perl + return 1 + endif + if search('^use\s\s*\k', 'nc', 30) + setf perl + return 1 + endif + return 0 +endfunc + +" Choose context, plaintex, or tex (LaTeX) based on these rules: +" 1. Check the first line of the file for "%&". +" 2. Check the first 1000 non-comment lines for LaTeX or ConTeXt keywords. +" 3. Default to "latex" or to g:tex_flavor, can be set in user's vimrc. +func dist#ft#FTtex() + let firstline = getline(1) + if firstline =~ '^%&\s*\a\+' + let format = tolower(matchstr(firstline, '\a\+')) + let format = substitute(format, 'pdf', '', '') + if format == 'tex' + let format = 'latex' + elseif format == 'plaintex' + let format = 'plain' + endif + elseif expand('%') =~ 'tex/context/.*/.*.tex' + let format = 'context' + else + " Default value, may be changed later: + let format = exists("g:tex_flavor") ? g:tex_flavor : 'plain' + " Save position, go to the top of the file, find first non-comment line. + let save_cursor = getpos('.') + call cursor(1,1) + let firstNC = search('^\s*[^[:space:]%]', 'c', 1000) + if firstNC " Check the next thousand lines for a LaTeX or ConTeXt keyword. + let lpat = 'documentclass\>\|usepackage\>\|begin{\|newcommand\>\|renewcommand\>' + let cpat = 'start\a\+\|setup\a\+\|usemodule\|enablemode\|enableregime\|setvariables\|useencoding\|usesymbols\|stelle\a\+\|verwende\a\+\|stel\a\+\|gebruik\a\+\|usa\a\+\|imposta\a\+\|regle\a\+\|utilisemodule\>' + let kwline = search('^\s*\\\%(' . lpat . '\)\|^\s*\\\(' . cpat . '\)', + \ 'cnp', firstNC + 1000) + if kwline == 1 " lpat matched + let format = 'latex' + elseif kwline == 2 " cpat matched + let format = 'context' + endif " If neither matched, keep default set above. + " let lline = search('^\s*\\\%(' . lpat . '\)', 'cn', firstNC + 1000) + " let cline = search('^\s*\\\%(' . cpat . '\)', 'cn', firstNC + 1000) + " if cline > 0 + " let format = 'context' + " endif + " if lline > 0 && (cline == 0 || cline > lline) + " let format = 'tex' + " endif + endif " firstNC + call setpos('.', save_cursor) + endif " firstline =~ '^%&\s*\a\+' + + " Translation from formats to file types. TODO: add AMSTeX, RevTex, others? + if format == 'plain' + setf plaintex + elseif format == 'context' + setf context + else " probably LaTeX + setf tex + endif + return +endfunc + +func dist#ft#FTxml() + let n = 1 + while n < 100 && n < line("$") + let line = getline(n) + " DocBook 4 or DocBook 5. + let is_docbook4 = line =~ '\)' && getline(n) !~ '^\s*#\s*include' + setf racc + return + endif + let n = n + 1 + endwhile + setf yacc +endfunc + +func dist#ft#Redif() + let lnum = 1 + while lnum <= 5 && lnum < line('$') + if getline(lnum) =~ "^\ctemplate-type:" + setf redif + return + endif + let lnum = lnum + 1 + endwhile +endfunc + + +" Restore 'cpoptions' +let &cpo = s:cpo_save +unlet s:cpo_save diff --git a/runtime/autoload/filetype.vim b/runtime/autoload/filetype.vim deleted file mode 100644 index 66e64b29d8..0000000000 --- a/runtime/autoload/filetype.vim +++ /dev/null @@ -1,741 +0,0 @@ -" Vim functions for file type detection -" -" Maintainer: Bram Moolenaar -" Last Change: 2017 Nov 09 - -" These functions are moved here from runtime/filetype.vim to make startup -" faster. - -" Line continuation is used here, remove 'C' from 'cpoptions' -let s:cpo_save = &cpo -set cpo&vim - -func filetype#Check_inp() - if getline(1) =~ '^\*' - setf abaqus - else - let n = 1 - if line("$") > 500 - let nmax = 500 - else - let nmax = line("$") - endif - while n <= nmax - if getline(n) =~? "^header surface data" - setf trasys - break - endif - let n = n + 1 - endwhile - endif -endfunc - -" This function checks for the kind of assembly that is wanted by the user, or -" can be detected from the first five lines of the file. -func filetype#FTasm() - " make sure b:asmsyntax exists - if !exists("b:asmsyntax") - let b:asmsyntax = "" - endif - - if b:asmsyntax == "" - call filetype#FTasmsyntax() - endif - - " if b:asmsyntax still isn't set, default to asmsyntax or GNU - if b:asmsyntax == "" - if exists("g:asmsyntax") - let b:asmsyntax = g:asmsyntax - else - let b:asmsyntax = "asm" - endif - endif - - exe "setf " . fnameescape(b:asmsyntax) -endfunc - -func filetype#FTasmsyntax() - " see if file contains any asmsyntax=foo overrides. If so, change - " b:asmsyntax appropriately - let head = " ".getline(1)." ".getline(2)." ".getline(3)." ".getline(4). - \" ".getline(5)." " - let match = matchstr(head, '\sasmsyntax=\zs[a-zA-Z0-9]\+\ze\s') - if match != '' - let b:asmsyntax = match - elseif ((head =~? '\.title') || (head =~? '\.ident') || (head =~? '\.macro') || (head =~? '\.subtitle') || (head =~? '\.library')) - let b:asmsyntax = "vmasm" - endif -endfunc - -" Check if one of the first five lines contains "VB_Name". In that case it is -" probably a Visual Basic file. Otherwise it's assumed to be "alt" filetype. -func filetype#FTVB(alt) - if getline(1).getline(2).getline(3).getline(4).getline(5) =~? 'VB_Name\|Begin VB\.\(Form\|MDIForm\|UserControl\)' - setf vb - else - exe "setf " . a:alt - endif -endfunc - -func filetype#FTbtm() - if exists("g:dosbatch_syntax_for_btm") && g:dosbatch_syntax_for_btm - setf dosbatch - else - setf btm - endif -endfunc - -func filetype#BindzoneCheck(default) - if getline(1).getline(2).getline(3).getline(4) =~ '^; <<>> DiG [0-9.]\+.* <<>>\|$ORIGIN\|$TTL\|IN\s\+SOA' - setf bindzone - elseif a:default != '' - exe 'setf ' . a:default - endif -endfunc - -func filetype#FTlpc() - if exists("g:lpc_syntax_for_c") - let lnum = 1 - while lnum <= 12 - if getline(lnum) =~# '^\(//\|inherit\|private\|protected\|nosave\|string\|object\|mapping\|mixed\)' - setf lpc - return - endif - let lnum = lnum + 1 - endwhile - endif - setf c -endfunc - -func filetype#FTheader() - if match(getline(1, min([line("$"), 200])), '^@\(interface\|end\|class\)') > -1 - if exists("g:c_syntax_for_h") - setf objc - else - setf objcpp - endif - elseif exists("g:c_syntax_for_h") - setf c - elseif exists("g:ch_syntax_for_h") - setf ch - else - setf cpp - endif -endfunc - -" This function checks if one of the first ten lines start with a '@'. In -" that case it is probably a change file. -" If the first line starts with # or ! it's probably a ch file. -" If a line has "main", "include", "//" ir "/*" it's probably ch. -" Otherwise CHILL is assumed. -func filetype#FTchange() - let lnum = 1 - while lnum <= 10 - if getline(lnum)[0] == '@' - setf change - return - endif - if lnum == 1 && (getline(1)[0] == '#' || getline(1)[0] == '!') - setf ch - return - endif - if getline(lnum) =~ "MODULE" - setf chill - return - endif - if getline(lnum) =~ 'main\s*(\|#\s*include\|//' - setf ch - return - endif - let lnum = lnum + 1 - endwhile - setf chill -endfunc - -func filetype#FTent() - " This function checks for valid cl syntax in the first five lines. - " Look for either an opening comment, '#', or a block start, '{". - " If not found, assume SGML. - let lnum = 1 - while lnum < 6 - let line = getline(lnum) - if line =~ '^\s*[#{]' - setf cl - return - elseif line !~ '^\s*$' - " Not a blank line, not a comment, and not a block start, - " so doesn't look like valid cl code. - break - endif - let lnum = lnum + 1 - endw - setf dtd -endfunc - -func filetype#EuphoriaCheck() - if exists('g:filetype_euphoria') - exe 'setf ' . g:filetype_euphoria - else - setf euphoria3 - endif -endfunc - -func filetype#DtraceCheck() - let lines = getline(1, min([line("$"), 100])) - if match(lines, '^module\>\|^import\>') > -1 - " D files often start with a module and/or import statement. - setf d - elseif match(lines, '^#!\S\+dtrace\|#pragma\s\+D\s\+option\|:\S\{-}:\S\{-}:') > -1 - setf dtrace - else - setf d - endif -endfunc - -func filetype#FTe() - if exists('g:filetype_euphoria') - exe 'setf ' . g:filetype_euphoria - else - let n = 1 - while n < 100 && n < line("$") - if getline(n) =~ "^\\s*\\(<'\\|'>\\)\\s*$" - setf specman - return - endif - let n = n + 1 - endwhile - setf eiffel - endif -endfunc - -" Distinguish between HTML, XHTML and Django -func filetype#FThtml() - let n = 1 - while n < 10 && n < line("$") - if getline(n) =~ '\\|{#\s\+' - setf htmldjango - return - endif - let n = n + 1 - endwhile - setf html -endfunc - -" Distinguish between standard IDL and MS-IDL -func filetype#FTidl() - let n = 1 - while n < 50 && n < line("$") - if getline(n) =~ '^\s*import\s\+"\(unknwn\|objidl\)\.idl"' - setf msidl - return - endif - let n = n + 1 - endwhile - setf idl -endfunc - -" Distinguish between "default" and Cproto prototype file. */ -func filetype#ProtoCheck(default) - " Cproto files have a comment in the first line and a function prototype in - " the second line, it always ends in ";". Indent files may also have - " comments, thus we can't match comments to see the difference. - " IDL files can have a single ';' in the second line, require at least one - " chacter before the ';'. - if getline(2) =~ '.;$' - setf cpp - else - exe 'setf ' . a:default - endif -endfunc - -func filetype#FTm() - let n = 1 - let saw_comment = 0 " Whether we've seen a multiline comment leader. - while n < 100 - let line = getline(n) - if line =~ '^\s*/\*' - " /* ... */ is a comment in Objective C and Murphi, so we can't conclude - " it's either of them yet, but track this as a hint in case we don't see - " anything more definitive. - let saw_comment = 1 - endif - if line =~ '^\s*\(#\s*\(include\|import\)\>\|@import\>\|//\)' - setf objc - return - endif - if line =~ '^\s*%' - setf matlab - return - endif - if line =~ '^\s*(\*' - setf mma - return - endif - if line =~ '^\c\s*\(\(type\|var\)\>\|--\)' - setf murphi - return - endif - let n = n + 1 - endwhile - - if saw_comment - " We didn't see anything definitive, but this looks like either Objective C - " or Murphi based on the comment leader. Assume the former as it is more - " common. - setf objc - elseif exists("g:filetype_m") - " Use user specified default filetype for .m - exe "setf " . g:filetype_m - else - " Default is matlab - setf matlab - endif -endfunc - -func filetype#FTmms() - let n = 1 - while n < 10 - let line = getline(n) - if line =~ '^\s*\(%\|//\)' || line =~ '^\*' - setf mmix - return - endif - if line =~ '^\s*#' - setf make - return - endif - let n = n + 1 - endwhile - setf mmix -endfunc - -" This function checks if one of the first five lines start with a dot. In -" that case it is probably an nroff file: 'filetype' is set and 1 is returned. -func filetype#FTnroff() - if getline(1)[0] . getline(2)[0] . getline(3)[0] . getline(4)[0] . getline(5)[0] =~ '\.' - setf nroff - return 1 - endif - return 0 -endfunc - -func filetype#FTmm() - let n = 1 - while n < 10 - let line = getline(n) - if line =~ '^\s*\(#\s*\(include\|import\)\>\|@import\>\|/\*\)' - setf objcpp - return - endif - let n = n + 1 - endwhile - setf nroff -endfunc - -func filetype#FTpl() - if exists("g:filetype_pl") - exe "setf " . g:filetype_pl - else - " recognize Prolog by specific text in the first non-empty line - " require a blank after the '%' because Perl uses "%list" and "%translate" - let l = getline(nextnonblank(1)) - if l =~ '\' || l =~ '^\s*\(%\+\(\s\|$\)\|/\*\)' || l =~ ':-' - setf prolog - else - setf perl - endif - endif -endfunc - -func filetype#FTinc() - if exists("g:filetype_inc") - exe "setf " . g:filetype_inc - else - let lines = getline(1).getline(2).getline(3) - if lines =~? "perlscript" - setf aspperl - elseif lines =~ "<%" - setf aspvbs - elseif lines =~ "' - \ || line =~ '^\s*{' || line =~ '^\s*(\*' - setf pascal - return - elseif line !~ '^\s*$' || line =~ '^/\*' - " Not an empty line: Doesn't look like valid Pascal code. - " Or it looks like a Progress /* comment - break - endif - let lnum = lnum + 1 - endw - setf progress -endfunc - -func filetype#FTr() - let max = line("$") > 50 ? 50 : line("$") - - for n in range(1, max) - " Rebol is easy to recognize, check for that first - if getline(n) =~? '\' - setf rebol - return - endif - endfor - - for n in range(1, max) - " R has # comments - if getline(n) =~ '^\s*#' - setf r - return - endif - " Rexx has /* comments */ - if getline(n) =~ '^\s*/\*' - setf rexx - return - endif - endfor - - " Nothing recognized, use user default or assume Rexx - if exists("g:filetype_r") - exe "setf " . g:filetype_r - else - " Rexx used to be the default, but R appears to be much more popular. - setf r - endif -endfunc - -func filetype#McSetf() - " Rely on the file to start with a comment. - " MS message text files use ';', Sendmail files use '#' or 'dnl' - for lnum in range(1, min([line("$"), 20])) - let line = getline(lnum) - if line =~ '^\s*\(#\|dnl\)' - setf m4 " Sendmail .mc file - return - elseif line =~ '^\s*;' - setf msmessages " MS Message text file - return - endif - endfor - setf m4 " Default: Sendmail .mc file -endfunc - -" Called from filetype.vim and scripts.vim. -func filetype#SetFileTypeSH(name) - if expand("") =~ g:ft_ignore_pat - return - endif - if a:name =~ '\' - " Some .sh scripts contain #!/bin/csh. - call filetype#SetFileTypeShell("csh") - return - elseif a:name =~ '\' - " Some .sh scripts contain #!/bin/tcsh. - call filetype#SetFileTypeShell("tcsh") - return - elseif a:name =~ '\' - " Some .sh scripts contain #!/bin/zsh. - call filetype#SetFileTypeShell("zsh") - return - elseif a:name =~ '\' - let b:is_kornshell = 1 - if exists("b:is_bash") - unlet b:is_bash - endif - if exists("b:is_sh") - unlet b:is_sh - endif - elseif exists("g:bash_is_sh") || a:name =~ '\' || a:name =~ '\' - let b:is_bash = 1 - if exists("b:is_kornshell") - unlet b:is_kornshell - endif - if exists("b:is_sh") - unlet b:is_sh - endif - elseif a:name =~ '\' - let b:is_sh = 1 - if exists("b:is_kornshell") - unlet b:is_kornshell - endif - if exists("b:is_bash") - unlet b:is_bash - endif - endif - call filetype#SetFileTypeShell("sh") -endfunc - -" For shell-like file types, check for an "exec" command hidden in a comment, -" as used for Tcl. -" Also called from scripts.vim, thus can't be local to this script. -func filetype#SetFileTypeShell(name) - if expand("") =~ g:ft_ignore_pat - return - endif - let l = 2 - while l < 20 && l < line("$") && getline(l) =~ '^\s*\(#\|$\)' - " Skip empty and comment lines. - let l = l + 1 - endwhile - if l < line("$") && getline(l) =~ '\s*exec\s' && getline(l - 1) =~ '^\s*#.*\\$' - " Found an "exec" line after a comment with continuation - let n = substitute(getline(l),'\s*exec\s\+\([^ ]*/\)\=', '', '') - if n =~ '\:p') - if path =~ '^/\(etc/udev/\%(rules\.d/\)\=.*\.rules\|lib/udev/\%(rules\.d/\)\=.*\.rules\)$' - setf udevrules - return - endif - if path =~ '^/etc/ufw/' - setf conf " Better than hog - return - endif - if path =~ '^/\(etc\|usr/share\)/polkit-1/rules\.d' - setf javascript - return - endif - try - let config_lines = readfile('/etc/udev/udev.conf') - catch /^Vim\%((\a\+)\)\=:E484/ - setf hog - return - endtry - let dir = expand(':p:h') - for line in config_lines - if line =~ s:ft_rules_udev_rules_pattern - let udev_rules = substitute(line, s:ft_rules_udev_rules_pattern, '\1', "") - if dir == udev_rules - setf udevrules - endif - break - endif - endfor - setf hog -endfunc - -func filetype#SQL() - if exists("g:filetype_sql") - exe "setf " . g:filetype_sql - else - setf sql - endif -endfunc - -" If the file has an extension of 't' and is in a directory 't' or 'xt' then -" it is almost certainly a Perl test file. -" If the first line starts with '#' and contains 'perl' it's probably a Perl -" file. -" (Slow test) If a file contains a 'use' statement then it is almost certainly -" a Perl file. -func filetype#FTperl() - let dirname = expand("%:p:h:t") - if expand("%:e") == 't' && (dirname == 't' || dirname == 'xt') - setf perl - return 1 - endif - if getline(1)[0] == '#' && getline(1) =~ 'perl' - setf perl - return 1 - endif - if search('^use\s\s*\k', 'nc', 30) - setf perl - return 1 - endif - return 0 -endfunc - -" Choose context, plaintex, or tex (LaTeX) based on these rules: -" 1. Check the first line of the file for "%&". -" 2. Check the first 1000 non-comment lines for LaTeX or ConTeXt keywords. -" 3. Default to "latex" or to g:tex_flavor, can be set in user's vimrc. -func filetype#FTtex() - let firstline = getline(1) - if firstline =~ '^%&\s*\a\+' - let format = tolower(matchstr(firstline, '\a\+')) - let format = substitute(format, 'pdf', '', '') - if format == 'tex' - let format = 'latex' - elseif format == 'plaintex' - let format = 'plain' - endif - elseif expand('%') =~ 'tex/context/.*/.*.tex' - let format = 'context' - else - " Default value, may be changed later: - let format = exists("g:tex_flavor") ? g:tex_flavor : 'plain' - " Save position, go to the top of the file, find first non-comment line. - let save_cursor = getpos('.') - call cursor(1,1) - let firstNC = search('^\s*[^[:space:]%]', 'c', 1000) - if firstNC " Check the next thousand lines for a LaTeX or ConTeXt keyword. - let lpat = 'documentclass\>\|usepackage\>\|begin{\|newcommand\>\|renewcommand\>' - let cpat = 'start\a\+\|setup\a\+\|usemodule\|enablemode\|enableregime\|setvariables\|useencoding\|usesymbols\|stelle\a\+\|verwende\a\+\|stel\a\+\|gebruik\a\+\|usa\a\+\|imposta\a\+\|regle\a\+\|utilisemodule\>' - let kwline = search('^\s*\\\%(' . lpat . '\)\|^\s*\\\(' . cpat . '\)', - \ 'cnp', firstNC + 1000) - if kwline == 1 " lpat matched - let format = 'latex' - elseif kwline == 2 " cpat matched - let format = 'context' - endif " If neither matched, keep default set above. - " let lline = search('^\s*\\\%(' . lpat . '\)', 'cn', firstNC + 1000) - " let cline = search('^\s*\\\%(' . cpat . '\)', 'cn', firstNC + 1000) - " if cline > 0 - " let format = 'context' - " endif - " if lline > 0 && (cline == 0 || cline > lline) - " let format = 'tex' - " endif - endif " firstNC - call setpos('.', save_cursor) - endif " firstline =~ '^%&\s*\a\+' - - " Translation from formats to file types. TODO: add AMSTeX, RevTex, others? - if format == 'plain' - setf plaintex - elseif format == 'context' - setf context - else " probably LaTeX - setf tex - endif - return -endfunc - -func filetype#FTxml() - let n = 1 - while n < 100 && n < line("$") - let line = getline(n) - " DocBook 4 or DocBook 5. - let is_docbook4 = line =~ '\)' && getline(n) !~ '^\s*#\s*include' - setf racc - return - endif - let n = n + 1 - endwhile - setf yacc -endfunc - -func filetype#Redif() - let lnum = 1 - while lnum <= 5 && lnum < line('$') - if getline(lnum) =~ "^\ctemplate-type:" - setf redif - return - endif - let lnum = lnum + 1 - endwhile -endfunc - - -" Restore 'cpoptions' -let &cpo = s:cpo_save -unlet s:cpo_save diff --git a/runtime/filetype.vim b/runtime/filetype.vim index 6996db017d..0301bdd0a1 100644 --- a/runtime/filetype.vim +++ b/runtime/filetype.vim @@ -52,7 +52,7 @@ endfunc au BufNewFile,BufRead $VIMRUNTIME/doc/*.txt setf help " Abaqus or Trasys -au BufNewFile,BufRead *.inp call filetype#Check_inp() +au BufNewFile,BufRead *.inp call dist#ft#Check_inp() " A-A-P recipe au BufNewFile,BufRead *.aap setf aap @@ -150,7 +150,7 @@ au BufNewFile,BufRead */boot/grub/menu.lst,*/boot/grub/grub.conf,*/etc/grub.conf " Assembly (all kinds) " *.lst is not pure assembly, it has two extra columns (address, byte codes) -au BufNewFile,BufRead *.asm,*.[sS],*.[aA],*.mac,*.lst call filetype#FTasm() +au BufNewFile,BufRead *.asm,*.[sS],*.[aA],*.mac,*.lst call dist#ft#FTasm() " Macro (VAX) au BufNewFile,BufRead *.mar setf vmasm @@ -180,7 +180,7 @@ au BufNewFile,BufRead *.awk setf awk au BufNewFile,BufRead *.mch,*.ref,*.imp setf b " BASIC or Visual Basic -au BufNewFile,BufRead *.bas call filetype#FTVB("basic") +au BufNewFile,BufRead *.bas call dist#ft#FTVB("basic") " Visual Basic Script (close to Visual Basic) or Visual Basic .NET au BufNewFile,BufRead *.vb,*.vbs,*.dsm,*.ctl setf vb @@ -198,7 +198,7 @@ au BufNewFile,BufRead *.cmd \ if getline(1) =~ '^/\*' | setf rexx | else | setf dosbatch | endif " Batch file for 4DOS -au BufNewFile,BufRead *.btm call filetype#FTbtm() +au BufNewFile,BufRead *.btm call dist#ft#FTbtm() " BC calculator au BufNewFile,BufRead *.bc setf bc @@ -218,7 +218,7 @@ au BufNewFile,BufRead named*.conf,rndc*.conf,rndc*.key setf named " BIND zone au BufNewFile,BufRead named.root setf bindzone -au BufNewFile,BufRead *.db call filetype#BindzoneCheck('') +au BufNewFile,BufRead *.db call dist#ft#BindzoneCheck('') " Blank au BufNewFile,BufRead *.bl setf blank @@ -233,7 +233,7 @@ if has("fname_case") endif " C or lpc -au BufNewFile,BufRead *.c call filetype#FTlpc() +au BufNewFile,BufRead *.c call dist#ft#FTlpc() " Calendar au BufNewFile,BufRead calendar setf calendar @@ -287,7 +287,7 @@ endif " .h files can be C, Ch C++, ObjC or ObjC++. " Set c_syntax_for_h if you want C, ch_syntax_for_h if you want Ch. ObjC is " detected automatically. -au BufNewFile,BufRead *.h call filetype#FTheader() +au BufNewFile,BufRead *.h call dist#ft#FTheader() " Ch (CHscript) au BufNewFile,BufRead *.chf setf ch @@ -321,7 +321,7 @@ au BufNewFile,BufRead NEWS au BufNewFile,BufRead *..ch setf chill " Changes for WEB and CWEB or CHILL -au BufNewFile,BufRead *.ch call filetype#FTchange() +au BufNewFile,BufRead *.ch call dist#ft#FTchange() " ChordPro au BufNewFile,BufRead *.chopro,*.crd,*.cho,*.crdpro,*.chordpro setf chordpro @@ -333,7 +333,7 @@ au BufNewFile,BufRead *.dcl,*.icl setf clean au BufNewFile,BufRead *.eni setf cl " Clever or dtd -au BufNewFile,BufRead *.ent call filetype#FTent() +au BufNewFile,BufRead *.ent call dist#ft#FTent() " Clipper (or FoxPro; could also be eviews) au BufNewFile,BufRead *.prg @@ -388,9 +388,9 @@ au BufNewFile,BufRead *enlightenment/*.cfg setf c au BufNewFile,BufRead *Eterm/*.cfg setf eterm " Euphoria 3 or 4 -au BufNewFile,BufRead *.eu,*.ew,*.ex,*.exu,*.exw call filetype#EuphoriaCheck() +au BufNewFile,BufRead *.eu,*.ew,*.ex,*.exu,*.exw call dist#ft#EuphoriaCheck() if has("fname_case") - au BufNewFile,BufRead *.EU,*.EW,*.EX,*.EXU,*.EXW call filetype#EuphoriaCheck() + au BufNewFile,BufRead *.EU,*.EW,*.EX,*.EXU,*.EXW call dist#ft#EuphoriaCheck() endif " Lynx config files @@ -437,7 +437,7 @@ au BufNewFile,BufRead */etc/dnsmasq.conf setf dnsmasq au BufNewFile,BufRead *.desc setf desc " the D language or dtrace -au BufNewFile,BufRead *.d call filetype#DtraceCheck() +au BufNewFile,BufRead *.d call dist#ft#DtraceCheck() " Desktop files au BufNewFile,BufRead *.desktop,.directory setf desktop @@ -469,7 +469,7 @@ au BufNewFile,BufRead *.rul \ endif " DCL (Digital Command Language - vms) or DNS zone file -au BufNewFile,BufRead *.com call filetype#BindzoneCheck('dcl') +au BufNewFile,BufRead *.com call dist#ft#BindzoneCheck('dcl') " DOT au BufNewFile,BufRead *.dot setf dot @@ -517,7 +517,7 @@ au BufNewFile,BufRead .editorconfig setf dosini au BufNewFile,BufRead *.ecd setf ecd " Eiffel or Specman or Euphoria -au BufNewFile,BufRead *.e,*.E call filetype#FTe() +au BufNewFile,BufRead *.e,*.E call dist#ft#FTe() " Elinks configuration au BufNewFile,BufRead */etc/elinks.conf,*/.elinks/elinks.conf setf elinks @@ -690,7 +690,7 @@ au BufNewFile,BufRead *.hex,*.h32 setf hex au BufNewFile,BufRead *.t.html setf tilde " HTML (.shtml and .stm for server side) -au BufNewFile,BufRead *.html,*.htm,*.shtml,*.stm call filetype#FThtml() +au BufNewFile,BufRead *.html,*.htm,*.shtml,*.stm call dist#ft#FThtml() " HTML with Ruby - eRuby au BufNewFile,BufRead *.erb,*.rhtml setf eruby @@ -717,7 +717,7 @@ au BufNewFile,BufRead *.htt,*.htb setf httest au BufNewFile,BufRead *.icn setf icon " IDL (Interface Description Language) -au BufNewFile,BufRead *.idl call filetype#FTidl() +au BufNewFile,BufRead *.idl call dist#ft#FTidl() " Microsoft IDL (Interface Description Language) Also *.idl " MOF = WMI (Windows Management Instrumentation) Managed Object Format @@ -728,10 +728,10 @@ au BufNewFile,BufRead */.icewm/menu setf icemenu " Indent profile (must come before IDL *.pro!) au BufNewFile,BufRead .indent.pro setf indent -au BufNewFile,BufRead indent.pro call filetype#ProtoCheck('indent') +au BufNewFile,BufRead indent.pro call dist#ft#ProtoCheck('indent') " IDL (Interactive Data Language) -au BufNewFile,BufRead *.pro call filetype#ProtoCheck('idlang') +au BufNewFile,BufRead *.pro call dist#ft#ProtoCheck('idlang') " Indent RC au BufNewFile,BufRead indentrc setf indent @@ -945,7 +945,7 @@ au BufNewFile,BufRead *.markdown,*.mdown,*.mkd,*.mkdn,*.mdwn,*.md setf markdown au BufNewFile,BufRead *.mason,*.mhtml,*.comp setf mason " Mathematica, Matlab, Murphi or Objective C -au BufNewFile,BufRead *.m call filetype#FTm() +au BufNewFile,BufRead *.m call dist#ft#FTm() " Mathematica notebook au BufNewFile,BufRead *.nb setf mma @@ -975,7 +975,7 @@ au BufNewFile,BufRead *.mgl setf mgl au BufNewFile,BufRead *.mix,*.mixal setf mix " MMIX or VMS makefile -au BufNewFile,BufRead *.mms call filetype#FTmms() +au BufNewFile,BufRead *.mms call dist#ft#FTmms() " Symbian meta-makefile definition (MMP) au BufNewFile,BufRead *.mmp setf mmp @@ -1063,10 +1063,10 @@ au BufNewFile,BufRead *.me \ setf nroff | \ endif au BufNewFile,BufRead *.tr,*.nr,*.roff,*.tmac,*.mom setf nroff -au BufNewFile,BufRead *.[1-9] call filetype#FTnroff() +au BufNewFile,BufRead *.[1-9] call dist#ft#FTnroff() " Nroff or Objective C++ -au BufNewFile,BufRead *.mm call filetype#FTmm() +au BufNewFile,BufRead *.mm call dist#ft#FTmm() " Not Quite C au BufNewFile,BufRead *.nqc setf nqc @@ -1121,9 +1121,9 @@ au BufNewFile,BufRead *.pcmk setf pcmk " Perl if has("fname_case") - au BufNewFile,BufRead *.pl,*.PL call filetype#FTpl() + au BufNewFile,BufRead *.pl,*.PL call dist#ft#FTpl() else - au BufNewFile,BufRead *.pl call filetype#FTpl() + au BufNewFile,BufRead *.pl call dist#ft#FTpl() endif au BufNewFile,BufRead *.plx,*.al,*.psgi setf perl au BufNewFile,BufRead *.p6,*.pm6,*.pl6 setf perl6 @@ -1190,7 +1190,7 @@ au BufNewFile,BufRead *.pov setf pov au BufNewFile,BufRead .povrayrc setf povini " Povray, PHP or assembly -au BufNewFile,BufRead *.inc call filetype#FTinc() +au BufNewFile,BufRead *.inc call dist#ft#FTinc() " Printcap and Termcap au BufNewFile,BufRead *printcap @@ -1219,13 +1219,13 @@ au BufNewFile,BufRead *.action setf privoxy au BufNewFile,BufRead .procmail,.procmailrc setf procmail " Progress or CWEB -au BufNewFile,BufRead *.w call filetype#FTprogress_cweb() +au BufNewFile,BufRead *.w call dist#ft#FTprogress_cweb() " Progress or assembly -au BufNewFile,BufRead *.i call filetype#FTprogress_asm() +au BufNewFile,BufRead *.i call dist#ft#FTprogress_asm() " Progress or Pascal -au BufNewFile,BufRead *.p call filetype#FTprogress_pascal() +au BufNewFile,BufRead *.p call dist#ft#FTprogress_pascal() " Software Distributor Product Specification File (POSIX 1387.2-1995) au BufNewFile,BufRead *.psf setf psf @@ -1311,7 +1311,7 @@ else endif " Rexx, Rebol or R -au BufNewFile,BufRead *.r,*.R call filetype#FTr() +au BufNewFile,BufRead *.r,*.R call dist#ft#FTr() " Remind au BufNewFile,BufRead .reminders,*.remind,*.rem setf remind @@ -1407,7 +1407,7 @@ au BufNewFile,BufRead *.siv setf sieve au BufNewFile,BufRead sendmail.cf setf sm " Sendmail .mc files are actually m4. Could also be MS Message text file. -au BufNewFile,BufRead *.mc call filetype#McSetf() +au BufNewFile,BufRead *.mc call dist#ft#McSetf() " Services au BufNewFile,BufRead */etc/services setf services @@ -1448,23 +1448,23 @@ au BufNewFile,BufRead sgml.catalog* call s:StarSetf('catalog') " Shell scripts (sh, ksh, bash, bash2, csh); Allow .profile_foo etc. " Gentoo ebuilds and Arch Linux PKGBUILDs are actually bash scripts -au BufNewFile,BufRead .bashrc*,bashrc,bash.bashrc,.bash[_-]profile*,.bash[_-]logout*,.bash[_-]aliases*,*.bash,*/{,.}bash[_-]completion{,.d,.sh}{,/*},*.ebuild,*.eclass,PKGBUILD* call filetype#SetFileTypeSH("bash") -au BufNewFile,BufRead .kshrc*,*.ksh call filetype#SetFileTypeSH("ksh") -au BufNewFile,BufRead */etc/profile,.profile*,*.sh,*.env call filetype#SetFileTypeSH(getline(1)) +au BufNewFile,BufRead .bashrc*,bashrc,bash.bashrc,.bash[_-]profile*,.bash[_-]logout*,.bash[_-]aliases*,*.bash,*/{,.}bash[_-]completion{,.d,.sh}{,/*},*.ebuild,*.eclass,PKGBUILD* call dist#ft#SetFileTypeSH("bash") +au BufNewFile,BufRead .kshrc*,*.ksh call dist#ft#SetFileTypeSH("ksh") +au BufNewFile,BufRead */etc/profile,.profile*,*.sh,*.env call dist#ft#SetFileTypeSH(getline(1)) " Shell script (Arch Linux) or PHP file (Drupal) au BufNewFile,BufRead *.install \ if getline(1) =~ ' -" Last change: 2017 Nov 09 +" Last change: 2017 Nov 11 " This file is called by an autocommand for every file that has just been " loaded into a buffer. It checks if the type of file can be recognized by @@ -66,19 +66,19 @@ if s:line1 =~# "^#!" " Bourne-like shell scripts: bash bash2 ksh ksh93 sh if s:name =~# '^\(bash\d*\|\|ksh\d*\|sh\)\>' - call filetype#SetFileTypeSH(s:line1) " defined in filetype.vim + call dist#ft#SetFileTypeSH(s:line1) " defined in filetype.vim " csh scripts elseif s:name =~# '^csh\>' if exists("g:filetype_csh") - call filetype#SetFileTypeShell(g:filetype_csh) + call dist#ft#SetFileTypeShell(g:filetype_csh) else - call filetype#SetFileTypeShell("csh") + call dist#ft#SetFileTypeShell("csh") endif " tcsh scripts elseif s:name =~# '^tcsh\>' - call filetype#SetFileTypeShell("tcsh") + call dist#ft#SetFileTypeShell("tcsh") " Z shell scripts elseif s:name =~# '^zsh\>' @@ -185,7 +185,7 @@ else " Bourne-like shell scripts: sh ksh bash bash2 if s:line1 =~# '^:$' - call filetype#SetFileTypeSH(s:line1) " defined in filetype.vim + call dist#ft#SetFileTypeSH(s:line1) " defined in filetype.vim " Z shell scripts elseif s:line1 =~# '^#compdef\>' || s:line1 =~# '^#autoload\>' || -- cgit From eb00fc0cf07f7aac5d9e3c31624f2a37dcdc4237 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Mon, 2 Apr 2018 23:25:08 +0200 Subject: vim-patch:8.0.0564: cannot detect Bazel BUILD files on some systems Problem: Cannot detect Bazel BUILD files on some systems. Solution: Check for BUILD after script checks. (Issue vim/vim#1340) https://github.com/vim/vim/commit/39170e2d9761345df4be67d4d3928ac1094b9adf vim-patch:8.0.1283: test 86 fails under ASAN --- runtime/filetype.vim | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'runtime') diff --git a/runtime/filetype.vim b/runtime/filetype.vim index 0301bdd0a1..f8a29fa2b3 100644 --- a/runtime/filetype.vim +++ b/runtime/filetype.vim @@ -227,9 +227,10 @@ au BufNewFile,BufRead *.bl setf blank au BufNewFile,BufRead */etc/blkid.tab,*/etc/blkid.tab.old setf xml " Bazel (http://bazel.io) -autocmd BufRead,BufNewFile *.bzl,WORKSPACE setfiletype bzl +autocmd BufRead,BufNewFile *.bzl,WORKSPACE setf bzl if has("fname_case") - autocmd BufRead,BufNewFile BUILD setfiletype bzl + " There is another check for BUILD further below. + autocmd BufRead,BufNewFile BUILD setf bzl endif " C or lpc @@ -1934,6 +1935,11 @@ au BufNewFile,BufRead *asterisk*/*voicemail.conf* call s:StarSetf('asteriskvm') " Bazaar version control au BufNewFile,BufRead bzr_log.* setf bzr +" Bazel build file +if !has("fname_case") + au BufNewFile,BufRead BUILD setf bzl +endif + " BIND zone au BufNewFile,BufRead */named/db.*,*/bind/db.* call s:StarSetf('bindzone') -- cgit From 224ebc0078f29ac3189d7fbd9a59b386ae2ee303 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Wed, 4 Apr 2018 01:08:07 +0200 Subject: insert-mode: interpret unmapped META as ESC closes #2454 closes #8213 ref #7972 --- runtime/doc/insert.txt | 9 +++++---- runtime/doc/options.txt | 9 ++++----- 2 files changed, 9 insertions(+), 9 deletions(-) (limited to 'runtime') diff --git a/runtime/doc/insert.txt b/runtime/doc/insert.txt index 9ae35bea52..1feff0723b 100644 --- a/runtime/doc/insert.txt +++ b/runtime/doc/insert.txt @@ -40,10 +40,11 @@ char action ~ *i_CTRL-[* *i_* or CTRL-[ End insert or Replace mode, go back to Normal mode. Finish abbreviation. - Note: If your key is hard to hit on your keyboard, train - yourself to use CTRL-[. - If Esc doesn't work and you are using a Mac, try CTRL-Esc. - Or disable Listening under Accessibility preferences. + Note: If your key is hard to hit, try CTRL-[ instead. + *i_META* *i_ALT* + |ALT| (|META|) acts like if the chord is not mapped. + For example acts like x if does not have an + insert-mode mapping. *i_CTRL-C* CTRL-C Quit insert mode, go back to Normal mode. Do not check for abbreviations. Does not trigger the |InsertLeave| autocommand diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt index d9ce668962..0b7c61ea18 100644 --- a/runtime/doc/options.txt +++ b/runtime/doc/options.txt @@ -6290,15 +6290,14 @@ A jump table for the options with a short description can be found at |Q_op|. *'timeoutlen'* *'tm'* 'timeoutlen' 'tm' number (default 1000) global - The time in milliseconds that is waited for a mapped sequence to - complete. + Time in milliseconds to wait for a mapped sequence to complete. *'ttimeoutlen'* *'ttm'* 'ttimeoutlen' 'ttm' number (default 50) global - The time in milliseconds that is waited for a key code - sequence to complete. Also used for CTRL-\ CTRL-N and CTRL-\ CTRL-G - when part of a command has been typed. + Time in milliseconds to wait for a key code sequence to complete. Also + used for CTRL-\ CTRL-N and CTRL-\ CTRL-G when part of a command has + been typed. *'title'* *'notitle'* 'title' boolean (default off) -- cgit From 9f598e57656fe072114b9f1e73d3051423e13234 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Sun, 8 Apr 2018 13:06:26 +0200 Subject: serverstop(): return FALSE for invalid address --- runtime/doc/eval.txt | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) (limited to 'runtime') diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt index 767fc133d8..084936e9d2 100644 --- a/runtime/doc/eval.txt +++ b/runtime/doc/eval.txt @@ -1789,8 +1789,10 @@ v:scrollstart String describing the script or function that caused the *v:servername* *servername-variable* *$NVIM_LISTEN_ADDRESS* -v:servername Default Nvim server address. Equivalent to - |$NVIM_LISTEN_ADDRESS| on startup. |serverstop()| +v:servername Primary listen address of the current Nvim instance, the first + item returned by |serverlist()|. Can be set by + |--listen| or |$NVIM_LISTEN_ADDRESS| on startup. + See also |serverstart()| and |serverstop()|. Read-only. @@ -6638,15 +6640,11 @@ server2client({clientid}, {string}) *server2client()* :echo server2client(expand(""), "HELLO") < serverlist() *serverlist()* - Returns a list of available server names in a list. - When there are no servers an empty string is returned. + Returns a list of server addresses, or empty if all servers + were stopped. |serverstart()| |serverstop()| Example: > :echo serverlist() -< {Nvim} *--serverlist* - The Vim command-line option `--serverlist` was removed from - Nvim, but it can be imitated: > - nvim --cmd "echo serverlist()" --cmd "q" -< + serverstart([{address}]) *serverstart()* Opens a socket or named pipe at {address} and listens for |RPC| messages. Clients can send |API| commands to the address @@ -6674,13 +6672,9 @@ serverstart([{address}]) *serverstart()* < |$NVIM_LISTEN_ADDRESS| is set to {address} if not already set. - *--servername* - The Vim command-line option `--servername` can be imitated: > - nvim --cmd "let g:server_addr = serverstart('foo')" -< serverstop({address}) *serverstop()* - Closes the pipe or socket at {address}. Does nothing if - {address} is empty or invalid. + Closes the pipe or socket at {address}. + Returns TRUE if {address} is valid, else FALSE. If |$NVIM_LISTEN_ADDRESS| is stopped it is unset. If |v:servername| is stopped it is set to the next available address returned by |serverlist()|. -- cgit From 507bda1c95cdac2886f64e59aa6bbf85c3fac389 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Sun, 8 Apr 2018 17:20:25 +0200 Subject: server: introduce --listen, deprecate $NVIM_LISTEN_ADDRESS --- runtime/doc/deprecated.txt | 4 ++++ runtime/doc/eval.txt | 8 +++----- runtime/doc/msgpack_rpc.txt | 5 ++--- runtime/doc/starting.txt | 4 ++++ 4 files changed, 13 insertions(+), 8 deletions(-) (limited to 'runtime') diff --git a/runtime/doc/deprecated.txt b/runtime/doc/deprecated.txt index ea61e847c7..03699b3dfb 100644 --- a/runtime/doc/deprecated.txt +++ b/runtime/doc/deprecated.txt @@ -22,6 +22,10 @@ Commands ~ *:wv* *:wviminfo* Deprecated alias to |:wshada| command. +Environment Variables ~ +*$NVIM_LISTEN_ADDRESS* Deprecated in favor of |--listen|. If both are given, + $NVIM_LISTEN_ADDRESS is ignored. + Events ~ *EncodingChanged* Never fired; 'encoding' is always "utf-8". *FileEncoding* Never fired; equivalent to |EncodingChanged|. diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt index 084936e9d2..11c4b62403 100644 --- a/runtime/doc/eval.txt +++ b/runtime/doc/eval.txt @@ -1788,11 +1788,9 @@ v:scrollstart String describing the script or function that caused the hit-enter prompt. *v:servername* *servername-variable* - *$NVIM_LISTEN_ADDRESS* -v:servername Primary listen address of the current Nvim instance, the first - item returned by |serverlist()|. Can be set by - |--listen| or |$NVIM_LISTEN_ADDRESS| on startup. - See also |serverstart()| and |serverstop()|. +v:servername Primary listen-address of the current Nvim instance, the first + item returned by |serverlist()|. Can be set by |--listen| or + |$NVIM_LISTEN_ADDRESS| at startup. |serverstart()| |serverstop()| Read-only. diff --git a/runtime/doc/msgpack_rpc.txt b/runtime/doc/msgpack_rpc.txt index 11fad105b5..01d4e10cea 100644 --- a/runtime/doc/msgpack_rpc.txt +++ b/runtime/doc/msgpack_rpc.txt @@ -70,9 +70,8 @@ An rpc socket is automatically created with each instance. The socket location is stored in |v:servername|. By default this is a named pipe with an automatically generated address. See |XXX|. -To make Nvim listen on a TCP/IP socket instead, set the - |$NVIM_LISTEN_ADDRESS| environment variable before starting Nvim: > - NVIM_LISTEN_ADDRESS=127.0.0.1:6666 nvim +To make Nvim listen on a TCP/IP socket instead, specify |--listen|: > + nvim --listen 127.0.0.1:6666 Date: Wed, 11 Apr 2018 22:07:00 +0200 Subject: test/util: expect_err() (#8257) other cleanup, ref #8245 --- runtime/doc/starting.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'runtime') diff --git a/runtime/doc/starting.txt b/runtime/doc/starting.txt index 991f88f7b6..21c47edc24 100644 --- a/runtime/doc/starting.txt +++ b/runtime/doc/starting.txt @@ -356,8 +356,8 @@ argument. See also |silent-mode|, which does start a (limited) UI. --listen {addr} *--listen* - Start |RPC| server on socket or TCP address {addr}. Sets the - primary listen address |v:servername| to {addr}. |serverstart()| + Start |RPC| server on pipe or TCP address {addr}. Sets the + primary listen address |v:servername| to {addr}. |serverstart()| ============================================================================== 2. Initialization *initialization* *startup* @@ -1395,4 +1395,4 @@ RPC clients for debugging. $NVIM_LOG_FILE contains the log file path: > Usually the file is ~/.local/share/nvim/log unless that path is inaccessible or if $NVIM_LOG_FILE was set before |startup|. - vim:tw=78:ts=8:ft=help:norl: + vim:noet:tw=78:ts=8:ft=help:norl: -- cgit