Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fix integration tutorials on lazy dependency issue #133

Merged
merged 8 commits into from
Apr 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,10 @@ lua require('lsp-progress').setup()

## Integration

> [!IMPORTANT]
>
> Don't directly put `require('lsp-progress').progress` as lualine component or heirline's component provider, wrap it with a function to avoid the dependency issue, see [#131](/~https://github.com/linrongbin16/lsp-progress.nvim/issues/131).

### [lualine.nvim](/~https://github.com/nvim-lualine/lualine.nvim)

```lua
Expand All @@ -248,7 +252,9 @@ require("lualine").setup({
lualine_b = { ... },
lualine_c = {
-- invoke `progress` here.
require('lsp-progress').progress,
function()
return require('lsp-progress').progress()
end,
},
...
}
Expand All @@ -267,7 +273,9 @@ vim.api.nvim_create_autocmd("User", {

```lua
local LspProgress = {
provider = require('lsp-progress').progress,
provider = function()
return require('lsp-progress').progress(),
end,
update = {
'User',
pattern = 'LspProgressStatusUpdated',
Expand All @@ -280,11 +288,9 @@ local LspProgress = {
local StatusLine = {
-- Other StatusLine components
{ ... },
{ ... },

-- Lsp progress status component here
LspProgress,
...
}

require('heirline').setup({
Expand Down
69 changes: 69 additions & 0 deletions minimal_init/minimal_lualine_init.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
-- bootstrap lazy
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
vim.fn.system({
"git",
"clone",
"--filter=blob:none",
"/~https://github.com/folke/lazy.nvim.git",
lazypath,
})
end
vim.opt.runtimepath:prepend(lazypath)

-- install plugins
local plugins = {
{
"nvim-lualine/lualine.nvim",
event = "VimEnter",
dependencies = {
"nvim-tree/nvim-web-devicons",
{
"linrongbin16/lsp-progress.nvim",
opts = {},
},
},
config = function(_, opts)
require("lualine").setup(opts)

vim.api.nvim_create_augroup("lualine_augroup", { clear = true })
vim.api.nvim_create_autocmd("User", {
group = "lualine_augroup",
pattern = "LspProgressStatusUpdated",
callback = require("lualine").refresh,
})
end,
opts = {
options = {
component_separators = { left = "|", right = "|" },
globalstatus = true,
},
sections = {
lualine_a = {
{
"mode",
fmt = function(str)
return str:sub(1, 1)
end,
},
},
lualine_b = {
{ "branch", icons_enabled = false },
},
lualine_c = {
function()
return require("lsp-progress").progress()
end,
},
},
tabline = {
lualine_a = {
"buffers",
},
},
},
},
}

-- Setup lazy.nvim
require("lazy").setup(plugins)
Loading