diff options
160 files changed, 630 insertions, 589 deletions
@@ -143,14 +143,10 @@ iwyu: build/.ran-cmake cmake --build build > build/iwyu.log iwyu-fix-includes --only_re="src/nvim" --ignore_re="(src/nvim/eval/encode.c|src/nvim/auto/|src/nvim/os/lang.c|src/nvim/map.c\ |src/nvim/api/extmark.h\ - |src/nvim/api/private/dispatch.h\ |src/nvim/api/private/helpers.h\ |src/nvim/api/private/validate.h\ - |src/nvim/api/ui.h\ - |src/nvim/ascii_defs.h\ |src/nvim/assert_defs.h\ |src/nvim/autocmd.h\ - |src/nvim/autocmd_defs.h\ |src/nvim/buffer.h\ |src/nvim/buffer_defs.h\ |src/nvim/channel.h\ @@ -178,7 +174,6 @@ iwyu: build/.ran-cmake |src/nvim/event/time.h\ |src/nvim/event/wstream.h\ |src/nvim/ex_cmds.h\ - |src/nvim/ex_cmds_defs.h\ |src/nvim/ex_docmd.h\ |src/nvim/extmark.h\ |src/nvim/file_search.h\ @@ -217,10 +212,7 @@ iwyu: build/.ran-cmake |src/nvim/syntax.h\ |src/nvim/textobject.h\ |src/nvim/tui/input.h\ - |src/nvim/tui/tui.h\ |src/nvim/ui.h\ - |src/nvim/ui_client.h\ - |src/nvim/ui_compositor.h\ |src/nvim/viml/parser/expressions.h\ |src/nvim/viml/parser/parser.h\ |src/nvim/window.h\ diff --git a/runtime/doc/dev_style.txt b/runtime/doc/dev_style.txt index cb28f1a845..02fd07ce24 100644 --- a/runtime/doc/dev_style.txt +++ b/runtime/doc/dev_style.txt @@ -190,7 +190,7 @@ Function declarations ~ Every function must not have a separate declaration. -Function declarations are created by the gendeclarations.lua script. >c +Function declarations are created by the gen_declarations.lua script. >c static void f(void); diff --git a/runtime/lua/vim/treesitter/dev.lua b/runtime/lua/vim/treesitter/dev.lua index d6825eb024..69ddc9b558 100644 --- a/runtime/lua/vim/treesitter/dev.lua +++ b/runtime/lua/vim/treesitter/dev.lua @@ -8,6 +8,7 @@ local M = {} ---@field opts table Options table with the following keys: --- - anon (boolean): If true, display anonymous nodes --- - lang (boolean): If true, display the language alongside each node +--- - indent (number): Number of spaces to indent nested lines. Default is 2. ---@field nodes TSP.Node[] ---@field named TSP.Node[] local TSTreeView = {} @@ -143,6 +144,7 @@ function TSTreeView:new(bufnr, lang) opts = { anon = false, lang = false, + indent = 2, }, } @@ -212,7 +214,7 @@ local function set_inspector_cursor(treeview, lang, source_buf, inspect_buf, ins local cursor_node_id = cursor_node:id() for i, v in treeview:iter() do if v.id == cursor_node_id then - local start = v.depth + local start = v.depth * treeview.opts.indent ---@type integer local end_col = start + #v.text api.nvim_buf_set_extmark(inspect_buf, treeview.ns, i - 1, start, { end_col = end_col, @@ -236,8 +238,13 @@ function TSTreeView:draw(bufnr) for _, item in self:iter() do local range_str = get_range_str(item.lnum, item.col, item.end_lnum, item.end_col) local lang_str = self.opts.lang and string.format(' %s', item.lang) or '' - local line = - string.format('%s%s ; %s%s', string.rep(' ', item.depth), item.text, range_str, lang_str) + local line = string.format( + '%s%s ; %s%s', + string.rep(' ', item.depth * self.opts.indent), + item.text, + range_str, + lang_str + ) if self.opts.lang then lang_hl_marks[#lang_hl_marks + 1] = { diff --git a/runtime/syntax/html.vim b/runtime/syntax/html.vim index 82c829a2e1..c975ae8620 100644 --- a/runtime/syntax/html.vim +++ b/runtime/syntax/html.vim @@ -3,9 +3,9 @@ " Maintainer: Doug Kearns <dougkearns@gmail.com> " Previous Maintainers: Jorge Maldonado Ventura <jorgesumle@freakspot.net> " Claudio Fleiner <claudio@fleiner.com> -" Last Change: 2023 Feb 20 +" Last Change: 2023 Nov 28 -" Please check :help html.vim for some comments and a description of the options +" See :help html.vim for some comments and a description of the options " quit when a syntax file was already loaded if !exists("main_syntax") @@ -28,7 +28,6 @@ syn case ignore " mark illegal characters syn match htmlError "[<>&]" - " tags syn region htmlString contained start=+"+ end=+"+ contains=htmlSpecialChar,javaScriptExpression,@htmlPreproc syn region htmlString contained start=+'+ end=+'+ contains=htmlSpecialChar,javaScriptExpression,@htmlPreproc @@ -39,7 +38,6 @@ syn match htmlTagN contained +<\s*[-a-zA-Z0-9]\++hs=s+1 contains=htmlTagName, syn match htmlTagN contained +</\s*[-a-zA-Z0-9]\++hs=s+2 contains=htmlTagName,htmlSpecialTagName,@htmlTagNameCluster syn match htmlTagError contained "[^>]<"ms=s+1 - " tag names syn keyword htmlTagName contained address applet area a base basefont syn keyword htmlTagName contained big blockquote br caption center @@ -61,7 +59,7 @@ syn keyword htmlTagName contained article aside audio bdi canvas data syn keyword htmlTagName contained datalist details dialog embed figcaption syn keyword htmlTagName contained figure footer header hgroup keygen main syn keyword htmlTagName contained mark menuitem meter nav output picture -syn keyword htmlTagName contained progress rb rp rt rtc ruby section +syn keyword htmlTagName contained progress rb rp rt rtc ruby search section syn keyword htmlTagName contained slot source summary template time track syn keyword htmlTagName contained video wbr @@ -88,19 +86,72 @@ syn keyword htmlArg contained size src start target text type url syn keyword htmlArg contained usemap ismap valign value vlink vspace width wrap syn match htmlArg contained "\<\%(http-equiv\|href\|title\)="me=e-1 -" aria attributes -exe 'syn match htmlArg contained "\<aria-\%(' . join([ - \ 'activedescendant', 'atomic', 'autocomplete', 'busy', 'checked', 'colcount', - \ 'colindex', 'colspan', 'controls', 'current', 'describedby', 'details', - \ 'disabled', 'dropeffect', 'errormessage', 'expanded', 'flowto', 'grabbed', - \ 'haspopup', 'hidden', 'invalid', 'keyshortcuts', 'label', 'labelledby', 'level', - \ 'live', 'modal', 'multiline', 'multiselectable', 'orientation', 'owns', - \ 'placeholder', 'posinset', 'pressed', 'readonly', 'relevant', 'required', - \ 'roledescription', 'rowcount', 'rowindex', 'rowspan', 'selected', 'setsize', - \ 'sort', 'valuemax', 'valuemin', 'valuenow', 'valuetext' - \ ], '\|') . '\)\>"' syn keyword htmlArg contained role +" ARIA attributes {{{1 +let s:aria =<< trim END + activedescendant + atomic + autocomplete + braillelabel + brailleroledescription + busy + checked + colcount + colindex + colindextext + colspan + controls + current + describedby + description + details + disabled + errormessage + expanded + flowto + haspopup + hidden + invalid + keyshortcuts + label + labelledby + level + live + modal + multiline + multiselectable + orientation + owns + placeholder + posinset + pressed + readonly + relevant + required + roledescription + rowcount + rowindex + rowindextext + rowspan + selected + setsize + sort + valuemax + valuemin + valuenow + valuetext +END +let s:aria_deprecated =<< trim END + dropeffect + grabbed +END + +call extend(s:aria, s:aria_deprecated) +exe 'syn match htmlArg contained "\%#=1\<aria-\%(' .. s:aria->join('\|') .. '\)\>"' +unlet s:aria s:aria_deprecated +" }}} + " Netscape extensions syn keyword htmlTagName contained frame noframes frameset nobr blink syn keyword htmlTagName contained layer ilayer nolayer spacer @@ -321,9 +372,9 @@ if !exists("html_no_rendering") hi def htmlUnderlineItalic term=italic,underline cterm=italic,underline gui=italic,underline hi def htmlItalic term=italic cterm=italic gui=italic if v:version > 800 || v:version == 800 && has("patch1038") - hi def htmlStrike term=strikethrough cterm=strikethrough gui=strikethrough + hi def htmlStrike term=strikethrough cterm=strikethrough gui=strikethrough else - hi def htmlStrike term=underline cterm=underline gui=underline + hi def htmlStrike term=underline cterm=underline gui=underline endif endif endif @@ -356,4 +407,5 @@ endif let &cpo = s:cpo_save unlet s:cpo_save -" vim: ts=8 + +" vim: nowrap sw=2 sts=2 ts=8 noet fdm=marker: diff --git a/scripts/lintcommit.lua b/scripts/lintcommit.lua index d2c8601c25..a3ad4657e9 100644 --- a/scripts/lintcommit.lua +++ b/scripts/lintcommit.lua @@ -74,7 +74,11 @@ local function validate_commit(commit_message) if after_idx > vim.tbl_count(commit_split) then return [[Commit message does not include colons.]] end - local after_colon = commit_split[after_idx] + local after_colon = '' + while after_idx <= vim.tbl_count(commit_split) do + after_colon = after_colon .. commit_split[after_idx] + after_idx = after_idx + 1 + end -- Check if commit introduces a breaking change. if vim.endswith(before_colon, "!") then @@ -239,11 +243,14 @@ function M._test() ['refactor(): empty scope'] = false, ['ci( ): whitespace as scope'] = false, ['ci: period at end of sentence.'] = false, + ['ci: period: at end of sentence.'] = false, ['ci: Capitalized first word'] = false, ['ci: UPPER_CASE First Word'] = true, ['unknown: using unknown type'] = false, ['feat: foo:bar'] = true, + ['feat: :foo:bar'] = true, ['feat(something): foo:bar'] = true, + ['feat(something): :foo:bar'] = true, ['feat(:grep): read from pipe'] = true, ['feat(:grep/:make): read from pipe'] = true, ['feat(:grep): foo:bar'] = true, diff --git a/src/clint.py b/src/clint.py index 1f588322f3..a45969af31 100755 --- a/src/clint.py +++ b/src/clint.py @@ -880,32 +880,31 @@ def CheckForHeaderGuard(filename, lines, error): error(filename, 0, 'build/header_guard', 5, 'No "#pragma once" found in header') + def CheckIncludes(filename, lines, error): - """Checks that headers only include _defs headers + """Checks that headers only include _defs headers. Args: filename: The name of the C++ header file. lines: An array of strings, each representing a line of the file. error: The function to call with any errors found. """ - if filename.endswith('.c.h') or filename.endswith('.in.h') or FileInfo(filename).RelativePath() in { + if (filename.endswith('.c.h') + or filename.endswith('.in.h') + or FileInfo(filename).RelativePath() in { 'func_attr.h', 'os/pty_process.h', - }: + }): return # These should be synced with the ignored headers in the `iwyu` target in # the Makefile. check_includes_ignore = [ "src/nvim/api/extmark.h", - "src/nvim/api/private/dispatch.h", "src/nvim/api/private/helpers.h", "src/nvim/api/private/validate.h", - "src/nvim/api/ui.h", - "src/nvim/ascii_defs.h", "src/nvim/assert_defs.h", "src/nvim/autocmd.h", - "src/nvim/autocmd_defs.h", "src/nvim/buffer.h", "src/nvim/buffer_defs.h", "src/nvim/channel.h", @@ -933,7 +932,6 @@ def CheckIncludes(filename, lines, error): "src/nvim/event/time.h", "src/nvim/event/wstream.h", "src/nvim/ex_cmds.h", - "src/nvim/ex_cmds_defs.h", "src/nvim/ex_docmd.h", "src/nvim/extmark.h", "src/nvim/file_search.h", @@ -972,10 +970,7 @@ def CheckIncludes(filename, lines, error): "src/nvim/syntax.h", "src/nvim/textobject.h", "src/nvim/tui/input.h", - "src/nvim/tui/tui.h", "src/nvim/ui.h", - "src/nvim/ui_client.h", - "src/nvim/ui_compositor.h", "src/nvim/viml/parser/expressions.h", "src/nvim/viml/parser/parser.h", "src/nvim/window.h", @@ -999,12 +994,29 @@ def CheckIncludes(filename, lines, error): if name in skip_headers: continue if (not name.endswith('.h.generated.h') and + not name.endswith('/defs.h') and not name.endswith('_defs.h') and - not name.endswith('/defs.h')): + not name.endswith('_defs.generated.h') and + not name.endswith('_enum.generated.h')): error(filename, i, 'build/include_defs', 5, 'Headers should not include non-"_defs" headers') +def CheckNonSymbols(filename, lines, error): + """Checks that a _defs.h header only contains non-symbols. + + Args: + filename: The name of the C++ header file. + lines: An array of strings, each representing a line of the file. + error: The function to call with any errors found. + """ + for i, line in enumerate(lines): + # Only a check against extern variables for now. + if line.startswith('EXTERN ') or line.startswith('extern '): + error(filename, i, 'build/defs_header', 5, + '"_defs" headers should not contain extern variables') + + def CheckForBadCharacters(filename, lines, error): """Logs an error for each line containing bad characters. @@ -2292,6 +2304,8 @@ def ProcessFileData(filename, file_extension, lines, error, if file_extension == 'h': CheckForHeaderGuard(filename, lines, error) CheckIncludes(filename, lines, error) + if filename.endswith('/defs.h') or filename.endswith('_defs.h'): + CheckNonSymbols(filename, lines, error) RemoveMultiLineComments(filename, lines, error) clean_lines = CleansedLines(lines, init_lines) diff --git a/src/klib/kvec.h b/src/klib/kvec.h index 5677a93b1b..f9ecca3d55 100644 --- a/src/klib/kvec.h +++ b/src/klib/kvec.h @@ -160,10 +160,12 @@ (v).size = 0, \ (v).items = (v).init_array) +static inline void *_memcpy_free(void *restrict dest, void *restrict src, size_t size) + REAL_FATTR_NONNULL_ALL REAL_FATTR_NONNULL_RET REAL_FATTR_ALWAYS_INLINE; + /// Move data to a new destination and free source static inline void *_memcpy_free(void *const restrict dest, void *const restrict src, const size_t size) - FUNC_ATTR_NONNULL_ALL FUNC_ATTR_NONNULL_RET FUNC_ATTR_ALWAYS_INLINE { memcpy(dest, src, size); XFREE_CLEAR(src); diff --git a/src/nvim/CMakeLists.txt b/src/nvim/CMakeLists.txt index 3505f8be4f..a8ce9edff8 100644 --- a/src/nvim/CMakeLists.txt +++ b/src/nvim/CMakeLists.txt @@ -463,7 +463,7 @@ endif() #------------------------------------------------------------------------------- get_target_property(prop main_lib INTERFACE_COMPILE_DEFINITIONS) -foreach(gen_cdef DO_NOT_DEFINE_EMPTY_ATTRIBUTES ${prop}) +foreach(gen_cdef ${prop}) if(NOT ${gen_cdef} MATCHES "INCLUDE_GENERATED_DECLARATIONS") list(APPEND gen_cflags "-D${gen_cdef}") endif() diff --git a/src/nvim/api/autocmd.c b/src/nvim/api/autocmd.c index 08d9d8e117..2ce08bdf40 100644 --- a/src/nvim/api/autocmd.c +++ b/src/nvim/api/autocmd.c @@ -17,7 +17,6 @@ #include "nvim/buffer.h" #include "nvim/eval/typval.h" #include "nvim/ex_cmds_defs.h" -#include "nvim/func_attr.h" #include "nvim/globals.h" #include "nvim/lua/executor.h" #include "nvim/memory.h" diff --git a/src/nvim/api/buffer.c b/src/nvim/api/buffer.c index 0df231868d..9d0ac5d6ef 100644 --- a/src/nvim/api/buffer.c +++ b/src/nvim/api/buffer.c @@ -24,7 +24,6 @@ #include "nvim/drawscreen.h" #include "nvim/ex_cmds.h" #include "nvim/extmark.h" -#include "nvim/func_attr.h" #include "nvim/globals.h" #include "nvim/lua/executor.h" #include "nvim/mapping.h" diff --git a/src/nvim/api/command.c b/src/nvim/api/command.c index 2a57ce9a19..7116f4bce0 100644 --- a/src/nvim/api/command.c +++ b/src/nvim/api/command.c @@ -18,7 +18,6 @@ #include "nvim/ex_cmds.h" #include "nvim/ex_docmd.h" #include "nvim/ex_eval.h" -#include "nvim/func_attr.h" #include "nvim/garray.h" #include "nvim/globals.h" #include "nvim/lua/executor.h" diff --git a/src/nvim/api/deprecated.c b/src/nvim/api/deprecated.c index 2ec11236d7..11795033cc 100644 --- a/src/nvim/api/deprecated.c +++ b/src/nvim/api/deprecated.c @@ -14,7 +14,6 @@ #include "nvim/buffer_defs.h" #include "nvim/decoration.h" #include "nvim/extmark.h" -#include "nvim/func_attr.h" #include "nvim/globals.h" #include "nvim/highlight.h" #include "nvim/highlight_group.h" diff --git a/src/nvim/api/extmark.c b/src/nvim/api/extmark.c index d71498d6ed..80b1546329 100644 --- a/src/nvim/api/extmark.c +++ b/src/nvim/api/extmark.c @@ -17,7 +17,6 @@ #include "nvim/decoration_provider.h" #include "nvim/drawscreen.h" #include "nvim/extmark.h" -#include "nvim/func_attr.h" #include "nvim/grid.h" #include "nvim/highlight_group.h" #include "nvim/marktree.h" diff --git a/src/nvim/api/options.c b/src/nvim/api/options.c index c012a69c7b..9cf91bad42 100644 --- a/src/nvim/api/options.c +++ b/src/nvim/api/options.c @@ -11,7 +11,6 @@ #include "nvim/autocmd.h" #include "nvim/buffer.h" #include "nvim/eval/window.h" -#include "nvim/func_attr.h" #include "nvim/globals.h" #include "nvim/macros_defs.h" #include "nvim/memory.h" diff --git a/src/nvim/api/private/converter.c b/src/nvim/api/private/converter.c index 90023171e5..ef57bde32d 100644 --- a/src/nvim/api/private/converter.c +++ b/src/nvim/api/private/converter.c @@ -11,7 +11,6 @@ #include "nvim/eval/typval.h" #include "nvim/eval/typval_defs.h" #include "nvim/eval/userfunc.h" -#include "nvim/func_attr.h" #include "nvim/lua/executor.h" #include "nvim/memory.h" #include "nvim/types_defs.h" diff --git a/src/nvim/api/private/dispatch.h b/src/nvim/api/private/dispatch.h index 6a2c9eaf54..88f846f813 100644 --- a/src/nvim/api/private/dispatch.h +++ b/src/nvim/api/private/dispatch.h @@ -14,12 +14,12 @@ typedef Object (*ApiDispatchWrapper)(uint64_t channel_id, Array args, Arena *are struct MsgpackRpcRequestHandler { const char *name; ApiDispatchWrapper fn; - bool fast; // Function is safe to be executed immediately while running the - // uv loop (the loop is run very frequently due to breakcheck). - // If "fast" is false, the function is deferred, i e the call will - // be put in the event queue, for safe handling later. - bool arena_return; // return value is allocated in the arena (or statically) - // and should not be freed as such. + bool fast; ///< Function is safe to be executed immediately while running the + ///< uv loop (the loop is run very frequently due to breakcheck). + ///< If "fast" is false, the function is deferred, i e the call will + ///< be put in the event queue, for safe handling later. + bool arena_return; ///< return value is allocated in the arena (or statically) + ///< and should not be freed as such. }; extern const MsgpackRpcRequestHandler method_handlers[]; diff --git a/src/nvim/api/private/helpers.c b/src/nvim/api/private/helpers.c index be39836a5b..b23684aee9 100644 --- a/src/nvim/api/private/helpers.c +++ b/src/nvim/api/private/helpers.c @@ -20,7 +20,6 @@ #include "nvim/eval/typval_defs.h" #include "nvim/eval/vars.h" #include "nvim/ex_eval.h" -#include "nvim/func_attr.h" #include "nvim/garray.h" #include "nvim/globals.h" #include "nvim/highlight_group.h" diff --git a/src/nvim/api/tabpage.c b/src/nvim/api/tabpage.c index c854a22477..303f2ca817 100644 --- a/src/nvim/api/tabpage.c +++ b/src/nvim/api/tabpage.c @@ -6,11 +6,14 @@ #include "nvim/api/tabpage.h" #include "nvim/api/vim.h" #include "nvim/buffer_defs.h" -#include "nvim/func_attr.h" #include "nvim/globals.h" #include "nvim/memory.h" #include "nvim/window.h" +#ifdef INCLUDE_GENERATED_DECLARATIONS +# include "api/tabpage.c.generated.h" +#endif + /// Gets the windows in a tabpage /// /// @param tabpage Tabpage handle, or 0 for current tabpage diff --git a/src/nvim/api/ui.c b/src/nvim/api/ui.c index 836a68546c..7e64ce9cd1 100644 --- a/src/nvim/api/ui.c +++ b/src/nvim/api/ui.c @@ -17,7 +17,6 @@ #include "nvim/eval.h" #include "nvim/event/loop.h" #include "nvim/event/wstream.h" -#include "nvim/func_attr.h" #include "nvim/globals.h" #include "nvim/grid.h" #include "nvim/highlight.h" diff --git a/src/nvim/api/ui.h b/src/nvim/api/ui.h index 26a91d0dbc..b1f4ff97d9 100644 --- a/src/nvim/api/ui.h +++ b/src/nvim/api/ui.h @@ -4,9 +4,8 @@ #include "nvim/api/private/defs.h" // IWYU pragma: keep #include "nvim/highlight_defs.h" // IWYU pragma: keep -#include "nvim/map_defs.h" #include "nvim/types_defs.h" // IWYU pragma: keep -#include "nvim/ui.h" +#include "nvim/ui_defs.h" // IWYU pragma: keep #ifdef INCLUDE_GENERATED_DECLARATIONS # include "api/ui.h.generated.h" diff --git a/src/nvim/api/vim.c b/src/nvim/api/vim.c index d631b10af9..270f2e4432 100644 --- a/src/nvim/api/vim.c +++ b/src/nvim/api/vim.c @@ -31,7 +31,6 @@ #include "nvim/ex_docmd.h" #include "nvim/ex_eval.h" #include "nvim/fold.h" -#include "nvim/func_attr.h" #include "nvim/getchar.h" #include "nvim/globals.h" #include "nvim/grid.h" diff --git a/src/nvim/api/vimscript.c b/src/nvim/api/vimscript.c index c75bf21572..25a34f769c 100644 --- a/src/nvim/api/vimscript.c +++ b/src/nvim/api/vimscript.c @@ -15,7 +15,6 @@ #include "nvim/eval/typval.h" #include "nvim/eval/userfunc.h" #include "nvim/ex_docmd.h" -#include "nvim/func_attr.h" #include "nvim/garray.h" #include "nvim/globals.h" #include "nvim/memory.h" diff --git a/src/nvim/api/win_config.c b/src/nvim/api/win_config.c index 4e23717dc6..825a0583ef 100644 --- a/src/nvim/api/win_config.c +++ b/src/nvim/api/win_config.c @@ -13,7 +13,6 @@ #include "nvim/buffer_defs.h" #include "nvim/decoration.h" #include "nvim/drawscreen.h" -#include "nvim/func_attr.h" #include "nvim/globals.h" #include "nvim/grid.h" #include "nvim/highlight_group.h" diff --git a/src/nvim/api/window.c b/src/nvim/api/window.c index de5b40940f..d18971c756 100644 --- a/src/nvim/api/window.c +++ b/src/nvim/api/window.c @@ -15,7 +15,6 @@ #include "nvim/drawscreen.h" #include "nvim/eval/window.h" #include "nvim/ex_docmd.h" -#include "nvim/func_attr.h" #include "nvim/gettext.h" #include "nvim/globals.h" #include "nvim/lua/executor.h" @@ -27,6 +26,10 @@ #include "nvim/types_defs.h" #include "nvim/window.h" +#ifdef INCLUDE_GENERATED_DECLARATIONS +# include "api/window.c.generated.h" +#endif + /// Gets the current buffer in a window /// /// @param window Window handle, or 0 for current window diff --git a/src/nvim/arabic.c b/src/nvim/arabic.c index 84f4297c99..f575bf30b8 100644 --- a/src/nvim/arabic.c +++ b/src/nvim/arabic.c @@ -22,7 +22,6 @@ #include "nvim/arabic.h" #include "nvim/ascii_defs.h" -#include "nvim/func_attr.h" #include "nvim/macros_defs.h" #include "nvim/option_vars.h" diff --git a/src/nvim/arglist.c b/src/nvim/arglist.c index d2734e6c5a..541534abf9 100644 --- a/src/nvim/arglist.c +++ b/src/nvim/arglist.c @@ -20,7 +20,6 @@ #include "nvim/ex_cmds_defs.h" #include "nvim/ex_getln.h" #include "nvim/fileio.h" -#include "nvim/func_attr.h" #include "nvim/garray.h" #include "nvim/gettext.h" #include "nvim/globals.h" diff --git a/src/nvim/ascii_defs.h b/src/nvim/ascii_defs.h index 4125336796..3de04cd9fa 100644 --- a/src/nvim/ascii_defs.h +++ b/src/nvim/ascii_defs.h @@ -107,6 +107,10 @@ static inline bool ascii_isbdigit(int c) REAL_FATTR_CONST REAL_FATTR_ALWAYS_INLINE; +static inline bool ascii_isodigit(int c) + REAL_FATTR_CONST + REAL_FATTR_ALWAYS_INLINE; + static inline bool ascii_isspace(int c) REAL_FATTR_CONST REAL_FATTR_ALWAYS_INLINE; diff --git a/src/nvim/autocmd.c b/src/nvim/autocmd.c index 74a1dbdbc3..044746b7be 100644 --- a/src/nvim/autocmd.c +++ b/src/nvim/autocmd.c @@ -23,7 +23,6 @@ #include "nvim/ex_docmd.h" #include "nvim/ex_eval.h" #include "nvim/fileio.h" -#include "nvim/func_attr.h" #include "nvim/getchar.h" #include "nvim/gettext.h" #include "nvim/globals.h" diff --git a/src/nvim/base64.c b/src/nvim/base64.c index 295dedd8d3..7f7d121442 100644 --- a/src/nvim/base64.c +++ b/src/nvim/base64.c @@ -3,7 +3,7 @@ #include <stdint.h> #include <string.h> -#include "auto/config.h" // IWYU pragma: keep +#include "auto/config.h" #include "nvim/base64.h" #include "nvim/memory.h" @@ -12,7 +12,7 @@ #endif #ifdef INCLUDE_GENERATED_DECLARATIONS -# include "base64.c.generated.h" // IWYU pragma: export +# include "base64.c.generated.h" #endif static const char alphabet[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; @@ -65,6 +65,7 @@ static inline uint32_t htobe32(uint32_t host_32bits) /// @param src_len Length of the string /// @return Base64 encoded string char *base64_encode(const char *src, size_t src_len) + FUNC_ATTR_NONNULL_ALL { assert(src != NULL); diff --git a/src/nvim/buffer_defs.h b/src/nvim/buffer_defs.h index e59539f900..8928eea028 100644 --- a/src/nvim/buffer_defs.h +++ b/src/nvim/buffer_defs.h @@ -357,8 +357,6 @@ typedef struct { #define BUF_UPDATE_CALLBACKS_INIT { LUA_NOREF, LUA_NOREF, LUA_NOREF, \ LUA_NOREF, LUA_NOREF, false, false } -EXTERN int curbuf_splice_pending INIT( = 0); - #define BUF_HAS_QF_ENTRY 1 #define BUF_HAS_LL_ENTRY 2 @@ -904,12 +902,7 @@ enum { kFloatAnchorSouth = 2, }; -// NW -> 0 -// NE -> kFloatAnchorEast -// SW -> kFloatAnchorSouth -// SE -> kFloatAnchorSouth | kFloatAnchorEast -EXTERN const char *const float_anchor_str[] INIT( = { "NW", "NE", "SW", "SE" }); - +/// Keep in sync with float_relative_str in winfloat.h typedef enum { kFloatRelativeEditor = 0, kFloatRelativeWindow = 1, @@ -917,9 +910,6 @@ typedef enum { kFloatRelativeMouse = 3, } FloatRelative; -EXTERN const char *const float_relative_str[] INIT( = { "editor", "win", - "cursor", "mouse" }); - typedef enum { kWinStyleUnused = 0, kWinStyleMinimal, /// Minimal UI: no number column, eob markers, etc diff --git a/src/nvim/buffer_updates.c b/src/nvim/buffer_updates.c index 01bcb9d7be..a91a890d0e 100644 --- a/src/nvim/buffer_updates.c +++ b/src/nvim/buffer_updates.c @@ -11,7 +11,6 @@ #include "nvim/buffer.h" #include "nvim/buffer_defs.h" #include "nvim/buffer_updates.h" -#include "nvim/func_attr.h" #include "nvim/globals.h" #include "nvim/log.h" #include "nvim/lua/executor.h" @@ -22,7 +21,7 @@ #include "nvim/types_defs.h" #ifdef INCLUDE_GENERATED_DECLARATIONS -# include "buffer_updates.c.generated.h" // IWYU pragma: export +# include "buffer_updates.c.generated.h" #endif // Register a channel. Return True if the channel was added, or already added. diff --git a/src/nvim/bufwrite.c b/src/nvim/bufwrite.c index f774fcb057..06bd05b11d 100644 --- a/src/nvim/bufwrite.c +++ b/src/nvim/bufwrite.c @@ -23,7 +23,6 @@ #include "nvim/ex_cmds_defs.h" #include "nvim/ex_eval.h" #include "nvim/fileio.h" -#include "nvim/func_attr.h" #include "nvim/gettext.h" #include "nvim/globals.h" #include "nvim/highlight.h" diff --git a/src/nvim/change.c b/src/nvim/change.c index 81a55b92ee..efc2db1413 100644 --- a/src/nvim/change.c +++ b/src/nvim/change.c @@ -21,7 +21,6 @@ #include "nvim/ex_cmds_defs.h" #include "nvim/extmark.h" #include "nvim/fold.h" -#include "nvim/func_attr.h" #include "nvim/gettext.h" #include "nvim/globals.h" #include "nvim/highlight.h" diff --git a/src/nvim/channel.h b/src/nvim/channel.h index 5c9d708ac2..6deea08c83 100644 --- a/src/nvim/channel.h +++ b/src/nvim/channel.h @@ -122,7 +122,9 @@ static inline Channel *find_channel(uint64_t id) } static inline Stream *channel_instream(Channel *chan) - FUNC_ATTR_NONNULL_ALL + REAL_FATTR_NONNULL_ALL; + +static inline Stream *channel_instream(Channel *chan) { switch (chan->streamtype) { case kChannelStreamProc: @@ -142,7 +144,9 @@ static inline Stream *channel_instream(Channel *chan) } static inline Stream *channel_outstream(Channel *chan) - FUNC_ATTR_NONNULL_ALL + REAL_FATTR_NONNULL_ALL; + +static inline Stream *channel_outstream(Channel *chan) { switch (chan->streamtype) { case kChannelStreamProc: diff --git a/src/nvim/cmdexpand.c b/src/nvim/cmdexpand.c index 367b86ec55..523145af1b 100644 --- a/src/nvim/cmdexpand.c +++ b/src/nvim/cmdexpand.c @@ -26,7 +26,6 @@ #include "nvim/ex_cmds.h" #include "nvim/ex_docmd.h" #include "nvim/ex_getln.h" -#include "nvim/func_attr.h" #include "nvim/garray.h" #include "nvim/garray_defs.h" #include "nvim/getchar.h" diff --git a/src/nvim/cmdhist.c b/src/nvim/cmdhist.c index 4556b74396..7ebe3c34a1 100644 --- a/src/nvim/cmdhist.c +++ b/src/nvim/cmdhist.c @@ -15,7 +15,6 @@ #include "nvim/ex_cmds.h" #include "nvim/ex_cmds_defs.h" #include "nvim/ex_getln.h" -#include "nvim/func_attr.h" #include "nvim/gettext.h" #include "nvim/globals.h" #include "nvim/macros_defs.h" diff --git a/src/nvim/context.c b/src/nvim/context.c index 59309fcf16..5f47cfc225 100644 --- a/src/nvim/context.c +++ b/src/nvim/context.c @@ -16,7 +16,6 @@ #include "nvim/eval/typval.h" #include "nvim/eval/userfunc.h" #include "nvim/ex_docmd.h" -#include "nvim/func_attr.h" #include "nvim/hashtab.h" #include "nvim/keycodes.h" #include "nvim/memory.h" diff --git a/src/nvim/cursor_shape.c b/src/nvim/cursor_shape.c index 5aff3b5598..fe07c33df5 100644 --- a/src/nvim/cursor_shape.c +++ b/src/nvim/cursor_shape.c @@ -8,7 +8,6 @@ #include "nvim/charset.h" #include "nvim/cursor_shape.h" #include "nvim/ex_getln.h" -#include "nvim/func_attr.h" #include "nvim/gettext.h" #include "nvim/globals.h" #include "nvim/highlight_group.h" diff --git a/src/nvim/debugger.c b/src/nvim/debugger.c index a343c1ad6b..000fe13502 100644 --- a/src/nvim/debugger.c +++ b/src/nvim/debugger.c @@ -18,7 +18,6 @@ #include "nvim/ex_docmd.h" #include "nvim/ex_getln.h" #include "nvim/fileio.h" -#include "nvim/func_attr.h" #include "nvim/garray.h" #include "nvim/getchar.h" #include "nvim/gettext.h" diff --git a/src/nvim/decoration.h b/src/nvim/decoration.h index f5448c051b..e5bac169dc 100644 --- a/src/nvim/decoration.h +++ b/src/nvim/decoration.h @@ -14,9 +14,11 @@ // actual Decor* data is in decoration_defs.h -EXTERN const char *const virt_text_pos_str[] INIT( = { "eol", "overlay", "win_col", "right_align", - "inline" }); +/// Keep in sync with VirtTextPos in decoration_defs.h +EXTERN const char *const virt_text_pos_str[] +INIT( = { "eol", "overlay", "win_col", "right_align", "inline" }); +/// Keep in sync with HlMode in decoration_defs.h EXTERN const char *const hl_mode_str[] INIT( = { "", "replace", "combine", "blend" }); typedef enum { @@ -43,8 +45,8 @@ typedef struct { VirtTextPos pos; } ui; } data; - int attr_id; // cached lookup of inl.hl_id if it was a highlight - bool owned; // ephemeral decoration, free memory immediately + int attr_id; ///< cached lookup of inl.hl_id if it was a highlight + bool owned; ///< ephemeral decoration, free memory immediately DecorPriority priority; DecorRangeKind kind; /// Screen column to draw the virtual text. diff --git a/src/nvim/decoration_defs.h b/src/nvim/decoration_defs.h index dc5d7b9ae4..6e7dc08f80 100644 --- a/src/nvim/decoration_defs.h +++ b/src/nvim/decoration_defs.h @@ -15,6 +15,7 @@ typedef struct { typedef kvec_t(VirtTextChunk) VirtText; #define VIRTTEXT_EMPTY ((VirtText)KV_INITIAL_VALUE) +/// Keep in sync with virt_text_pos_str[] in decoration.h typedef enum { kVPosEndOfLine, kVPosOverlay, @@ -28,6 +29,7 @@ typedef kvec_t(struct virt_line { VirtText line; bool left_col; }) VirtLines; typedef uint16_t DecorPriority; #define DECOR_PRIORITY_BASE 0x1000 +/// Keep in sync with hl_mode_str[] in decoration.h typedef enum { kHlModeUnknown, kHlModeReplace, diff --git a/src/nvim/diff.c b/src/nvim/diff.c index 0b7f6f266b..6578a1121c 100644 --- a/src/nvim/diff.c +++ b/src/nvim/diff.c @@ -32,7 +32,6 @@ #include "nvim/extmark.h" #include "nvim/fileio.h" #include "nvim/fold.h" -#include "nvim/func_attr.h" #include "nvim/garray.h" #include "nvim/gettext.h" #include "nvim/globals.h" diff --git a/src/nvim/digraph.c b/src/nvim/digraph.c index 99d5cf1035..6b3c4e902b 100644 --- a/src/nvim/digraph.c +++ b/src/nvim/digraph.c @@ -17,7 +17,6 @@ #include "nvim/ex_cmds_defs.h" #include "nvim/ex_docmd.h" #include "nvim/ex_getln.h" -#include "nvim/func_attr.h" #include "nvim/garray.h" #include "nvim/getchar.h" #include "nvim/gettext.h" diff --git a/src/nvim/drawscreen.c b/src/nvim/drawscreen.c index 6cc623cb72..1abbc0c102 100644 --- a/src/nvim/drawscreen.c +++ b/src/nvim/drawscreen.c @@ -76,7 +76,6 @@ #include "nvim/eval.h" #include "nvim/ex_getln.h" #include "nvim/fold.h" -#include "nvim/func_attr.h" #include "nvim/getchar.h" #include "nvim/gettext.h" #include "nvim/globals.h" diff --git a/src/nvim/edit.c b/src/nvim/edit.c index 71a12ea1b0..dd7cd9a573 100644 --- a/src/nvim/edit.c +++ b/src/nvim/edit.c @@ -24,7 +24,6 @@ #include "nvim/extmark.h" #include "nvim/fileio.h" #include "nvim/fold.h" -#include "nvim/func_attr.h" #include "nvim/getchar.h" #include "nvim/gettext.h" #include "nvim/globals.h" @@ -1472,7 +1471,7 @@ void edit_putchar(int c, bool highlight) /// @return the effective prompt for the specified buffer. char *buf_prompt_text(const buf_T *const buf) - FUNC_ATTR_NONNULL_ALL FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_PURE + FUNC_ATTR_NONNULL_ALL FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_PURE { if (buf->b_prompt_text == NULL) { return "% "; diff --git a/src/nvim/eval.c b/src/nvim/eval.c index f4479d06a6..a43ca3d78a 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -36,7 +36,6 @@ #include "nvim/ex_eval.h" #include "nvim/ex_getln.h" #include "nvim/ex_session.h" -#include "nvim/func_attr.h" #include "nvim/garray.h" #include "nvim/getchar.h" #include "nvim/gettext.h" diff --git a/src/nvim/eval/buffer.c b/src/nvim/eval/buffer.c index c60a104381..1f3b92804d 100644 --- a/src/nvim/eval/buffer.c +++ b/src/nvim/eval/buffer.c @@ -14,7 +14,6 @@ #include "nvim/eval/funcs.h" #include "nvim/eval/typval.h" #include "nvim/eval/typval_defs.h" -#include "nvim/func_attr.h" #include "nvim/globals.h" #include "nvim/macros_defs.h" #include "nvim/memline.h" diff --git a/src/nvim/eval/decode.c b/src/nvim/eval/decode.c index 03f79fca84..a6407693d7 100644 --- a/src/nvim/eval/decode.c +++ b/src/nvim/eval/decode.c @@ -14,7 +14,6 @@ #include "nvim/eval/encode.h" #include "nvim/eval/typval.h" #include "nvim/eval/typval_defs.h" -#include "nvim/func_attr.h" #include "nvim/garray.h" #include "nvim/gettext.h" #include "nvim/macros_defs.h" diff --git a/src/nvim/eval/encode.h b/src/nvim/eval/encode.h index 26a3286f2b..699956d8ac 100644 --- a/src/nvim/eval/encode.h +++ b/src/nvim/eval/encode.h @@ -36,9 +36,11 @@ typedef struct { size_t li_length; ///< Length of the string inside the read item. } ListReaderState; +static inline ListReaderState encode_init_lrstate(const list_T *list) + REAL_FATTR_NONNULL_ALL; + /// Initialize ListReaderState structure static inline ListReaderState encode_init_lrstate(const list_T *const list) - FUNC_ATTR_NONNULL_ALL { return (ListReaderState) { .list = list, diff --git a/src/nvim/eval/executor.c b/src/nvim/eval/executor.c index dc23fcdc72..b483f5fbef 100644 --- a/src/nvim/eval/executor.c +++ b/src/nvim/eval/executor.c @@ -5,7 +5,6 @@ #include "nvim/eval/executor.h" #include "nvim/eval/typval.h" #include "nvim/eval/typval_defs.h" -#include "nvim/func_attr.h" #include "nvim/garray.h" #include "nvim/gettext.h" #include "nvim/globals.h" @@ -15,7 +14,7 @@ #include "nvim/vim_defs.h" #ifdef INCLUDE_GENERATED_DECLARATIONS -# include "eval/executor.c.generated.h" // IWYU pragma: export +# include "eval/executor.c.generated.h" #endif char *e_list_index_out_of_range_nr diff --git a/src/nvim/eval/funcs.c b/src/nvim/eval/funcs.c index 13425b21d1..0054c47678 100644 --- a/src/nvim/eval/funcs.c +++ b/src/nvim/eval/funcs.c @@ -58,7 +58,6 @@ #include "nvim/ex_getln.h" #include "nvim/file_search.h" #include "nvim/fileio.h" -#include "nvim/func_attr.h" #include "nvim/garray.h" #include "nvim/getchar.h" #include "nvim/gettext.h" diff --git a/src/nvim/eval/typval.h b/src/nvim/eval/typval.h index 58f74a9796..efa6017f4b 100644 --- a/src/nvim/eval/typval.h +++ b/src/nvim/eval/typval.h @@ -85,6 +85,9 @@ static inline void tv_list_set_lock(list_T *const l, const VarLockStatus lock) l->lv_lock = lock; } +static inline void tv_list_set_copyid(list_T *l, int copyid) + REAL_FATTR_NONNULL_ALL; + /// Set list copyID /// /// Does not expect NULL list, be careful. @@ -92,7 +95,6 @@ static inline void tv_list_set_lock(list_T *const l, const VarLockStatus lock) /// @param[out] l List to modify. /// @param[in] copyid New copyID. static inline void tv_list_set_copyid(list_T *const l, const int copyid) - FUNC_ATTR_NONNULL_ALL { l->lv_copyID = copyid; } @@ -442,22 +444,20 @@ static inline bool tv_get_float_chk(const typval_T *const tv, float_T *const ret } static inline DictWatcher *tv_dict_watcher_node_data(QUEUE *q) - REAL_FATTR_NONNULL_ALL REAL_FATTR_NONNULL_RET REAL_FATTR_PURE - REAL_FATTR_WARN_UNUSED_RESULT REAL_FATTR_ALWAYS_INLINE - FUNC_ATTR_NO_SANITIZE_ADDRESS; + REAL_FATTR_ALWAYS_INLINE REAL_FATTR_NONNULL_ALL REAL_FATTR_NONNULL_RET + REAL_FATTR_NO_SANITIZE_ADDRESS REAL_FATTR_PURE REAL_FATTR_WARN_UNUSED_RESULT; /// Compute the `DictWatcher` address from a QUEUE node. /// /// This only exists for .asan-blacklist (ASAN doesn't handle QUEUE_DATA pointer /// arithmetic). static inline DictWatcher *tv_dict_watcher_node_data(QUEUE *q) - FUNC_ATTR_NO_SANITIZE_ADDRESS { return QUEUE_DATA(q, DictWatcher, node); } static inline bool tv_is_func(typval_T tv) - FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_ALWAYS_INLINE FUNC_ATTR_CONST; + REAL_FATTR_WARN_UNUSED_RESULT REAL_FATTR_ALWAYS_INLINE REAL_FATTR_CONST; /// Check whether given typval_T contains a function /// diff --git a/src/nvim/eval/userfunc.c b/src/nvim/eval/userfunc.c index 23b3c4e1b2..e0bf30b158 100644 --- a/src/nvim/eval/userfunc.c +++ b/src/nvim/eval/userfunc.c @@ -23,7 +23,6 @@ #include "nvim/ex_docmd.h" #include "nvim/ex_eval.h" #include "nvim/ex_getln.h" -#include "nvim/func_attr.h" #include "nvim/garray.h" #include "nvim/getchar.h" #include "nvim/gettext.h" diff --git a/src/nvim/eval/vars.c b/src/nvim/eval/vars.c index 2968f75f4d..670ee39f4b 100644 --- a/src/nvim/eval/vars.c +++ b/src/nvim/eval/vars.c @@ -25,7 +25,6 @@ #include "nvim/ex_cmds_defs.h" #include "nvim/ex_docmd.h" #include "nvim/ex_eval.h" -#include "nvim/func_attr.h" #include "nvim/garray.h" #include "nvim/gettext.h" #include "nvim/globals.h" diff --git a/src/nvim/event/libuv_process.c b/src/nvim/event/libuv_process.c index be48b39af1..8264adb1fc 100644 --- a/src/nvim/event/libuv_process.c +++ b/src/nvim/event/libuv_process.c @@ -7,7 +7,6 @@ #include "nvim/event/libuv_process.h" #include "nvim/event/process.h" #include "nvim/event/stream.h" -#include "nvim/func_attr.h" #include "nvim/log.h" #include "nvim/os/os.h" #include "nvim/ui_client.h" diff --git a/src/nvim/event/multiqueue.c b/src/nvim/event/multiqueue.c index 3ab41bd299..677b7e8e6a 100644 --- a/src/nvim/event/multiqueue.c +++ b/src/nvim/event/multiqueue.c @@ -48,7 +48,6 @@ #include "nvim/event/defs.h" #include "nvim/event/multiqueue.h" -#include "nvim/func_attr.h" #include "nvim/lib/queue.h" #include "nvim/memory.h" diff --git a/src/nvim/event/process.c b/src/nvim/event/process.c index 864fc2c1d8..b69612337c 100644 --- a/src/nvim/event/process.c +++ b/src/nvim/event/process.c @@ -7,7 +7,6 @@ #include "nvim/event/libuv_process.h" #include "nvim/event/loop.h" #include "nvim/event/process.h" -#include "nvim/func_attr.h" #include "nvim/globals.h" #include "nvim/log.h" #include "nvim/main.h" diff --git a/src/nvim/event/rstream.c b/src/nvim/event/rstream.c index 73828a2271..88363e86e9 100644 --- a/src/nvim/event/rstream.c +++ b/src/nvim/event/rstream.c @@ -8,7 +8,6 @@ #include "nvim/event/loop.h" #include "nvim/event/rstream.h" #include "nvim/event/stream.h" -#include "nvim/func_attr.h" #include "nvim/log.h" #include "nvim/macros_defs.h" #include "nvim/main.h" diff --git a/src/nvim/event/signal.c b/src/nvim/event/signal.c index e64d526856..07223be987 100644 --- a/src/nvim/event/signal.c +++ b/src/nvim/event/signal.c @@ -3,7 +3,6 @@ #include "nvim/event/loop.h" #include "nvim/event/signal.h" -#include "nvim/func_attr.h" #ifdef INCLUDE_GENERATED_DECLARATIONS # include "event/signal.c.generated.h" diff --git a/src/nvim/event/socket.c b/src/nvim/event/socket.c index e787e023f0..c90b177eb7 100644 --- a/src/nvim/event/socket.c +++ b/src/nvim/event/socket.c @@ -10,7 +10,6 @@ #include "nvim/event/loop.h" #include "nvim/event/socket.h" #include "nvim/event/stream.h" -#include "nvim/func_attr.h" #include "nvim/gettext.h" #include "nvim/log.h" #include "nvim/main.h" diff --git a/src/nvim/event/stream.c b/src/nvim/event/stream.c index aff116bad9..17c1b0a072 100644 --- a/src/nvim/event/stream.c +++ b/src/nvim/event/stream.c @@ -6,7 +6,6 @@ #include "nvim/event/loop.h" #include "nvim/event/stream.h" -#include "nvim/func_attr.h" #include "nvim/log.h" #include "nvim/rbuffer.h" #ifdef MSWIN diff --git a/src/nvim/event/time.c b/src/nvim/event/time.c index f678f25f3f..0b624d9547 100644 --- a/src/nvim/event/time.c +++ b/src/nvim/event/time.c @@ -3,7 +3,6 @@ #include "nvim/event/loop.h" #include "nvim/event/time.h" -#include "nvim/func_attr.h" #ifdef INCLUDE_GENERATED_DECLARATIONS # include "event/time.c.generated.h" diff --git a/src/nvim/event/wstream.c b/src/nvim/event/wstream.c index e8f757874b..239f64c013 100644 --- a/src/nvim/event/wstream.c +++ b/src/nvim/event/wstream.c @@ -5,7 +5,6 @@ #include "nvim/event/loop.h" #include "nvim/event/stream.h" #include "nvim/event/wstream.h" -#include "nvim/func_attr.h" #include "nvim/macros_defs.h" #include "nvim/memory.h" diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c index e369397047..c0aca071e2 100644 --- a/src/nvim/ex_cmds.c +++ b/src/nvim/ex_cmds.c @@ -43,7 +43,6 @@ #include "nvim/extmark.h" #include "nvim/fileio.h" #include "nvim/fold.h" -#include "nvim/func_attr.h" #include "nvim/getchar.h" #include "nvim/gettext.h" #include "nvim/globals.h" diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c index 0b466bbe4e..bf5a3944e6 100644 --- a/src/nvim/ex_docmd.c +++ b/src/nvim/ex_docmd.c @@ -39,7 +39,6 @@ #include "nvim/file_search.h" #include "nvim/fileio.h" #include "nvim/fold.h" -#include "nvim/func_attr.h" #include "nvim/garray.h" #include "nvim/getchar.h" #include "nvim/gettext.h" @@ -7424,7 +7423,9 @@ static void ex_terminal(exarg_T *eap) char shell_argv[512] = { 0 }; while (*p != NULL) { - snprintf(tempstring, sizeof(tempstring), ",\"%s\"", *p); + char *escaped = vim_strsave_escaped(*p, "\"\\"); + snprintf(tempstring, sizeof(tempstring), ",\"%s\"", escaped); + xfree(escaped); xstrlcat(shell_argv, tempstring, sizeof(shell_argv)); p++; } diff --git a/src/nvim/ex_eval.c b/src/nvim/ex_eval.c index d2a1d53b78..bc4cb634e8 100644 --- a/src/nvim/ex_eval.c +++ b/src/nvim/ex_eval.c @@ -18,7 +18,6 @@ #include "nvim/ex_docmd.h" #include "nvim/ex_eval.h" #include "nvim/ex_eval_defs.h" -#include "nvim/func_attr.h" #include "nvim/gettext.h" #include "nvim/globals.h" #include "nvim/memory.h" diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index 64ef17b157..f31f8fec55 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -34,7 +34,6 @@ #include "nvim/ex_eval.h" #include "nvim/ex_getln.h" #include "nvim/extmark.h" -#include "nvim/func_attr.h" #include "nvim/garray.h" #include "nvim/getchar.h" #include "nvim/gettext.h" diff --git a/src/nvim/ex_session.c b/src/nvim/ex_session.c index 71c01922bc..45f05e10f2 100644 --- a/src/nvim/ex_session.c +++ b/src/nvim/ex_session.c @@ -20,7 +20,6 @@ #include "nvim/file_search.h" #include "nvim/fileio.h" #include "nvim/fold.h" -#include "nvim/func_attr.h" #include "nvim/garray.h" #include "nvim/gettext.h" #include "nvim/globals.h" diff --git a/src/nvim/extmark.h b/src/nvim/extmark.h index 061cd0ed5f..1a7a1ddeff 100644 --- a/src/nvim/extmark.h +++ b/src/nvim/extmark.h @@ -13,7 +13,7 @@ #include "nvim/pos_defs.h" #include "nvim/types_defs.h" -EXTERN int extmark_splice_pending INIT( = 0); +EXTERN int curbuf_splice_pending INIT( = 0); typedef kvec_t(MTPair) ExtmarkInfoArray; diff --git a/src/nvim/fileio.c b/src/nvim/fileio.c index 0bb664bcf5..4fe5b1cd44 100644 --- a/src/nvim/fileio.c +++ b/src/nvim/fileio.c @@ -31,7 +31,6 @@ #include "nvim/ex_eval.h" #include "nvim/fileio.h" #include "nvim/fold.h" -#include "nvim/func_attr.h" #include "nvim/garray.h" #include "nvim/garray_defs.h" #include "nvim/getchar.h" diff --git a/src/nvim/fold.c b/src/nvim/fold.c index c905b2d3ed..e372b9f461 100644 --- a/src/nvim/fold.c +++ b/src/nvim/fold.c @@ -27,7 +27,6 @@ #include "nvim/ex_session.h" #include "nvim/extmark.h" #include "nvim/fold.h" -#include "nvim/func_attr.h" #include "nvim/garray.h" #include "nvim/garray_defs.h" #include "nvim/gettext.h" diff --git a/src/nvim/func_attr.h b/src/nvim/func_attr.h index 15370dcb3e..d638fda531 100644 --- a/src/nvim/func_attr.h +++ b/src/nvim/func_attr.h @@ -1,24 +1,16 @@ -// If DEFINE_FUNC_ATTRIBUTES macro is not defined then all function attributes -// are defined as empty values. -// -// If DO_NOT_DEFINE_EMPTY_ATTRIBUTES then empty macros are not defined. Thus -// undefined DEFINE_FUNC_ATTRIBUTES and defined DO_NOT_DEFINE_EMPTY_ATTRIBUTES +// Undefined DEFINE_FUNC_ATTRIBUTES and undefined DEFINE_EMPTY_ATTRIBUTES // leaves file with untouched FUNC_ATTR_* macros. This variant is used for -// scripts/gendeclarations.lua. +// scripts/gen_declarations.lua. // -// Empty macros are used for *.c files. (undefined DEFINE_FUNC_ATTRIBUTES and -// undefined DO_NOT_DEFINE_EMPTY_ATTRIBUTES) +// Empty macros are used for *.c files. +// (undefined DEFINE_FUNC_ATTRIBUTES and defined DEFINE_EMPTY_ATTRIBUTES) // // Macros defined as __attribute__((*)) are used by generated header files. -// (defined DEFINE_FUNC_ATTRIBUTES and undefined -// DO_NOT_DEFINE_EMPTY_ATTRIBUTES) -// -// Defined DEFINE_FUNC_ATTRIBUTES and defined DO_NOT_DEFINE_EMPTY_ATTRIBUTES is -// not used by anything. +// (defined DEFINE_FUNC_ATTRIBUTES and undefined DEFINE_EMPTY_ATTRIBUTES) // FUNC_ATTR_* macros should be in *.c files for declarations generator. If you // define a function for which declaration is not generated by -// gendeclarations.lua (e.g. template hash implementation) then you should use +// gen_declarations.lua (e.g. template hash implementation) then you should use // REAL_FATTR_* macros. // gcc and clang expose their version as follows: @@ -217,7 +209,7 @@ # endif #endif -#ifdef DEFINE_FUNC_ATTRIBUTES +#if defined(DEFINE_FUNC_ATTRIBUTES) || defined(DEFINE_EMPTY_ATTRIBUTES) /// Fast (non-deferred) API function. # define FUNC_API_FAST /// Internal C function not exposed in the RPC API. @@ -234,6 +226,9 @@ # define FUNC_API_SINCE(X) /// API function deprecated since the given API level. # define FUNC_API_DEPRECATED_SINCE(X) +#endif + +#if defined(DEFINE_FUNC_ATTRIBUTES) # define FUNC_ATTR_MALLOC REAL_FATTR_MALLOC # define FUNC_ATTR_ALLOC_SIZE(x) REAL_FATTR_ALLOC_SIZE(x) # define FUNC_ATTR_ALLOC_SIZE_PROD(x, y) REAL_FATTR_ALLOC_SIZE_PROD(x, y) @@ -250,7 +245,7 @@ # define FUNC_ATTR_NO_SANITIZE_UNDEFINED REAL_FATTR_NO_SANITIZE_UNDEFINED # define FUNC_ATTR_NO_SANITIZE_ADDRESS REAL_FATTR_NO_SANITIZE_ADDRESS # define FUNC_ATTR_PRINTF(x, y) REAL_FATTR_PRINTF(x, y) -#elif !defined(DO_NOT_DEFINE_EMPTY_ATTRIBUTES) +#elif defined(DEFINE_EMPTY_ATTRIBUTES) # define FUNC_ATTR_MALLOC # define FUNC_ATTR_ALLOC_SIZE(x) # define FUNC_ATTR_ALLOC_SIZE_PROD(x, y) diff --git a/src/nvim/garray.c b/src/nvim/garray.c index 24b6fb0007..28339c3059 100644 --- a/src/nvim/garray.c +++ b/src/nvim/garray.c @@ -5,7 +5,6 @@ #include <stdint.h> #include <string.h> -#include "nvim/func_attr.h" #include "nvim/garray.h" #include "nvim/log.h" #include "nvim/memory.h" @@ -13,7 +12,7 @@ #include "nvim/strings.h" #ifdef INCLUDE_GENERATED_DECLARATIONS -# include "garray.c.generated.h" // IWYU pragma: export +# include "garray.c.generated.h" #endif /// Clear an allocated growing array. diff --git a/src/nvim/generators/gen_api_dispatch.lua b/src/nvim/generators/gen_api_dispatch.lua index 9720cca477..81b5096557 100644 --- a/src/nvim/generators/gen_api_dispatch.lua +++ b/src/nvim/generators/gen_api_dispatch.lua @@ -752,9 +752,9 @@ for _, fn in ipairs(functions) do end output:write(string.format([[ -void nlua_add_api_functions(lua_State *lstate); // silence -Wmissing-prototypes void nlua_add_api_functions(lua_State *lstate) - FUNC_ATTR_NONNULL_ALL + REAL_FATTR_NONNULL_ALL; +void nlua_add_api_functions(lua_State *lstate) { lua_createtable(lstate, 0, %u); ]], #lua_c_functions)) diff --git a/src/nvim/generators/gen_declarations.lua b/src/nvim/generators/gen_declarations.lua index f9e9c6b0a8..fecca5191e 100644 --- a/src/nvim/generators/gen_declarations.lua +++ b/src/nvim/generators/gen_declarations.lua @@ -164,7 +164,7 @@ if fname == '--help' then print([[ Usage: - gendeclarations.lua definitions.c static.h non-static.h definitions.i + gen_declarations.lua definitions.c static.h non-static.h definitions.i Generates declarations for a C file definitions.c, putting declarations for static functions into static.h and declarations for non-static functions into @@ -202,17 +202,10 @@ local text = preproc_f:read("*all") preproc_f:close() -local header = [[ +local non_static = [[ #define DEFINE_FUNC_ATTRIBUTES #include "nvim/func_attr.h" #undef DEFINE_FUNC_ATTRIBUTES -]] - -local footer = [[ -#include "nvim/func_attr.h" -]] - -local non_static = header .. [[ #ifndef DLLEXPORT # ifdef MSWIN # define DLLEXPORT __declspec(dllexport) @@ -222,7 +215,20 @@ local non_static = header .. [[ #endif ]] -local static = header +local static = [[ +#define DEFINE_FUNC_ATTRIBUTES +#include "nvim/func_attr.h" +#undef DEFINE_FUNC_ATTRIBUTES +]] + +local non_static_footer = [[ +#include "nvim/func_attr.h" +]] + +local static_footer = [[ +#define DEFINE_EMPTY_ATTRIBUTES +#include "nvim/func_attr.h" // IWYU pragma: export +]] if fname:find('.*/src/nvim/.*%.c$') then -- Add an IWYU pragma comment if the corresponding .h file exists. @@ -307,8 +313,8 @@ while init ~= nil do end end -non_static = non_static .. footer -static = static .. footer +non_static = non_static .. non_static_footer +static = static .. static_footer local F F = io.open(static_fname, 'w') diff --git a/src/nvim/getchar.c b/src/nvim/getchar.c index 73af78d3e2..0ccf1823f8 100644 --- a/src/nvim/getchar.c +++ b/src/nvim/getchar.c @@ -26,7 +26,6 @@ #include "nvim/ex_cmds.h" #include "nvim/ex_docmd.h" #include "nvim/ex_getln.h" -#include "nvim/func_attr.h" #include "nvim/garray.h" #include "nvim/getchar.h" #include "nvim/gettext.h" diff --git a/src/nvim/hashtab.c b/src/nvim/hashtab.c index 475666be5e..e6a0e55ed2 100644 --- a/src/nvim/hashtab.c +++ b/src/nvim/hashtab.c @@ -24,7 +24,6 @@ #include <string.h> #include "nvim/ascii_defs.h" -#include "nvim/func_attr.h" #include "nvim/gettext.h" #include "nvim/hashtab.h" #include "nvim/memory.h" diff --git a/src/nvim/help.c b/src/nvim/help.c index c23dc7fd9d..dc4f6c44ff 100644 --- a/src/nvim/help.c +++ b/src/nvim/help.c @@ -16,7 +16,6 @@ #include "nvim/ex_docmd.h" #include "nvim/extmark_defs.h" #include "nvim/fileio.h" -#include "nvim/func_attr.h" #include "nvim/garray.h" #include "nvim/gettext.h" #include "nvim/globals.h" diff --git a/src/nvim/highlight.h b/src/nvim/highlight.h index e5d3f3d1ca..ea8a663a9f 100644 --- a/src/nvim/highlight.h +++ b/src/nvim/highlight.h @@ -6,8 +6,99 @@ #include "nvim/api/private/defs.h" // IWYU pragma: keep #include "nvim/buffer_defs.h" // IWYU pragma: keep #include "nvim/highlight_defs.h" // IWYU pragma: export +#include "nvim/macros_defs.h" #include "nvim/option_vars.h" -#include "nvim/ui.h" +#include "nvim/types_defs.h" +#include "nvim/ui_defs.h" // IWYU pragma: keep + +EXTERN const char *hlf_names[] INIT( = { + [HLF_8] = "SpecialKey", + [HLF_EOB] = "EndOfBuffer", + [HLF_TERM] = "TermCursor", + [HLF_TERMNC] = "TermCursorNC", + [HLF_AT] = "NonText", + [HLF_D] = "Directory", + [HLF_E] = "ErrorMsg", + [HLF_I] = "IncSearch", + [HLF_L] = "Search", + [HLF_LC] = "CurSearch", + [HLF_M] = "MoreMsg", + [HLF_CM] = "ModeMsg", + [HLF_N] = "LineNr", + [HLF_LNA] = "LineNrAbove", + [HLF_LNB] = "LineNrBelow", + [HLF_CLN] = "CursorLineNr", + [HLF_CLS] = "CursorLineSign", + [HLF_CLF] = "CursorLineFold", + [HLF_R] = "Question", + [HLF_S] = "StatusLine", + [HLF_SNC] = "StatusLineNC", + [HLF_C] = "WinSeparator", + [HLF_T] = "Title", + [HLF_V] = "Visual", + [HLF_VNC] = "VisualNC", + [HLF_VSP] = "VertSplit", + [HLF_W] = "WarningMsg", + [HLF_WM] = "WildMenu", + [HLF_FL] = "Folded", + [HLF_FC] = "FoldColumn", + [HLF_ADD] = "DiffAdd", + [HLF_CHD] = "DiffChange", + [HLF_DED] = "DiffDelete", + [HLF_TXD] = "DiffText", + [HLF_SC] = "SignColumn", + [HLF_CONCEAL] = "Conceal", + [HLF_SPB] = "SpellBad", + [HLF_SPC] = "SpellCap", + [HLF_SPR] = "SpellRare", + [HLF_SPL] = "SpellLocal", + [HLF_PNI] = "Pmenu", + [HLF_PSI] = "PmenuSel", + [HLF_PNK] = "PmenuKind", + [HLF_PSK] = "PmenuKindSel", + [HLF_PNX] = "PmenuExtra", + [HLF_PSX] = "PmenuExtraSel", + [HLF_PSB] = "PmenuSbar", + [HLF_PST] = "PmenuThumb", + [HLF_TP] = "TabLine", + [HLF_TPS] = "TabLineSel", + [HLF_TPF] = "TabLineFill", + [HLF_CUC] = "CursorColumn", + [HLF_CUL] = "CursorLine", + [HLF_MC] = "ColorColumn", + [HLF_QFL] = "QuickFixLine", + [HLF_0] = "Whitespace", + [HLF_INACTIVE] = "NormalNC", + [HLF_MSGSEP] = "MsgSeparator", + [HLF_NFLOAT] = "NormalFloat", + [HLF_MSG] = "MsgArea", + [HLF_BORDER] = "FloatBorder", + [HLF_WBR] = "WinBar", + [HLF_WBRNC] = "WinBarNC", + [HLF_CU] = "Cursor", + [HLF_BTITLE] = "FloatTitle", + [HLF_BFOOTER] = "FloatFooter", +}); + +EXTERN int highlight_attr[HLF_COUNT + 1]; // Highl. attr for each context. +EXTERN int highlight_attr_last[HLF_COUNT]; // copy for detecting changed groups +EXTERN int highlight_user[9]; // User[1-9] attributes +EXTERN int highlight_stlnc[9]; // On top of user +EXTERN int cterm_normal_fg_color INIT( = 0); +EXTERN int cterm_normal_bg_color INIT( = 0); +EXTERN RgbValue normal_fg INIT( = -1); +EXTERN RgbValue normal_bg INIT( = -1); +EXTERN RgbValue normal_sp INIT( = -1); + +EXTERN NS ns_hl_global INIT( = 0); // global highlight namespace +EXTERN NS ns_hl_win INIT( = -1); // highlight namespace for the current window +EXTERN NS ns_hl_fast INIT( = -1); // highlight namespace specified in a fast callback +EXTERN NS ns_hl_active INIT( = 0); // currently active/cached namespace + +EXTERN int *hl_attr_active INIT( = highlight_attr); + +// Enums need a typecast to be used as array index. +#define HL_ATTR(n) hl_attr_active[(int)(n)] #ifdef INCLUDE_GENERATED_DECLARATIONS # include "highlight.h.generated.h" @@ -20,8 +111,6 @@ static inline int win_hl_attr(win_T *wp, int hlf) return ((wp->w_ns_hl_attr && ns_hl_fast < 0) ? wp->w_ns_hl_attr : hl_attr_active)[hlf]; } -#define HLATTRS_DICT_SIZE 16 - #define HL_SET_DEFAULT_COLORS(rgb_fg, rgb_bg, rgb_sp) \ do { \ bool dark_ = (*p_bg == 'd'); \ @@ -29,6 +118,3 @@ static inline int win_hl_attr(win_T *wp, int hlf) rgb_bg = rgb_bg != -1 ? rgb_bg : (dark_ ? 0x000000 : 0xFFFFFF); \ rgb_sp = rgb_sp != -1 ? rgb_sp : 0xFF0000; \ } while (0); - -// Enums need a typecast to be used as array index. -#define HL_ATTR(n) hl_attr_active[(int)(n)] diff --git a/src/nvim/highlight_defs.h b/src/nvim/highlight_defs.h index 24070199ee..ec77bf7860 100644 --- a/src/nvim/highlight_defs.h +++ b/src/nvim/highlight_defs.h @@ -1,9 +1,7 @@ #pragma once -#include <inttypes.h> - -#include "nvim/macros_defs.h" -#include "nvim/types_defs.h" +#include <stdbool.h> +#include <stdint.h> typedef int32_t RgbValue; @@ -54,164 +52,78 @@ typedef struct attr_entry { } /// Values for index in highlight_attr[]. -/// When making changes, also update hlf_names below! +/// When making changes, also update hlf_names in highlight.h! typedef enum { - HLF_8 = 0, // Meta & special keys listed with ":map", text that is - // displayed different from what it is - HLF_EOB, // after the last line in the buffer - HLF_TERM, // terminal cursor focused - HLF_TERMNC, // terminal cursor unfocused - HLF_AT, // @ characters at end of screen, characters that don't really exist in the text - HLF_D, // directories in CTRL-D listing - HLF_E, // error messages - HLF_I, // incremental search - HLF_L, // last search string - HLF_LC, // current search match - HLF_M, // "--More--" message - HLF_CM, // Mode (e.g., "-- INSERT --") - HLF_N, // line number for ":number" and ":#" commands - HLF_LNA, // LineNrAbove - HLF_LNB, // LineNrBelow - HLF_CLN, // current line number when 'cursorline' is set - HLF_CLS, // current line sign column - HLF_CLF, // current line fold - HLF_R, // return to continue message and yes/no questions - HLF_S, // status lines - HLF_SNC, // status lines of not-current windows - HLF_C, // window split separators - HLF_VSP, // VertSplit - HLF_T, // Titles for output from ":set all", ":autocmd" etc. - HLF_V, // Visual mode - HLF_VNC, // Visual mode, autoselecting and not clipboard owner - HLF_W, // warning messages - HLF_WM, // Wildmenu highlight - HLF_FL, // Folded line - HLF_FC, // Fold column - HLF_ADD, // Added diff line - HLF_CHD, // Changed diff line - HLF_DED, // Deleted diff line - HLF_TXD, // Text Changed in diff line - HLF_SC, // Sign column - HLF_CONCEAL, // Concealed text - HLF_SPB, // SpellBad - HLF_SPC, // SpellCap - HLF_SPR, // SpellRare - HLF_SPL, // SpellLocal - HLF_PNI, // popup menu normal item - HLF_PSI, // popup menu selected item - HLF_PNK, // popup menu normal item "kind" - HLF_PSK, // popup menu selected item "kind" - HLF_PNX, // popup menu normal item "menu" (extra text) - HLF_PSX, // popup menu selected item "menu" (extra text) - HLF_PSB, // popup menu scrollbar - HLF_PST, // popup menu scrollbar thumb - HLF_TP, // tabpage line - HLF_TPS, // tabpage line selected - HLF_TPF, // tabpage line filler - HLF_CUC, // 'cursorcolumn' - HLF_CUL, // 'cursorline' - HLF_MC, // 'colorcolumn' - HLF_QFL, // selected quickfix line - HLF_0, // Whitespace - HLF_INACTIVE, // NormalNC: Normal text in non-current windows - HLF_MSGSEP, // message separator line - HLF_NFLOAT, // Floating window - HLF_MSG, // Message area - HLF_BORDER, // Floating window border - HLF_WBR, // Window bars - HLF_WBRNC, // Window bars of not-current windows - HLF_CU, // Cursor - HLF_BTITLE, // Float Border Title - HLF_BFOOTER, // Float Border Footer - HLF_COUNT, // MUST be the last one + HLF_8 = 0, ///< Meta & special keys listed with ":map", text that is + ///< displayed different from what it is + HLF_EOB, ///< after the last line in the buffer + HLF_TERM, ///< terminal cursor focused + HLF_TERMNC, ///< terminal cursor unfocused + HLF_AT, ///< @ characters at end of screen, characters that don't really exist in the text + HLF_D, ///< directories in CTRL-D listing + HLF_E, ///< error messages + HLF_I, ///< incremental search + HLF_L, ///< last search string + HLF_LC, ///< current search match + HLF_M, ///< "--More--" message + HLF_CM, ///< Mode (e.g., "-- INSERT --") + HLF_N, ///< line number for ":number" and ":#" commands + HLF_LNA, ///< LineNrAbove + HLF_LNB, ///< LineNrBelow + HLF_CLN, ///< current line number when 'cursorline' is set + HLF_CLS, ///< current line sign column + HLF_CLF, ///< current line fold + HLF_R, ///< return to continue message and yes/no questions + HLF_S, ///< status lines + HLF_SNC, ///< status lines of not-current windows + HLF_C, ///< window split separators + HLF_VSP, ///< VertSplit + HLF_T, ///< Titles for output from ":set all", ":autocmd" etc. + HLF_V, ///< Visual mode + HLF_VNC, ///< Visual mode, autoselecting and not clipboard owner + HLF_W, ///< warning messages + HLF_WM, ///< Wildmenu highlight + HLF_FL, ///< Folded line + HLF_FC, ///< Fold column + HLF_ADD, ///< Added diff line + HLF_CHD, ///< Changed diff line + HLF_DED, ///< Deleted diff line + HLF_TXD, ///< Text Changed in diff line + HLF_SC, ///< Sign column + HLF_CONCEAL, ///< Concealed text + HLF_SPB, ///< SpellBad + HLF_SPC, ///< SpellCap + HLF_SPR, ///< SpellRare + HLF_SPL, ///< SpellLocal + HLF_PNI, ///< popup menu normal item + HLF_PSI, ///< popup menu selected item + HLF_PNK, ///< popup menu normal item "kind" + HLF_PSK, ///< popup menu selected item "kind" + HLF_PNX, ///< popup menu normal item "menu" (extra text) + HLF_PSX, ///< popup menu selected item "menu" (extra text) + HLF_PSB, ///< popup menu scrollbar + HLF_PST, ///< popup menu scrollbar thumb + HLF_TP, ///< tabpage line + HLF_TPS, ///< tabpage line selected + HLF_TPF, ///< tabpage line filler + HLF_CUC, ///< 'cursorcolumn' + HLF_CUL, ///< 'cursorline' + HLF_MC, ///< 'colorcolumn' + HLF_QFL, ///< selected quickfix line + HLF_0, ///< Whitespace + HLF_INACTIVE, ///< NormalNC: Normal text in non-current windows + HLF_MSGSEP, ///< message separator line + HLF_NFLOAT, ///< Floating window + HLF_MSG, ///< Message area + HLF_BORDER, ///< Floating window border + HLF_WBR, ///< Window bars + HLF_WBRNC, ///< Window bars of not-current windows + HLF_CU, ///< Cursor + HLF_BTITLE, ///< Float Border Title + HLF_BFOOTER, ///< Float Border Footer + HLF_COUNT, ///< MUST be the last one } hlf_T; -EXTERN const char *hlf_names[] INIT( = { - [HLF_8] = "SpecialKey", - [HLF_EOB] = "EndOfBuffer", - [HLF_TERM] = "TermCursor", - [HLF_TERMNC] = "TermCursorNC", - [HLF_AT] = "NonText", - [HLF_D] = "Directory", - [HLF_E] = "ErrorMsg", - [HLF_I] = "IncSearch", - [HLF_L] = "Search", - [HLF_LC] = "CurSearch", - [HLF_M] = "MoreMsg", - [HLF_CM] = "ModeMsg", - [HLF_N] = "LineNr", - [HLF_LNA] = "LineNrAbove", - [HLF_LNB] = "LineNrBelow", - [HLF_CLN] = "CursorLineNr", - [HLF_CLS] = "CursorLineSign", - [HLF_CLF] = "CursorLineFold", - [HLF_R] = "Question", - [HLF_S] = "StatusLine", - [HLF_SNC] = "StatusLineNC", - [HLF_C] = "WinSeparator", - [HLF_T] = "Title", - [HLF_V] = "Visual", - [HLF_VNC] = "VisualNC", - [HLF_VSP] = "VertSplit", - [HLF_W] = "WarningMsg", - [HLF_WM] = "WildMenu", - [HLF_FL] = "Folded", - [HLF_FC] = "FoldColumn", - [HLF_ADD] = "DiffAdd", - [HLF_CHD] = "DiffChange", - [HLF_DED] = "DiffDelete", - [HLF_TXD] = "DiffText", - [HLF_SC] = "SignColumn", - [HLF_CONCEAL] = "Conceal", - [HLF_SPB] = "SpellBad", - [HLF_SPC] = "SpellCap", - [HLF_SPR] = "SpellRare", - [HLF_SPL] = "SpellLocal", - [HLF_PNI] = "Pmenu", - [HLF_PSI] = "PmenuSel", - [HLF_PNK] = "PmenuKind", - [HLF_PSK] = "PmenuKindSel", - [HLF_PNX] = "PmenuExtra", - [HLF_PSX] = "PmenuExtraSel", - [HLF_PSB] = "PmenuSbar", - [HLF_PST] = "PmenuThumb", - [HLF_TP] = "TabLine", - [HLF_TPS] = "TabLineSel", - [HLF_TPF] = "TabLineFill", - [HLF_CUC] = "CursorColumn", - [HLF_CUL] = "CursorLine", - [HLF_MC] = "ColorColumn", - [HLF_QFL] = "QuickFixLine", - [HLF_0] = "Whitespace", - [HLF_INACTIVE] = "NormalNC", - [HLF_MSGSEP] = "MsgSeparator", - [HLF_NFLOAT] = "NormalFloat", - [HLF_MSG] = "MsgArea", - [HLF_BORDER] = "FloatBorder", - [HLF_WBR] = "WinBar", - [HLF_WBRNC] = "WinBarNC", - [HLF_CU] = "Cursor", - [HLF_BTITLE] = "FloatTitle", - [HLF_BFOOTER] = "FloatFooter", -}); - -EXTERN int highlight_attr[HLF_COUNT + 1]; // Highl. attr for each context. -EXTERN int highlight_attr_last[HLF_COUNT]; // copy for detecting changed groups -EXTERN int highlight_user[9]; // User[1-9] attributes -EXTERN int highlight_stlnc[9]; // On top of user -EXTERN int cterm_normal_fg_color INIT( = 0); -EXTERN int cterm_normal_bg_color INIT( = 0); -EXTERN RgbValue normal_fg INIT( = -1); -EXTERN RgbValue normal_bg INIT( = -1); -EXTERN RgbValue normal_sp INIT( = -1); - -EXTERN NS ns_hl_global INIT( = 0); // global highlight namespace -EXTERN NS ns_hl_win INIT( = -1); // highlight namespace for the current window -EXTERN NS ns_hl_fast INIT( = -1); // highlight namespace specified in a fast callback -EXTERN NS ns_hl_active INIT( = 0); // currently active/cached namespace - -EXTERN int *hl_attr_active INIT( = highlight_attr); - typedef enum { kHlUnknown, kHlUI, @@ -246,3 +158,5 @@ typedef struct { } ColorItem; #define COLOR_ITEM_INITIALIZER { .attr_id = -1, .link_id = -1, .version = -1, \ .is_default = false, .link_global = false } + +enum { HLATTRS_DICT_SIZE = 16, }; diff --git a/src/nvim/highlight_group.c b/src/nvim/highlight_group.c index 3f1758894e..3953a459bc 100644 --- a/src/nvim/highlight_group.c +++ b/src/nvim/highlight_group.c @@ -24,7 +24,6 @@ #include "nvim/eval/typval_defs.h" #include "nvim/eval/vars.h" #include "nvim/ex_docmd.h" -#include "nvim/func_attr.h" #include "nvim/garray.h" #include "nvim/gettext.h" #include "nvim/globals.h" diff --git a/src/nvim/indent.c b/src/nvim/indent.c index 348f3a6528..5dced37b40 100644 --- a/src/nvim/indent.c +++ b/src/nvim/indent.c @@ -17,7 +17,6 @@ #include "nvim/ex_cmds_defs.h" #include "nvim/ex_docmd.h" #include "nvim/extmark.h" -#include "nvim/func_attr.h" #include "nvim/gettext.h" #include "nvim/globals.h" #include "nvim/indent.h" diff --git a/src/nvim/indent_c.c b/src/nvim/indent_c.c index c140d468d8..6c133c1e99 100644 --- a/src/nvim/indent_c.c +++ b/src/nvim/indent_c.c @@ -9,7 +9,6 @@ #include "nvim/charset.h" #include "nvim/cursor.h" #include "nvim/edit.h" -#include "nvim/func_attr.h" #include "nvim/globals.h" #include "nvim/indent.h" #include "nvim/indent_c.h" diff --git a/src/nvim/insexpand.c b/src/nvim/insexpand.c index 728277e5a3..4595c6913b 100644 --- a/src/nvim/insexpand.c +++ b/src/nvim/insexpand.c @@ -25,7 +25,6 @@ #include "nvim/ex_getln.h" #include "nvim/extmark.h" #include "nvim/fileio.h" -#include "nvim/func_attr.h" #include "nvim/garray.h" #include "nvim/getchar.h" #include "nvim/gettext.h" diff --git a/src/nvim/keycodes.c b/src/nvim/keycodes.c index 745500fe39..49ec245359 100644 --- a/src/nvim/keycodes.c +++ b/src/nvim/keycodes.c @@ -10,7 +10,6 @@ #include "nvim/charset.h" #include "nvim/eval/typval_defs.h" #include "nvim/eval/vars.h" -#include "nvim/func_attr.h" #include "nvim/gettext.h" #include "nvim/globals.h" #include "nvim/keycodes.h" diff --git a/src/nvim/lib/queue.h b/src/nvim/lib/queue.h index 40769e44b5..0c4ab7e9ed 100644 --- a/src/nvim/lib/queue.h +++ b/src/nvim/lib/queue.h @@ -44,22 +44,29 @@ typedef struct _queue { } // ffi.cdef is unable to swallow `bool` in place of `int` here. +static inline int QUEUE_EMPTY(const QUEUE *q) + REAL_FATTR_ALWAYS_INLINE REAL_FATTR_PURE REAL_FATTR_WARN_UNUSED_RESULT; + static inline int QUEUE_EMPTY(const QUEUE *const q) - FUNC_ATTR_ALWAYS_INLINE FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT { return q == q->next; } #define QUEUE_HEAD(q) (q)->next -static inline void QUEUE_INIT(QUEUE *const q) FUNC_ATTR_ALWAYS_INLINE +static inline void QUEUE_INIT(QUEUE *q) + REAL_FATTR_ALWAYS_INLINE; + +static inline void QUEUE_INIT(QUEUE *const q) { q->next = q; q->prev = q; } +static inline void QUEUE_ADD(QUEUE *h, QUEUE *n) + REAL_FATTR_ALWAYS_INLINE; + static inline void QUEUE_ADD(QUEUE *const h, QUEUE *const n) - FUNC_ATTR_ALWAYS_INLINE { h->prev->next = n->next; n->next->prev = h->prev; @@ -67,8 +74,10 @@ static inline void QUEUE_ADD(QUEUE *const h, QUEUE *const n) h->prev->next = h; } +static inline void QUEUE_INSERT_HEAD(QUEUE *h, QUEUE *q) + REAL_FATTR_ALWAYS_INLINE; + static inline void QUEUE_INSERT_HEAD(QUEUE *const h, QUEUE *const q) - FUNC_ATTR_ALWAYS_INLINE { q->next = h->next; q->prev = h; @@ -76,8 +85,10 @@ static inline void QUEUE_INSERT_HEAD(QUEUE *const h, QUEUE *const q) h->next = q; } +static inline void QUEUE_INSERT_TAIL(QUEUE *h, QUEUE *q) + REAL_FATTR_ALWAYS_INLINE; + static inline void QUEUE_INSERT_TAIL(QUEUE *const h, QUEUE *const q) - FUNC_ATTR_ALWAYS_INLINE { q->next = h; q->prev = h->prev; @@ -85,7 +96,10 @@ static inline void QUEUE_INSERT_TAIL(QUEUE *const h, QUEUE *const q) h->prev = q; } -static inline void QUEUE_REMOVE(QUEUE *const q) FUNC_ATTR_ALWAYS_INLINE +static inline void QUEUE_REMOVE(QUEUE *q) + REAL_FATTR_ALWAYS_INLINE; + +static inline void QUEUE_REMOVE(QUEUE *const q) { q->prev->next = q->next; q->next->prev = q->prev; diff --git a/src/nvim/log.c b/src/nvim/log.c index aeee088cd3..a93dab6238 100644 --- a/src/nvim/log.c +++ b/src/nvim/log.c @@ -19,7 +19,6 @@ #include "auto/config.h" #include "nvim/ascii_defs.h" #include "nvim/eval.h" -#include "nvim/func_attr.h" #include "nvim/globals.h" #include "nvim/log.h" #include "nvim/memory.h" diff --git a/src/nvim/lua/converter.c b/src/nvim/lua/converter.c index 4598d48c4a..fd2bdbd677 100644 --- a/src/nvim/lua/converter.c +++ b/src/nvim/lua/converter.c @@ -16,7 +16,6 @@ #include "nvim/eval/typval_defs.h" #include "nvim/eval/typval_encode.h" #include "nvim/eval/userfunc.h" -#include "nvim/func_attr.h" #include "nvim/gettext.h" #include "nvim/lua/converter.h" #include "nvim/lua/executor.h" diff --git a/src/nvim/lua/spell.c b/src/nvim/lua/spell.c index c261c5105e..e6c38ea9cb 100644 --- a/src/nvim/lua/spell.c +++ b/src/nvim/lua/spell.c @@ -15,10 +15,11 @@ #include "nvim/spell.h" #ifdef INCLUDE_GENERATED_DECLARATIONS -# include "lua/spell.c.generated.h" // IWYU pragma: export +# include "lua/spell.c.generated.h" #endif int nlua_spell_check(lua_State *lstate) + FUNC_ATTR_NONNULL_ALL { if (lua_gettop(lstate) < 1) { return luaL_error(lstate, "Expected 1 argument"); @@ -99,6 +100,7 @@ static const luaL_Reg spell_functions[] = { }; int luaopen_spell(lua_State *L) + FUNC_ATTR_NONNULL_ALL { lua_newtable(L); luaL_register(L, NULL, spell_functions); diff --git a/src/nvim/lua/stdlib.c b/src/nvim/lua/stdlib.c index 33770b2e62..d7a7abe3c8 100644 --- a/src/nvim/lua/stdlib.c +++ b/src/nvim/lua/stdlib.c @@ -22,7 +22,6 @@ #include "nvim/eval/vars.h" #include "nvim/ex_eval.h" #include "nvim/fold.h" -#include "nvim/func_attr.h" #include "nvim/globals.h" #include "nvim/lua/base64.h" #include "nvim/lua/converter.h" diff --git a/src/nvim/main.c b/src/nvim/main.c index 6585bd1df7..937035eace 100644 --- a/src/nvim/main.c +++ b/src/nvim/main.c @@ -26,7 +26,6 @@ #include "nvim/ascii_defs.h" #include "nvim/autocmd.h" #include "nvim/buffer.h" -#include "nvim/buffer_defs.h" #include "nvim/channel.h" #include "nvim/decoration.h" #include "nvim/decoration_provider.h" @@ -42,9 +41,9 @@ #include "nvim/ex_cmds.h" #include "nvim/ex_docmd.h" #include "nvim/ex_getln.h" +#include "nvim/extmark.h" #include "nvim/fileio.h" #include "nvim/fold.h" -#include "nvim/func_attr.h" #include "nvim/garray.h" #include "nvim/getchar.h" #include "nvim/gettext.h" @@ -97,6 +96,7 @@ #include "nvim/version.h" #include "nvim/vim_defs.h" #include "nvim/window.h" +#include "nvim/winfloat.h" #ifdef MSWIN # include "nvim/os/os_win_console.h" #endif diff --git a/src/nvim/mapping.c b/src/nvim/mapping.c index 17593a9121..56544a9956 100644 --- a/src/nvim/mapping.c +++ b/src/nvim/mapping.c @@ -24,7 +24,6 @@ #include "nvim/eval/typval_defs.h" #include "nvim/ex_cmds_defs.h" #include "nvim/ex_session.h" -#include "nvim/func_attr.h" #include "nvim/garray.h" #include "nvim/getchar.h" #include "nvim/gettext.h" @@ -143,7 +142,7 @@ mapblock_T *get_buf_maphash_list(int state, int c) /// @param index The index in the maphash[] /// @param buf The buffer to get the maphash from. NULL for global mapblock_T *get_maphash(int index, buf_T *buf) - FUNC_ATTR_PURE + FUNC_ATTR_PURE { if (index >= MAX_MAPHASH) { return NULL; diff --git a/src/nvim/mark.h b/src/nvim/mark.h index 3237ae541e..990be69028 100644 --- a/src/nvim/mark.h +++ b/src/nvim/mark.h @@ -50,9 +50,11 @@ SET_FMARK(&(xfmarkp__->fmark), mark_, fnum_, view_); \ } while (0) +static inline int mark_global_index(char name) + REAL_FATTR_CONST; + /// Convert mark name to the offset static inline int mark_global_index(const char name) - FUNC_ATTR_CONST { return (ASCII_ISUPPER(name) ? (name - 'A') @@ -61,9 +63,11 @@ static inline int mark_global_index(const char name) : -1)); } +static inline int mark_local_index(char name) + REAL_FATTR_CONST; + /// Convert local mark name to the offset static inline int mark_local_index(const char name) - FUNC_ATTR_CONST { return (ASCII_ISLOWER(name) ? (name - 'a') @@ -117,6 +121,9 @@ static inline void clearpos(pos_T *a) a->coladd = 0; } +/// Global marks (marks with file number or name) +EXTERN xfmark_T namedfm[NGLOBALMARKS] INIT( = { 0 }); + #ifdef INCLUDE_GENERATED_DECLARATIONS # include "mark.h.generated.h" #endif diff --git a/src/nvim/mark_defs.h b/src/nvim/mark_defs.h index 67532d030f..04672a5c52 100644 --- a/src/nvim/mark_defs.h +++ b/src/nvim/mark_defs.h @@ -84,6 +84,3 @@ typedef struct xfilemark { } xfmark_T; #define INIT_XFMARK { INIT_FMARK, NULL } - -/// Global marks (marks with file number or name) -EXTERN xfmark_T namedfm[NGLOBALMARKS] INIT( = { 0 }); diff --git a/src/nvim/match.c b/src/nvim/match.c index 0a7c264d4f..7543fb2b9d 100644 --- a/src/nvim/match.c +++ b/src/nvim/match.c @@ -16,7 +16,6 @@ #include "nvim/ex_cmds_defs.h" #include "nvim/ex_docmd.h" #include "nvim/fold.h" -#include "nvim/func_attr.h" #include "nvim/gettext.h" #include "nvim/globals.h" #include "nvim/highlight.h" diff --git a/src/nvim/math.c b/src/nvim/math.c index 96ff1bef10..79e0be691b 100644 --- a/src/nvim/math.c +++ b/src/nvim/math.c @@ -7,10 +7,11 @@ #include "nvim/math.h" #ifdef INCLUDE_GENERATED_DECLARATIONS -# include "math.c.generated.h" // IWYU pragma: export +# include "math.c.generated.h" #endif int xfpclassify(double d) + FUNC_ATTR_CONST { uint64_t m; @@ -29,11 +30,13 @@ int xfpclassify(double d) } int xisinf(double d) + FUNC_ATTR_CONST { return FP_INFINITE == xfpclassify(d); } int xisnan(double d) + FUNC_ATTR_CONST { return FP_NAN == xfpclassify(d); } diff --git a/src/nvim/memline.c b/src/nvim/memline.c index 3c671121b7..5e768839ba 100644 --- a/src/nvim/memline.c +++ b/src/nvim/memline.c @@ -56,7 +56,6 @@ #include "nvim/eval/typval.h" #include "nvim/ex_cmds_defs.h" #include "nvim/fileio.h" -#include "nvim/func_attr.h" #include "nvim/getchar.h" #include "nvim/gettext.h" #include "nvim/globals.h" diff --git a/src/nvim/memory.c b/src/nvim/memory.c index df6c81fe0d..35ae6afde7 100644 --- a/src/nvim/memory.c +++ b/src/nvim/memory.c @@ -16,7 +16,6 @@ #include "nvim/decoration_provider.h" #include "nvim/drawline.h" #include "nvim/eval.h" -#include "nvim/func_attr.h" #include "nvim/gettext.h" #include "nvim/globals.h" #include "nvim/highlight.h" diff --git a/src/nvim/menu.c b/src/nvim/menu.c index 3252a73970..bc850d8961 100644 --- a/src/nvim/menu.c +++ b/src/nvim/menu.c @@ -15,7 +15,6 @@ #include "nvim/eval/typval.h" #include "nvim/ex_cmds_defs.h" #include "nvim/ex_docmd.h" -#include "nvim/func_attr.h" #include "nvim/garray.h" #include "nvim/getchar.h" #include "nvim/gettext.h" diff --git a/src/nvim/message.c b/src/nvim/message.c index 3268ff389a..8d11b793dc 100644 --- a/src/nvim/message.c +++ b/src/nvim/message.c @@ -24,7 +24,6 @@ #include "nvim/ex_cmds_defs.h" #include "nvim/ex_eval.h" #include "nvim/fileio.h" -#include "nvim/func_attr.h" #include "nvim/garray.h" #include "nvim/getchar.h" #include "nvim/gettext.h" diff --git a/src/nvim/mouse.c b/src/nvim/mouse.c index 8fe3864424..7a7b687385 100644 --- a/src/nvim/mouse.c +++ b/src/nvim/mouse.c @@ -15,7 +15,6 @@ #include "nvim/eval/typval.h" #include "nvim/ex_docmd.h" #include "nvim/fold.h" -#include "nvim/func_attr.h" #include "nvim/getchar.h" #include "nvim/globals.h" #include "nvim/grid.h" diff --git a/src/nvim/move.c b/src/nvim/move.c index 9ed3978490..227d064a27 100644 --- a/src/nvim/move.c +++ b/src/nvim/move.c @@ -22,7 +22,6 @@ #include "nvim/eval/typval.h" #include "nvim/eval/window.h" #include "nvim/fold.h" -#include "nvim/func_attr.h" #include "nvim/getchar.h" #include "nvim/gettext.h" #include "nvim/globals.h" diff --git a/src/nvim/msgpack_rpc/channel.c b/src/nvim/msgpack_rpc/channel.c index 0fb1ebf931..50210e4936 100644 --- a/src/nvim/msgpack_rpc/channel.c +++ b/src/nvim/msgpack_rpc/channel.c @@ -20,7 +20,6 @@ #include "nvim/event/rstream.h" #include "nvim/event/stream.h" #include "nvim/event/wstream.h" -#include "nvim/func_attr.h" #include "nvim/globals.h" #include "nvim/log.h" #include "nvim/main.h" diff --git a/src/nvim/msgpack_rpc/helpers.c b/src/nvim/msgpack_rpc/helpers.c index 1fdfc9e536..d2be321e7a 100644 --- a/src/nvim/msgpack_rpc/helpers.c +++ b/src/nvim/msgpack_rpc/helpers.c @@ -10,7 +10,6 @@ #include "msgpack/pack.h" #include "nvim/api/private/helpers.h" #include "nvim/assert_defs.h" -#include "nvim/func_attr.h" #include "nvim/memory.h" #include "nvim/msgpack_rpc/helpers.h" #include "nvim/types_defs.h" diff --git a/src/nvim/msgpack_rpc/server.c b/src/nvim/msgpack_rpc/server.c index f3627eaa61..e60c1b88a5 100644 --- a/src/nvim/msgpack_rpc/server.c +++ b/src/nvim/msgpack_rpc/server.c @@ -7,7 +7,6 @@ #include "nvim/channel.h" #include "nvim/eval.h" #include "nvim/event/socket.h" -#include "nvim/func_attr.h" #include "nvim/garray.h" #include "nvim/log.h" #include "nvim/main.h" diff --git a/src/nvim/normal.c b/src/nvim/normal.c index 1f789dc153..8083bb00f5 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -34,7 +34,6 @@ #include "nvim/ex_getln.h" #include "nvim/fileio.h" #include "nvim/fold.h" -#include "nvim/func_attr.h" #include "nvim/getchar.h" #include "nvim/gettext.h" #include "nvim/globals.h" diff --git a/src/nvim/ops.h b/src/nvim/ops.h index 67a613cbca..4dab51b15d 100644 --- a/src/nvim/ops.h +++ b/src/nvim/ops.h @@ -102,13 +102,15 @@ typedef enum { YREG_PUT, } yreg_mode_t; +static inline int op_reg_index(int regname) + REAL_FATTR_CONST; + /// Convert register name into register index /// /// @param[in] regname Register name. /// /// @return Index in y_regs array or -1 if register name was not recognized. static inline int op_reg_index(const int regname) - FUNC_ATTR_CONST { if (ascii_isdigit(regname)) { return regname - '0'; @@ -127,11 +129,13 @@ static inline int op_reg_index(const int regname) } } +static inline bool is_literal_register(int regname) + REAL_FATTR_CONST; + /// @see get_yank_register /// @return true when register should be inserted literally /// (selection or clipboard) static inline bool is_literal_register(const int regname) - FUNC_ATTR_CONST { return regname == '*' || regname == '+'; } diff --git a/src/nvim/option.c b/src/nvim/option.c index 96d6d8e01e..882722a575 100644 --- a/src/nvim/option.c +++ b/src/nvim/option.c @@ -49,7 +49,6 @@ #include "nvim/ex_getln.h" #include "nvim/ex_session.h" #include "nvim/fold.h" -#include "nvim/func_attr.h" #include "nvim/garray.h" #include "nvim/gettext.h" #include "nvim/globals.h" diff --git a/src/nvim/optionstr.c b/src/nvim/optionstr.c index 281ec86171..0a7d77e817 100644 --- a/src/nvim/optionstr.c +++ b/src/nvim/optionstr.c @@ -19,7 +19,6 @@ #include "nvim/eval/vars.h" #include "nvim/ex_getln.h" #include "nvim/fold.h" -#include "nvim/func_attr.h" #include "nvim/gettext.h" #include "nvim/globals.h" #include "nvim/highlight_group.h" diff --git a/src/nvim/os/env.c b/src/nvim/os/env.c index 8620c79069..b1e680e469 100644 --- a/src/nvim/os/env.c +++ b/src/nvim/os/env.c @@ -14,7 +14,6 @@ #include "nvim/charset.h" #include "nvim/cmdexpand.h" #include "nvim/eval.h" -#include "nvim/func_attr.h" #include "nvim/gettext.h" #include "nvim/globals.h" #include "nvim/log.h" @@ -46,6 +45,10 @@ # include <sys/utsname.h> #endif +#ifdef INCLUDE_GENERATED_DECLARATIONS +# include "os/env.c.generated.h" +#endif + // Because `uv_os_getenv` requires allocating, we must manage a map to maintain // the behavior of `os_getenv`. static PMap(cstr_t) envmap = MAP_INIT; diff --git a/src/nvim/os/fs.c b/src/nvim/os/fs.c index 8f939c3b40..a8c7fcc38f 100644 --- a/src/nvim/os/fs.c +++ b/src/nvim/os/fs.c @@ -17,7 +17,6 @@ #endif #include "auto/config.h" -#include "nvim/func_attr.h" #include "nvim/os/fs.h" #if defined(HAVE_ACL) diff --git a/src/nvim/os/input.c b/src/nvim/os/input.c index f3bd1c7ed9..b86c51424c 100644 --- a/src/nvim/os/input.c +++ b/src/nvim/os/input.c @@ -12,7 +12,6 @@ #include "nvim/event/multiqueue.h" #include "nvim/event/rstream.h" #include "nvim/event/stream.h" -#include "nvim/func_attr.h" #include "nvim/getchar.h" #include "nvim/gettext.h" #include "nvim/globals.h" diff --git a/src/nvim/os/process.c b/src/nvim/os/process.c index d9ec3a7a8a..5263451488 100644 --- a/src/nvim/os/process.c +++ b/src/nvim/os/process.c @@ -44,7 +44,7 @@ #endif #ifdef INCLUDE_GENERATED_DECLARATIONS -# include "os/process.c.generated.h" // IWYU pragma: export +# include "os/process.c.generated.h" #endif #ifdef MSWIN @@ -114,6 +114,7 @@ bool os_proc_tree_kill(int pid, int sig) /// @param[out] proc_count Number of child processes. /// @return 0 on success, 1 if process not found, 2 on other error. int os_proc_children(int ppid, int **proc_list, size_t *proc_count) + FUNC_ATTR_NONNULL_ALL { if (ppid < 0) { return 2; diff --git a/src/nvim/os/pty_process_unix.c b/src/nvim/os/pty_process_unix.c index f801646967..d4be3086ea 100644 --- a/src/nvim/os/pty_process_unix.c +++ b/src/nvim/os/pty_process_unix.c @@ -35,7 +35,6 @@ #include "nvim/event/loop.h" #include "nvim/event/process.h" #include "nvim/event/stream.h" -#include "nvim/func_attr.h" #include "nvim/log.h" #include "nvim/os/fs.h" #include "nvim/os/os_defs.h" diff --git a/src/nvim/os/shell.c b/src/nvim/os/shell.c index 191be784e8..cb8066a62d 100644 --- a/src/nvim/os/shell.c +++ b/src/nvim/os/shell.c @@ -20,7 +20,6 @@ #include "nvim/event/wstream.h" #include "nvim/ex_cmds.h" #include "nvim/fileio.h" -#include "nvim/func_attr.h" #include "nvim/gettext.h" #include "nvim/globals.h" #include "nvim/macros_defs.h" diff --git a/src/nvim/os/signal.c b/src/nvim/os/signal.c index c920cb655e..3a861b87b4 100644 --- a/src/nvim/os/signal.c +++ b/src/nvim/os/signal.c @@ -9,7 +9,6 @@ #include "nvim/autocmd.h" #include "nvim/eval.h" #include "nvim/event/signal.h" -#include "nvim/func_attr.h" #include "nvim/globals.h" #include "nvim/log.h" #include "nvim/main.h" diff --git a/src/nvim/os/stdpaths.c b/src/nvim/os/stdpaths.c index 7691aa5122..ede17bc7c8 100644 --- a/src/nvim/os/stdpaths.c +++ b/src/nvim/os/stdpaths.c @@ -4,13 +4,16 @@ #include "nvim/ascii_defs.h" #include "nvim/fileio.h" -#include "nvim/func_attr.h" #include "nvim/globals.h" #include "nvim/memory.h" #include "nvim/os/os.h" #include "nvim/os/stdpaths_defs.h" #include "nvim/path.h" +#ifdef INCLUDE_GENERATED_DECLARATIONS +# include "os/stdpaths.c.generated.h" +#endif + /// Names of the environment variables, mapped to XDGVarType values static const char *xdg_env_vars[] = { [kXDGConfigHome] = "XDG_CONFIG_HOME", diff --git a/src/nvim/os/time.c b/src/nvim/os/time.c index 49b43af6c0..7f3e44f680 100644 --- a/src/nvim/os/time.c +++ b/src/nvim/os/time.c @@ -8,7 +8,6 @@ #include "auto/config.h" #include "nvim/event/loop.h" -#include "nvim/func_attr.h" #include "nvim/gettext.h" #include "nvim/globals.h" #include "nvim/log.h" @@ -19,7 +18,7 @@ #include "nvim/os/time.h" #ifdef INCLUDE_GENERATED_DECLARATIONS -# include "os/time.c.generated.h" // IWYU pragma: export +# include "os/time.c.generated.h" #endif /// Gets a high-resolution (nanosecond), monotonically-increasing time relative diff --git a/src/nvim/os/users.c b/src/nvim/os/users.c index ae0994a73f..5db7a19411 100644 --- a/src/nvim/os/users.c +++ b/src/nvim/os/users.c @@ -22,6 +22,10 @@ # include "nvim/message.h" #endif +#ifdef INCLUDE_GENERATED_DECLARATIONS +# include "os/users.c.generated.h" +#endif + // All user names (for ~user completion as done by shell). static garray_T ga_users = GA_EMPTY_INIT_VALUE; diff --git a/src/nvim/path.c b/src/nvim/path.c index c7212c7ade..100d66dfff 100644 --- a/src/nvim/path.c +++ b/src/nvim/path.c @@ -153,7 +153,7 @@ char *path_tail_with_sep(char *fname) /// /// @return The position of the last path separator + 1. const char *invocation_path_tail(const char *invocation, size_t *len) - FUNC_ATTR_NONNULL_RET FUNC_ATTR_NONNULL_ARG(1) + FUNC_ATTR_NONNULL_RET FUNC_ATTR_NONNULL_ARG(1) { const char *tail = get_past_head(invocation); const char *p = tail; diff --git a/src/nvim/plines.c b/src/nvim/plines.c index 6e9f92c193..fbddb1ab4a 100644 --- a/src/nvim/plines.c +++ b/src/nvim/plines.c @@ -10,7 +10,6 @@ #include "nvim/decoration.h" #include "nvim/diff.h" #include "nvim/fold.h" -#include "nvim/func_attr.h" #include "nvim/globals.h" #include "nvim/indent.h" #include "nvim/macros_defs.h" diff --git a/src/nvim/profile.c b/src/nvim/profile.c index 53ff57dacb..543f91304a 100644 --- a/src/nvim/profile.c +++ b/src/nvim/profile.c @@ -15,7 +15,6 @@ #include "nvim/eval/userfunc.h" #include "nvim/ex_cmds_defs.h" #include "nvim/fileio.h" -#include "nvim/func_attr.h" #include "nvim/garray.h" #include "nvim/gettext.h" #include "nvim/globals.h" diff --git a/src/nvim/quickfix.c b/src/nvim/quickfix.c index 4e20eb8925..112f9aa35a 100644 --- a/src/nvim/quickfix.c +++ b/src/nvim/quickfix.c @@ -29,7 +29,6 @@ #include "nvim/ex_getln.h" #include "nvim/fileio.h" #include "nvim/fold.h" -#include "nvim/func_attr.h" #include "nvim/garray.h" #include "nvim/gettext.h" #include "nvim/globals.h" diff --git a/src/nvim/rbuffer.c b/src/nvim/rbuffer.c index f74f68adb6..aff06ee31b 100644 --- a/src/nvim/rbuffer.c +++ b/src/nvim/rbuffer.c @@ -3,13 +3,12 @@ #include <stddef.h> #include <string.h> -#include "nvim/func_attr.h" #include "nvim/macros_defs.h" #include "nvim/memory.h" #include "nvim/rbuffer.h" #ifdef INCLUDE_GENERATED_DECLARATIONS -# include "rbuffer.c.generated.h" // IWYU pragma: export +# include "rbuffer.c.generated.h" #endif /// Creates a new `RBuffer` instance. @@ -214,7 +213,7 @@ size_t rbuffer_read(RBuffer *buf, char *dst, size_t dst_size) } char *rbuffer_get(RBuffer *buf, size_t index) - FUNC_ATTR_NONNULL_ALL FUNC_ATTR_NONNULL_RET + FUNC_ATTR_NONNULL_ALL FUNC_ATTR_NONNULL_RET { assert(index < buf->size); char *rptr = buf->read_ptr + index; diff --git a/src/nvim/regexp.c b/src/nvim/regexp.c index 3536196a3b..20c06340be 100644 --- a/src/nvim/regexp.c +++ b/src/nvim/regexp.c @@ -21,7 +21,6 @@ #include "nvim/eval.h" #include "nvim/eval/typval.h" #include "nvim/eval/userfunc.h" -#include "nvim/func_attr.h" #include "nvim/garray.h" #include "nvim/gettext.h" #include "nvim/globals.h" diff --git a/src/nvim/runtime.c b/src/nvim/runtime.c index 38d3942126..087c26a46f 100644 --- a/src/nvim/runtime.c +++ b/src/nvim/runtime.c @@ -26,7 +26,6 @@ #include "nvim/ex_cmds_defs.h" #include "nvim/ex_docmd.h" #include "nvim/ex_eval.h" -#include "nvim/func_attr.h" #include "nvim/garray.h" #include "nvim/getchar.h" #include "nvim/gettext.h" diff --git a/src/nvim/search.c b/src/nvim/search.c index 642219c1e0..a23d27635f 100644 --- a/src/nvim/search.c +++ b/src/nvim/search.c @@ -24,7 +24,6 @@ #include "nvim/ex_getln.h" #include "nvim/fileio.h" #include "nvim/fold.h" -#include "nvim/func_attr.h" #include "nvim/getchar.h" #include "nvim/gettext.h" #include "nvim/globals.h" diff --git a/src/nvim/shada.c b/src/nvim/shada.c index be898142f0..d288c36f65 100644 --- a/src/nvim/shada.c +++ b/src/nvim/shada.c @@ -25,7 +25,6 @@ #include "nvim/ex_cmds.h" #include "nvim/ex_docmd.h" #include "nvim/fileio.h" -#include "nvim/func_attr.h" #include "nvim/garray.h" #include "nvim/gettext.h" #include "nvim/globals.h" diff --git a/src/nvim/sign.c b/src/nvim/sign.c index d05c708d2c..f901f371ce 100644 --- a/src/nvim/sign.c +++ b/src/nvim/sign.c @@ -26,7 +26,6 @@ #include "nvim/ex_docmd.h" #include "nvim/extmark.h" #include "nvim/fold.h" -#include "nvim/func_attr.h" #include "nvim/gettext.h" #include "nvim/globals.h" #include "nvim/highlight.h" @@ -46,6 +45,10 @@ #include "nvim/vim_defs.h" #include "nvim/window.h" +#ifdef INCLUDE_GENERATED_DECLARATIONS +# include "sign.c.generated.h" +#endif + static PMap(cstr_t) sign_map INIT( = MAP_INIT); static kvec_t(Integer) sign_ns INIT( = MAP_INIT); @@ -910,7 +913,7 @@ static dict_T *sign_get_placed_info_dict(MTKey mark) /// Returns information about signs placed in a buffer as list of dicts. list_T *get_buffer_signs(buf_T *buf) - FUNC_ATTR_NONNULL_RET FUNC_ATTR_NONNULL_ALL FUNC_ATTR_WARN_UNUSED_RESULT + FUNC_ATTR_NONNULL_RET FUNC_ATTR_NONNULL_ALL FUNC_ATTR_WARN_UNUSED_RESULT { list_T *const l = tv_list_alloc(kListLenMayKnow); MarkTreeIter itr[1]; diff --git a/src/nvim/spell.c b/src/nvim/spell.c index 905f5c25b4..5065bee347 100644 --- a/src/nvim/spell.c +++ b/src/nvim/spell.c @@ -73,7 +73,6 @@ #include "nvim/ex_cmds.h" #include "nvim/ex_cmds_defs.h" #include "nvim/ex_docmd.h" -#include "nvim/func_attr.h" #include "nvim/garray.h" #include "nvim/gettext.h" #include "nvim/globals.h" diff --git a/src/nvim/spellfile.c b/src/nvim/spellfile.c index 2607fddc31..4aa0508329 100644 --- a/src/nvim/spellfile.c +++ b/src/nvim/spellfile.c @@ -241,7 +241,6 @@ #include "nvim/drawscreen.h" #include "nvim/ex_cmds_defs.h" #include "nvim/fileio.h" -#include "nvim/func_attr.h" #include "nvim/garray.h" #include "nvim/gettext.h" #include "nvim/globals.h" diff --git a/src/nvim/spellsuggest.c b/src/nvim/spellsuggest.c index d9dd28527e..bdac5aa587 100644 --- a/src/nvim/spellsuggest.c +++ b/src/nvim/spellsuggest.c @@ -17,7 +17,6 @@ #include "nvim/eval.h" #include "nvim/eval/typval.h" #include "nvim/fileio.h" -#include "nvim/func_attr.h" #include "nvim/garray.h" #include "nvim/garray_defs.h" #include "nvim/getchar.h" diff --git a/src/nvim/state.c b/src/nvim/state.c index 900eac0826..199003b61c 100644 --- a/src/nvim/state.c +++ b/src/nvim/state.c @@ -26,10 +26,11 @@ #include "nvim/ui.h" #ifdef INCLUDE_GENERATED_DECLARATIONS -# include "state.c.generated.h" // IWYU pragma: export +# include "state.c.generated.h" #endif void state_enter(VimState *s) + FUNC_ATTR_NONNULL_ALL { while (true) { int check_result = s->check ? s->check(s) : 1; @@ -168,6 +169,7 @@ int get_real_state(void) /// The first character represents the major mode, the following ones the minor /// ones. void get_mode(char *buf) + FUNC_ATTR_NONNULL_ALL { int i = 0; diff --git a/src/nvim/strings.c b/src/nvim/strings.c index a439d11818..169909ea56 100644 --- a/src/nvim/strings.c +++ b/src/nvim/strings.c @@ -30,6 +30,10 @@ #include "nvim/types_defs.h" #include "nvim/vim_defs.h" +#ifdef INCLUDE_GENERATED_DECLARATIONS +# include "strings.c.generated.h" +#endif + static const char e_cannot_mix_positional_and_non_positional_str[] = N_("E1500: Cannot mix positional and non-positional arguments: %s"); static const char e_fmt_arg_nr_unused_str[] @@ -461,9 +465,6 @@ char *vim_strchr(const char *const string, const int c) // Sort an array of strings. -#ifdef INCLUDE_GENERATED_DECLARATIONS -# include "strings.c.generated.h" -#endif static int sort_compare(const void *s1, const void *s2) FUNC_ATTR_NONNULL_ALL { diff --git a/src/nvim/strings.h b/src/nvim/strings.h index d717362f87..8478676f13 100644 --- a/src/nvim/strings.h +++ b/src/nvim/strings.h @@ -10,6 +10,10 @@ #include "nvim/os/os_defs.h" #include "nvim/types_defs.h" // IWYU pragma: keep +static inline char *strappend(char *dst, const char *src) + REAL_FATTR_ALWAYS_INLINE REAL_FATTR_NONNULL_ALL + REAL_FATTR_NONNULL_RET REAL_FATTR_WARN_UNUSED_RESULT; + /// Append string to string and return pointer to the next byte /// /// Unlike strcat, this one does *not* add NUL byte and returns pointer to the @@ -20,8 +24,6 @@ /// /// @return pointer to the byte just past the appended byte. static inline char *strappend(char *const dst, const char *const src) - FUNC_ATTR_ALWAYS_INLINE FUNC_ATTR_NONNULL_ALL FUNC_ATTR_WARN_UNUSED_RESULT - FUNC_ATTR_NONNULL_RET { const size_t src_len = strlen(src); return (char *)memmove(dst, src, src_len) + src_len; diff --git a/src/nvim/syntax.c b/src/nvim/syntax.c index 11282ea170..f6f0fca74a 100644 --- a/src/nvim/syntax.c +++ b/src/nvim/syntax.c @@ -20,7 +20,6 @@ #include "nvim/ex_cmds_defs.h" #include "nvim/ex_docmd.h" #include "nvim/fold.h" -#include "nvim/func_attr.h" #include "nvim/garray.h" #include "nvim/gettext.h" #include "nvim/globals.h" diff --git a/src/nvim/tag.c b/src/nvim/tag.c index c6a1a13606..7fa02d2e0a 100644 --- a/src/nvim/tag.c +++ b/src/nvim/tag.c @@ -23,7 +23,6 @@ #include "nvim/file_search.h" #include "nvim/fileio.h" #include "nvim/fold.h" -#include "nvim/func_attr.h" #include "nvim/garray.h" #include "nvim/gettext.h" #include "nvim/globals.h" diff --git a/src/nvim/terminal.c b/src/nvim/terminal.c index 1527738165..03a7744b18 100644 --- a/src/nvim/terminal.c +++ b/src/nvim/terminal.c @@ -59,7 +59,6 @@ #include "nvim/event/multiqueue.h" #include "nvim/event/time.h" #include "nvim/ex_docmd.h" -#include "nvim/func_attr.h" #include "nvim/getchar.h" #include "nvim/globals.h" #include "nvim/highlight.h" diff --git a/src/nvim/testing.c b/src/nvim/testing.c index cada04d276..6515da7500 100644 --- a/src/nvim/testing.c +++ b/src/nvim/testing.c @@ -12,7 +12,6 @@ #include "nvim/eval/typval.h" #include "nvim/eval/typval_defs.h" #include "nvim/ex_docmd.h" -#include "nvim/func_attr.h" #include "nvim/garray.h" #include "nvim/gettext.h" #include "nvim/globals.h" diff --git a/src/nvim/textformat.c b/src/nvim/textformat.c index b69d438a59..7219e04add 100644 --- a/src/nvim/textformat.c +++ b/src/nvim/textformat.c @@ -14,7 +14,6 @@ #include "nvim/eval.h" #include "nvim/eval/typval_defs.h" #include "nvim/ex_cmds_defs.h" -#include "nvim/func_attr.h" #include "nvim/getchar.h" #include "nvim/globals.h" #include "nvim/indent.h" diff --git a/src/nvim/textobject.c b/src/nvim/textobject.c index d4310d47a4..6e61e9be61 100644 --- a/src/nvim/textobject.c +++ b/src/nvim/textobject.c @@ -11,7 +11,6 @@ #include "nvim/edit.h" #include "nvim/eval/funcs.h" #include "nvim/fold.h" -#include "nvim/func_attr.h" #include "nvim/globals.h" #include "nvim/indent.h" #include "nvim/macros_defs.h" diff --git a/src/nvim/tui/input.c b/src/nvim/tui/input.c index bdbb5e4872..639bfc0f79 100644 --- a/src/nvim/tui/input.c +++ b/src/nvim/tui/input.c @@ -7,7 +7,6 @@ #include "nvim/api/private/defs.h" #include "nvim/api/private/helpers.h" #include "nvim/event/defs.h" -#include "nvim/func_attr.h" #include "nvim/macros_defs.h" #include "nvim/main.h" #include "nvim/map_defs.h" diff --git a/src/nvim/tui/tui.c b/src/nvim/tui/tui.c index 197bbcabb5..c71eb633e9 100644 --- a/src/nvim/tui/tui.c +++ b/src/nvim/tui/tui.c @@ -18,7 +18,6 @@ #include "nvim/event/loop.h" #include "nvim/event/signal.h" #include "nvim/event/stream.h" -#include "nvim/func_attr.h" #include "nvim/globals.h" #include "nvim/grid.h" #include "nvim/highlight_defs.h" @@ -35,8 +34,8 @@ #include "nvim/tui/tui.h" #include "nvim/types_defs.h" #include "nvim/ugrid.h" -#include "nvim/ui.h" #include "nvim/ui_client.h" +#include "nvim/ui_defs.h" #ifdef MSWIN # include "nvim/os/os_win_console.h" diff --git a/src/nvim/tui/tui.h b/src/nvim/tui/tui.h index 8eb4ac9bd8..34a98004f3 100644 --- a/src/nvim/tui/tui.h +++ b/src/nvim/tui/tui.h @@ -3,7 +3,7 @@ #include "nvim/api/private/defs.h" // IWYU pragma: keep #include "nvim/highlight_defs.h" // IWYU pragma: keep #include "nvim/types_defs.h" // IWYU pragma: keep -#include "nvim/ui.h" +#include "nvim/ui_defs.h" // IWYU pragma: keep typedef struct TUIData TUIData; diff --git a/src/nvim/ui.c b/src/nvim/ui.c index 36f34bc75a..07166d229e 100644 --- a/src/nvim/ui.c +++ b/src/nvim/ui.c @@ -1,7 +1,6 @@ #include <assert.h> #include <limits.h> #include <stdbool.h> -#include <stddef.h> #include <stdint.h> #include <stdlib.h> #include <string.h> @@ -37,6 +36,11 @@ #include "nvim/window.h" #include "nvim/winfloat.h" +typedef struct ui_event_callback { + LuaRef cb; + bool ext_widgets[kUIGlobalCount]; +} UIEventCallback; + #ifdef INCLUDE_GENERATED_DECLARATIONS # include "ui.c.generated.h" #endif @@ -692,7 +696,7 @@ void ui_call_event(char *name, Array args) ui_log(name); } -void ui_cb_update_ext(void) +static void ui_cb_update_ext(void) { memset(ui_cb_ext, 0, ARRAY_SIZE(ui_cb_ext)); @@ -708,7 +712,7 @@ void ui_cb_update_ext(void) } } -void free_ui_event_callback(UIEventCallback *event_cb) +static void free_ui_event_callback(UIEventCallback *event_cb) { api_free_luaref(event_cb->cb); xfree(event_cb); diff --git a/src/nvim/ui.h b/src/nvim/ui.h index 666a869c89..f61398a7a0 100644 --- a/src/nvim/ui.h +++ b/src/nvim/ui.h @@ -1,34 +1,16 @@ #pragma once -#include <stdbool.h> -#include <stddef.h> -#include <stdint.h> +#include <stdint.h> // IWYU pragma: keep -#include "nvim/api/private/defs.h" +#include "nvim/api/private/defs.h" // IWYU pragma: keep #include "nvim/event/multiqueue.h" -#include "nvim/globals.h" -#include "nvim/highlight_defs.h" +#include "nvim/grid_defs.h" // IWYU pragma: keep +#include "nvim/highlight_defs.h" // IWYU pragma: keep #include "nvim/macros_defs.h" -#include "nvim/memory.h" -#include "nvim/types_defs.h" - -struct ui_t; - -typedef enum { - kUICmdline = 0, - kUIPopupmenu, - kUITabline, - kUIWildmenu, - kUIMessages, -#define kUIGlobalCount kUILinegrid - kUILinegrid, - kUIMultigrid, - kUIHlState, - kUITermColors, - kUIFloatDebug, - kUIExtCount, -} UIExtension; +#include "nvim/types_defs.h" // IWYU pragma: keep +#include "nvim/ui_defs.h" // IWYU pragma: export +/// Keep in sync with UIExtension in ui_defs.h EXTERN const char *ui_ext_names[] INIT( = { "ext_cmdline", "ext_popupmenu", @@ -42,83 +24,6 @@ EXTERN const char *ui_ext_names[] INIT( = { "_debug_float", }); -typedef struct ui_t UI; - -enum { - kLineFlagWrap = 1, - kLineFlagInvalid = 2, -}; - -typedef int LineFlags; - -typedef struct { - uint64_t channel_id; - -#define UI_BUF_SIZE 4096 ///< total buffer size for pending msgpack data. - /// guaranteed size available for each new event (so packing of simple events - /// and the header of grid_line will never fail) -#define EVENT_BUF_SIZE 256 - char buf[UI_BUF_SIZE]; ///< buffer of packed but not yet sent msgpack data - char *buf_wptr; ///< write head of buffer - const char *cur_event; ///< name of current event (might get multiple arglists) - Array call_buf; ///< buffer for constructing a single arg list (max 16 elements!) - - // state for write_cb, while packing a single arglist to msgpack. This - // might fail due to buffer overflow. - size_t pack_totlen; - bool buf_overflow; - char *temp_buf; - - // We start packing the two outermost msgpack arrays before knowing the total - // number of elements. Thus track the location where array size will need - // to be written in the msgpack buffer, once the specific array is finished. - char *nevents_pos; - char *ncalls_pos; - uint32_t nevents; ///< number of distinct events (top-level args to "redraw" - uint32_t ncalls; ///< number of calls made to the current event (plus one for the name!) - bool flushed_events; ///< events where sent to client without "flush" event - - size_t ncells_pending; ///< total number of cells since last buffer flush - - int hl_id; // Current highlight for legacy put event. - Integer cursor_row, cursor_col; // Intended visible cursor position. - - // Position of legacy cursor, used both for drawing and visible user cursor. - Integer client_row, client_col; - bool wildmenu_active; -} UIData; - -struct ui_t { - bool rgb; - bool override; ///< Force highest-requested UI capabilities. - bool composed; - bool ui_ext[kUIExtCount]; ///< Externalized UI capabilities. - int width; - int height; - int pum_nlines; /// actual nr. lines shown in PUM - bool pum_pos; /// UI reports back pum position? - double pum_row; - double pum_col; - double pum_height; - double pum_width; - - // TUI fields. - char *term_name; - char *term_background; ///< Deprecated. No longer needed since background color detection happens - ///< in Lua. To be removed in a future release. - int term_colors; - bool stdin_tty; - bool stdout_tty; - - // TODO(bfredl): integrate into struct! - UIData data[1]; -}; - -typedef struct ui_event_callback { - LuaRef cb; - bool ext_widgets[kUIGlobalCount]; -} UIEventCallback; - // uncrustify:off #ifdef INCLUDE_GENERATED_DECLARATIONS # include "ui.h.generated.h" diff --git a/src/nvim/ui_client.c b/src/nvim/ui_client.c index 30f44d182d..a7a1c5912a 100644 --- a/src/nvim/ui_client.c +++ b/src/nvim/ui_client.c @@ -11,7 +11,6 @@ #include "nvim/eval.h" #include "nvim/eval/typval_defs.h" #include "nvim/event/loop.h" -#include "nvim/func_attr.h" #include "nvim/globals.h" #include "nvim/highlight.h" #include "nvim/log.h" diff --git a/src/nvim/ui_compositor.h b/src/nvim/ui_compositor.h index f3f5981680..b0dd8e126b 100644 --- a/src/nvim/ui_compositor.h +++ b/src/nvim/ui_compositor.h @@ -1,10 +1,9 @@ #pragma once #include "nvim/api/private/defs.h" // IWYU pragma: keep -#include "nvim/event/defs.h" #include "nvim/grid_defs.h" // IWYU pragma: keep #include "nvim/types_defs.h" // IWYU pragma: keep -#include "nvim/ui.h" +#include "nvim/ui_defs.h" // IWYU pragma: keep #ifdef INCLUDE_GENERATED_DECLARATIONS # include "ui_compositor.h.generated.h" diff --git a/src/nvim/ui_defs.h b/src/nvim/ui_defs.h new file mode 100644 index 0000000000..c4707d4d7c --- /dev/null +++ b/src/nvim/ui_defs.h @@ -0,0 +1,95 @@ +#pragma once + +#include <stdbool.h> +#include <stddef.h> +#include <stdint.h> + +#include "nvim/api/private/defs.h" + +/// Keep in sync with ui_ext_names[] in ui.h +typedef enum { + kUICmdline = 0, + kUIPopupmenu, + kUITabline, + kUIWildmenu, + kUIMessages, +#define kUIGlobalCount kUILinegrid + kUILinegrid, + kUIMultigrid, + kUIHlState, + kUITermColors, + kUIFloatDebug, + kUIExtCount, +} UIExtension; + +enum { + kLineFlagWrap = 1, + kLineFlagInvalid = 2, +}; + +typedef int LineFlags; + +typedef struct ui_t UI; + +typedef struct { + uint64_t channel_id; + +#define UI_BUF_SIZE 4096 ///< total buffer size for pending msgpack data. + /// guaranteed size available for each new event (so packing of simple events + /// and the header of grid_line will never fail) +#define EVENT_BUF_SIZE 256 + char buf[UI_BUF_SIZE]; ///< buffer of packed but not yet sent msgpack data + char *buf_wptr; ///< write head of buffer + const char *cur_event; ///< name of current event (might get multiple arglists) + Array call_buf; ///< buffer for constructing a single arg list (max 16 elements!) + + // state for write_cb, while packing a single arglist to msgpack. This + // might fail due to buffer overflow. + size_t pack_totlen; + bool buf_overflow; + char *temp_buf; + + // We start packing the two outermost msgpack arrays before knowing the total + // number of elements. Thus track the location where array size will need + // to be written in the msgpack buffer, once the specific array is finished. + char *nevents_pos; + char *ncalls_pos; + uint32_t nevents; ///< number of distinct events (top-level args to "redraw" + uint32_t ncalls; ///< number of calls made to the current event (plus one for the name!) + bool flushed_events; ///< events where sent to client without "flush" event + + size_t ncells_pending; ///< total number of cells since last buffer flush + + int hl_id; // Current highlight for legacy put event. + Integer cursor_row, cursor_col; // Intended visible cursor position. + + // Position of legacy cursor, used both for drawing and visible user cursor. + Integer client_row, client_col; + bool wildmenu_active; +} UIData; + +struct ui_t { + bool rgb; + bool override; ///< Force highest-requested UI capabilities. + bool composed; + bool ui_ext[kUIExtCount]; ///< Externalized UI capabilities. + int width; + int height; + int pum_nlines; /// actual nr. lines shown in PUM + bool pum_pos; /// UI reports back pum position? + double pum_row; + double pum_col; + double pum_height; + double pum_width; + + // TUI fields. + char *term_name; + char *term_background; ///< Deprecated. No longer needed since background color detection happens + ///< in Lua. To be removed in a future release. + int term_colors; + bool stdin_tty; + bool stdout_tty; + + // TODO(bfredl): integrate into struct! + UIData data[1]; +}; diff --git a/src/nvim/undo.c b/src/nvim/undo.c index 93a973c33d..928dd2967c 100644 --- a/src/nvim/undo.c +++ b/src/nvim/undo.c @@ -99,7 +99,6 @@ #include "nvim/extmark.h" #include "nvim/fileio.h" #include "nvim/fold.h" -#include "nvim/func_attr.h" #include "nvim/garray.h" #include "nvim/getchar.h" #include "nvim/gettext.h" diff --git a/src/nvim/usercmd.c b/src/nvim/usercmd.c index 7c65af5138..9872468ba9 100644 --- a/src/nvim/usercmd.c +++ b/src/nvim/usercmd.c @@ -16,7 +16,6 @@ #include "nvim/cmdexpand_defs.h" #include "nvim/eval.h" #include "nvim/ex_docmd.h" -#include "nvim/func_attr.h" #include "nvim/garray.h" #include "nvim/gettext.h" #include "nvim/globals.h" diff --git a/src/nvim/version.c b/src/nvim/version.c index cb9088afae..fc93a01b32 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -20,7 +20,6 @@ #include "nvim/charset.h" #include "nvim/drawscreen.h" #include "nvim/ex_cmds_defs.h" -#include "nvim/func_attr.h" #include "nvim/gettext.h" #include "nvim/globals.h" #include "nvim/grid.h" diff --git a/src/nvim/viml/parser/expressions.c b/src/nvim/viml/parser/expressions.c index 8b637fbb9b..11f5276053 100644 --- a/src/nvim/viml/parser/expressions.c +++ b/src/nvim/viml/parser/expressions.c @@ -59,7 +59,6 @@ #include "nvim/assert_defs.h" #include "nvim/charset.h" #include "nvim/eval.h" -#include "nvim/func_attr.h" #include "nvim/gettext.h" #include "nvim/keycodes.h" #include "nvim/macros_defs.h" diff --git a/src/nvim/viml/parser/parser.c b/src/nvim/viml/parser/parser.c index b854aedca6..d8679208c3 100644 --- a/src/nvim/viml/parser/parser.c +++ b/src/nvim/viml/parser/parser.c @@ -5,6 +5,7 @@ #endif void parser_simple_get_line(void *cookie, ParserLine *ret_pline) + FUNC_ATTR_NONNULL_ALL { ParserLine **plines_p = (ParserLine **)cookie; *ret_pline = **plines_p; diff --git a/src/nvim/window.c b/src/nvim/window.c index bcf245ef93..7728efde33 100644 --- a/src/nvim/window.c +++ b/src/nvim/window.c @@ -33,7 +33,6 @@ #include "nvim/file_search.h" #include "nvim/fileio.h" #include "nvim/fold.h" -#include "nvim/func_attr.h" #include "nvim/garray.h" #include "nvim/getchar.h" #include "nvim/gettext.h" diff --git a/src/nvim/winfloat.c b/src/nvim/winfloat.c index 44f0e2fc0b..0eea21eb9d 100644 --- a/src/nvim/winfloat.c +++ b/src/nvim/winfloat.c @@ -9,7 +9,6 @@ #include "nvim/ascii_defs.h" #include "nvim/buffer_defs.h" #include "nvim/drawscreen.h" -#include "nvim/func_attr.h" #include "nvim/globals.h" #include "nvim/grid.h" #include "nvim/macros_defs.h" diff --git a/src/nvim/winfloat.h b/src/nvim/winfloat.h index 876ea9ccea..877a12a9e7 100644 --- a/src/nvim/winfloat.h +++ b/src/nvim/winfloat.h @@ -2,6 +2,17 @@ #include "nvim/api/private/defs.h" // IWYU pragma: keep #include "nvim/buffer_defs.h" // IWYU pragma: keep +#include "nvim/macros_defs.h" + +/// NW -> 0 +/// NE -> kFloatAnchorEast +/// SW -> kFloatAnchorSouth +/// SE -> kFloatAnchorSouth | kFloatAnchorEast +EXTERN const char *const float_anchor_str[] INIT( = { "NW", "NE", "SW", "SE" }); + +/// Keep in sync with FloatRelative in buffer_defs.h +EXTERN const char *const float_relative_str[] +INIT( = { "editor", "win", "cursor", "mouse" }); #ifdef INCLUDE_GENERATED_DECLARATIONS # include "winfloat.h.generated.h" diff --git a/test/functional/terminal/buffer_spec.lua b/test/functional/terminal/buffer_spec.lua index 6fcd029a5b..6d8c214d87 100644 --- a/test/functional/terminal/buffer_spec.lua +++ b/test/functional/terminal/buffer_spec.lua @@ -261,7 +261,6 @@ describe(':terminal buffer', function() end) it('it works with set rightleft #11438', function() - skip(is_os('win')) local columns = eval('&columns') feed(string.rep('a', columns)) command('set rightleft') diff --git a/test/functional/terminal/ex_terminal_spec.lua b/test/functional/terminal/ex_terminal_spec.lua index f628e261a2..77fe57dd94 100644 --- a/test/functional/terminal/ex_terminal_spec.lua +++ b/test/functional/terminal/ex_terminal_spec.lua @@ -141,46 +141,40 @@ describe(':terminal', function() end) end) -describe(':terminal (with fake shell)', function() +local function test_terminal_with_fake_shell(backslash) + -- shell-test.c is a fake shell that prints its arguments and exits. + local shell_path = testprg('shell-test') + if backslash then + shell_path = shell_path:gsub('/', [[\]]) + end + local screen before_each(function() clear() screen = Screen.new(50, 4) screen:attach({rgb=false}) - -- shell-test.c is a fake shell that prints its arguments and exits. - nvim('set_option_value', 'shell', testprg('shell-test'), {}) + nvim('set_option_value', 'shell', shell_path, {}) nvim('set_option_value', 'shellcmdflag', 'EXE', {}) nvim('set_option_value', 'shellxquote', '', {}) end) - -- Invokes `:terminal {cmd}` using a fake shell (shell-test.c) which prints - -- the {cmd} and exits immediately. - -- When no argument is given and the exit code is zero, the terminal buffer - -- closes automatically. - local function terminal_with_fake_shell(cmd) - feed_command("terminal "..(cmd and cmd or "")) - end - it('with no argument, acts like termopen()', function() - skip(is_os('win')) - -- Use the EXIT subcommand to end the process with a non-zero exit code to - -- prevent the buffer from closing automatically - nvim('set_option_value', 'shellcmdflag', 'EXIT', {}) - terminal_with_fake_shell(1) + command('autocmd! nvim_terminal TermClose') + feed_command('terminal') retry(nil, 4 * screen.timeout, function() screen:expect([[ - ^ | - [Process exited 1] | + ^ready $ | + [Process exited 0] | | - :terminal 1 | + :terminal | ]]) end) end) it("with no argument, and 'shell' is set to empty string", function() nvim('set_option_value', 'shell', '', {}) - terminal_with_fake_shell() + feed_command('terminal') screen:expect([[ ^ | ~ | @@ -190,21 +184,19 @@ describe(':terminal (with fake shell)', function() end) it("with no argument, but 'shell' has arguments, acts like termopen()", function() - skip(is_os('win')) - nvim('set_option_value', 'shell', testprg('shell-test')..' -t jeff', {}) - terminal_with_fake_shell() + nvim('set_option_value', 'shell', shell_path ..' INTERACT', {}) + feed_command('terminal') screen:expect([[ - ^jeff $ | - [Process exited 0] | + ^interact $ | + | | :terminal | ]]) end) it('executes a given command through the shell', function() - skip(is_os('win')) command('set shellxquote=') -- win: avoid extra quotes - terminal_with_fake_shell('echo hi') + feed_command('terminal echo hi') screen:expect([[ ^ready $ echo hi | | @@ -214,10 +206,9 @@ describe(':terminal (with fake shell)', function() end) it("executes a given command through the shell, when 'shell' has arguments", function() - skip(is_os('win')) - nvim('set_option_value', 'shell', testprg('shell-test')..' -t jeff', {}) + nvim('set_option_value', 'shell', shell_path ..' -t jeff', {}) command('set shellxquote=') -- win: avoid extra quotes - terminal_with_fake_shell('echo hi') + feed_command('terminal echo hi') screen:expect([[ ^jeff $ echo hi | | @@ -227,9 +218,8 @@ describe(':terminal (with fake shell)', function() end) it('allows quotes and slashes', function() - skip(is_os('win')) command('set shellxquote=') -- win: avoid extra quotes - terminal_with_fake_shell([[echo 'hello' \ "world"]]) + feed_command([[terminal echo 'hello' \ "world"]]) screen:expect([[ ^ready $ echo 'hello' \ "world" | | @@ -247,31 +237,32 @@ describe(':terminal (with fake shell)', function() end) it('ignores writes if the backing stream closes', function() - terminal_with_fake_shell() - feed('iiXXXXXXX') - poke_eventloop() - -- Race: Though the shell exited (and streams were closed by SIGCHLD - -- handler), :terminal cleanup is pending on the main-loop. - -- This write should be ignored (not crash, #5445). - feed('iiYYYYYYY') - assert_alive() + command('autocmd! nvim_terminal TermClose') + feed_command('terminal') + feed('iiXXXXXXX') + poke_eventloop() + -- Race: Though the shell exited (and streams were closed by SIGCHLD + -- handler), :terminal cleanup is pending on the main-loop. + -- This write should be ignored (not crash, #5445). + feed('iiYYYYYYY') + assert_alive() end) it('works with findfile()', function() + command('autocmd! nvim_terminal TermClose') feed_command('terminal') eq('term://', string.match(eval('bufname("%")'), "^term://")) eq('scripts/shadacat.py', eval('findfile("scripts/shadacat.py", ".")')) end) it('works with :find', function() - skip(is_os('win')) - nvim('set_option_value', 'shellcmdflag', 'EXIT', {}) - terminal_with_fake_shell(1) + command('autocmd! nvim_terminal TermClose') + feed_command('terminal') screen:expect([[ - ^ | - [Process exited 1] | + ^ready $ | + [Process exited 0] | | - :terminal 1 | + :terminal | ]]) eq('term://', string.match(eval('bufname("%")'), "^term://")) feed([[<C-\><C-N>]]) @@ -284,9 +275,8 @@ describe(':terminal (with fake shell)', function() end) it('works with gf', function() - skip(is_os('win')) command('set shellxquote=') -- win: avoid extra quotes - terminal_with_fake_shell([[echo "scripts/shadacat.py"]]) + feed_command([[terminal echo "scripts/shadacat.py"]]) retry(nil, 4 * screen.timeout, function() screen:expect([[ ^ready $ echo "scripts/shadacat.py" | @@ -311,4 +301,13 @@ describe(':terminal (with fake shell)', function() terminal]]) end end) +end + +describe(':terminal (with fake shell)', function() + test_terminal_with_fake_shell(false) + if is_os('win') then + describe("when 'shell' uses backslashes", function() + test_terminal_with_fake_shell(true) + end) + end end) diff --git a/test/functional/terminal/scrollback_spec.lua b/test/functional/terminal/scrollback_spec.lua index 1e278e4cff..d687dff230 100644 --- a/test/functional/terminal/scrollback_spec.lua +++ b/test/functional/terminal/scrollback_spec.lua @@ -600,21 +600,24 @@ describe("pending scrollback line handling", function() assert_alive() end) - it("does not crash after nvim_buf_call #14891", function() - skip(is_os('win')) - exec_lua [[ + it('does not crash after nvim_buf_call #14891', function() + exec_lua([[ local bufnr = vim.api.nvim_create_buf(false, true) + local args = ... vim.api.nvim_buf_call(bufnr, function() - vim.fn.termopen({"echo", ("hi\n"):rep(11)}) + vim.fn.termopen(args) end) vim.api.nvim_win_set_buf(0, bufnr) - vim.cmd("startinsert") - ]] + vim.cmd('startinsert') + ]], is_os('win') + and {'cmd.exe', '/c', 'for /L %I in (1,1,12) do @echo hi'} + or {'printf', ('hi\n'):rep(12)} + ) screen:expect [[ hi | hi | hi | - | + hi | | [Process exited 0]{2: } | {3:-- TERMINAL --} | |