aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--runtime/doc/options.txt19
-rw-r--r--runtime/doc/vim_diff.txt3
-rw-r--r--runtime/ftplugin/c.lua13
-rw-r--r--src/nvim/options.lua6
-rw-r--r--test/functional/api/buffer_spec.lua2
-rw-r--r--test/old/testdir/setup.vim2
6 files changed, 30 insertions, 15 deletions
diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt
index 4f5f2e8b80..7729ec5d38 100644
--- a/runtime/doc/options.txt
+++ b/runtime/doc/options.txt
@@ -1396,8 +1396,8 @@ A jump table for the options with a short description can be found at |Q_op|.
'commentstring' 'cms' string (default "")
local to buffer
A template for a comment. The "%s" in the value is replaced with the
- comment text. Currently only used to add markers for folding, see
- |fold-marker|.
+ comment text. For example, C uses "/*%s*/". Currently only used to
+ add markers for folding, see |fold-marker|.
*'complete'* *'cpt'* *E535*
'complete' 'cpt' string (default: ".,w,b,u,t")
@@ -1861,7 +1861,7 @@ A jump table for the options with a short description can be found at |Q_op|.
'indentexpr'.
*'define'* *'def'*
-'define' 'def' string (default "^\s*#\s*define")
+'define' 'def' string (default "")
global or local to buffer |global-local|
Pattern to be used to find a macro definition. It is a search
pattern, just like for the "/" command. This option is used for the
@@ -1870,8 +1870,7 @@ A jump table for the options with a short description can be found at |Q_op|.
{match with 'define'}{non-ID chars}{defined name}{non-ID char}
See |option-backslash| about inserting backslashes to include a space
or backslash.
- The default value is for C programs. For C++ this value would be
- useful, to include const type declarations: >
+ For C++ this value would be useful, to include const type declarations: >
^\(#\s*define\|[a-z]*\s*const\s*[a-z]*\)
< You can also use "\ze" just before the name and continue the pattern
to check what is following. E.g. for Javascript, if a function is
@@ -3309,12 +3308,11 @@ A jump table for the options with a short description can be found at |Q_op|.
|Command-line-mode| is done.
*'include'* *'inc'*
-'include' 'inc' string (default "^\s*#\s*include")
+'include' 'inc' string (default "")
global or local to buffer |global-local|
Pattern to be used to find an include command. It is a search
- pattern, just like for the "/" command (See |pattern|). The default
- value is for C programs. This option is used for the commands "[i",
- "]I", "[d", etc.
+ pattern, just like for the "/" command (See |pattern|). This option
+ is used for the commands "[i", "]I", "[d", etc.
Normally the 'isfname' option is used to recognize the file name that
comes after the matched pattern. But if "\zs" appears in the pattern
then the text matched from "\zs" to the end, or until "\ze" if it
@@ -4489,8 +4487,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.
*'path'* *'pa'* *E343* *E345* *E347* *E854*
-'path' 'pa' string (default on Unix: ".,/usr/include,,"
- other systems: ".,,")
+'path' 'pa' string (default: ".,,")
global or local to buffer |global-local|
This is a list of directories which will be searched when using the
|gf|, [f, ]f, ^Wf, |:find|, |:sfind|, |:tabfind| and other commands,
diff --git a/runtime/doc/vim_diff.txt b/runtime/doc/vim_diff.txt
index 102f867fbd..2c7ca487e6 100644
--- a/runtime/doc/vim_diff.txt
+++ b/runtime/doc/vim_diff.txt
@@ -37,6 +37,7 @@ Defaults *nvim-defaults*
- 'commentstring' defaults to ""
- 'compatible' is always disabled
- 'complete' excludes "i"
+- 'define' defaults to "". The C ftplugin sets it to "^\\s*#\\s*define"
- 'directory' defaults to ~/.local/state/nvim/swap// (|xdg|), auto-created
- 'display' defaults to "lastline"
- 'encoding' is UTF-8 (cf. 'fileencoding' for file-content encoding)
@@ -46,6 +47,7 @@ Defaults *nvim-defaults*
- 'hidden' is enabled
- 'history' defaults to 10000 (the maximum)
- 'hlsearch' is enabled
+- 'include' defaults to "". The C ftplugin sets it to "^\\s*#\\s*include"
- 'incsearch' is enabled
- 'joinspaces' is disabled
- 'langnoremap' is enabled
@@ -55,6 +57,7 @@ Defaults *nvim-defaults*
- 'mouse' defaults to "nvi"
- 'mousemodel' defaults to "popup_setpos"
- 'nrformats' defaults to "bin,hex"
+- 'path' defaults to ".,,". The C ftplugin adds "/usr/include" if it exists.
- 'ruler' is enabled
- 'sessionoptions' includes "unix,slash", excludes "options"
- 'shortmess' includes "CF", excludes "S"
diff --git a/runtime/ftplugin/c.lua b/runtime/ftplugin/c.lua
index b4e68148f5..0ddbf09470 100644
--- a/runtime/ftplugin/c.lua
+++ b/runtime/ftplugin/c.lua
@@ -1 +1,14 @@
+-- These are the default option values in Vim, but not in Nvim, so must be set explicitly.
vim.bo.commentstring = '/*%s*/'
+vim.bo.define = '^\\s*#\\s*define'
+vim.bo.include = '^\\s*#\\s*include'
+
+if vim.fn.isdirectory('/usr/include') == 1 then
+ vim.cmd([[
+ setlocal path^=/usr/include
+ setlocal path-=.
+ setlocal path^=.
+ ]])
+end
+
+vim.b.undo_ftplugin = vim.b.undo_ftplugin .. '|setl path<'
diff --git a/src/nvim/options.lua b/src/nvim/options.lua
index 2d6b049a48..d3566ba318 100644
--- a/src/nvim/options.lua
+++ b/src/nvim/options.lua
@@ -570,7 +570,7 @@ return {
alloced=true,
redraw={'curswant'},
varname='p_def',
- defaults={if_true="^\\s*#\\s*define"}
+ defaults={if_true=""}
},
{
full_name='delcombine', abbreviation='deco',
@@ -1227,7 +1227,7 @@ return {
type='string', scope={'global', 'buffer'},
alloced=true,
varname='p_inc',
- defaults={if_true="^\\s*#\\s*include"}
+ defaults={if_true=""}
},
{
full_name='includeexpr', abbreviation='inex',
@@ -1815,7 +1815,7 @@ return {
deny_duplicates=true,
expand=true,
varname='p_path',
- defaults={if_true=".,/usr/include,,"}
+ defaults={if_true=".,,"}
},
{
full_name='preserveindent', abbreviation='pi',
diff --git a/test/functional/api/buffer_spec.lua b/test/functional/api/buffer_spec.lua
index bf9e952319..d9d4539fe8 100644
--- a/test/functional/api/buffer_spec.lua
+++ b/test/functional/api/buffer_spec.lua
@@ -706,7 +706,7 @@ describe('api/buf', function()
nvim('set_option_value', 'define', 'test', {buf = 0})
eq('test', nvim('get_option_value', 'define', {buf = 0}))
-- Doesn't change the global value
- eq([[^\s*#\s*define]], nvim('get_option_value', 'define', {scope='global'}))
+ eq("", nvim('get_option_value', 'define', {scope='global'}))
end)
it('returns values for unset local options', function()
diff --git a/test/old/testdir/setup.vim b/test/old/testdir/setup.vim
index 9c53c0466d..94fbf2bef1 100644
--- a/test/old/testdir/setup.vim
+++ b/test/old/testdir/setup.vim
@@ -3,12 +3,14 @@ if exists('s:did_load')
set backspace=
set commentstring=/*%s*/
set complete=.,w,b,u,t,i
+ set define=^\\s*#\\s*define
set directory&
set directory^=.
set display=
set fillchars=vert:\|,foldsep:\|,fold:-
set formatoptions=tcq
set fsync
+ set include=^\\s*#\\s*include
set laststatus=1
set listchars=eol:$
set joinspaces