new feature custom lsp progress

This commit is contained in:
asep komarudin 2023-03-03 19:15:17 +07:00
parent 7f02b38730
commit 06f0332a8f
8 changed files with 71 additions and 102 deletions

View file

@ -12,7 +12,6 @@
"cmp_luasnip": { "branch": "master", "commit": "18095520391186d634a0045dacaa346291096566" }, "cmp_luasnip": { "branch": "master", "commit": "18095520391186d634a0045dacaa346291096566" },
"code_runner.nvim": { "branch": "main", "commit": "a010649236fe245eaab2641a13228cd601499715" }, "code_runner.nvim": { "branch": "main", "commit": "a010649236fe245eaab2641a13228cd601499715" },
"dressing.nvim": { "branch": "master", "commit": "5f44f829481640be0f96759c965ae22a3bcaf7ce" }, "dressing.nvim": { "branch": "master", "commit": "5f44f829481640be0f96759c965ae22a3bcaf7ce" },
"fidget.nvim": { "branch": "main", "commit": "688b4fec4517650e29c3e63cfbb6e498b3112ba1" },
"friendly-snippets": { "branch": "main", "commit": "009887b76f15d16f69ae1341f86a7862f61cf2a1" }, "friendly-snippets": { "branch": "main", "commit": "009887b76f15d16f69ae1341f86a7862f61cf2a1" },
"gitsigns.nvim": { "branch": "main", "commit": "bb808fc7376ed7bac0fbe8f47b83d4bf01738167" }, "gitsigns.nvim": { "branch": "main", "commit": "bb808fc7376ed7bac0fbe8f47b83d4bf01738167" },
"impatient.nvim": { "branch": "main", "commit": "969f2c5c90457612c09cf2a13fee1adaa986d350" }, "impatient.nvim": { "branch": "main", "commit": "969f2c5c90457612c09cf2a13fee1adaa986d350" },
@ -20,6 +19,7 @@
"jaq-nvim": { "branch": "master", "commit": "236296aae555657487d1bb4d066cbde9d79d8cd4" }, "jaq-nvim": { "branch": "master", "commit": "236296aae555657487d1bb4d066cbde9d79d8cd4" },
"lazy.nvim": { "branch": "main", "commit": "8d18ef44e769e98a8dc974ca85275de1d8cc7c04" }, "lazy.nvim": { "branch": "main", "commit": "8d18ef44e769e98a8dc974ca85275de1d8cc7c04" },
"live-server": { "branch": "main", "commit": "ecd7c1418823b65dd2bca710587c80afe42c973e" }, "live-server": { "branch": "main", "commit": "ecd7c1418823b65dd2bca710587c80afe42c973e" },
"lsp-progress.nvim": { "branch": "main", "commit": "9c0cf47587ee3cf2c9267ff2296876f214e631e5" },
"lualine.nvim": { "branch": "master", "commit": "e99d733e0213ceb8f548ae6551b04ae32e590c80" }, "lualine.nvim": { "branch": "master", "commit": "e99d733e0213ceb8f548ae6551b04ae32e590c80" },
"lunar.nvim": { "branch": "master", "commit": "29eedf78c430ad9acebdcba814d77619edbe2bac" }, "lunar.nvim": { "branch": "master", "commit": "29eedf78c430ad9acebdcba814d77619edbe2bac" },
"mason-lspconfig.nvim": { "branch": "main", "commit": "e4badf7984f7a5f0ac7dc10657dbedbd99a82f94" }, "mason-lspconfig.nvim": { "branch": "main", "commit": "e4badf7984f7a5f0ac7dc10657dbedbd99a82f94" },

View file

