diff options
| author | Abouzar Parvan <[email protected]> | 2021-07-30 23:14:25 +0430 | 
|---|---|---|
| committer | GitHub <[email protected]> | 2021-07-30 14:44:25 -0400 | 
| commit | ce8c63c6bf99bc5d8be5fc6c8db6023318791ac2 (patch) | |
| tree | 433da248fc3e01ee2d541d873abad56d9310e5cf /lua/core | |
| parent | 176106f2234ef7807918b0c131bbd70df3e7c562 (diff) | |
Fix the galaxyline null pointer issue (#1179)
Diffstat (limited to 'lua/core')
| -rw-r--r-- | lua/core/galaxyline.lua | 25 | 
1 files changed, 22 insertions, 3 deletions
| diff --git a/lua/core/galaxyline.lua b/lua/core/galaxyline.lua index aafe99bc..cf7d35d0 100644 --- a/lua/core/galaxyline.lua +++ b/lua/core/galaxyline.lua @@ -200,19 +200,38 @@ table.insert(gls.right, {    },  }) +-- TODO: this function doesn't need to be this complicated  local function get_attached_provider_name(msg)    msg = msg or "LSP Inactive" -    local buf_ft = vim.bo.filetype    local buf_clients = vim.lsp.buf_get_clients()    if next(buf_clients) == nil then      return msg    end + +  local utils = require "utils" +  local config = require("null-ls.config").get() +  local builtins = require "null-ls.builtins" +  -- concat all the builtin formatters and linters from null-ls +  local all_things = builtins.formatting +  for k, v in pairs(builtins.diagnostics) do +    all_things[k] = v +  end + +  -- if we open multiple filetypes in the same session +  -- null-ls will register multiple formatter/linters +  -- but only use the ones that support vim.bo.filetype +  -- so we need to filter them    local buf_client_names = {}    for _, client in pairs(buf_clients) do      if client.name == "null-ls" then -      table.insert(buf_client_names, lvim.lang[buf_ft].linters[1]) -      table.insert(buf_client_names, lvim.lang[buf_ft].formatter.exe) +      -- for every registered formatter/linter in the current buffer +      for _, v in pairs(config._names) do +        -- show only the ones that are being used for the current filetype +        if utils.has_value(all_things[v].filetypes, buf_ft) then +          table.insert(buf_client_names, v) +        end +      end      else        table.insert(buf_client_names, client.name)      end | 
