Skip to content

Commit dfcfc65

Browse files
refactor(ex.lsp.null_ls)!: Rename ex.lsp.null_ls to ex.lsp.none_ls
1 parent eaa09f0 commit dfcfc65

File tree

4 files changed

+30
-28
lines changed

4 files changed

+30
-28
lines changed

Makefile

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ LUALINE=$(START)/nvim-lspconfig
1818

1919
# Specific for components:
2020
LSPCONFIG=$(START)/lualine.nvim
21-
NULL_LS=$(START)/null-ls.nvim
21+
NONE_LS=$(START)/none-ls.nvim
2222
# ====================
2323

2424
define HELP
@@ -74,7 +74,7 @@ install:
7474
@[ -d $(DEVICONS) ] || git clone --depth 1 https://github.com/nvim-tree/nvim-web-devicons $(DEVICONS)
7575
@[ -d $(LSPCONFIG) ] || git clone --depth 1 https://github.com/neovim/nvim-lspconfig $(LSPCONFIG)
7676
@[ -d $(LUALINE) ] || git clone --depth 1 https://github.com/nvim-lualine/lualine.nvim $(LUALINE)
77-
@[ -d $(NULL_LS) ] || git clone --depth 1 https://github.com/nvimtools/none-ls.nvim $(NULL_LS)
77+
@[ -d $(NONE_LS) ] || git clone --depth 1 https://github.com/nvimtools/none-ls.nvim $(NONE_LS)
7878
ifdef plugin
7979
@[ -d $(START)/$(notdir $(plugin)) ] || git clone --depth 1 https://github.com/$(plugin) $(START)/$(notdir $(plugin))
8080
endif

README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ for `lualine.nvim` with additional components.
1818
- [ex.git.branch](#exgitbranch)
1919
- [ex.lsp.single](#exlspsingle)
2020
- [ex.lsp.all](#exlspall)
21-
- [ex.lsp.null_ls](#exlspnull_ls)
21+
- [ex.lsp.none_ls](#exlspnone_ls)
2222
- [🛠️ Tools](#tools)
2323

2424
## 📥 <a name="installation">Installation</a>
@@ -500,7 +500,7 @@ on_click = function(clicks, button, modified)
500500
end
501501
```
502502

503-
### ex.lsp.null_ls
503+
### ex.lsp.none_ls
504504

505505
This component shows names of the
506506
[null-ls](https://github.com/nvimtools/none-ls.nvim) sources according to the specified
@@ -512,7 +512,7 @@ duplicated names are merged.
512512
sections = {
513513
lualine_a = {
514514
{
515-
'ex.lsp.null_ls',
515+
'ex.lsp.none_ls',
516516

517517
-- The table or function that returns the table with the source query.
518518
-- By default it shows only actual sorces. To show all registered sources

lua/lualine/components/ex/lsp/null_ls.lua lua/lualine/components/ex/lsp/none_ls.lua

+17-15
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
1-
local log = require('plenary.log').new({ plugin = 'ex.lsp.null-ls' })
1+
local log = require('plenary.log').new({ plugin = 'ex.lsp.none-ls' })
22

33
-- we should be ready to three possible cases:
4-
-- * when null-ls is not loaded we should load it only on demand;
5-
-- * when null-ls is not installed we should mock it to avoid errors;
4+
-- * when none-ls is not loaded we should load it only on demand;
5+
-- * when none-ls is not installed we should mock it to avoid errors;
66
-- * when it is installed and loaded we should use it.
7-
local null_ls = setmetatable({}, {
7+
local none_ls = setmetatable({}, {
88
__index = function(self, key)
9-
-- attempt to lazy load null-ls plugin
9+
-- attempt to lazy load none-ls plugin
1010
if rawget(self, 'is_installed') == nil then
11-
local is_installed, null_ls = pcall(require, 'null-ls')
11+
-- null-ls is old name of the none-ls plugin,
12+
-- which is still used for back compatibility
13+
local is_installed, none_ls = pcall(require, 'null-ls')
1214
rawset(self, 'is_installed', is_installed)
13-
rawset(self, 'null_ls', null_ls)
15+
rawset(self, 'none_ls', none_ls)
1416
if is_installed then
1517
log.debug('none-ls is installed')
1618
else
@@ -19,7 +21,7 @@ local null_ls = setmetatable({}, {
1921
end
2022
-- return original plugin if it's installed
2123
if rawget(self, 'is_installed') then
22-
return rawget(self, 'null_ls')[key]
24+
return rawget(self, 'none_ls')[key]
2325
end
2426
-- return mock:
2527
if key == 'get_source' then
@@ -36,19 +38,19 @@ local null_ls = setmetatable({}, {
3638
end,
3739
})
3840

39-
local NullLS = require('lualine.ex.component'):extend({
41+
local NoneLS = require('lualine.ex.component'):extend({
4042
icon = '',
4143
query = function()
4244
return { filetype = vim.bo.filetype }
4345
end,
44-
component_name = 'ex_lsp_null_ls',
46+
component_name = 'ex_lsp_none_ls',
4547
source_names_separator = ',',
4648
is_enabled = function(component)
47-
return null_ls.is_registered(component:get_query())
49+
return none_ls.is_registered(component:get_query())
4850
end,
4951
})
5052

51-
function NullLS:get_query()
53+
function NoneLS:get_query()
5254
if type(self.options.query) == 'function' then
5355
return self.options.query()
5456
else
@@ -57,8 +59,8 @@ function NullLS:get_query()
5759
end
5860

5961
-- get sources by query, and concatenate their unique names with {source_names_separator}
60-
function NullLS:update_status()
61-
local sources = null_ls.get_source(self:get_query())
62+
function NoneLS:update_status()
63+
local sources = none_ls.get_source(self:get_query())
6264
log.fmt_debug(
6365
'For query %s was found sources: %s',
6466
vim.inspect(self.options.query),
@@ -77,4 +79,4 @@ function NullLS:update_status()
7779
return table.concat(names, self.options.source_names_separator)
7880
end
7981

80-
return NullLS
82+
return NoneLS

tests/components/null_ls_spec.lua tests/components/none_ls_spec.lua

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
1-
local null_ls = require('null-ls')
1+
local none_ls = require('null-ls')
22
local l = require('tests.ex.lualine')
33
local t = require('tests.ex.busted') --:ignore_all_tests()
44

55
local eq = assert.are.equal
66

7-
local component_name = 'ex.lsp.null_ls'
7+
local component_name = 'ex.lsp.none_ls'
88
describe(component_name, function()
9-
null_ls.setup({
9+
none_ls.setup({
1010
sources = {
11-
null_ls.builtins.completion.spell,
12-
null_ls.builtins.formatting.stylua,
13-
null_ls.builtins.hover.dictionary,
14-
null_ls.builtins.diagnostics.clang_check,
11+
none_ls.builtins.completion.spell,
12+
none_ls.builtins.formatting.stylua,
13+
none_ls.builtins.hover.dictionary,
14+
none_ls.builtins.diagnostics.clang_check,
1515
},
1616
})
1717
describe('draw method', function()
@@ -38,7 +38,7 @@ describe(component_name, function()
3838
end)
3939
end)
4040
it('should show names only of sources sutisfied to the query', function()
41-
local opts = { query = { method = null_ls.methods.HOVER } }
41+
local opts = { query = { method = none_ls.methods.HOVER } }
4242
l.test_matched_component(component_name, opts, function(ctbl)
4343
eq('dictionary', ctbl.value)
4444
end)

0 commit comments

Comments
 (0)