@ -10,7 +10,13 @@ return {
event = "BufWinEnter", event = "BufWinEnter",
config = function() config = function()
vim.opt.lazyredraw = false vim.opt.lazyredraw = false
require("noice").setup() require("noice").setup({
lsp = {
progress = {
enabled = false,
},
},
})
end, end,
}, },
{ {

6
lua/custom/ui.lua Normal file
View file

@ -0,0 +1,6 @@
local m = {}
-- 0 disable progress
-- 1 lualine lsp progress
-- 2 fidget progress
m.progress = 1
return m

View file

@ -66,98 +66,6 @@ return {
{ "<s-tab>", function() require("luasnip").jump(-1) end, mode = { "i", "s" } }, { "<s-tab>", function() require("luasnip").jump(-1) end, mode = { "i", "s" } },
}, },
}, },
-- for cmp
{
"hrsh7th/nvim-cmp",
version = false, -- last release is way too old
event = "InsertEnter",
dependencies = {
"hrsh7th/cmp-nvim-lsp",
"hrsh7th/cmp-buffer",
"hrsh7th/cmp-path",
"saadparwaiz1/cmp_luasnip",
"hrsh7th/cmp-nvim-lua",
-- {
-- "hrsh7th/cmp-cmdline",
-- --event = "BufWinEnter",
-- event = "VeryLazy",
-- config = function()
-- require("user.cmdline")
-- end,
-- },
},
opts = function()
local cmp = require("cmp")
local luasnip = require("luasnip")
local check_backspace = function()
local col = vim.fn.col(".") - 1
return col == 0 or vim.fn.getline("."):sub(col, col):match("%s")
end
return {
completion = {
completeopt = "menu,menuone,noinsert",
},
snippet = {
expand = function(args)
require("luasnip").lsp_expand(args.body)
end,
},
mapping = cmp.mapping.preset.insert({
["<C-b>"] = cmp.mapping.scroll_docs(-4),
["<C-f>"] = cmp.mapping.scroll_docs(4),
["<C-Space>"] = cmp.mapping.complete(),
["<C-e>"] = cmp.mapping.abort(),
["<CR>"] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items.
["<Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_next_item()
elseif luasnip.expandable() then
luasnip.expand()
elseif luasnip.expand_or_jumpable() then
luasnip.expand_or_jump()
elseif check_backspace() then
fallback()
else
fallback()
end
end, {
"i",
"s",
}),
}),
sources = cmp.config.sources({
{ name = "nvim_lsp" },
{ name = "luasnip" },
{ name = "buffer" },
{ name = "path" },
{ name = "nvim_lua" },
}),
formatting = {
fields = { "kind", "abbr", "menu" },
format = function(entry, vim_item)
vim_item.kind = string.format("%s", require("user.icons")["kind"][vim_item.kind])
vim_item.menu = ({
nvim_lsp = "(LSP)",
luasnip = "(Snippet)",
buffer = "(Buffer)",
path = "(Path)",
})[entry.source.name]
return vim_item
end,
},
window = {
completion = cmp.config.window.bordered(),
documentation = cmp.config.window.bordered(),
},
experimental = {
ghost_text = false,
native_menu = false,
},
}
end,
},
{ {
"neovim/nvim-lspconfig", "neovim/nvim-lspconfig",
event = "BufWinEnter", event = "BufWinEnter",

View file

@ -0,0 +1,47 @@
local fidget = true
local lualine = false
local data_exists, custom_ui = pcall(require, "custom.ui")
if data_exists then
if type(custom_ui) == "table" then
if custom_ui.progress == 1 then
fidget = false
lualine = true
elseif custom_ui.progress == 2 then
fidget = true
lualine = false
elseif custom_ui.progress == 0 then
fidget = false
lualine = false
else
fidget = true
lualine = false
end
end
else
fidget = true
lualine = false
end
return {
{
"j-hui/fidget.nvim",
enabled = fidget,
event = "BufRead",
config = function()
require("fidget").setup()
end,
},
{
"linrongbin16/lsp-progress.nvim",
enabled = lualine,
branch = "main",
event = { "BufRead" },
config = function()
require("lsp-progress").setup({
format = function(client_messages)
local sign = "" -- nf-fa-gear \uf013
return #client_messages > 0 and (sign .. " " .. table.concat(client_messages, " ")) or sign
end,
})
end,
},
}

View file

@ -87,11 +87,4 @@ return {
require("user.telescope") require("user.telescope")
end, end,
}, },
{
"j-hui/fidget.nvim",
event = "BufRead",
config = function()
require("fidget").setup()
end,
},
} }

View file

@ -170,6 +170,11 @@ local lsp_info = {
--icon = " ", --icon = " ",
icon = icons.ui.Gear .. "", icon = icons.ui.Gear .. "",
} }
local lsp_progress = {}
local data_exists, lspprogress = pcall(require, "lsp-progress")
if data_exists then
lsp_progress = lspprogress.progress
end
lualine.setup({ lualine.setup({
options = { options = {
@ -202,7 +207,7 @@ lualine.setup({
sections = { sections = {
lualine_a = { branch }, lualine_a = { branch },
lualine_b = { mode }, lualine_b = { mode },
lualine_c = { diagnostics, lsp_info }, lualine_c = { diagnostics, lsp_info, lsp_progress },
-- lualine_c = { diagnostics, lsp_info, "lsp_progress" }, -- lualine_c = { diagnostics, lsp_info, "lsp_progress" },
-- lualine_c = { file_name, lsp_info }, -- lualine_c = { file_name, lsp_info },
-- lualine_x = { "encoding", "fileformat", "filetype" }, -- lualine_x = { "encoding", "fileformat", "filetype" },

View file

@ -3,6 +3,10 @@ if not status_ok then
return return
end end
configs.setup({ configs.setup({
ensure_installed = {
"lua",
"vim",
},
ignore_install = { "phpdoc" }, -- List of parsers to ignore installing ignore_install = { "phpdoc" }, -- List of parsers to ignore installing
highlight = { highlight = {
enable = true, enable = true,