diff options
author | Michael Lingelbach <m.j.lbach@gmail.com> | 2021-09-17 11:31:56 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-09-17 11:31:56 -0700 |
commit | ede5695eb194e9b607421415525177888b447753 (patch) | |
tree | 0d14ccef65029e69c839b9606e4b39a98e4b3971 /runtime/lua/vim/lsp/diagnostic.lua | |
parent | 4d7dcbe49f4a1cd691211e4fd316af51241f6544 (diff) | |
parent | 32c0631183a64925d38a13819db9557f8da02738 (diff) | |
download | rneovim-ede5695eb194e9b607421415525177888b447753.tar.gz rneovim-ede5695eb194e9b607421415525177888b447753.tar.bz2 rneovim-ede5695eb194e9b607421415525177888b447753.zip |
Merge pull request #15696 from gpanders/diagnostic-sign-fix
Diagnostic hot fixes
Diffstat (limited to 'runtime/lua/vim/lsp/diagnostic.lua')
-rw-r--r-- | runtime/lua/vim/lsp/diagnostic.lua | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/runtime/lua/vim/lsp/diagnostic.lua b/runtime/lua/vim/lsp/diagnostic.lua index eef840bee5..41c8bd36ec 100644 --- a/runtime/lua/vim/lsp/diagnostic.lua +++ b/runtime/lua/vim/lsp/diagnostic.lua @@ -52,7 +52,7 @@ end ---@private local function line_byte_from_position(lines, lnum, col, offset_encoding) - if offset_encoding == "utf-8" then + if not lines or offset_encoding == "utf-8" then return col end @@ -73,7 +73,19 @@ local function get_buf_lines(bufnr) local filename = vim.api.nvim_buf_get_name(bufnr) local f = io.open(filename) - local lines = vim.split(f:read("*a"), "\n") + if not f then + return + end + + local content = f:read("*a") + if not content then + -- Some LSP servers report diagnostics at a directory level, in which case + -- io.read() returns nil + f:close() + return + end + + local lines = vim.split(content, "\n") f:close() return lines end @@ -183,10 +195,6 @@ function M.on_publish_diagnostics(_, result, ctx, config) local diagnostics = result.diagnostics if config then - if vim.F.if_nil(config.severity_sort, false) then - table.sort(diagnostics, function(a, b) return a.severity > b.severity end) - end - for _, opt in pairs(config) do if type(opt) == 'table' then if not opt.severity and opt.severity_limit then |