Skip to content

Commit

Permalink
feat: reintroduce fidget
Browse files Browse the repository at this point in the history
  • Loading branch information
aceforeverd committed Nov 25, 2023
1 parent 7973891 commit 772885b
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 17 deletions.
1 change: 1 addition & 0 deletions lua/aceforeverd/apperance/feline.lua
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,7 @@ local function gen_winbar_components()
{
{
provider = { name = 'file_info', opts = { type = 'relative' } },
short_provider = { name = 'file_info', opts = { type = 'relative-short' } },
hl = { fg = bit_green },
},
{
Expand Down
7 changes: 0 additions & 7 deletions lua/aceforeverd/lsp/common.lua
Original file line number Diff line number Diff line change
Expand Up @@ -225,18 +225,11 @@ end

function M.on_attach(client, bufnr)
-- omnifunc, tagfunc, formatexpr is set from neovim runtime by default if LSP supports

-- lsp-status
local s3, lsp_status = pcall(require, 'lsp-status')
if s3 then
lsp_status.on_attach(client)
end
end

-- Add additional capabilities supported by nvim-cmp
local capabilities = vim.lsp.protocol.make_client_capabilities()
capabilities = require('cmp_nvim_lsp').default_capabilities(capabilities)
capabilities = vim.tbl_extend('keep', capabilities, require('lsp-status').capabilities)
M.capabilities = capabilities

-- basic border, check :help nvim_open_win()
Expand Down
3 changes: 3 additions & 0 deletions lua/aceforeverd/lsp/jdtls.lua
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ function M.jdtls()

local extendedClientCapabilities = jdtls.extendedClientCapabilities
extendedClientCapabilities.resolveAdditionalTextEditsSupport = true
-- Switching to standard LSP progress events (as soon as it lands, see link)
-- https://github.com/eclipse/eclipse.jdt.ls/pull/2030#issuecomment-1210815017
extendedClientCapabilities.progressReportProvider = false

-- Finding supported Java in sdkman
-- or u can search in more locations
Expand Down
18 changes: 13 additions & 5 deletions lua/aceforeverd/lsp/servers.lua
Original file line number Diff line number Diff line change
Expand Up @@ -73,39 +73,47 @@ return {
offsetEncoding = { 'utf-16' },
})

local clangd_handlers = vim.tbl_deep_extend('error', general_lsp_config.handlers, lsp_status.extensions.clangd.setup())
-- use lsp-status's handler, disabling fidget
clangd_handlers['$/progress'] = require('lsp-status.util').mk_handler(require('lsp-status.messaging').progress_callback)

local clangd_cfg = {
on_attach = function(client, bufnr)
on_attach(client, bufnr)
vim.keymap.set(
'n',
'<Leader>af',
'<cmd>ClangdSwitchSourceHeader<cr>',
{ noremap = true, silent = true, buffer = bufnr }
{ noremap = true, silent = true, buffer = bufnr, desc = 'switch source' }
)
vim.keymap.set(
'n',
'<C-w>av',
'<c-w>v<cmd>ClangdSwitchSourceHeader<cr>',
{ noremap = true, silent = true, buffer = bufnr }
{ noremap = true, silent = true, buffer = bufnr, desc = 'switch source (vsplit)' }
)
vim.keymap.set(
'n',
'<C-w>as',
'<c-w>s<cmd>ClangdSwitchSourceHeader<cr>',
{ noremap = true, silent = true, buffer = bufnr }
{ noremap = true, silent = true, buffer = bufnr, desc = 'switch source (split)' }
)
vim.keymap.set(
'n',
'<Leader>ai',
'<cmd>ClangdToggleInlayHints<cr>',
{ noremap = true, silent = true, buffer = bufnr }
{ noremap = true, silent = true, buffer = bufnr, desc = 'toggle inlay hints' }
)

require("clangd_extensions.inlay_hints").setup_autocmd()
require("clangd_extensions.inlay_hints").set_inlay_hints()

-- use lsp-status only for clangd
-- clangd file status is not LSP [progress protocal](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#workDoneProgress) so only lsp-status handle it
lsp_status.on_attach(client)
end,
capabilities = clangd_caps,
handlers = vim.tbl_deep_extend('error', general_lsp_config.handlers, lsp_status.extensions.clangd.setup()),
handlers = clangd_handlers,
init_options = { clangdFileStatus = true },
cmd = {
'clangd',
Expand Down
11 changes: 7 additions & 4 deletions lua/aceforeverd/plugins/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -112,12 +112,17 @@ M.plugin_list = {
status_symbol = '🐶',
diagnostics = false,
})

lsp_status.register_progress()
end,
lazy = true,
},

{
'j-hui/fidget.nvim',
config = function()
require('fidget').setup()
end
},

{
'p00f/clangd_extensions.nvim',
config = function()
Expand Down Expand Up @@ -177,8 +182,6 @@ M.plugin_list = {
'SmiteshP/nvim-navic',
'SmiteshP/nvim-navbuddy',
'MunifTanjim/nui.nvim',
-- statusline
'nvim-lua/lsp-status.nvim',
},
config = function()
require('aceforeverd.lsp').setup()
Expand Down
8 changes: 7 additions & 1 deletion lua/aceforeverd/util/statusline.lua
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,13 @@ end
local lsp_status
if vim.g.lsp_process_provider == 'lsp_status' then
lsp_status = function()
return require('lsp-status').status()
if vim.tbl_contains({'c', 'cpp', 'objc'}, vim.bo.filetype) == true then
-- use lsp-status that comes with clangd file status
return require('lsp-status').status()
else
-- vim.lsp.status() ?
return ''
end
end
end

Expand Down

0 comments on commit 772885b

Please sign in to comment.