mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
refactor(defaults): do not use C specific default values for options (#22500)
The options 'path', 'include', and 'define' all use C-specific default values. This may have made sense a long time ago when Vim was mostly used just for writing C, but this is no longer the case, and we have ample support for filetype specific configuration. Make the default values of these options empty and move the C-specific values into a filetype plugin where they belong. Co-authored-by: zeertzjq <zeertzjq@outlook.com>
This commit is contained in:
parent
4382d2ed56
commit
fcfe535e98
@ -1396,8 +1396,8 @@ A jump table for the options with a short description can be found at |Q_op|.
|
|||||||
'commentstring' 'cms' string (default "")
|
'commentstring' 'cms' string (default "")
|
||||||
local to buffer
|
local to buffer
|
||||||
A template for a comment. The "%s" in the value is replaced with the
|
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
|
comment text. For example, C uses "/*%s*/". Currently only used to
|
||||||
|fold-marker|.
|
add markers for folding, see |fold-marker|.
|
||||||
|
|
||||||
*'complete'* *'cpt'* *E535*
|
*'complete'* *'cpt'* *E535*
|
||||||
'complete' 'cpt' string (default: ".,w,b,u,t")
|
'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'.
|
'indentexpr'.
|
||||||
|
|
||||||
*'define'* *'def'*
|
*'define'* *'def'*
|
||||||
'define' 'def' string (default "^\s*#\s*define")
|
'define' 'def' string (default "")
|
||||||
global or local to buffer |global-local|
|
global or local to buffer |global-local|
|
||||||
Pattern to be used to find a macro definition. It is a search
|
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
|
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}
|
{match with 'define'}{non-ID chars}{defined name}{non-ID char}
|
||||||
See |option-backslash| about inserting backslashes to include a space
|
See |option-backslash| about inserting backslashes to include a space
|
||||||
or backslash.
|
or backslash.
|
||||||
The default value is for C programs. For C++ this value would be
|
For C++ this value would be useful, to include const type declarations: >
|
||||||
useful, to include const type declarations: >
|
|
||||||
^\(#\s*define\|[a-z]*\s*const\s*[a-z]*\)
|
^\(#\s*define\|[a-z]*\s*const\s*[a-z]*\)
|
||||||
< You can also use "\ze" just before the name and continue the pattern
|
< 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
|
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.
|
|Command-line-mode| is done.
|
||||||
|
|
||||||
*'include'* *'inc'*
|
*'include'* *'inc'*
|
||||||
'include' 'inc' string (default "^\s*#\s*include")
|
'include' 'inc' string (default "")
|
||||||
global or local to buffer |global-local|
|
global or local to buffer |global-local|
|
||||||
Pattern to be used to find an include command. It is a search
|
Pattern to be used to find an include command. It is a search
|
||||||
pattern, just like for the "/" command (See |pattern|). The default
|
pattern, just like for the "/" command (See |pattern|). This option
|
||||||
value is for C programs. This option is used for the commands "[i",
|
is used for the commands "[i", "]I", "[d", etc.
|
||||||
"]I", "[d", etc.
|
|
||||||
Normally the 'isfname' option is used to recognize the file name that
|
Normally the 'isfname' option is used to recognize the file name that
|
||||||
comes after the matched pattern. But if "\zs" appears in the pattern
|
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
|
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.
|
Only normal file name characters can be used, "/\*?[|<>" are illegal.
|
||||||
|
|
||||||
*'path'* *'pa'* *E343* *E345* *E347* *E854*
|
*'path'* *'pa'* *E343* *E345* *E347* *E854*
|
||||||
'path' 'pa' string (default on Unix: ".,/usr/include,,"
|
'path' 'pa' string (default: ".,,")
|
||||||
other systems: ".,,")
|
|
||||||
global or local to buffer |global-local|
|
global or local to buffer |global-local|
|
||||||
This is a list of directories which will be searched when using the
|
This is a list of directories which will be searched when using the
|
||||||
|gf|, [f, ]f, ^Wf, |:find|, |:sfind|, |:tabfind| and other commands,
|
|gf|, [f, ]f, ^Wf, |:find|, |:sfind|, |:tabfind| and other commands,
|
||||||
|
@ -37,6 +37,7 @@ Defaults *nvim-defaults*
|
|||||||
- 'commentstring' defaults to ""
|
- 'commentstring' defaults to ""
|
||||||
- 'compatible' is always disabled
|
- 'compatible' is always disabled
|
||||||
- 'complete' excludes "i"
|
- '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
|
- 'directory' defaults to ~/.local/state/nvim/swap// (|xdg|), auto-created
|
||||||
- 'display' defaults to "lastline"
|
- 'display' defaults to "lastline"
|
||||||
- 'encoding' is UTF-8 (cf. 'fileencoding' for file-content encoding)
|
- 'encoding' is UTF-8 (cf. 'fileencoding' for file-content encoding)
|
||||||
@ -46,6 +47,7 @@ Defaults *nvim-defaults*
|
|||||||
- 'hidden' is enabled
|
- 'hidden' is enabled
|
||||||
- 'history' defaults to 10000 (the maximum)
|
- 'history' defaults to 10000 (the maximum)
|
||||||
- 'hlsearch' is enabled
|
- 'hlsearch' is enabled
|
||||||
|
- 'include' defaults to "". The C ftplugin sets it to "^\\s*#\\s*include"
|
||||||
- 'incsearch' is enabled
|
- 'incsearch' is enabled
|
||||||
- 'joinspaces' is disabled
|
- 'joinspaces' is disabled
|
||||||
- 'langnoremap' is enabled
|
- 'langnoremap' is enabled
|
||||||
@ -55,6 +57,7 @@ Defaults *nvim-defaults*
|
|||||||
- 'mouse' defaults to "nvi"
|
- 'mouse' defaults to "nvi"
|
||||||
- 'mousemodel' defaults to "popup_setpos"
|
- 'mousemodel' defaults to "popup_setpos"
|
||||||
- 'nrformats' defaults to "bin,hex"
|
- 'nrformats' defaults to "bin,hex"
|
||||||
|
- 'path' defaults to ".,,". The C ftplugin adds "/usr/include" if it exists.
|
||||||
- 'ruler' is enabled
|
- 'ruler' is enabled
|
||||||
- 'sessionoptions' includes "unix,slash", excludes "options"
|
- 'sessionoptions' includes "unix,slash", excludes "options"
|
||||||
- 'shortmess' includes "CF", excludes "S"
|
- 'shortmess' includes "CF", excludes "S"
|
||||||
|
@ -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.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<'
|
||||||
|
@ -570,7 +570,7 @@ return {
|
|||||||
alloced=true,
|
alloced=true,
|
||||||
redraw={'curswant'},
|
redraw={'curswant'},
|
||||||
varname='p_def',
|
varname='p_def',
|
||||||
defaults={if_true="^\\s*#\\s*define"}
|
defaults={if_true=""}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
full_name='delcombine', abbreviation='deco',
|
full_name='delcombine', abbreviation='deco',
|
||||||
@ -1227,7 +1227,7 @@ return {
|
|||||||
type='string', scope={'global', 'buffer'},
|
type='string', scope={'global', 'buffer'},
|
||||||
alloced=true,
|
alloced=true,
|
||||||
varname='p_inc',
|
varname='p_inc',
|
||||||
defaults={if_true="^\\s*#\\s*include"}
|
defaults={if_true=""}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
full_name='includeexpr', abbreviation='inex',
|
full_name='includeexpr', abbreviation='inex',
|
||||||
@ -1815,7 +1815,7 @@ return {
|
|||||||
deny_duplicates=true,
|
deny_duplicates=true,
|
||||||
expand=true,
|
expand=true,
|
||||||
varname='p_path',
|
varname='p_path',
|
||||||
defaults={if_true=".,/usr/include,,"}
|
defaults={if_true=".,,"}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
full_name='preserveindent', abbreviation='pi',
|
full_name='preserveindent', abbreviation='pi',
|
||||||
|
@ -706,7 +706,7 @@ describe('api/buf', function()
|
|||||||
nvim('set_option_value', 'define', 'test', {buf = 0})
|
nvim('set_option_value', 'define', 'test', {buf = 0})
|
||||||
eq('test', nvim('get_option_value', 'define', {buf = 0}))
|
eq('test', nvim('get_option_value', 'define', {buf = 0}))
|
||||||
-- Doesn't change the global value
|
-- 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)
|
end)
|
||||||
|
|
||||||
it('returns values for unset local options', function()
|
it('returns values for unset local options', function()
|
||||||
|
@ -3,12 +3,14 @@ if exists('s:did_load')
|
|||||||
set backspace=
|
set backspace=
|
||||||
set commentstring=/*%s*/
|
set commentstring=/*%s*/
|
||||||
set complete=.,w,b,u,t,i
|
set complete=.,w,b,u,t,i
|
||||||
|
set define=^\\s*#\\s*define
|
||||||
set directory&
|
set directory&
|
||||||
set directory^=.
|
set directory^=.
|
||||||
set display=
|
set display=
|
||||||
set fillchars=vert:\|,foldsep:\|,fold:-
|
set fillchars=vert:\|,foldsep:\|,fold:-
|
||||||
set formatoptions=tcq
|
set formatoptions=tcq
|
||||||
set fsync
|
set fsync
|
||||||
|
set include=^\\s*#\\s*include
|
||||||
set laststatus=1
|
set laststatus=1
|
||||||
set listchars=eol:$
|
set listchars=eol:$
|
||||||
set joinspaces
|
set joinspaces
|
||||||
|
Loading…
Reference in New Issue
Block a user