diff options
author | Christian Clason <c.clason@uni-graz.at> | 2022-07-07 18:27:18 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-07-07 18:27:18 +0200 |
commit | aa4f9c5341f5280f16cce0630ea54b84eef717b3 (patch) | |
tree | 52e82a04b3f364f50b810c92c0e0a3378ccd17a0 /runtime/lua/vim/diagnostic.lua | |
parent | 34d41baf8a8e4ab8c006b7f29a8106e60e311aa2 (diff) | |
download | rneovim-aa4f9c5341f5280f16cce0630ea54b84eef717b3.tar.gz rneovim-aa4f9c5341f5280f16cce0630ea54b84eef717b3.tar.bz2 rneovim-aa4f9c5341f5280f16cce0630ea54b84eef717b3.zip |
refactor(lua): reformat with stylua 0.14.0 (#19264)
* reformat Lua runtime to make lint CI pass
* reduce max line length to 100
Diffstat (limited to 'runtime/lua/vim/diagnostic.lua')
-rw-r--r-- | runtime/lua/vim/diagnostic.lua | 36 |
1 files changed, 21 insertions, 15 deletions
diff --git a/runtime/lua/vim/diagnostic.lua b/runtime/lua/vim/diagnostic.lua index afc0a4095c..07a3c87da0 100644 --- a/runtime/lua/vim/diagnostic.lua +++ b/runtime/lua/vim/diagnostic.lua @@ -68,7 +68,10 @@ local all_namespaces = {} ---@private local function to_severity(severity) if type(severity) == 'string' then - return assert(M.severity[string.upper(severity)], string.format('Invalid severity: %s', severity)) + return assert( + M.severity[string.upper(severity)], + string.format('Invalid severity: %s', severity) + ) end return severity end @@ -277,7 +280,8 @@ local function set_diagnostic_cache(namespace, bufnr, diagnostics) for _, diagnostic in ipairs(diagnostics) do assert(diagnostic.lnum, 'Diagnostic line number is required') assert(diagnostic.col, 'Diagnostic column is required') - diagnostic.severity = diagnostic.severity and to_severity(diagnostic.severity) or M.severity.ERROR + diagnostic.severity = diagnostic.severity and to_severity(diagnostic.severity) + or M.severity.ERROR diagnostic.end_lnum = diagnostic.end_lnum or diagnostic.lnum diagnostic.end_col = diagnostic.end_col or diagnostic.col diagnostic.namespace = namespace @@ -322,13 +326,8 @@ local function save_extmarks(namespace, bufnr) }) diagnostic_attached_buffers[bufnr] = true end - diagnostic_cache_extmarks[bufnr][namespace] = vim.api.nvim_buf_get_extmarks( - bufnr, - namespace, - 0, - -1, - { details = true } - ) + diagnostic_cache_extmarks[bufnr][namespace] = + vim.api.nvim_buf_get_extmarks(bufnr, namespace, 0, -1, { details = true }) end local registered_autocmds = {} @@ -482,7 +481,8 @@ local function next_diagnostic(position, search_forward, bufnr, opts, namespace) bufnr = get_bufnr(bufnr) local wrap = vim.F.if_nil(opts.wrap, true) local line_count = vim.api.nvim_buf_line_count(bufnr) - local diagnostics = get_diagnostics(bufnr, vim.tbl_extend('keep', opts, { namespace = namespace }), true) + local diagnostics = + get_diagnostics(bufnr, vim.tbl_extend('keep', opts, { namespace = namespace }), true) local line_diagnostics = diagnostic_lines(diagnostics) for i = 0, line_count do local offset = i * (search_forward and 1 or -1) @@ -971,7 +971,10 @@ M.handlers.virtual_text = { if opts.virtual_text.format then diagnostics = reformat_diagnostics(opts.virtual_text.format, diagnostics) end - if opts.virtual_text.source and (opts.virtual_text.source ~= 'if_many' or count_sources(bufnr) > 1) then + if + opts.virtual_text.source + and (opts.virtual_text.source ~= 'if_many' or count_sources(bufnr) > 1) + then diagnostics = prefix_source(diagnostics) end if opts.virtual_text.severity then @@ -1279,7 +1282,9 @@ function M.open_float(opts, ...) -- LSP servers can send diagnostics with `end_col` past the length of the line local line_length = #vim.api.nvim_buf_get_lines(bufnr, lnum, lnum + 1, true)[1] diagnostics = vim.tbl_filter(function(d) - return d.lnum == lnum and math.min(d.col, line_length - 1) <= col and (d.end_col >= col or d.end_lnum > lnum) + return d.lnum == lnum + and math.min(d.col, line_length - 1) <= col + and (d.end_col >= col or d.end_lnum > lnum) end, diagnostics) end @@ -1333,9 +1338,10 @@ function M.open_float(opts, ...) diagnostics = prefix_source(diagnostics) end - local prefix_opt = if_nil(opts.prefix, (scope == 'cursor' and #diagnostics <= 1) and '' or function(_, i) - return string.format('%d. ', i) - end) + local prefix_opt = + if_nil(opts.prefix, (scope == 'cursor' and #diagnostics <= 1) and '' or function(_, i) + return string.format('%d. ', i) + end) local prefix, prefix_hl_group if prefix_opt then |