diff options
| author | Lewis Russell <lewis6991@gmail.com> | 2026-09-24 13:30:07 +0100 |
|---|---|---|
| committer | Lewis Russell <me@lewisr.dev> | 2026-09-25 10:28:19 +0100 |
| commit | d7af8707026968887ea4ee3a4e6fa51fd4372033 (patch) | |
| tree | 19cae6c571311bbd5af56575dcc710485568f7b8 /runtime/lua/vim/lsp.lua | |
| parent | f6aac851ddd82db5241a56ddfb9cc9a9aec8f7e5 (diff) | |
| download | rneovim-d7af8707026968887ea4ee3a4e6fa51fd4372033.tar.gz rneovim-d7af8707026968887ea4ee3a4e6fa51fd4372033.tar.bz2 rneovim-d7af8707026968887ea4ee3a4e6fa51fd4372033.zip | |
fix(lua): enable nil-safety diagnostics in runtime code
Enable EmmyLua's need-check-nil diagnostic and resolve nullable values
through more precise types, explicit invariants, and guards for missing
runtime state. Keep analyzer-specific workarounds local and update the
affected API documentation.
Exclude the bundled re.lua from analysis so its nil-check warnings do
not fail CI.
AI-assisted
Diffstat (limited to 'runtime/lua/vim/lsp.lua')
| -rw-r--r-- | runtime/lua/vim/lsp.lua | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/runtime/lua/vim/lsp.lua b/runtime/lua/vim/lsp.lua index d30ab8fd36..1a633924fa 100644 --- a/runtime/lua/vim/lsp.lua +++ b/runtime/lua/vim/lsp.lua @@ -343,6 +343,7 @@ lsp.config = setmetatable({ _configs = {} }, { -- Calls to vim.lsp.config in lsp/* have a lower precedence than calls from other sites. local rtp_config --- @type vim.lsp.Config? for _, v in ipairs(api.nvim_get_runtime_file(('lsp/%s.lua'):format(name), true)) do + --- @diagnostic disable-next-line: need-check-nil EmmyLuaLs/emmylua-analyzer-rust#1259 local config = assert(loadfile(v))() ---@type any? if type(config) == 'table' then --- @type vim.lsp.Config? @@ -1412,7 +1413,7 @@ function lsp.formatexpr(opts) local params = util.make_formatting_params() local method ---@type vim.lsp.protocol.Method.ClientToServer.Request? if client:supports_method('textDocument/rangeFormatting') then - local end_line = vim.fn.getline(end_lnum) --[[@as string]] + local end_line = vim.fn.getline(end_lnum) local end_col = vim.str_utfindex(end_line, client.offset_encoding) --- @cast params +lsp.DocumentRangeFormattingParams params.range = { |