From ce8c63c6bf99bc5d8be5fc6c8db6023318791ac2 Mon Sep 17 00:00:00 2001 From: Abouzar Parvan Date: Fri, 30 Jul 2021 23:14:25 +0430 Subject: Fix the galaxyline null pointer issue (#1179) --- lua/core/galaxyline.lua | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) (limited to 'lua/core/galaxyline.lua') 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 -- cgit v1.2.3 From 9d89929d9bb47d1f78c2d3945b761da2f24a5643 Mon Sep 17 00:00:00 2001 From: kylo252 <59826753+kylo252@users.noreply.github.com> Date: Sat, 31 Jul 2021 06:06:08 +0200 Subject: Enable querying lang-server formatting capabilities (#1078) --- lua/core/galaxyline.lua | 30 +++++++++--------------------- 1 file changed, 9 insertions(+), 21 deletions(-) (limited to 'lua/core/galaxyline.lua') diff --git a/lua/core/galaxyline.lua b/lua/core/galaxyline.lua index cf7d35d0..2aae0242 100644 --- a/lua/core/galaxyline.lua +++ b/lua/core/galaxyline.lua @@ -6,6 +6,8 @@ if not status_ok then return end +local utils = require "utils" + -- NOTE: if someone defines colors but doesn't have them then this will break local palette_status_ok, colors = pcall(require, lvim.colorscheme .. ".palette") if not palette_status_ok then @@ -200,36 +202,22 @@ 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_ft = vim.bo.filetype local buf_client_names = {} + local null_ls_providers = require("lsp.null-ls").requested_providers for _, client in pairs(buf_clients) do if client.name == "null-ls" then - -- 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) + for _, provider in pairs(null_ls_providers) do + if vim.tbl_contains(provider.filetypes, buf_ft) then + if not vim.tbl_contains(buf_client_names, provider.name) then + table.insert(buf_client_names, provider.name) + end end end else -- cgit v1.2.3 From 2db171eee417de8916237c053244d7a44deac5c1 Mon Sep 17 00:00:00 2001 From: Abouzar Parvan Date: Sat, 31 Jul 2021 12:15:01 +0430 Subject: fix luacheck issues (#1184) --- lua/core/galaxyline.lua | 2 -- 1 file changed, 2 deletions(-) (limited to 'lua/core/galaxyline.lua') diff --git a/lua/core/galaxyline.lua b/lua/core/galaxyline.lua index 2aae0242..63cffcf9 100644 --- a/lua/core/galaxyline.lua +++ b/lua/core/galaxyline.lua @@ -6,8 +6,6 @@ if not status_ok then return end -local utils = require "utils" - -- NOTE: if someone defines colors but doesn't have them then this will break local palette_status_ok, colors = pcall(require, lvim.colorscheme .. ".palette") if not palette_status_ok then -- cgit v1.2.3 From 8157f50d1308f42f3db1c7f69c226eb2e5c0b796 Mon Sep 17 00:00:00 2001 From: kylo252 <59826753+kylo252@users.noreply.github.com> Date: Sat, 31 Jul 2021 15:04:22 +0200 Subject: feat: get null-ls registered providers by filetype (#1186) --- lua/core/galaxyline.lua | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) (limited to 'lua/core/galaxyline.lua') diff --git a/lua/core/galaxyline.lua b/lua/core/galaxyline.lua index 63cffcf9..b2325b19 100644 --- a/lua/core/galaxyline.lua +++ b/lua/core/galaxyline.lua @@ -203,25 +203,19 @@ table.insert(gls.right, { local function get_attached_provider_name(msg) msg = msg or "LSP Inactive" local buf_clients = vim.lsp.buf_get_clients() + local utils = require "utils" if next(buf_clients) == nil then return msg end local buf_ft = vim.bo.filetype local buf_client_names = {} - local null_ls_providers = require("lsp.null-ls").requested_providers + local null_ls_providers = require("lsp.null-ls").get_registered_providers_by_filetype(buf_ft) for _, client in pairs(buf_clients) do - if client.name == "null-ls" then - for _, provider in pairs(null_ls_providers) do - if vim.tbl_contains(provider.filetypes, buf_ft) then - if not vim.tbl_contains(buf_client_names, provider.name) then - table.insert(buf_client_names, provider.name) - end - end - end - else + if client.name ~= "null-ls" then table.insert(buf_client_names, client.name) end end + utils.list_extend_unique(buf_client_names, null_ls_providers) return table.concat(buf_client_names, ", ") end -- cgit v1.2.3 From 990bb622e0a7f90881a6016570c6f205499b1c0d Mon Sep 17 00:00:00 2001 From: kylo252 <59826753+kylo252@users.noreply.github.com> Date: Fri, 6 Aug 2021 10:39:08 +0200 Subject: chore: remove now-redundant utility function --- lua/core/galaxyline.lua | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'lua/core/galaxyline.lua') diff --git a/lua/core/galaxyline.lua b/lua/core/galaxyline.lua index b2325b19..d3f9342b 100644 --- a/lua/core/galaxyline.lua +++ b/lua/core/galaxyline.lua @@ -203,7 +203,6 @@ table.insert(gls.right, { local function get_attached_provider_name(msg) msg = msg or "LSP Inactive" local buf_clients = vim.lsp.buf_get_clients() - local utils = require "utils" if next(buf_clients) == nil then return msg end @@ -215,7 +214,7 @@ local function get_attached_provider_name(msg) table.insert(buf_client_names, client.name) end end - utils.list_extend_unique(buf_client_names, null_ls_providers) + vim.list_extend(buf_client_names, null_ls_providers) return table.concat(buf_client_names, ", ") end -- cgit v1.2.3 From 405423108fc31981c40116a827e845a1179c9053 Mon Sep 17 00:00:00 2001 From: kylo252 <59826753+kylo252@users.noreply.github.com> Date: Mon, 9 Aug 2021 19:02:37 +0200 Subject: feat: Add an async logger using plenary (#1207) Co-authored-by: rebuilt --- lua/core/galaxyline.lua | 2 ++ 1 file changed, 2 insertions(+) (limited to 'lua/core/galaxyline.lua') diff --git a/lua/core/galaxyline.lua b/lua/core/galaxyline.lua index d3f9342b..ee0a317d 100644 --- a/lua/core/galaxyline.lua +++ b/lua/core/galaxyline.lua @@ -1,8 +1,10 @@ -- if not package.loaded['galaxyline'] then -- return -- end +local Log = require "core.log" local status_ok, gl = pcall(require, "galaxyline") if not status_ok then + Log:get_default().error "Failed to load galaxyline" return end -- cgit v1.2.3